|
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/. */ |
|
5 |
|
6 #ifndef TEXTUREIMAGEEGL_H_ |
|
7 #define TEXTUREIMAGEEGL_H_ |
|
8 |
|
9 #include "GLTextureImage.h" |
|
10 |
|
11 namespace mozilla { |
|
12 namespace gl { |
|
13 |
|
14 class TextureImageEGL |
|
15 : public TextureImage |
|
16 { |
|
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 = gfxImageFormat::Unknown); |
|
26 |
|
27 virtual ~TextureImageEGL(); |
|
28 |
|
29 virtual void GetUpdateRegion(nsIntRegion& aForRegion); |
|
30 |
|
31 virtual gfx::DrawTarget* BeginUpdate(nsIntRegion& aRegion); |
|
32 |
|
33 virtual void EndUpdate(); |
|
34 |
|
35 virtual bool DirectUpdate(gfx::DataSourceSurface* aSurf, const nsIntRegion& aRegion, const gfx::IntPoint& aFrom = gfx::IntPoint(0,0)); |
|
36 |
|
37 virtual void BindTexture(GLenum aTextureUnit); |
|
38 |
|
39 virtual GLuint GetTextureID() |
|
40 { |
|
41 // Ensure the texture is allocated before it is used. |
|
42 if (mTextureState == Created) { |
|
43 Resize(mSize); |
|
44 } |
|
45 return mTexture; |
|
46 }; |
|
47 |
|
48 virtual bool InUpdate() const { return !!mUpdateDrawTarget; } |
|
49 |
|
50 virtual void Resize(const gfx::IntSize& aSize); |
|
51 |
|
52 bool BindTexImage(); |
|
53 |
|
54 bool ReleaseTexImage(); |
|
55 |
|
56 virtual bool CreateEGLSurface(gfxASurface* aSurface) |
|
57 { |
|
58 return false; |
|
59 } |
|
60 |
|
61 virtual void DestroyEGLSurface(void); |
|
62 |
|
63 protected: |
|
64 typedef gfxImageFormat ImageFormat; |
|
65 |
|
66 GLContext* mGLContext; |
|
67 |
|
68 nsIntRect mUpdateRect; |
|
69 gfx::SurfaceFormat mUpdateFormat; |
|
70 RefPtr<gfx::DrawTarget> mUpdateDrawTarget; |
|
71 EGLImage mEGLImage; |
|
72 GLuint mTexture; |
|
73 EGLSurface mSurface; |
|
74 EGLConfig mConfig; |
|
75 TextureState mTextureState; |
|
76 |
|
77 bool mBound; |
|
78 }; |
|
79 |
|
80 already_AddRefed<TextureImage> |
|
81 CreateTextureImageEGL(GLContext *gl, |
|
82 const gfx::IntSize& aSize, |
|
83 TextureImage::ContentType aContentType, |
|
84 GLenum aWrapMode, |
|
85 TextureImage::Flags aFlags, |
|
86 TextureImage::ImageFormat aImageFormat); |
|
87 |
|
88 already_AddRefed<TextureImage> |
|
89 TileGenFuncEGL(GLContext *gl, |
|
90 const nsIntSize& aSize, |
|
91 TextureImage::ContentType aContentType, |
|
92 TextureImage::Flags aFlags, |
|
93 TextureImage::ImageFormat aImageFormat); |
|
94 |
|
95 } |
|
96 } |
|
97 |
|
98 #endif // TEXTUREIMAGEEGL_H_ |