Simplify the signature of sk/aaa_fill_path

Previously, the clipRect is either equal to nullptr or clipRgn's bound
(after necessary supersampling shift). Hence we drop one of them to make
the signature simpler.

BUG=skia:

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

Change-Id: Ied8d5313809d6cf90374365b01f2b8d52f2236e2
Reviewed-on: https://skia-review.googlesource.com/4874
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Yuqian Li <liyuqian@google.com>
diff --git a/src/core/SkScan.h b/src/core/SkScan.h
index c0610bf..24e0088 100644
--- a/src/core/SkScan.h
+++ b/src/core/SkScan.h
@@ -87,9 +87,6 @@
     static void AntiHairLineRgn(const SkPoint[], int count, const SkRegion*, SkBlitter*);
     static void AAAFillPath(const SkPath& path, const SkRegion& origClip, SkBlitter* blitter,
                             bool forceRLE = false); // SkAAClip uses forceRLE
-    static void aaa_fill_path(const SkPath& path, const SkIRect* clipRect, AdditiveBlitter*,
-                   int start_y, int stop_y, const SkRegion& clipRgn, bool isUsingMask,
-                   bool forceRLE);
 };
 
 /** Assign an SkXRect from a SkIRect, by promoting the src rect's coordinates
diff --git a/src/core/SkScanPriv.h b/src/core/SkScanPriv.h
index 4ff91bb..4c237e0 100644
--- a/src/core/SkScanPriv.h
+++ b/src/core/SkScanPriv.h
@@ -30,10 +30,13 @@
     const SkIRect*      fClipRect;
 };
 
-// clipRect == null means path is entirely inside the clip
-void sk_fill_path(const SkPath& path, const SkIRect* clipRect,
+void sk_fill_path(const SkPath& path, const SkIRect& clipRect,
                   SkBlitter* blitter, int start_y, int stop_y, int shiftEdgesUp,
-                  const SkRegion& clipRgn);
+                  bool pathContainedInClip);
+
+void aaa_fill_path(const SkPath& path, const SkIRect& clipRect, AdditiveBlitter*,
+                   int start_y, int stop_y, bool pathContainedInClip, bool isUsingMask,
+                   bool forceRLE);
 
 // blit the rects above and below avoid, clipped to clip
 void sk_blit_above(SkBlitter*, const SkIRect& avoid, const SkRegion& clip);
diff --git a/src/core/SkScan_AAAPath.cpp b/src/core/SkScan_AAAPath.cpp
index 3915fea..1c989f8 100644
--- a/src/core/SkScan_AAAPath.cpp
+++ b/src/core/SkScan_AAAPath.cpp
@@ -1143,8 +1143,8 @@
     #endif
 }
 
-void SkScan::aaa_fill_path(const SkPath& path, const SkIRect* clipRect, AdditiveBlitter* blitter,
-                   int start_y, int stop_y, const SkRegion& clipRgn, bool isUsingMask,
+void aaa_fill_path(const SkPath& path, const SkIRect& clipRect, AdditiveBlitter* blitter,
+                   int start_y, int stop_y, bool pathContainedInClip, bool isUsingMask,
                    bool forceRLE) { // forceRLE implies that SkAAClip is calling us
     SkASSERT(blitter);
 
@@ -1157,12 +1157,13 @@
     const bool canCullToTheRight = !path.isConvex();
 
     SkASSERT(gSkUseAnalyticAA.load());
-    int count = builder.build(path, clipRect, 0, canCullToTheRight, true);
+    const SkIRect* builderClip = pathContainedInClip ? nullptr : &clipRect;
+    int count = builder.build(path, builderClip, 0, canCullToTheRight, true);
     SkASSERT(count >= 0);
 
     SkAnalyticEdge** list = (SkAnalyticEdge**)builder.analyticEdgeList();
 
-    SkIRect rect = clipRgn.getBounds();
+    SkIRect rect = clipRect;
     if (0 == count) {
         if (path.isInverseFillType()) {
             /*
@@ -1208,11 +1209,11 @@
 
     // now edge is the head of the sorted linklist
 
-    if (clipRect && start_y < clipRect->fTop) {
-        start_y = clipRect->fTop;
+    if (!pathContainedInClip && start_y < clipRect.fTop) {
+        start_y = clipRect.fTop;
     }
-    if (clipRect && stop_y > clipRect->fBottom) {
-        stop_y = clipRect->fBottom;
+    if (!pathContainedInClip && stop_y > clipRect.fBottom) {
+        stop_y = clipRect.fBottom;
     }
 
     if (!path.isInverseFillType() && path.isConvex()) {
@@ -1349,12 +1350,12 @@
 
     if (MaskAdditiveBlitter::canHandleRect(ir) && !isInverse && !forceRLE) {
         MaskAdditiveBlitter additiveBlitter(blitter, ir, *clipRgn, isInverse);
-        aaa_fill_path(path, clipRect, &additiveBlitter, ir.fTop, ir.fBottom, *clipRgn, true,
-                      forceRLE);
+        aaa_fill_path(path, clipRgn->getBounds(), &additiveBlitter, ir.fTop, ir.fBottom,
+                clipRect == nullptr, true, forceRLE);
     } else {
         RunBasedAdditiveBlitter additiveBlitter(blitter, ir, *clipRgn, isInverse);
-        aaa_fill_path(path, clipRect, &additiveBlitter, ir.fTop, ir.fBottom, *clipRgn, false,
-                      forceRLE);
+        aaa_fill_path(path, clipRgn->getBounds(), &additiveBlitter, ir.fTop, ir.fBottom,
+                clipRect == nullptr, false, forceRLE);
     }
 
     if (isInverse) {
diff --git a/src/core/SkScan_AntiPath.cpp b/src/core/SkScan_AntiPath.cpp
index 53dac3f..1d214e3 100644
--- a/src/core/SkScan_AntiPath.cpp
+++ b/src/core/SkScan_AntiPath.cpp
@@ -691,6 +691,9 @@
         return;
     }
 
+    SkASSERT(clipper.getClipRect() == nullptr ||
+            *clipper.getClipRect() == clipRgn->getBounds());
+
     // now use the (possibly wrapped) blitter
     blitter = clipper.getBlitter();
 
@@ -715,10 +718,12 @@
     if (!isInverse && MaskSuperBlitter::CanHandleRect(ir) && !forceRLE) {
         MaskSuperBlitter    superBlit(blitter, ir, *clipRgn, isInverse);
         SkASSERT(SkIntToScalar(ir.fTop) <= path.getBounds().fTop);
-        sk_fill_path(path, superClipRect, &superBlit, ir.fTop, ir.fBottom, SHIFT, *clipRgn);
+        sk_fill_path(path, clipRgn->getBounds(), &superBlit, ir.fTop, ir.fBottom, SHIFT,
+                superClipRect == nullptr);
     } else {
         SuperBlitter    superBlit(blitter, ir, *clipRgn, isInverse);
-        sk_fill_path(path, superClipRect, &superBlit, ir.fTop, ir.fBottom, SHIFT, *clipRgn);
+        sk_fill_path(path, clipRgn->getBounds(), &superBlit, ir.fTop, ir.fBottom, SHIFT,
+                superClipRect == nullptr);
     }
 
     if (isInverse) {
diff --git a/src/core/SkScan_Path.cpp b/src/core/SkScan_Path.cpp
index 9ce18b0..ec0fe06 100644
--- a/src/core/SkScan_Path.cpp
+++ b/src/core/SkScan_Path.cpp
@@ -421,21 +421,24 @@
     return list[0];
 }
 
-// clipRect may be null, even though we always have a clip. This indicates that
-// the path is contained in the clip, and so we can ignore it during the blit
-//
-// clipRect (if no null) has already been shifted up
-//
-void sk_fill_path(const SkPath& path, const SkIRect* clipRect, SkBlitter* blitter,
-                  int start_y, int stop_y, int shiftEdgesUp, const SkRegion& clipRgn) {
+// clipRect has not been shifted up
+void sk_fill_path(const SkPath& path, const SkIRect& clipRect, SkBlitter* blitter,
+                  int start_y, int stop_y, int shiftEdgesUp, bool pathContainedInClip) {
     SkASSERT(blitter);
 
+    SkIRect shiftedClip = clipRect;
+    shiftedClip.fLeft <<= shiftEdgesUp;
+    shiftedClip.fRight <<= shiftEdgesUp;
+    shiftedClip.fTop <<= shiftEdgesUp;
+    shiftedClip.fBottom <<= shiftEdgesUp;
+
     SkEdgeBuilder   builder;
 
     // If we're convex, then we need both edges, even the right edge is past the clip
     const bool canCullToTheRight = !path.isConvex();
 
-    int count = builder.build(path, clipRect, shiftEdgesUp, canCullToTheRight);
+    SkIRect* builderClip = pathContainedInClip ? nullptr : &shiftedClip;
+    int count = builder.build(path, builderClip, shiftEdgesUp, canCullToTheRight);
     SkASSERT(count >= 0);
 
     SkEdge**    list = builder.edgeList();
@@ -448,7 +451,7 @@
              *  we need to restrict our drawing to the intersection of the clip
              *  and those two limits.
              */
