allow clip calls w/o op param, remove unnecessary kReplace ops
authorreed <reed@google.com>
Wed, 21 Sep 2016 18:15:07 +0000 (11:15 -0700)
committerCommit bot <commit-bot@chromium.org>
Wed, 21 Sep 2016 18:15:07 +0000 (11:15 -0700)
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2357333002

Review-Url: https://codereview.chromium.org/2357333002

18 files changed:
gm/aaclip.cpp
gm/bigblurs.cpp
gm/circularclips.cpp
gm/clip_strokerect.cpp
gm/complexclip.cpp
gm/complexclip3.cpp
gm/distantclip.cpp
gm/imagefilters.cpp
gm/path_stroke_with_zero_length.cpp
gm/pathopsinverse.cpp
gm/pathopsskpclip.cpp
gm/rrectclipdrawpaint.cpp
gm/rrects.cpp
gm/samplerstress.cpp
gm/simpleaaclip.cpp
gm/skbug1719.cpp
include/core/SkCanvas.h
samplecode/SampleClipDrawMatch.cpp

index d6576691ea9e0dee915939efa00fe51479a94670..26a25c13856878383abe80318c99c896220d60ff 100644 (file)
@@ -85,7 +85,7 @@ static void draw(SkCanvas* canvas, SkRect& target, int x, int y) {
     canvas->drawRect(target, borderPaint);
     target.inset(SkIntToScalar(2), SkIntToScalar(2));
     canvas->drawRect(target, backgroundPaint);
-    canvas->clipRect(target, SkCanvas::kIntersect_Op, true);
+    canvas->clipRect(target, true);
     target.inset(SkIntToScalar(-4), SkIntToScalar(-4));
     canvas->drawRect(target, foregroundPaint);
     canvas->restore();
index ee5ccd1345e2ac355bf09ccf22fa40fdcc9afb77..0acd190972c3c25bcdd57cfc73d224fe0c4e0fc2 100644 (file)
@@ -80,7 +80,7 @@ protected:
                                                        SkIntToScalar(kCloseUpSize),
                                                        SkIntToScalar(kCloseUpSize));
 
-                    canvas->clipRect(clipRect, SkCanvas::kReplace_Op, false);
+                    canvas->clipRect(clipRect);
 
                     canvas->translate(desiredX-origins[k].fX,
                                       desiredY-origins[k].fY);
index 39be1a5aec81abc05aca0d1468ad266f9f3ae348..f505310e4de688ff37d9b27883dc375de1696c1e 100644 (file)
@@ -54,8 +54,8 @@ protected:
         canvas->save();
         canvas->scale(10, 10);
         canvas->translate(-((fX1 + fX2)/2 - fR), -(fY - 2*fR/3));
-        canvas->clipPath(fCircle1, SkCanvas::kReplace_Op, true);
-        canvas->clipPath(fCircle2, SkCanvas::kIntersect_Op, true);
+        canvas->clipPath(fCircle1, true);
+        canvas->clipPath(fCircle2, true);
 
         canvas->drawRect(rect, fillPaint);
 
@@ -73,7 +73,7 @@ protected:
             for (size_t op = 0; op < SK_ARRAY_COUNT(ops); op++) {
                 canvas->save();
 
-                canvas->clipPath(fCircle1, SkCanvas::kReplace_Op);
+                canvas->clipPath(fCircle1);
                 canvas->clipPath(fCircle2, ops[op]);
 
                 canvas->drawRect(rect, fillPaint);
index 814455d1454ee15c4d811460b7a0a54f69cba59d..34adf8a1cf941a2275fa769b20d3597ab2436fa7 100644 (file)
@@ -36,7 +36,7 @@ protected:
         SkRect rect = SkRect::MakeXYWH(20, 0, 100, 20);
 
         canvas->save();
-        canvas->clipRect(rect, SkCanvas::kReplace_Op, true);
+        canvas->clipRect(rect, true);
         canvas->drawRect(r, p);
         canvas->restore();
 
@@ -54,7 +54,7 @@ protected:
         SkRect rect2 = SkRect::MakeXYWH(20, 120, 100, 19);
 
         canvas->save();
-        canvas->clipRect(rect2, SkCanvas::kReplace_Op, true);
+        canvas->clipRect(rect2, true);
         canvas->drawRect(r2, p);
         canvas->restore();
 
index fb94957f02619e6b08c69fdf1ff0353ee33bfc9b..2f8fa3d32582ccb3fc2770fa4cc224241ff5503e 100644 (file)
@@ -130,7 +130,7 @@ protected:
                                       SkPath::kEvenOdd_FillType);
                     clipB.setFillType(doInvB ? SkPath::kInverseEvenOdd_FillType :
                                       SkPath::kEvenOdd_FillType);
