Bug 1243418 - Fix up incorrect 'aOverwrite' usage and impl in GLUploadHelpers r=jgilbert
authorJames Willcox <snorp@snorp.net>
Wed, 27 Jan 2016 10:09:01 -0600
changeset 282909 e3ee9f8005b34e564f5bc207c8c0d0f8d7a9500f
parent 282908 de75dce16ee4db1ed112c56a235fa08e719b41d2
child 282910 6f964a309e55f201693b9674a07ca8426798b29c
push id71356
push userjwillcox@mozilla.com
push dateWed, 03 Feb 2016 20:17:10 +0000
treeherdermozilla-inbound@e3ee9f8005b3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs1243418
milestone47.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 1243418 - Fix up incorrect 'aOverwrite' usage and impl in GLUploadHelpers r=jgilbert
gfx/gl/GLTextureImage.cpp
gfx/gl/GLUploadHelpers.cpp
gfx/gl/GLUploadHelpers.h
gfx/gl/TextureImageEGL.cpp
--- a/gfx/gl/GLTextureImage.cpp
+++ b/gfx/gl/GLTextureImage.cpp
@@ -168,24 +168,25 @@ BasicTextureImage::EndUpdate()
     NS_ASSERTION(!!mUpdateDrawTarget, "EndUpdate() without BeginUpdate()?");
 
     // FIXME: this is the slow boat.  Make me fast (with GLXPixmap?).
 
     RefPtr<gfx::SourceSurface> updateSnapshot = mUpdateDrawTarget->Snapshot();
     RefPtr<gfx::DataSourceSurface> updateData = updateSnapshot->GetDataSurface();
 
     bool relative = FinishedSurfaceUpdate();
+    bool needInit = mTextureState == Created;
     size_t uploadSize;
     mTextureFormat =
         UploadSurfaceToTexture(mGLContext,
                                updateData,
                                mUpdateRegion,
                                mTexture,
                                &uploadSize,
-                               mTextureState == Created,
+                               needInit,
                                mUpdateOffset,
                                relative);
     FinishedSurfaceUpload();
     if (uploadSize > 0) {
         UpdateUploadSize(uploadSize);
     }
 
     mUpdateDrawTarget = nullptr;
@@ -225,23 +226,24 @@ BasicTextureImage::DirectUpdate(gfx::Dat
     if (mTextureState != Valid) {
         bounds = IntRect(0, 0, mSize.width, mSize.height);
         region = nsIntRegion(bounds);
     } else {
         region = aRegion;
     }
 
     size_t uploadSize;
+    bool needInit = mTextureState == Created;
     mTextureFormat =
         UploadSurfaceToTexture(mGLContext,
                                aSurf,
                                region,
                                mTexture,
                                &uploadSize,
-                               mTextureState == Created,
+                               needInit,
                                bounds.TopLeft() + IntPoint(aFrom.x, aFrom.y),
                                false);
     if (uploadSize > 0) {
         UpdateUploadSize(uploadSize);
     }
     mTextureState = Valid;
     return true;
 }
