Bug 660090 - EGL: Allocate Texture in Constructor; r=florian.haenel,romaxa
authorJoe Drew <joe@drew.ca>
Tue, 26 Jul 2011 13:51:56 -0700
changeset 73444 b5c330319eddbd8ccd017c145c57940d3be8f223
parent 73443 86ff239e3948b71dc041981a2dfd5a97c05d12e0
child 73445 2148365fbb7cf081d55dc61fcbdd4b5f448506c7
push id20871
push usereakhgari@mozilla.com
push dateThu, 28 Jul 2011 14:37:48 +0000
treeherdermozilla-central@fe48bbfeff94 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian
bugs660090
milestone8.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 660090 - EGL: Allocate Texture in Constructor; r=florian.haenel,romaxa
gfx/thebes/GLContextProviderEGL.cpp
--- a/gfx/thebes/GLContextProviderEGL.cpp
+++ b/gfx/thebes/GLContextProviderEGL.cpp
@@ -1166,31 +1166,33 @@ public:
                 mShaderType = RGBXLayerProgramType;
 #else
                 mUpdateFormat = gfxASurface::ImageFormatARGB32;
                 mShaderType = RGBALayerProgramType;
 #endif
             } else {
                 mShaderType = RGBALayerProgramType;
             }
-            CreateBackingSurface(gfxIntSize(aSize.width, aSize.height));
         } else {
             // Convert RGB24 to either ARGB32 on mobile.  We can't
             // generate GL_RGB data, so we'll always have an alpha byte
             // for RGB24.  No easy way to upload that to GL.
             // 
             // Note that if we start using RGB565 here, we'll need to
             // watch for a) setting mIsRGBFormat to TRUE; and b) getting
             // the stride right.
             if (mUpdateFormat == gfxASurface::ImageFormatRGB24) {
                 mUpdateFormat = gfxASurface::ImageFormatARGB32;
             }
             // We currently always use BGRA type textures
             mShaderType = BGRALayerProgramType;
         }
+
+	// We resize here so we should have a valid buffer after creation
+        Resize(aSize);
     }
 
     virtual ~TextureImageEGL()
     {
         GLContext *ctx = mGLContext;
         if (ctx->IsDestroyed() || !NS_IsMainThread()) {
             ctx = ctx->GetSharedContext();
         }
@@ -1394,19 +1396,25 @@ public:
     virtual void Resize(const nsIntSize& aSize)
     {
         NS_ASSERTION(!mUpdateSurface, "Resize() while in update?");
 
         if (mSize == aSize && mCreated)
             return;
 
         mGLContext->fBindTexture(LOCAL_GL_TEXTURE_2D, mTexture);
-        if (mBackingSurface) {
+	
+        // Try to generate a backin surface first if we have the ability
+        if (gUseBackingSurface) {
             CreateBackingSurface(gfxIntSize(aSize.width, aSize.height));
-        } else {
+        }
+
+        if (!mBackingSurface) {
+            // If we don't have a backing surface or failed to obtain one,
+            // use the GL Texture failsafe
             mGLContext->fTexImage2D(LOCAL_GL_TEXTURE_2D,
                                     0,
                                     GLFormatForImage(mUpdateFormat),
                                     aSize.width,
                                     aSize.height,
                                     0,
                                     GLFormatForImage(mUpdateFormat),
                                     GLTypeForImage(mUpdateFormat),