-                    canvas->clipPath(clipA, SkCanvas::kIntersect_Op, fDoAAClip);
+                    canvas->clipPath(clipA, fDoAAClip);
                     canvas->clipPath(clipB, gOps[op].fOp, fDoAAClip);
 
                     // In the inverse case we need to prevent the draw from covering the whole
index fd8cd3510040858506df9289f11d9e59d1b4ebc0..59c78ec5a334ff11c97a297b3c339f52d72f7d00 100644 (file)
@@ -84,7 +84,7 @@ protected:
                                                SkPath::kEvenOdd_FillType);
                         secondClip->setFillType(doInvB ? SkPath::kInverseEvenOdd_FillType :
                                                 SkPath::kEvenOdd_FillType);
-                        canvas->clipPath(*firstClip, SkCanvas::kIntersect_Op, doAAA);
+                        canvas->clipPath(*firstClip, doAAA);
                         canvas->clipPath(*secondClip, gOps[op].fOp, doAAB);
 
                         // draw rect clipped
index f4931ddc2707504a1c944527f8c9ca28e7e54ba6..24fbacaf4d55639d2a6bfa113b98fe77af7d39a6 100644 (file)
@@ -39,7 +39,7 @@ protected:
         SkRect r = SkRect::MakeXYWH(-kExtents, kOffset - kExtents, 2 * kExtents, 2 * kExtents);
         SkPath p;
         p.addRoundRect(r, 5, 5);
-        rec->clipPath(p, SkCanvas::kIntersect_Op, true);
+        rec->clipPath(p, true);
         rec->drawColor(SK_ColorGREEN);
         rec->restore();
         sk_sp<SkPicture> pict(recorder.finishRecordingAsPicture());
index 3e8d39a8792576d4ee657d145f1a616c60f92510..e9f54a312d8ea3592112abba37a2f86bbb0f9f5f 100644 (file)
@@ -122,7 +122,7 @@ static void draw_set(SkCanvas* canvas, sk_sp<SkImageFilter> filters[], int count
     for (int i = 0; i < count; ++i) {
         canvas->save();
         SkRRect rr = SkRRect::MakeRectXY(r.makeOffset(dx, dy), 20, 20);
-        canvas->clipRRect(rr, SkCanvas::kIntersect_Op, true);
+        canvas->clipRRect(rr, true);
         canvas->saveLayer({ &rr.getBounds(), nullptr, filters[i].get(), 0 });
         canvas->drawColor(0x40FFFFFF);
         canvas->restore();
index 9c05541877f96e0df35d0c76245b6972f47b590a..0f6d200b6ff6602372a0148bd955991cdaa0e425 100644 (file)
@@ -167,7 +167,7 @@ private:
         } else {
             fClipS.transform(clipM, &clip);
         }
-        canvas->clipPath(clip, SkCanvas::kIntersect_Op, true);
+        canvas->clipPath(clip, true);
         canvas->scale(scale, scale);
         canvas->drawBitmap(offscreen, (bounds.fLeft - 17) / scale,
                     (bounds.fTop - 20 + 420) / scale);
@@ -180,7 +180,7 @@ private:
             clipM.postTranslate(bounds.fLeft - 17 - 275, bounds.fTop - 24.5f + 420);
             SkPath clip;
             fClipR.transform(clipM, &clip);
-            canvas->clipPath(clip, SkCanvas::kIntersect_Op, true);
+            canvas->clipPath(clip, true);
             canvas->scale(10.f, 10.f);
             canvas->drawBitmap(offscreen, (bounds.fLeft - 17 - 275
                     + (index >= 5 ? 5 : 0)) / scale, (bounds.fTop - 20 + 420) / scale);
index 176bc769e24f64211cdd9e758cba8000aeb5bec3..918666ca382b83765a81487f23a2e3b210c78715 100644 (file)
@@ -75,7 +75,7 @@ protected:
                 two.addRect(40, 40, 100, 100);
                 canvas->save();
                 canvas->translate(0, SkIntToScalar(yPos));
-                canvas->clipRect(SkRect::MakeWH(110, 110), SkCanvas::kIntersect_Op, true);
+                canvas->clipRect(SkRect::MakeWH(110, 110), true);
                 canvas->drawPath(one, fOnePaint);
                 canvas->drawPath(one, fOutlinePaint);
                 canvas->drawPath(two, fTwoPaint);
@@ -87,7 +87,7 @@ protected:
                     Op(one, two, (SkPathOp) op, &result);
                     canvas->save();
                     canvas->translate(SkIntToScalar(xPos), SkIntToScalar(yPos));
-                    canvas->clipRect(SkRect::MakeWH(110, 110), SkCanvas::kIntersect_Op, true);
+                    canvas->clipRect(SkRect::MakeWH(110, 110), true);
                     canvas->drawPath(result, fOpPaint[op]);
                     canvas->drawPath(result, fOutlinePaint);
                     canvas->restore();
index 77ba84c73c058814255c9f4802242dc526d1d364..18be6815799cce254d59be00b2213dfd1e4edd29 100644 (file)
@@ -42,9 +42,9 @@ protected:
             SkIntToScalar(700)
         };
         p.addRoundRect(r, SkIntToScalar(50), SkIntToScalar(50));
