Bug 1078109 - Make sure we initialize tiled textures to the format we're going to upload with. r=jgilbert
authorMatt Woodrow <mwoodrow@mozilla.com>
Wed, 08 Oct 2014 13:10:59 +1300
changeset 209247 43c963b56723f6d318bdda0eb906d3cb5b08717a
parent 209246 c78b949b21da028939c2dac178e06fce5984cb8c
child 209248 81eafec98b48dad1ae75659cdc3235bf7e5c8be0
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersjgilbert
bugs1078109
milestone35.0a1
Bug 1078109 - Make sure we initialize tiled textures to the format we're going to upload with. r=jgilbert
gfx/gl/GLTextureImage.cpp
--- a/gfx/gl/GLTextureImage.cpp
+++ b/gfx/gl/GLTextureImage.cpp
@@ -227,24 +227,37 @@ BasicTextureImage::DirectUpdate(gfx::Dat
 
 void
 BasicTextureImage::Resize(const gfx::IntSize& aSize)
 {
     NS_ASSERTION(!mUpdateDrawTarget, "Resize() while in update?");
 
     mGLContext->fBindTexture(LOCAL_GL_TEXTURE_2D, mTexture);
 
+    // This matches the logic in UploadImageDataToTexture so that
+    // we avoid mixing formats.
+    GLenum format;
+    GLenum type;
+    if (mGLContext->GetPreferredARGB32Format() == LOCAL_GL_BGRA) {
+        MOZ_ASSERT(!mGLContext->IsGLES());
+        format = LOCAL_GL_BGRA;
+        type = LOCAL_GL_UNSIGNED_INT_8_8_8_8_REV;
+    } else {
+        format = LOCAL_GL_RGBA;
+        type = LOCAL_GL_UNSIGNED_BYTE;
+    }
+
     mGLContext->fTexImage2D(LOCAL_GL_TEXTURE_2D,
                             0,
                             LOCAL_GL_RGBA,
                             aSize.width,
                             aSize.height,
                             0,
-                            LOCAL_GL_RGBA,
-                            LOCAL_GL_UNSIGNED_BYTE,
+                            format,
+                            type,
                             nullptr);
 
     mTextureState = Allocated;
     mSize = aSize;
 }
 
 gfx::IntSize TextureImage::GetSize() const {
   return mSize;