Bug 1543744 - use clip bounds when drawing masks with Skia. r=mattwoodrow
authorLee Salzman <lsalzman@mozilla.com>
Thu, 11 Apr 2019 19:00:32 +0000
changeset 469103 35caf615155e3fc9638eed7b00cd99ac08dd4f7b
parent 469102 6534d80a3329536b4bb9068f9d56ccb030616750
child 469104 6ceb09138e9b90584c87c4212a0f2df71e3e01c2
push id35856
push usercsabou@mozilla.com
push dateFri, 12 Apr 2019 03:19:48 +0000
treeherdermozilla-central@940684cd1065 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1543744
milestone68.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 1543744 - use clip bounds when drawing masks with Skia. r=mattwoodrow Differential Revision: https://phabricator.services.mozilla.com/D27112
gfx/skia/skia/src/core/SkDraw.cpp
--- a/gfx/skia/skia/src/core/SkDraw.cpp
+++ b/gfx/skia/skia/src/core/SkDraw.cpp
@@ -974,16 +974,21 @@ void SkDraw::drawPath(const SkPath& orig
     pathPtr->transform(*matrix, devPathPtr);
 
     this->drawDevPath(*devPathPtr, *paint, drawCoverage, customBlitter, doFill);
 }
 
 void SkDraw::drawBitmapAsMask(const SkBitmap& bitmap, const SkPaint& paint) const {
     SkASSERT(bitmap.colorType() == kAlpha_8_SkColorType);
 
+    // nothing to draw
+    if (fRC->isEmpty()) {
+        return;
+    }
+
     if (SkTreatAsSprite(*fMatrix, bitmap.dimensions(), paint)) {
         int ix = SkScalarRoundToInt(fMatrix->getTranslateX());
         int iy = SkScalarRoundToInt(fMatrix->getTranslateY());
 
         SkPixmap pmap;
         if (!bitmap.peekPixels(&pmap)) {
             return;
         }
@@ -1005,17 +1010,18 @@ void SkDraw::drawBitmapAsMask(const SkBi
         r.round(&mask.fBounds);
 
         // set the mask's bounds to the transformed bitmap-bounds,
         // clipped to the actual device
         {
             SkIRect    devBounds;
             devBounds.set(0, 0, fDst.width(), fDst.height());
             // need intersect(l, t, r, b) on irect
-            if (!mask.fBounds.intersect(devBounds)) {
+            if (!devBounds.intersect(fRC->getBounds()) ||
+                !mask.fBounds.intersect(devBounds)) {
                 return;
             }
         }
 
         mask.fFormat = SkMask::kA8_Format;
         mask.fRowBytes = SkAlign4(mask.fBounds.width());
         size_t size = mask.computeImageSize();
         if (0 == size) {