add inverted path draw cases to complexclip gm

Review URL: https://codereview.chromium.org/809163002
diff --git a/gm/complexclip.cpp b/gm/complexclip.cpp
index 61a19fd..ebb7707 100644
--- a/gm/complexclip.cpp
+++ b/gm/complexclip.cpp
@@ -18,14 +18,12 @@
 static const SkColor gClipBColor = SK_ColorRED;
 
 class ComplexClipGM : public GM {
-    bool fDoAAClip;
-    bool fDoSaveLayer;
 public:
-    ComplexClipGM(bool aaclip, bool saveLayer)
+    ComplexClipGM(bool aaclip, bool saveLayer, bool invertDraw)
     : fDoAAClip(aaclip)
-    , fDoSaveLayer(saveLayer) {
+    , fDoSaveLayer(saveLayer)
+    , fInvertDraw(invertDraw) {
         this->setBGColor(0xFFDDDDDD);
-//        this->setBGColor(SkColorSetRGB(0xB0,0xDD,0xB0));
     }
 
 protected:
@@ -36,9 +34,10 @@
 
     SkString onShortName() {
         SkString str;
-        str.printf("complexclip_%s%s",
+        str.printf("complexclip_%s%s%s",
                    fDoAAClip ? "aa" : "bw",
-                   fDoSaveLayer ? "_layer" : "");
+                   fDoSaveLayer ? "_layer" : "",
+                   fInvertDraw ? "_invert" : "");
         return str;
     }
 
@@ -60,7 +59,11 @@
         path.quadTo(SkIntToScalar(150), SkIntToScalar(150), SkIntToScalar(125), SkIntToScalar(150));
         path.lineTo(SkIntToScalar(50),  SkIntToScalar(150));
         path.close();
-        path.setFillType(SkPath::kEvenOdd_FillType);
+        if (fInvertDraw) {
+            path.setFillType(SkPath::kInverseEvenOdd_FillType);
+        } else {
+            path.setFillType(SkPath::kEvenOdd_FillType);
+        }
         SkPaint pathPaint;
         pathPaint.setAntiAlias(true);
         pathPaint.setColor(gPathColor);
@@ -134,6 +137,16 @@
                     canvas->clipPath(clipA, SkRegion::kIntersect_Op, fDoAAClip);
                     canvas->clipPath(clipB, gOps[op].fOp, fDoAAClip);
 
+                    // In the inverse case we need to prevent the draw from covering the whole
+                    // canvas.
+                    if (fInvertDraw) {
+                        SkRect rectClip = clipA.getBounds();
+                        rectClip.join(path.getBounds());
+                        rectClip.join(path.getBounds());
+                        rectClip.outset(5, 5);
+                        canvas->clipRect(rectClip);
+                    }
+
                     // draw path clipped
                     canvas->drawPath(path, pathPaint);
                 canvas->restore();
@@ -181,22 +194,22 @@
         canvas->drawPath(clipB, paint);
     }
 
+    bool fDoAAClip;
+    bool fDoSaveLayer;
+    bool fInvertDraw;
+
     typedef GM INHERITED;
 };
 
 //////////////////////////////////////////////////////////////////////////////
 
-// aliased and anti-aliased w/o a layer
-static GM* gFact0(void*) { return new ComplexClipGM(false, false); }
-static GM* gFact1(void*) { return new ComplexClipGM(true, false); }
-
-// aliased and anti-aliased w/ a layer
-static GM* gFact2(void*) { return new ComplexClipGM(false, true); }
-static GM* gFact3(void*) { return new ComplexClipGM(true, true); }
-
-static GMRegistry gReg0(gFact0);
-static GMRegistry gReg1(gFact1);
-static GMRegistry gReg2(gFact2);
-static GMRegistry gReg3(gFact3);
+DEF_GM( return SkNEW_ARGS(ComplexClipGM, (false, false, false)); )
+DEF_GM( return SkNEW_ARGS(ComplexClipGM, (false, false, true));  )
+DEF_GM( return SkNEW_ARGS(ComplexClipGM, (false, true,  false)); )
+DEF_GM( return SkNEW_ARGS(ComplexClipGM, (false, true,  true));  )
+DEF_GM( return SkNEW_ARGS(ComplexClipGM, (true,  false, false)); )
+DEF_GM( return SkNEW_ARGS(ComplexClipGM, (true,  false, true));  )
+DEF_GM( return SkNEW_ARGS(ComplexClipGM, (true,  true,  false)); )
+DEF_GM( return SkNEW_ARGS(ComplexClipGM, (true,  true,  true));  )
 
 }