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 283506 866edb59ba0903882c0933ab3c3cca89b4108063
parent 283505 9b3e1c0c851fd49cb83aaadd4766d4a7b1dd55a3
child 283507 456ca897229f57deee86b41f3658d97249f2d668
push id29986
push usercbook@mozilla.com
push dateTue, 09 Feb 2016 11:03:17 +0000
treeherdermozilla-central@2dfb45d74f42 [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
widget/cocoa/nsChildView.mm
--- 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
@@ -429,22 +429,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,
@@ -607,29 +607,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;
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -2960,38 +2960,37 @@ CanUploadSubtextures()
   return NSFoundationVersionNumber >= NSFoundationVersionWithProperStrideSupportForSubtextureUpload;
 }
 
 void
 RectTextureImage::EndUpdate(bool aKeepSurface)
 {
   MOZ_ASSERT(mInUpdate, "Ending update while not in update");
 
-  bool overwriteTexture = false;
+  bool needInit = !mTexture;
   LayoutDeviceIntRegion updateRegion = mUpdateRegion;
-  if (!mTexture || (mTextureSize != mBufferSize)) {
-    overwriteTexture = true;
+  if (mTextureSize != mBufferSize) {
     mTextureSize = mBufferSize;
   }
 
-  if (overwriteTexture || !CanUploadSubtextures()) {
+  if (needInit || !CanUploadSubtextures()) {
     updateRegion =
       LayoutDeviceIntRect(LayoutDeviceIntPoint(0, 0), mTextureSize);
   }
 
   gfx::IntPoint srcPoint = updateRegion.GetBounds().TopLeft().ToUnknownPoint();
   gfx::SurfaceFormat format = mUpdateDrawTarget->GetFormat();
   int bpp = gfx::BytesPerPixel(format);
   int32_t stride = mBufferSize.width * bpp;
   unsigned char* data = mUpdateDrawTargetData.get();
   data += srcPoint.y * stride + srcPoint.x * bpp;
 
   UploadImageDataToTexture(mGLContext, data, stride, format,
                            updateRegion.ToUnknownRegion(), mTexture, nullptr,
-                           overwriteTexture, /* aPixelBuffer = */ false,
+                           needInit, /* aPixelBuffer = */ false,
                            LOCAL_GL_TEXTURE0,
                            LOCAL_GL_TEXTURE_RECTANGLE_ARB);
 
 
 
   if (!aKeepSurface) {
     mUpdateDrawTarget = nullptr;
     mUpdateDrawTargetData = nullptr;