-            SkIRect rect = clipRgn.getBounds();
+            SkIRect rect = clipRect;
             if (rect.fTop < start_y) {
                 rect.fTop = start_y;
             }
@@ -484,18 +487,18 @@
 
     start_y = SkLeftShift(start_y, shiftEdgesUp);
     stop_y = SkLeftShift(stop_y, shiftEdgesUp);
-    if (clipRect && start_y < clipRect->fTop) {
-        start_y = clipRect->fTop;
+    if (!pathContainedInClip && start_y < shiftedClip.fTop) {
+        start_y = shiftedClip.fTop;
     }
-    if (clipRect && stop_y > clipRect->fBottom) {
-        stop_y = clipRect->fBottom;
+    if (!pathContainedInClip && stop_y > shiftedClip.fBottom) {
+        stop_y = shiftedClip.fBottom;
     }
 
     InverseBlitter  ib;
     PrePostProc     proc = nullptr;
 
     if (path.isInverseFillType()) {
-        ib.setBlitter(blitter, clipRgn.getBounds(), shiftEdgesUp);
+        ib.setBlitter(blitter, clipRect, shiftEdgesUp);
         blitter = &ib;
         proc = PrePostInverseBlitterProc;
     }
@@ -504,14 +507,8 @@
         SkASSERT(count >= 2);   // convex walker does not handle missing right edges
         walk_convex_edges(&headEdge, path.getFillType(), blitter, start_y, stop_y, nullptr);
     } else {
-        int rightEdge;
-        if (clipRect) {
-            rightEdge = clipRect->right();
-        } else {
-            rightEdge = SkScalarRoundToInt(path.getBounds().right()) << shiftEdgesUp;
-        }
-
-        walk_edges(&headEdge, path.getFillType(), blitter, start_y, stop_y, proc, rightEdge);
+        walk_edges(&headEdge, path.getFillType(), blitter, start_y, stop_y, proc,
+                shiftedClip.right());
     }
 }
 
@@ -676,8 +673,10 @@
         if (path.isInverseFillType()) {
             sk_blit_above(blitter, ir, *clipPtr);
         }
-        sk_fill_path(path, clipper.getClipRect(), blitter, ir.fTop, ir.fBottom,
-                     0, *clipPtr);
+        SkASSERT(clipper.getClipRect() == nullptr ||
+                *clipper.getClipRect() == clipPtr->getBounds());
+        sk_fill_path(path, clipPtr->getBounds(), blitter, ir.fTop, ir.fBottom,
+                     0, clipper.getClipRect() == nullptr);
         if (path.isInverseFillType()) {
             sk_blit_below(blitter, ir, *clipPtr);
         }