Bug 1250710 - Update usages of ScopedPackAlignment. - r=jrmuizel
authorJeff Gilbert <jgilbert@mozilla.com>
Tue, 14 Jun 2016 10:09:25 -0700
changeset 305272 ef99639a073ce3a042dcc3f61b15194a5e6bc33b
parent 305271 627980e477d31c42bee6bda0b1b4289a515616c6
child 305273 c8b9fe689adab82469aff1e1d0e0f4b9a3998288
push id79535
push userjgilbert@mozilla.com
push dateMon, 18 Jul 2016 04:46:14 +0000
treeherdermozilla-inbound@b658098634b8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1250710
milestone50.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 1250710 - Update usages of ScopedPackAlignment. - r=jrmuizel MozReview-Commit-ID: DgngFxBu8kn
gfx/gl/SharedSurface.cpp
gfx/layers/client/CanvasClient.cpp
--- a/gfx/gl/SharedSurface.cpp
+++ b/gfx/gl/SharedSurface.cpp
@@ -564,17 +564,21 @@ ReadbackSharedSurface(SharedSurface* src
                    readGLFormat == LOCAL_GL_BGRA);
         MOZ_ASSERT(readType == LOCAL_GL_UNSIGNED_BYTE);
 
         // ReadPixels from the current FB into lockedBits.
         {
             size_t alignment = 8;
             if (dstStride % 4 == 0)
                 alignment = 4;
-            ScopedPackAlignment autoAlign(gl, alignment);
+
+            ScopedPackState scopedPackState(gl);
+            if (alignment != 4) {
+                gl->fPixelStorei(LOCAL_GL_PACK_ALIGNMENT, alignment);
+            }
 
             gl->raw_fReadPixels(0, 0, width, height, readGLFormat, readType,
                                 dstBytes);
         }
     }
 
     const bool isReadRGBA = readGLFormat == LOCAL_GL_RGBA;
 
@@ -596,17 +600,17 @@ uint32_t
 ReadPixel(SharedSurface* src)
 {
     GLContext* gl = src->mGL;
 
     uint32_t pixel;
 
     ScopedReadbackFB a(src);
     {
-        ScopedPackAlignment autoAlign(gl, 4);
+        ScopedPackState scopedPackState(gl);
 
         UniquePtr<uint8_t[]> bytes(new uint8_t[4]);
         gl->raw_fReadPixels(0, 0, 1, 1, LOCAL_GL_RGBA, LOCAL_GL_UNSIGNED_BYTE,
                             bytes.get());
         memcpy(&pixel, bytes.get(), 4);
     }
 
     return pixel;
--- a/gfx/layers/client/CanvasClient.cpp
+++ b/gfx/layers/client/CanvasClient.cpp
@@ -304,32 +304,32 @@ TexClientFromReadback(SharedSurface* src
       // [RR, GG, BB, AA]
       texClient = factory.CreateR8G8B8AX8();
     } else {
       MOZ_CRASH("GFX: Bad `read{Format,Type}`.");
     }
 
     MOZ_ASSERT(texClient);
     if (!texClient)
-        return nullptr;
+      return nullptr;
 
     // With a texClient, we can lock for writing.
     TextureClientAutoLock autoLock(texClient, OpenMode::OPEN_WRITE);
     DebugOnly<bool> succeeded = autoLock.Succeeded();
     MOZ_ASSERT(succeeded, "texture should have locked");
 
     MappedTextureData mapped;
     texClient->BorrowMappedData(mapped);
 
     // ReadPixels from the current FB into mapped.data.
     auto width = src->mSize.width;
     auto height = src->mSize.height;
 
     {
-      ScopedPackAlignment autoAlign(gl, 4);
+      ScopedPackState scopedPackState(gl);
 
       MOZ_ASSERT(mapped.stride/4 == mapped.size.width);
       gl->raw_fReadPixels(0, 0, width, height, readFormat, readType, mapped.data);
     }
 
     // RB_SWAPPED doesn't work with D3D11. (bug 1051010)
     // RB_SWAPPED doesn't work with Basic. (bug ???????)
     // RB_SWAPPED doesn't work with D3D9. (bug ???????)