Bug 1225977 - fix DrawTargetSkia::MaskSurface with non-zero offset. r=jmuizelaar
authorLee Salzman <lsalzman@mozilla.com>
Thu, 19 Nov 2015 10:25:15 -0500
changeset 309064 1dccec2869705188acec5f999d08018be462ed7b
parent 309063 f1c08ce11d245c054bd265b2faca3e83e6587772
child 309065 69b0a3677dc10ea9540155e805fddbdf1fb571cb
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmuizelaar
bugs1225977
milestone45.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 1225977 - fix DrawTargetSkia::MaskSurface with non-zero offset. r=jmuizelaar
gfx/2d/DrawTargetSkia.cpp
--- a/gfx/2d/DrawTargetSkia.cpp
+++ b/gfx/2d/DrawTargetSkia.cpp
@@ -651,26 +651,30 @@ DrawTargetSkia::MaskSurface(const Patter
                             Point aOffset,
                             const DrawOptions &aOptions)
 {
   MarkChanged();
   AutoPaintSetup paint(mCanvas.get(), aOptions, aSource);
 
   TempBitmap bitmap = GetBitmapForSurface(aMask);
   if (bitmap.mBitmap.colorType() == kAlpha_8_SkColorType) {
+    if (aOffset != Point(0, 0)) {
+      SkMatrix transform;
+      transform.setTranslate(SkFloatToScalar(-aOffset.x), SkFloatToScalar(-aOffset.y));
+      SkShader* matrixShader = SkShader::CreateLocalMatrixShader(paint.mPaint.getShader(), transform);
+      SkSafeUnref(paint.mPaint.setShader(matrixShader));
+    }
+
     mCanvas->drawBitmap(bitmap.mBitmap, aOffset.x, aOffset.y, &paint.mPaint);
   } else {
     SkPaint maskPaint;
     TempBitmap tmpBitmap;
-    SetPaintPattern(maskPaint, SurfacePattern(aMask, ExtendMode::CLAMP), tmpBitmap);
-
-    SkMatrix transform = maskPaint.getShader()->getLocalMatrix();
-    transform.postTranslate(SkFloatToScalar(aOffset.x), SkFloatToScalar(aOffset.y));
-    SkShader* matrixShader = SkShader::CreateLocalMatrixShader(maskPaint.getShader(), transform);
-    SkSafeUnref(maskPaint.setShader(matrixShader));
+    SetPaintPattern(maskPaint,
+                    SurfacePattern(aMask, ExtendMode::CLAMP, Matrix::Translation(aOffset)),
+                    tmpBitmap);
 
     SkLayerRasterizer::Builder builder;
     builder.addLayer(maskPaint);
     SkAutoTUnref<SkRasterizer> raster(builder.detachRasterizer());
     paint.mPaint.setRasterizer(raster.get());
 
     IntSize size = aMask->GetSize();
     Rect rect = Rect(aOffset.x, aOffset.y, size.width, size.height);