From 1c19e4af27e24e33cc2ef9a4ec309f0422d44b65 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Thu, 18 Aug 2016 11:25:38 -0400 Subject: [PATCH] Bug 1296301 - use getClipDeviceBounds instead of getClipBounds in DrawTargetSkia. r=jrmuizel MozReview-Commit-ID: BEIAGS0hLzB --- gfx/2d/DrawTargetSkia.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/gfx/2d/DrawTargetSkia.cpp b/gfx/2d/DrawTargetSkia.cpp index b9081ab18c4c..ec6ed8fa6598 100644 --- a/gfx/2d/DrawTargetSkia.cpp +++ b/gfx/2d/DrawTargetSkia.cpp @@ -398,11 +398,20 @@ SetPaintPattern(SkPaint& aPaint, const Pattern& aPattern, Float aAlpha = 1.0) static inline Rect GetClipBounds(SkCanvas *aCanvas) { - SkRect clipBounds; - if (!aCanvas->getClipBounds(&clipBounds)) { + // Use a manually transformed getClipDeviceBounds instead of + // getClipBounds because getClipBounds inflates the the bounds + // by a pixel in each direction to compensate for antialiasing. + SkIRect deviceBounds; + if (!aCanvas->getClipDeviceBounds(&deviceBounds)) { return Rect(); } - return SkRectToRect(clipBounds); + SkMatrix inverseCTM; + if (!aCanvas->getTotalMatrix().invert(&inverseCTM)) { + return Rect(); + } + SkRect localBounds; + inverseCTM.mapRect(&localBounds, SkRect::Make(deviceBounds)); + return SkRectToRect(localBounds); } struct AutoPaintSetup {