Merge m-c to b2g-inbound.
[gecko.git] / gfx / gl / TextureImageEGL.h
blob35348faeb970bbf8745ab97ff4a12e2dd7885c90
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef TEXTUREIMAGEEGL_H_
7 #define TEXTUREIMAGEEGL_H_
9 #include "GLTextureImage.h"
11 namespace mozilla {
12 namespace gl {
14 class TextureImageEGL
15 : public TextureImage
17 public:
18 TextureImageEGL(GLuint aTexture,
19 const nsIntSize& aSize,
20 GLenum aWrapMode,
21 ContentType aContentType,
22 GLContext* aContext,
23 Flags aFlags = TextureImage::NoFlags,
24 TextureState aTextureState = Created,
25 TextureImage::ImageFormat aImageFormat = gfxImageFormatUnknown);
27 virtual ~TextureImageEGL();
29 virtual void GetUpdateRegion(nsIntRegion& aForRegion);
31 virtual gfxASurface* BeginUpdate(nsIntRegion& aRegion);
33 virtual void EndUpdate();
35 virtual bool DirectUpdate(gfxASurface* aSurf, const nsIntRegion& aRegion, const nsIntPoint& aFrom /* = nsIntPoint(0, 0) */);
37 virtual void BindTexture(GLenum aTextureUnit);
39 virtual GLuint GetTextureID()
41 // Ensure the texture is allocated before it is used.
42 if (mTextureState == Created) {
43 Resize(mSize);
45 return mTexture;
48 virtual bool InUpdate() const { return !!mUpdateSurface; }
50 virtual void Resize(const nsIntSize& aSize);
52 bool BindTexImage();
54 bool ReleaseTexImage();
56 virtual bool CreateEGLSurface(gfxASurface* aSurface)
58 return false;
61 virtual void DestroyEGLSurface(void);
63 protected:
64 typedef gfxImageFormat ImageFormat;
66 GLContext* mGLContext;
68 nsIntRect mUpdateRect;
69 ImageFormat mUpdateFormat;
70 nsRefPtr<gfxASurface> mUpdateSurface;
71 EGLImage mEGLImage;
72 GLuint mTexture;
73 EGLSurface mSurface;
74 EGLConfig mConfig;
75 TextureState mTextureState;
77 bool mBound;
79 virtual void ApplyFilter();
86 #endif // TEXTUREIMAGEEGL_H_