Bug 1286348 - Only set ROW_LENGTH if it's different. - r=mtseng
authorJeff Gilbert <jgilbert@mozilla.com>
Tue, 12 Jul 2016 12:43:39 -0700
changeset 387158 b15f05a94c716fdbed45b5f46a0fd5b8ae6443ef
parent 387157 8d95a6d0855871245bd01df1f81c5ab93ec48700
child 387159 034f54c5ac438256cfb185eaaab63065a19d2e0d
push id22898
push userCallek@gmail.com
push dateWed, 13 Jul 2016 13:20:13 +0000
reviewersmtseng
bugs1286348
milestone50.0a1
Bug 1286348 - Only set ROW_LENGTH if it's different. - r=mtseng MozReview-Commit-ID: 6Wl9iKeYudg
dom/canvas/TexUnpackBlob.cpp
--- a/dom/canvas/TexUnpackBlob.cpp
+++ b/dom/canvas/TexUnpackBlob.cpp
@@ -524,20 +524,29 @@ TexUnpackSurface::TexOrSubImage(bool isS
         return false;
     }
 
     //////
 
     gl::GLContext* const gl = webgl->gl;
     MOZ_ALWAYS_TRUE( gl->MakeCurrent() );
 
-    gl->fPixelStorei(LOCAL_GL_UNPACK_ROW_LENGTH, mRowLength);
+    const auto curEffectiveRowLength = FallbackOnZero(webgl->mPixelStore_UnpackRowLength,
+                                                      mWidth);
+
+    const bool changeRowLength = (mRowLength != curEffectiveRowLength);
+    if (changeRowLength) {
+        MOZ_ASSERT(webgl->IsWebGL2());
+        gl->fPixelStorei(LOCAL_GL_UNPACK_ROW_LENGTH, mRowLength);
+    }
 
     *out_error = DoTexOrSubImage(isSubImage, gl, target.get(), level, dstDUI, xOffset,
                                  yOffset, zOffset, mWidth, mHeight, mDepth, uploadBytes);
 
-    gl->fPixelStorei(LOCAL_GL_UNPACK_ROW_LENGTH, webgl->mPixelStore_UnpackRowLength);
+    if (changeRowLength) {
+        gl->fPixelStorei(LOCAL_GL_UNPACK_ROW_LENGTH, webgl->mPixelStore_UnpackRowLength);
+    }
 
     return true;
 }
 
 } // namespace webgl
 } // namespace mozilla