Bug 1006198 - Use 8byte aligned surface for CopyableCanvasLayer since that's the max WebGL supports for readback. r=nical
authorMatt Woodrow <mwoodrow@mozilla.com>
Tue, 13 May 2014 14:20:27 +1200
changeset 182943 0ff7d00bb9fbdeb79d05663f349f742fa4faad15
parent 182942 bbbe64df866efd71af223d4d082a57255315afdb
child 182944 b57bec9cf79fff0f6d5ff70e1f89ebbb0b395d93
push id26774
push userryanvm@gmail.com
push dateTue, 13 May 2014 20:27:07 +0000
treeherdermozilla-central@e5f321740d10 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1006198
milestone32.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 1006198 - Use 8byte aligned surface for CopyableCanvasLayer since that's the max WebGL supports for readback. r=nical
gfx/layers/CopyableCanvasLayer.cpp
--- a/gfx/layers/CopyableCanvasLayer.cpp
+++ b/gfx/layers/CopyableCanvasLayer.cpp
@@ -12,16 +12,17 @@
 #include "SurfaceTypes.h"               // for APITypeT, APITypeT::OpenGL, etc
 #include "gfxMatrix.h"                  // for gfxMatrix
 #include "gfxPattern.h"                 // for gfxPattern, etc
 #include "gfxPlatform.h"                // for gfxPlatform, gfxImageFormat
 #include "gfxRect.h"                    // for gfxRect
 #include "gfxUtils.h"                   // for gfxUtils
 #include "gfx2DGlue.h"                  // for thebes --> moz2d transition
 #include "mozilla/gfx/BaseSize.h"       // for BaseSize
+#include "mozilla/gfx/Tools.h"
 #include "nsDebug.h"                    // for NS_ASSERTION, NS_WARNING, etc
 #include "nsISupportsImpl.h"            // for gfxContext::AddRef, etc
 #include "nsRect.h"                     // for nsIntRect
 #include "nsSize.h"                     // for nsIntSize
 #include "gfxUtils.h"
 
 using namespace mozilla::gfx;
 using namespace mozilla::gl;
@@ -165,17 +166,19 @@ CopyableCanvasLayer::UpdateTarget(DrawTa
 DataSourceSurface*
 CopyableCanvasLayer::GetTempSurface(const IntSize& aSize,
                                     const SurfaceFormat aFormat)
 {
   if (!mCachedTempSurface ||
       aSize != mCachedTempSurface->GetSize() ||
       aFormat != mCachedTempSurface->GetFormat())
   {
-    mCachedTempSurface = Factory::CreateDataSourceSurface(aSize, aFormat);
+    // Create a surface aligned to 8 bytes since that's the highest alignment WebGL can handle.
+    uint32_t stride = GetAlignedStride<8>(aSize.width * BytesPerPixel(aFormat));
+    mCachedTempSurface = Factory::CreateDataSourceSurfaceWithStride(aSize, aFormat, stride);
   }
 
   return mCachedTempSurface;
 }
 
 void
 CopyableCanvasLayer::DiscardTempSurface()
 {