michael@0: /* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef SHARED_SURFACEIO_H_ michael@0: #define SHARED_SURFACEIO_H_ michael@0: michael@0: #include "gfxImageSurface.h" michael@0: #include "SharedSurfaceGL.h" michael@0: #include "mozilla/RefPtr.h" michael@0: michael@0: class MacIOSurface; michael@0: michael@0: namespace mozilla { michael@0: namespace gl { michael@0: michael@0: class SharedSurface_IOSurface : public SharedSurface_GL michael@0: { michael@0: public: michael@0: static SharedSurface_IOSurface* Create(MacIOSurface* surface, GLContext *gl, bool hasAlpha); michael@0: michael@0: ~SharedSurface_IOSurface(); michael@0: michael@0: virtual void LockProdImpl() MOZ_OVERRIDE { } michael@0: virtual void UnlockProdImpl() MOZ_OVERRIDE { } michael@0: michael@0: virtual void Fence() MOZ_OVERRIDE; michael@0: virtual bool WaitSync() MOZ_OVERRIDE { return true; } michael@0: michael@0: virtual bool ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, michael@0: GLenum format, GLenum type, GLvoid *pixels) MOZ_OVERRIDE; michael@0: michael@0: virtual GLuint ProdTexture() MOZ_OVERRIDE { michael@0: return mProdTex; michael@0: } michael@0: michael@0: virtual GLenum ProdTextureTarget() const MOZ_OVERRIDE { michael@0: return LOCAL_GL_TEXTURE_RECTANGLE_ARB; michael@0: } michael@0: michael@0: static SharedSurface_IOSurface* Cast(SharedSurface *surf) { michael@0: MOZ_ASSERT(surf->Type() == SharedSurfaceType::IOSurface); michael@0: return static_cast(surf); michael@0: } michael@0: michael@0: GLuint ConsTexture(GLContext* consGL); michael@0: michael@0: GLenum ConsTextureTarget() const { michael@0: return LOCAL_GL_TEXTURE_RECTANGLE_ARB; michael@0: } michael@0: michael@0: private: michael@0: SharedSurface_IOSurface(MacIOSurface* surface, GLContext* gl, const gfx::IntSize& size, bool hasAlpha); michael@0: michael@0: RefPtr mSurface; michael@0: nsRefPtr mImageSurface; michael@0: GLuint mProdTex; michael@0: const GLContext* mCurConsGL; michael@0: GLuint mConsTex; michael@0: }; michael@0: michael@0: class SurfaceFactory_IOSurface : public SurfaceFactory_GL michael@0: { michael@0: public: michael@0: SurfaceFactory_IOSurface(GLContext* gl, michael@0: const SurfaceCaps& caps) michael@0: : SurfaceFactory_GL(gl, SharedSurfaceType::IOSurface, caps) michael@0: { michael@0: } michael@0: michael@0: protected: michael@0: virtual SharedSurface* CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: } /* namespace gfx */ michael@0: } /* namespace mozilla */ michael@0: michael@0: #endif /* SHARED_SURFACEIO_H_ */