-        rec->clipPath(p, SkCanvas::kIntersect_Op, true);
+        rec->clipPath(p, true);
         rec->translate(SkIntToScalar(250), SkIntToScalar(250));
-        rec->clipPath(p, SkCanvas::kIntersect_Op, true);
+        rec->clipPath(p, true);
         rec->drawColor(0xffff0000);
         sk_sp<SkPicture> pict(recorder.finishRecordingAsPicture());
 
index 74b57835c8d41d8b669496f66356a4d40d1a7ed9..c997f845eb551fd6a3af1e38ed6c3b3b87f56761 100644 (file)
@@ -21,14 +21,14 @@ DEF_SIMPLE_GM(rrect_clip_draw_paint, canvas, 256, 256) {
 
     const SkRect layerRect = SkRect::MakeWH(256.f, 256.f);
     canvas->saveLayer(layerRect, nullptr);
-    canvas->clipRRect(rrect, SkCanvas::kIntersect_Op, true);
+    canvas->clipRRect(rrect, true);
     canvas->drawPaint(p);
     canvas->restore();
 
     canvas->concat(zoomOut);
     p.setColor(SK_ColorBLUE);
     canvas->saveLayer(layerRect, nullptr);
-    canvas->clipRRect(rrect, SkCanvas::kIntersect_Op, false);
+    canvas->clipRRect(rrect, false);
     canvas->drawPaint(p);
     canvas->restore();
 
@@ -38,7 +38,7 @@ DEF_SIMPLE_GM(rrect_clip_draw_paint, canvas, 256, 256) {
                                              SkShader::kClamp_TileMode));
     canvas->concat(zoomOut);
     canvas->saveLayer(layerRect, nullptr);
-    canvas->clipRRect(rrect, SkCanvas::kIntersect_Op, true);
+    canvas->clipRRect(rrect, true);
     canvas->drawPaint(p);
     canvas->restore();
 
@@ -47,7 +47,7 @@ DEF_SIMPLE_GM(rrect_clip_draw_paint, canvas, 256, 256) {
                                              SkShader::kClamp_TileMode));
     canvas->concat(zoomOut);
     canvas->saveLayer(layerRect, nullptr);
-    canvas->clipRRect(rrect, SkCanvas::kIntersect_Op, false);
+    canvas->clipRRect(rrect, false);
     canvas->drawPaint(p);
     canvas->restore();
 }
