Convert GrAppliedClip interface to builder style

GrAppliedClip was about at its limit for how many "make" functions it
could have. Window rectangles would push it over the edge. This change
makes it so GrDrawTarget supplies the original draw bounds to the
constructor, and then GrClip adds the various required clipping
techniques.

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

Review-Url: https://codereview.chromium.org/2246113002
diff --git a/tests/ClipStackTest.cpp b/tests/ClipStackTest.cpp
index a6b6362..5265ac2 100644
--- a/tests/ClipStackTest.cpp
+++ b/tests/ClipStackTest.cpp
@@ -916,7 +916,8 @@
     // they are equal.
 
     // All the clip elements will be contained within these bounds.
-    static const SkRect kBounds = SkRect::MakeWH(100, 100);
+    static const SkIRect kIBounds = SkIRect::MakeWH(100, 100);
+    static const SkRect kBounds = SkRect::Make(kIBounds);
 
     enum {
         kNumTests = 250,
@@ -1015,13 +1016,14 @@
                                 testCase.c_str());
 
         if (!reduced.elements().isEmpty()) {
+            REPORTER_ASSERT_MESSAGE(reporter, reduced.hasIBounds(), testCase.c_str());
             SkRect stackBounds;
             SkClipStack::BoundsType stackBoundsType;
             stack.getBounds(&stackBounds, &stackBoundsType);
             if (SkClipStack::kNormal_BoundsType == stackBoundsType) {
                 // Unless GrReducedClip starts doing some heroic tightening of the clip bounds, this
                 // will be true since the stack bounds are completely contained inside the query.
-                REPORTER_ASSERT_MESSAGE(reporter, GrClip::IsInsideClip(reduced.iBounds(), stackBounds),
+                REPORTER_ASSERT_MESSAGE(reporter, GrClip::IsInsideClip(reduced.ibounds(), stackBounds),
                                         testCase.c_str());
             }
             REPORTER_ASSERT_MESSAGE(reporter, reduced.requiresAA() == doAA, testCase.c_str());
@@ -1037,16 +1039,18 @@
             add_elem_to_stack(*iter.get(), &reducedStack);
         }
 
+        SkIRect ibounds = reduced.hasIBounds() ? reduced.ibounds() : kIBounds;
+
         // GrReducedClipStack assumes that the final result is clipped to the returned bounds
-        reducedStack.clipDevRect(reduced.iBounds(), SkRegion::kIntersect_Op);
-        stack.clipDevRect(reduced.iBounds(), SkRegion::kIntersect_Op);
+        reducedStack.clipDevRect(ibounds, SkRegion::kIntersect_Op);
+        stack.clipDevRect(ibounds, SkRegion::kIntersect_Op);
 
         // convert both the original stack and reduced stack to SkRegions and see if they're equal
         SkRegion region;
-        set_region_to_stack(stack, reduced.iBounds(), &region);
+        set_region_to_stack(stack, ibounds, &region);
 
         SkRegion reducedRegion;
-        set_region_to_stack(reducedStack, reduced.iBounds(), &reducedRegion);
+        set_region_to_stack(reducedStack, ibounds, &reducedRegion);
 
         REPORTER_ASSERT_MESSAGE(reporter, region == reducedRegion, testCase.c_str());
     }
@@ -1151,8 +1155,10 @@
             SkASSERT(reduced.genID() == testCases[i].reducedGenID);
             REPORTER_ASSERT(reporter, reduced.initialState() == testCases[i].initialState);
             SkASSERT(reduced.initialState() == testCases[i].initialState);
-            REPORTER_ASSERT(reporter, reduced.iBounds() == testCases[i].clipIRect);
-            SkASSERT(reduced.iBounds() == testCases[i].clipIRect);
+            REPORTER_ASSERT(reporter, reduced.hasIBounds());
+            SkASSERT(reduced.hasIBounds());
+            REPORTER_ASSERT(reporter, reduced.ibounds() == testCases[i].clipIRect);
+            SkASSERT(reduced.ibounds() == testCases[i].clipIRect);
         }
     }
 }
@@ -1197,7 +1203,9 @@
             return;
         case ClipMethod::kIgnoreClip:
             SkASSERT(0 == numExpectedElems);
-            REPORTER_ASSERT_MESSAGE(reporter, GrClip::IsInsideClip(reduced.iBounds(), queryBounds),
+            REPORTER_ASSERT_MESSAGE(reporter,
+                                    !reduced.hasIBounds() ||
+                                    GrClip::IsInsideClip(reduced.ibounds(), queryBounds),
                                     testName.c_str());
             REPORTER_ASSERT_MESSAGE(reporter, reduced.elements().isEmpty(), testName.c_str());
             REPORTER_ASSERT_MESSAGE(reporter,
@@ -1210,7 +1218,8 @@
             SkIRect expectedScissor;
             stackBounds.round(&expectedScissor);
             REPORTER_ASSERT_MESSAGE(reporter, reduced.elements().isEmpty(), testName.c_str());
-            REPORTER_ASSERT_MESSAGE(reporter, expectedScissor == reduced.iBounds(),
+            REPORTER_ASSERT_MESSAGE(reporter, reduced.hasIBounds(), testName.c_str());
+            REPORTER_ASSERT_MESSAGE(reporter, expectedScissor == reduced.ibounds(),
                                     testName.c_str());
             REPORTER_ASSERT_MESSAGE(reporter,
                                     GrReducedClip::InitialState::kAllIn == reduced.initialState(),
@@ -1224,7 +1233,8 @@
             }
             REPORTER_ASSERT_MESSAGE(reporter, numExpectedElems == reduced.elements().count(),
                                     testName.c_str());
-            REPORTER_ASSERT_MESSAGE(reporter, expectedClipIBounds == reduced.iBounds(),
+            REPORTER_ASSERT_MESSAGE(reporter, reduced.hasIBounds(), testName.c_str());
+            REPORTER_ASSERT_MESSAGE(reporter, expectedClipIBounds == reduced.ibounds(),
                                     testName.c_str());
             REPORTER_ASSERT_MESSAGE(reporter, reduced.requiresAA() == !reduced.elements().isEmpty(),
                                     testName.c_str());