diff options
-rw-r--r-- | gm/aaclip.cpp | 2 | ||||
-rw-r--r-- | gm/bigblurs.cpp | 2 | ||||
-rw-r--r-- | gm/circularclips.cpp | 6 | ||||
-rw-r--r-- | gm/clip_strokerect.cpp | 4 | ||||
-rw-r--r-- | gm/complexclip.cpp | 2 | ||||
-rw-r--r-- | gm/complexclip3.cpp | 2 | ||||
-rw-r--r-- | gm/distantclip.cpp | 2 | ||||
-rw-r--r-- | gm/imagefilters.cpp | 2 | ||||
-rw-r--r-- | gm/path_stroke_with_zero_length.cpp | 4 | ||||
-rw-r--r-- | gm/pathopsinverse.cpp | 4 | ||||
-rw-r--r-- | gm/pathopsskpclip.cpp | 4 | ||||
-rw-r--r-- | gm/rrectclipdrawpaint.cpp | 8 | ||||
-rw-r--r-- | gm/rrects.cpp | 2 | ||||
-rw-r--r-- | gm/samplerstress.cpp | 2 | ||||
-rw-r--r-- | gm/simpleaaclip.cpp | 4 | ||||
-rw-r--r-- | gm/skbug1719.cpp | 2 | ||||
-rw-r--r-- | include/core/SkCanvas.h | 24 | ||||
-rw-r--r-- | samplecode/SampleClipDrawMatch.cpp | 26 |
18 files changed, 60 insertions, 42 deletions
diff --git a/gm/aaclip.cpp b/gm/aaclip.cpp index d6576691ea..26a25c1385 100644 --- a/gm/aaclip.cpp +++ b/gm/aaclip.cpp @@ -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(); diff --git a/gm/bigblurs.cpp b/gm/bigblurs.cpp index ee5ccd1345..0acd190972 100644 --- a/gm/bigblurs.cpp +++ b/gm/bigblurs.cpp @@ -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); diff --git a/gm/circularclips.cpp b/gm/circularclips.cpp index 39be1a5aec..f505310e4d 100644 --- a/gm/circularclips.cpp +++ b/gm/circularclips.cpp @@ -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); diff --git a/gm/clip_strokerect.cpp b/gm/clip_strokerect.cpp index 814455d145..34adf8a1cf 100644 --- a/gm/clip_strokerect.cpp +++ b/gm/clip_strokerect.cpp @@ -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(); diff --git a/gm/complexclip.cpp b/gm/complexclip.cpp index fb94957f02..2f8fa3d325 100644 --- a/gm/complexclip.cpp +++ b/gm/complexclip.cpp @@ -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 diff --git a/gm/complexclip3.cpp b/gm/complexclip3.cpp index fd8cd35100..59c78ec5a3 100644 --- a/gm/complexclip3.cpp +++ b/gm/complexclip3.cpp @@ -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 diff --git a/gm/distantclip.cpp b/gm/distantclip.cpp index f4931ddc27..24fbacaf4d 100644 --- a/gm/distantclip.cpp +++ b/gm/distantclip.cpp @@ -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()); diff --git a/gm/imagefilters.cpp b/gm/imagefilters.cpp index 3e8d39a879..e9f54a312d 100644 --- a/gm/imagefilters.cpp +++ b/gm/imagefilters.cpp @@ -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(); diff --git a/gm/path_stroke_with_zero_length.cpp b/gm/path_stroke_with_zero_length.cpp index 9c05541877..0f6d200b6f 100644 --- a/gm/path_stroke_with_zero_length.cpp +++ b/gm/path_stroke_with_zero_length.cpp @@ -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); diff --git a/gm/pathopsinverse.cpp b/gm/pathopsinverse.cpp index 176bc769e2..918666ca38 100644 --- a/gm/pathopsinverse.cpp +++ b/gm/pathopsinverse.cpp @@ -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(); diff --git a/gm/pathopsskpclip.cpp b/gm/pathopsskpclip.cpp index 77ba84c73c..18be681579 100644 --- a/gm/pathopsskpclip.cpp +++ b/gm/pathopsskpclip.cpp @@ -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()); diff --git a/gm/rrectclipdrawpaint.cpp b/gm/rrectclipdrawpaint.cpp index 74b57835c8..c997f845eb 100644 --- a/gm/rrectclipdrawpaint.cpp +++ b/gm/rrectclipdrawpaint.cpp @@ -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(); } diff --git a/gm/rrects.cpp b/gm/rrects.cpp index 46c1c67072..1f47f77daa 100644 --- a/gm/rrects.cpp +++ b/gm/rrects.cpp @@ -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); diff --git a/gm/samplerstress.cpp b/gm/samplerstress.cpp index 83916bc986..e36e621fdc 100644 --- a/gm/samplerstress.cpp +++ b/gm/samplerstress.cpp @@ -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), diff --git a/gm/simpleaaclip.cpp b/gm/simpleaaclip.cpp index 87dc6877ef..9a8fe61eaa 100644 --- a/gm/simpleaaclip.cpp +++ b/gm/simpleaaclip.cpp @@ -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); } diff --git a/gm/skbug1719.cpp b/gm/skbug1719.cpp index 2fa6be883e..3c49aaac6e 100644 --- a/gm/skbug1719.cpp +++ b/gm/skbug1719.cpp @@ -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); } diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index acb52c9e2e..7bf84c978f 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -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 diff --git a/samplecode/SampleClipDrawMatch.cpp b/samplecode/SampleClipDrawMatch.cpp index ddb9f66836..ea30cc6094 100644 --- a/samplecode/SampleClipDrawMatch.cpp +++ b/samplecode/SampleClipDrawMatch.cpp @@ -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; } |