Bug 944412 - Fix an issue with the stride in SourceSurfaceSkia::InitFromData. r=gal
authorKevin Simons <kevin@comoyo.com>
Mon, 02 Dec 2013 11:03:13 -0500
changeset 173919 f6d8a9a56abbe302d67dbd49508be59717067fcd
parent 173918 67db0f727b94aa97bf39d264fde54a4843c2c82e
child 173920 72f2f506fe013bfba7d51b31dfe63e63d20e315c
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgal
bugs944412
milestone28.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 944412 - Fix an issue with the stride in SourceSurfaceSkia::InitFromData. r=gal After calling SkBitmap::copyTo, the InitFromData method assumed that the stride of the destination SkBitmap was now the same as the stride of the source bitmap. This was, however, not the case. Now the stride is read back out of the destination bitmap. This was causing a crash due to memory corruption for FORMAT_B8G8R8X8 surfaces.
gfx/2d/SourceSurfaceSkia.cpp
--- a/gfx/2d/SourceSurfaceSkia.cpp
+++ b/gfx/2d/SourceSurfaceSkia.cpp
@@ -70,25 +70,25 @@ SourceSurfaceSkia::InitFromData(unsigned
 
   if (!temp.copyTo(&mBitmap, GfxFormatToSkiaConfig(aFormat))) {
     return false;
   }
 
   if (aFormat == FORMAT_B8G8R8X8) {
     mBitmap.lockPixels();
     // We have to manually set the A channel to be 255 as Skia doesn't understand BGRX
-    ConvertBGRXToBGRA(reinterpret_cast<unsigned char*>(mBitmap.getPixels()), aSize, aStride);
+    ConvertBGRXToBGRA(reinterpret_cast<unsigned char*>(mBitmap.getPixels()), aSize, mBitmap.rowBytes());
     mBitmap.unlockPixels();
     mBitmap.notifyPixelsChanged();
     mBitmap.setIsOpaque(true);
   }
 
   mSize = aSize;
   mFormat = aFormat;
-  mStride = aStride;
+  mStride = mBitmap.rowBytes();
   return true;
 }
 
 unsigned char*
 SourceSurfaceSkia::GetData()
 {
   if (!mLocked) {
     mBitmap.lockPixels();