index 46c1c67072c62431d762dfc07928a74390f14f4a..1f47f77daa80170aba8f594903116cdda4b8ce51 100644 (file)
@@ -124,7 +124,7 @@ protected:
 #endif
                     } else if (kBW_Clip_Type == fType || kAA_Clip_Type == fType) {
                         bool aaClip = (kAA_Clip_Type == fType);
-                        canvas->clipRRect(fRRects[curRRect], SkCanvas::kReplace_Op, aaClip);
+                        canvas->clipRRect(fRRects[curRRect], aaClip);
                         canvas->drawRect(kMaxTileBound, paint);
                     } else {
                         canvas->drawRRect(fRRects[curRRect], paint);
index 83916bc9869b40b3baefd65b919a6f5c9dfe51c2..e36e621fdcc9e99dd2b18bfbf24ac1aea46ec3c0 100644 (file)
@@ -108,7 +108,7 @@ protected:
         SkPath path;
         path.addRoundRect(temp, SkIntToScalar(5), SkIntToScalar(5));
 
-        canvas->clipPath(path, SkCanvas::kReplace_Op, true); // AA is on
+        canvas->clipPath(path, true); // AA is on
 
         canvas->drawText("M", 1,
                          SkIntToScalar(100), SkIntToScalar(100),
index 87dc6877ef5a9cfe4269f97507f6f712842a51e6..9a8fe61eaa0c1e8756b6caaef20045f7df7efbfa 100644 (file)
@@ -106,11 +106,11 @@ protected:
         // create the clip mask with the supplied boolean op
         if (kPath_GeomType == fGeomType) {
             // path-based case
-            canvas->clipPath(fBasePath, SkCanvas::kReplace_Op, true);
+            canvas->clipPath(fBasePath, true);
             canvas->clipPath(fRectPath, op, true);
         } else {
             // rect-based case
-            canvas->clipRect(fBase, SkCanvas::kReplace_Op, true);
+            canvas->clipRect(fBase, true);
             canvas->clipRect(fRect, op, true);
         }
 
index 2fa6be883e4580419ac51f3b9b2fc6a1ce50f1f3..3c49aaac6e99103c4e1bc7aa66ea16322851a5f4 100644 (file)
@@ -65,6 +65,6 @@ DEF_SIMPLE_GM_BG(skbug1719, canvas, 300, 100,
                                    SkBlurMaskFilter::kHighQuality_BlurFlag));
         paint.setColorFilter(SkColorFilter::MakeModeFilter(0xBFFFFFFF, SkXfermode::kSrcIn_Mode));
 
-        canvas->clipPath(clipPath, SkCanvas::kIntersect_Op, true);
+        canvas->clipPath(clipPath, true);
         canvas->drawPath(drawPath, paint);
 }
index acb52c9e2eecea5f222d84be2563c73fe5cdcae1..7bf84c978fed4aa0d549c4c29ab94b3f19084aa6 100644 (file)
@@ -499,7 +499,13 @@ public:
      *  @param op The region op to apply to the current clip
      *  @param doAntiAlias true if the clip should be antialiased
      */
-    void clipRect(const SkRect& rect, ClipOp op = kIntersect_Op, bool doAntiAlias = false);
+    void clipRect(const SkRect& rect, ClipOp, bool doAntiAlias);
+    void clipRect(const SkRect& rect, ClipOp op) {
+        this->clipRect(rect, op, false);
+    }
+    void clipRect(const SkRect& rect, bool doAntiAlias = false) {
+        this->clipRect(rect, kIntersect_Op, doAntiAlias);
+    }
 
     /**
      *  Modify the current clip with the specified SkRRect.
@@ -507,7 +513,13 @@ public:
      *  @param op The region op to apply to the current clip
      *  @param doAntiAlias true if the clip should be antialiased
      */
-    void clipRRect(const SkRRect& rrect, ClipOp op = kIntersect_Op, bool doAntiAlias = false);
+    void clipRRect(const SkRRect& rrect, ClipOp op, bool doAntiAlias);
+    void clipRRect(const SkRRect& rrect, ClipOp op) {
+        this->clipRRect(rrect, op, false);
+    }
+    void clipRRect(const SkRRect& rrect, bool doAntiAlias = false) {
+        this->clipRRect(rrect, kIntersect_Op, doAntiAlias);
+    }
 
     /**
      *  Modify the current clip with the specified path.
@@ -515,7 +527,13 @@ public:
      *  @param op The region op to apply to the current clip
      *  @param doAntiAlias true if the clip should be antialiased
      */
