Snug the clip with path bounds inside SkAAClip
authorYuqian Li <liyuqian@google.com>
Thu, 10 Nov 2016 14:44:55 +0000 (09:44 -0500)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Thu, 10 Nov 2016 15:13:46 +0000 (15:13 +0000)
https://codereview.chromium.org/2482193004/ is related with this patch.

BUG=skia:

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4636

Change-Id: Ibd6d64578e08c75a3cfcef45489afc9b59ad40be
Reviewed-on: https://skia-review.googlesource.com/4636
Commit-Queue: Yuqian Li <liyuqian@google.com>
Reviewed-by: Mike Reed <reed@google.com>
src/core/SkAAClip.cpp

index 1a60754d91370a1888a6b99842bf77de24b88580..467939b4e733bfd9b0e0b737fc291521011302f1 100644 (file)
@@ -1403,12 +1403,18 @@ bool SkAAClip::setPath(const SkPath& path, const SkRegion* clip, bool doAA) {
         clip = &tmpClip;
     }
 
+    // Since we assert that the BuilderBlitter will never blit outside the intersection
+    // of clip and ibounds, we create this snugClip to be that intersection and send it
+    // to the scan-converter.
+    SkRegion snugClip(*clip);
+
     if (path.isInverseFillType()) {
         ibounds = clip->getBounds();
     } else {
         if (ibounds.isEmpty() || !ibounds.intersect(clip->getBounds())) {
             return this->setEmpty();
         }
+        snugClip.op(ibounds, SkRegion::kIntersect_Op);
     }
 
     Builder        builder(ibounds);
@@ -1416,12 +1422,12 @@ bool SkAAClip::setPath(const SkPath& path, const SkRegion* clip, bool doAA) {
 
     if (doAA) {
         if (gSkUseAnalyticAA.load()) {
-            SkScan::AAAFillPath(path, *clip, &blitter, true);
+            SkScan::AAAFillPath(path, snugClip, &blitter, true);
         } else {
-            SkScan::AntiFillPath(path, *clip, &blitter, true);
+            SkScan::AntiFillPath(path, snugClip, &blitter, true);
         }
     } else {
-        SkScan::FillPath(path, *clip, &blitter);
+        SkScan::FillPath(path, snugClip, &blitter);
     }
 
     blitter.finish();