--- a/gfx/gl/GLUploadHelpers.cpp
+++ b/gfx/gl/GLUploadHelpers.cpp
@@ -427,22 +427,22 @@ GetBytesPerTexel(GLenum format, GLenum t
 SurfaceFormat
 UploadImageDataToTexture(GLContext* gl,
                          unsigned char* aData,
                          int32_t aStride,
                          SurfaceFormat aFormat,
                          const nsIntRegion& aDstRegion,
                          GLuint& aTexture,
                          size_t* aOutUploadSize,
-                         bool aOverwrite,
+                         bool aNeedInit,
                          bool aPixelBuffer,
                          GLenum aTextureUnit,
                          GLenum aTextureTarget)
 {
-    bool textureInited = aOverwrite ? false : true;
+    bool textureInited = aNeedInit ? false : true;
     gl->MakeCurrent();
     gl->fActiveTexture(aTextureUnit);
 
     if (!aTexture) {
         gl->fGenTextures(1, &aTexture);
         gl->fBindTexture(aTextureTarget, aTexture);
         gl->fTexParameteri(aTextureTarget,
                            LOCAL_GL_TEXTURE_MIN_FILTER,
@@ -605,29 +605,29 @@ UploadImageDataToTexture(GLContext* gl,
 }
 
 SurfaceFormat
 UploadSurfaceToTexture(GLContext* gl,
                        DataSourceSurface* aSurface,
                        const nsIntRegion& aDstRegion,
                        GLuint& aTexture,
                        size_t* aOutUploadSize,
-                       bool aOverwrite,
+                       bool aNeedInit,
                        const gfx::IntPoint& aSrcPoint,
                        bool aPixelBuffer,
                        GLenum aTextureUnit,
                        GLenum aTextureTarget)
 {
     unsigned char* data = aPixelBuffer ? nullptr : aSurface->GetData();
     int32_t stride = aSurface->Stride();
     SurfaceFormat format = aSurface->GetFormat();
     data += DataOffset(aSrcPoint, stride, format);
     return UploadImageDataToTexture(gl, data, stride, format,
                                     aDstRegion, aTexture, aOutUploadSize,
-                                    aOverwrite, aPixelBuffer, aTextureUnit,
+                                    aNeedInit, aPixelBuffer, aTextureUnit,
                                     aTextureTarget);
 }
 
 bool
 CanUploadNonPowerOfTwo(GLContext* gl)
 {
     if (!gl->WorkAroundDriverBugs())
         return true;
--- a/gfx/gl/GLUploadHelpers.h
+++ b/gfx/gl/GLUploadHelpers.h
@@ -56,31 +56,31 @@ class GLContext;
 gfx::SurfaceFormat
 UploadImageDataToTexture(GLContext* gl,
                          unsigned char* aData,
                          int32_t aStride,
                          gfx::SurfaceFormat aFormat,
                          const nsIntRegion& aDstRegion,
                          GLuint& aTexture,
                          size_t* aOutUploadSize = nullptr,
-                         bool aOverwrite = false,
+                         bool aNeedInit = false,
                          bool aPixelBuffer = false,
                          GLenum aTextureUnit = LOCAL_GL_TEXTURE0,
                          GLenum aTextureTarget = LOCAL_GL_TEXTURE_2D);
 
 /**
   * Convenience wrapper around UploadImageDataToTexture for gfx::DataSourceSurface's.
   */
 gfx::SurfaceFormat
 UploadSurfaceToTexture(GLContext* gl,
                        gfx::DataSourceSurface *aSurface,
                        const nsIntRegion& aDstRegion,
                        GLuint& aTexture,
                        size_t* aOutUploadSize = nullptr,
-                       bool aOverwrite = false,
+                       bool aNeedInit = false,
                        const gfx::IntPoint& aSrcPoint = gfx::IntPoint(0, 0),
                        bool aPixelBuffer = false,
                        GLenum aTextureUnit = LOCAL_GL_TEXTURE0,
                        GLenum aTextureTarget = LOCAL_GL_TEXTURE_2D);
 
 bool CanUploadSubTextures(GLContext* gl);
 bool CanUploadNonPowerOfTwo(GLContext* gl);
 
--- a/gfx/gl/TextureImageEGL.cpp
+++ b/gfx/gl/TextureImageEGL.cpp
@@ -202,24 +202,25 @@ TextureImageEGL::DirectUpdate(gfx::DataS
     nsIntRegion region;
     if (mTextureState != Valid) {
         bounds = gfx::IntRect(0, 0, mSize.width, mSize.height);
         region = nsIntRegion(bounds);
     } else {
         region = aRegion;
     }
 
+    bool needInit = mTextureState == Created;
     size_t uploadSize = 0;
     mTextureFormat =
       UploadSurfaceToTexture(mGLContext,
                              aSurf,
                              region,
                              mTexture,
                              &uploadSize,
-                             mTextureState == Created,
+                             needInit,
                              bounds.TopLeft() + gfx::IntPoint(aFrom.x, aFrom.y),
                              false);
     if (uploadSize > 0) {
         UpdateUploadSize(uploadSize);
     }
 
     mTextureState = Valid;
     return true;