-    void clipPath(const SkPath& path, ClipOp op = kIntersect_Op, bool doAntiAlias = false);
+    void clipPath(const SkPath& path, ClipOp op, bool doAntiAlias);
+    void clipPath(const SkPath& path, ClipOp op) {
+        this->clipPath(path, op, false);
+    }
+    void clipPath(const SkPath& path, bool doAntiAlias = false) {
+        this->clipPath(path, kIntersect_Op, doAntiAlias);
+    }
 
     /** EXPERIMENTAL -- only used for testing
         Set to false to force clips to be hard, even if doAntiAlias=true is
index ddb9f66836d8f3dff363fff9c8e58b0d4269b288..ea30cc609459f19a3ccc56e22d2a9de9d068d8f1 100644 (file)
@@ -164,43 +164,43 @@ protected:
 
         switch (fGeom) {
         case kRect_Geometry:
-            canvas->clipRect(create_rect(offset), SkCanvas::kReplace_Op, useAA);
+            canvas->clipRect(create_rect(offset), useAA);
             break;
         case kRRect_Geometry:
-            canvas->clipRRect(create_rrect(offset), SkCanvas::kReplace_Op, useAA);
+            canvas->clipRRect(create_rrect(offset), useAA);
             break;
         case kCircle_Geometry:
-            canvas->clipRRect(create_circle(offset), SkCanvas::kReplace_Op, useAA);
+            canvas->clipRRect(create_circle(offset), useAA);
             break;
         case kConvexPath_Geometry:
-            canvas->clipPath(create_convex_path(offset), SkCanvas::kReplace_Op, useAA);
+            canvas->clipPath(create_convex_path(offset), useAA);
             break;
         case kConcavePath_Geometry:
-            canvas->clipPath(create_concave_path(offset), SkCanvas::kReplace_Op, useAA);
+            canvas->clipPath(create_concave_path(offset), useAA);
             break;
         case kRectAndRect_Geometry: {
             SkRect r = create_rect(offset);
             r.offset(fSign * kXlate, fSign * kXlate);
-            canvas->clipRect(r, SkCanvas::kReplace_Op, true); // AA here forces shader clips
-            canvas->clipRect(create_rect(offset), SkCanvas::kIntersect_Op, useAA);
+            canvas->clipRect(r, true); // AA here forces shader clips
+            canvas->clipRect(create_rect(offset), useAA);
             } break;
         case kRectAndRRect_Geometry: {
             SkRect r = create_rect(offset);
             r.offset(fSign * kXlate, fSign * kXlate);
-            canvas->clipRect(r, SkCanvas::kReplace_Op, true); // AA here forces shader clips
-            canvas->clipRRect(create_rrect(offset), SkCanvas::kIntersect_Op, useAA);
+            canvas->clipRect(r, true); // AA here forces shader clips
+            canvas->clipRRect(create_rrect(offset), useAA);
             } break;
         case kRectAndConvex_Geometry: {
             SkRect r = create_rect(offset);
             r.offset(fSign * kXlate, fSign * kXlate);
-            canvas->clipRect(r, SkCanvas::kReplace_Op, true); // AA here forces shader clips
-            canvas->clipPath(create_convex_path(offset), SkCanvas::kIntersect_Op, useAA);
+            canvas->clipRect(r, true); // AA here forces shader clips
+            canvas->clipPath(create_convex_path(offset), useAA);
             } break;
         case kRectAndConcave_Geometry: {
             SkRect r = create_rect(offset);
             r.offset(fSign * kXlate, fSign * kXlate);
-            canvas->clipRect(r, SkCanvas::kReplace_Op, true); // AA here forces shader clips
-            canvas->clipPath(create_concave_path(offset), SkCanvas::kIntersect_Op, useAA);
+            canvas->clipRect(r, true); // AA here forces shader clips
+            canvas->clipPath(create_concave_path(offset), useAA);
             } break;
         }