michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 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 TEXTUREIMAGEEGL_H_ michael@0: #define TEXTUREIMAGEEGL_H_ michael@0: michael@0: #include "GLTextureImage.h" michael@0: michael@0: namespace mozilla { michael@0: namespace gl { michael@0: michael@0: class TextureImageEGL michael@0: : public TextureImage michael@0: { michael@0: public: michael@0: TextureImageEGL(GLuint aTexture, michael@0: const nsIntSize& aSize, michael@0: GLenum aWrapMode, michael@0: ContentType aContentType, michael@0: GLContext* aContext, michael@0: Flags aFlags = TextureImage::NoFlags, michael@0: TextureState aTextureState = Created, michael@0: TextureImage::ImageFormat aImageFormat = gfxImageFormat::Unknown); michael@0: michael@0: virtual ~TextureImageEGL(); michael@0: michael@0: virtual void GetUpdateRegion(nsIntRegion& aForRegion); michael@0: michael@0: virtual gfx::DrawTarget* BeginUpdate(nsIntRegion& aRegion); michael@0: michael@0: virtual void EndUpdate(); michael@0: michael@0: virtual bool DirectUpdate(gfx::DataSourceSurface* aSurf, const nsIntRegion& aRegion, const gfx::IntPoint& aFrom = gfx::IntPoint(0,0)); michael@0: michael@0: virtual void BindTexture(GLenum aTextureUnit); michael@0: michael@0: virtual GLuint GetTextureID() michael@0: { michael@0: // Ensure the texture is allocated before it is used. michael@0: if (mTextureState == Created) { michael@0: Resize(mSize); michael@0: } michael@0: return mTexture; michael@0: }; michael@0: michael@0: virtual bool InUpdate() const { return !!mUpdateDrawTarget; } michael@0: michael@0: virtual void Resize(const gfx::IntSize& aSize); michael@0: michael@0: bool BindTexImage(); michael@0: michael@0: bool ReleaseTexImage(); michael@0: michael@0: virtual bool CreateEGLSurface(gfxASurface* aSurface) michael@0: { michael@0: return false; michael@0: } michael@0: michael@0: virtual void DestroyEGLSurface(void); michael@0: michael@0: protected: michael@0: typedef gfxImageFormat ImageFormat; michael@0: michael@0: GLContext* mGLContext; michael@0: michael@0: nsIntRect mUpdateRect; michael@0: gfx::SurfaceFormat mUpdateFormat; michael@0: RefPtr mUpdateDrawTarget; michael@0: EGLImage mEGLImage; michael@0: GLuint mTexture; michael@0: EGLSurface mSurface; michael@0: EGLConfig mConfig; michael@0: TextureState mTextureState; michael@0: michael@0: bool mBound; michael@0: }; michael@0: michael@0: already_AddRefed michael@0: CreateTextureImageEGL(GLContext *gl, michael@0: const gfx::IntSize& aSize, michael@0: TextureImage::ContentType aContentType, michael@0: GLenum aWrapMode, michael@0: TextureImage::Flags aFlags, michael@0: TextureImage::ImageFormat aImageFormat); michael@0: michael@0: already_AddRefed michael@0: TileGenFuncEGL(GLContext *gl, michael@0: const nsIntSize& aSize, michael@0: TextureImage::ContentType aContentType, michael@0: TextureImage::Flags aFlags, michael@0: TextureImage::ImageFormat aImageFormat); michael@0: michael@0: } michael@0: } michael@0: michael@0: #endif // TEXTUREIMAGEEGL_H_