Bug 998042 - 4-byte align Skia surfaces to interoperate with Cairo r=jrmuizel
authorLee Salzman <lsalzman@mozilla.com>
Thu, 08 Oct 2015 12:16:46 -0400
changeset 266940 997861ff71b1af99db75eeb9796f4f115f35871a
parent 266939 8c1e280e0bb545391c3ac9c8e29c1504a2593b06
child 266941 a2788bc9ed7ea00773d977cd71ba52764fef3980
push id66335
push userkwierso@gmail.com
push dateThu, 08 Oct 2015 22:07:09 +0000
treeherdermozilla-inbound@997861ff71b1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs998042
milestone44.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 998042 - 4-byte align Skia surfaces to interoperate with Cairo r=jrmuizel
gfx/2d/DrawTargetSkia.cpp
--- a/gfx/2d/DrawTargetSkia.cpp
+++ b/gfx/2d/DrawTargetSkia.cpp
@@ -832,30 +832,28 @@ DrawTargetSkia::Init(const IntSize &aSiz
 {
   SkAlphaType alphaType = (aFormat == SurfaceFormat::B8G8R8X8) ?
     kOpaque_SkAlphaType : kPremul_SkAlphaType;
 
   SkImageInfo skiInfo = SkImageInfo::Make(
         aSize.width, aSize.height,
         GfxFormatToSkiaColorType(aFormat),
         alphaType);
+  // we need to have surfaces that have a stride aligned to 4 for interop with cairo
+  int stride = (BytesPerPixel(aFormat)*aSize.width + (4-1)) & -4;
 
-  SkAutoTUnref<SkBaseDevice> device(SkBitmapDevice::Create(skiInfo));
-  if (!device) {
-      return false;
-  }
-
-  SkBitmap bitmap = device->accessBitmap(true);
+  SkBitmap bitmap;
+  bitmap.setInfo(skiInfo, stride);
   if (!bitmap.allocPixels()) {
     return false;
   }
 
   bitmap.eraseARGB(0, 0, 0, 0);
 
-  mCanvas.adopt(new SkCanvas(device.get()));
+  mCanvas.adopt(new SkCanvas(bitmap));
   mSize = aSize;
 
   mFormat = aFormat;
   return true;
 }
 
 #ifdef USE_SKIA_GPU
 bool