From f28ad894272018fd2855e3f77ea1236ea0cce1c0 Mon Sep 17 00:00:00 2001 From: reed Date: Fri, 18 Mar 2016 10:17:27 -0700 Subject: Revert of switch patheffects over to sk_sp (patchset #5 id:80001 of https://codereview.chromium.org/1813553005/ ) Reason for revert: some build breaks, possibly related to paint having to know what a patheffect is Original issue's description: > switch patheffects over to sk_sp > > BUG=skia: > GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1813553005 > > Committed: https://skia.googlesource.com/skia/+/9fbee18f691a0afed1e38a851048ce06063505ed TBR=caryclark@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1817543002 --- gm/arcto.cpp | 2 +- gm/bug530095.cpp | 13 +++++++------ gm/dashcircle.cpp | 2 +- gm/dashcubics.cpp | 34 ++++++++++++++++++---------------- gm/dashing.cpp | 13 +++++++------ gm/pathcontourstart.cpp | 5 ++++- gm/patheffects.cpp | 24 +++++++++++++----------- gm/strokes.cpp | 2 +- gm/stroketext.cpp | 2 +- gm/textbloblooper.cpp | 6 +++--- gm/texteffects.cpp | 12 ++++++------ 11 files changed, 62 insertions(+), 53 deletions(-) (limited to 'gm') diff --git a/gm/arcto.cpp b/gm/arcto.cpp index fcbc3d5926..584fca3c4f 100644 --- a/gm/arcto.cpp +++ b/gm/arcto.cpp @@ -223,6 +223,6 @@ DEF_SIMPLE_GM(bug583299, canvas, 300, 300) { SkScalar length = meas.getLength(); SkScalar intervals[] = {0, length }; int intervalCount = (int) SK_ARRAY_COUNT(intervals); - p.setPathEffect(SkDashPathEffect::Make(intervals, intervalCount, 0)); + p.setPathEffect(SkDashPathEffect::Create(intervals, intervalCount, 0))->unref(); canvas->drawPath(path, p); } diff --git a/gm/bug530095.cpp b/gm/bug530095.cpp index fa88c01b8f..76f6bc8f2e 100644 --- a/gm/bug530095.cpp +++ b/gm/bug530095.cpp @@ -20,13 +20,13 @@ DEF_SIMPLE_GM(bug530095, canvas, 900, 1200) { paint.setStrokeWidth(26); SkScalar intervals[] = {700, 700 }; int intervalCount = (int) SK_ARRAY_COUNT(intervals); - paint.setPathEffect(SkDashPathEffect::Make(intervals, intervalCount, -40)); + paint.setPathEffect(SkDashPathEffect::Create(intervals, intervalCount, -40))->unref(); canvas->drawPath(path1, paint); paint.setStrokeWidth(0.26f); SkScalar smIntervals[] = {7, 7 }; int smIntervalCount = (int) SK_ARRAY_COUNT(smIntervals); - paint.setPathEffect(SkDashPathEffect::Make(smIntervals, smIntervalCount, -0.40f)); + paint.setPathEffect(SkDashPathEffect::Create(smIntervals, smIntervalCount, -0.40f))->unref(); canvas->save(); canvas->scale(100, 100); canvas->translate(4, 0); @@ -34,14 +34,14 @@ DEF_SIMPLE_GM(bug530095, canvas, 900, 1200) { canvas->restore(); paint.setStrokeWidth(26); - paint.setPathEffect(SkDashPathEffect::Make(intervals, intervalCount, 0)); + paint.setPathEffect(SkDashPathEffect::Create(intervals, intervalCount, 0))->unref(); canvas->save(); canvas->translate(0, 400); canvas->drawPath(path1, paint); canvas->restore(); paint.setStrokeWidth(0.26f); - paint.setPathEffect(SkDashPathEffect::Make(smIntervals, smIntervalCount, 0)); + paint.setPathEffect(SkDashPathEffect::Create(smIntervals, smIntervalCount, 0))->unref(); canvas->scale(100, 100); canvas->translate(4, 4); canvas->drawPath(path2, paint); @@ -54,7 +54,8 @@ DEF_SIMPLE_GM(bug591993, canvas, 40, 140) { p.setStyle(SkPaint::kStroke_Style); p.setStrokeCap(SkPaint::kRound_Cap); p.setStrokeWidth(10); - const SkScalar intervals[] = { 100, 100 }; - p.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 100)); + SkScalar intervals[] = { 100, 100 }; + SkPathEffect* dash = SkDashPathEffect::Create(intervals, SK_ARRAY_COUNT(intervals), 100); + p.setPathEffect(dash)->unref(); canvas->drawLine(20, 20, 120, 20, p); } diff --git a/gm/dashcircle.cpp b/gm/dashcircle.cpp index a02c7d0f7b..cddd913723 100644 --- a/gm/dashcircle.cpp +++ b/gm/dashcircle.cpp @@ -68,7 +68,7 @@ DEF_SIMPLE_GM(dashcircle, canvas, 900, 1200) { for (int index = 0; index < dashExample.length; ++index) { intervals[index] = dashExample.pattern[index] * dashLength; } - p.setPathEffect(SkDashPathEffect::Make(intervals, intervalCount, 0)); + p.setPathEffect(SkDashPathEffect::Create(intervals, intervalCount, 0))->unref(); canvas->drawPath(circle, p); canvas->translate(0, radius * 2 + 50); } diff --git a/gm/dashcubics.cpp b/gm/dashcubics.cpp index 7736f2b47c..1773303f0c 100644 --- a/gm/dashcubics.cpp +++ b/gm/dashcubics.cpp @@ -14,24 +14,26 @@ /* * Inspired by http://code.google.com/p/chromium/issues/detail?id=112145 */ -static void flower(SkCanvas* canvas, const SkPath& path, SkScalar intervals[2], - SkPaint::Join join) { - SkPaint paint; - paint.setAntiAlias(true); - paint.setStyle(SkPaint::kStroke_Style); - paint.setStrokeJoin(join); - paint.setStrokeWidth(42); - canvas->drawPath(path, paint); +static void flower(SkCanvas* canvas, const SkPath& path, + SkScalar intervals[2], SkPaint::Join join) { + SkPathEffect* pe = SkDashPathEffect::Create(intervals, 2, 0); - paint.setColor(SK_ColorRED); - paint.setStrokeWidth(21); - paint.setPathEffect(SkDashPathEffect::Make(intervals, 2, 0)); - canvas->drawPath(path, paint); + SkPaint paint; + paint.setAntiAlias(true); + paint.setStyle(SkPaint::kStroke_Style); + paint.setStrokeJoin(join); + paint.setStrokeWidth(42); + canvas->drawPath(path, paint); - paint.setColor(SK_ColorGREEN); - paint.setPathEffect(nullptr); - paint.setStrokeWidth(0); - canvas->drawPath(path, paint); + paint.setColor(SK_ColorRED); + paint.setStrokeWidth(21); + paint.setPathEffect(pe)->unref(); + canvas->drawPath(path, paint); + + paint.setColor(SK_ColorGREEN); + paint.setPathEffect(nullptr); + paint.setStrokeWidth(0); + canvas->drawPath(path, paint); } DEF_SIMPLE_GM(dashcubics, canvas, 860, 700) { diff --git a/gm/dashing.cpp b/gm/dashing.cpp index 6cb1dea66c..c728d15a1a 100644 --- a/gm/dashing.cpp +++ b/gm/dashing.cpp @@ -21,7 +21,8 @@ static void drawline(SkCanvas* canvas, int on, int off, const SkPaint& paint, SkIntToScalar(off), }; - p.setPathEffect(SkDashPathEffect::Make(intervals, 2, phase)); + SkAutoTUnref effect(SkDashPathEffect::Create(intervals, 2, phase)); + p.setPathEffect(effect); canvas->drawLine(startX, startY, finalX, finalY, p); } @@ -174,7 +175,7 @@ protected: vals[i] = SkIntToScalar(*intervals++); } SkScalar phase = vals[0] / 2; - paint.setPathEffect(SkDashPathEffect::Make(vals, count, phase)); + paint.setPathEffect(SkDashPathEffect::Create(vals, count, phase))->unref(); for (size_t x = 0; x < SK_ARRAY_COUNT(gProc); ++x) { SkPath path; @@ -222,7 +223,7 @@ protected: SkScalar intervals[2] = { dashLength, dashLength }; - p.setPathEffect(SkDashPathEffect::Make(intervals, 2, phase)); + p.setPathEffect(SkDashPathEffect::Create(intervals, 2, phase))->unref(); SkPoint pts[2]; @@ -498,7 +499,7 @@ DEF_SIMPLE_GM(longpathdash, canvas, 512, 512) { p.setStyle(SkPaint::kStroke_Style); p.setStrokeWidth(1); const SkScalar intervals[] = { 1, 1 }; - p.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 0)); + p.setPathEffect(SkDashPathEffect::Create(intervals, SK_ARRAY_COUNT(intervals), 0))->unref(); canvas->drawPath(lines, p); } @@ -509,7 +510,7 @@ DEF_SIMPLE_GM(longlinedash, canvas, 512, 512) { p.setStrokeWidth(80); const SkScalar intervals[] = { 2, 2 }; - p.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 0)); + p.setPathEffect(SkDashPathEffect::Create(intervals, SK_ARRAY_COUNT(intervals), 0))->unref(); canvas->drawRect(SkRect::MakeXYWH(-10000, 100, 20000, 20), p); } @@ -539,7 +540,7 @@ DEF_SIMPLE_GM(dashtextcaps, canvas, 512, 512) { p.setARGB(0xff, 0xbb, 0x00, 0x00); sk_tool_utils::set_portable_typeface(&p); const SkScalar intervals[] = { 12, 12 }; - p.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 0)); + p.setPathEffect(SkDashPathEffect::Create(intervals, SK_ARRAY_COUNT(intervals), 0))->unref(); canvas->drawText("Sausages", 8, 10, 90, p); canvas->drawLine(8, 120, 456, 120, p); } diff --git a/gm/pathcontourstart.cpp b/gm/pathcontourstart.cpp index dbda7c3cae..de3644c9f1 100644 --- a/gm/pathcontourstart.cpp +++ b/gm/pathcontourstart.cpp @@ -26,11 +26,14 @@ public: intervals.push_back(len); } + SkAutoTUnref effect( + SkDashPathEffect::Create(intervals.begin(), intervals.count(), 0)); + fDashPaint.setAntiAlias(true); fDashPaint.setStyle(SkPaint::kStroke_Style); fDashPaint.setStrokeWidth(6); fDashPaint.setColor(0xff008000); - fDashPaint.setPathEffect(SkDashPathEffect::Make(intervals.begin(), intervals.count(), 0)); + fDashPaint.setPathEffect(effect); fPointsPaint.setColor(0xff800000); fPointsPaint.setStrokeWidth(3); diff --git a/gm/patheffects.cpp b/gm/patheffects.cpp index 9821b3a35d..517d02e547 100644 --- a/gm/patheffects.cpp +++ b/gm/patheffects.cpp @@ -17,14 +17,15 @@ namespace skiagm { static void compose_pe(SkPaint* paint) { SkPathEffect* pe = paint->getPathEffect(); - sk_sp corner = SkCornerPathEffect::Make(25); - sk_sp compose; + SkPathEffect* corner = SkCornerPathEffect::Create(25); + SkPathEffect* compose; if (pe) { - compose = SkComposePathEffect::Make(sk_ref_sp(pe), corner); + compose = SkComposePathEffect::Create(pe, corner); + corner->unref(); } else { compose = corner; } - paint->setPathEffect(compose); + paint->setPathEffect(compose)->unref(); } static void hair_pe(SkPaint* paint) { @@ -44,7 +45,8 @@ static void stroke_pe(SkPaint* paint) { static void dash_pe(SkPaint* paint) { SkScalar inter[] = { 20, 10, 10, 10 }; paint->setStrokeWidth(12); - paint->setPathEffect(SkDashPathEffect::Make(inter, SK_ARRAY_COUNT(inter), 0)); + paint->setPathEffect(SkDashPathEffect::Create(inter, SK_ARRAY_COUNT(inter), + 0))->unref(); compose_pe(paint); } @@ -67,8 +69,8 @@ static void one_d_pe(SkPaint* paint) { path.offset(SkIntToScalar(-6), 0); scale(&path, 1.5f); - paint->setPathEffect(SkPath1DPathEffect::Make(path, SkIntToScalar(21), 0, - SkPath1DPathEffect::kRotate_Style)); + paint->setPathEffect(SkPath1DPathEffect::Create(path, SkIntToScalar(21), 0, + SkPath1DPathEffect::kRotate_Style))->unref(); compose_pe(paint); } @@ -81,21 +83,21 @@ static void fill_pe(SkPaint* paint) { } static void discrete_pe(SkPaint* paint) { - paint->setPathEffect(SkDiscretePathEffect::Make(10, 4)); + paint->setPathEffect(SkDiscretePathEffect::Create(10, 4))->unref(); } -static sk_sp MakeTileEffect() { +static SkPathEffect* MakeTileEffect() { SkMatrix m; m.setScale(SkIntToScalar(12), SkIntToScalar(12)); SkPath path; path.addCircle(0, 0, SkIntToScalar(5)); - return SkPath2DPathEffect::Make(m, path); + return SkPath2DPathEffect::Create(m, path); } static void tile_pe(SkPaint* paint) { - paint->setPathEffect(MakeTileEffect()); + paint->setPathEffect(MakeTileEffect())->unref(); } static const PE_Proc gPE2[] = { fill_pe, discrete_pe, tile_pe }; diff --git a/gm/strokes.cpp b/gm/strokes.cpp index f64a87640c..261db9c69d 100644 --- a/gm/strokes.cpp +++ b/gm/strokes.cpp @@ -128,7 +128,7 @@ protected: canvas->drawPath(fMoveZfPath, strokePaint); dashPaint = strokePaint; const SkScalar intervals[] = { 0, 10 }; - dashPaint.setPathEffect(SkDashPathEffect::Make(intervals, 2, 0)); + dashPaint.setPathEffect(SkDashPathEffect::Create(intervals, 2, 0))->unref(); SkPath fillPath; dashPaint.getFillPath(fDashedfPath, &fillPath); canvas->translate(0, 20); diff --git a/gm/stroketext.cpp b/gm/stroketext.cpp index b247d8a711..d0a9882256 100644 --- a/gm/stroketext.cpp +++ b/gm/stroketext.cpp @@ -55,7 +55,7 @@ static void draw_text_set(SkCanvas* canvas, const SkPaint& paint) { canvas->translate(200, 0); SkPaint p(paint); - p.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), phase)); + p.setPathEffect(SkDashPathEffect::Create(intervals, SK_ARRAY_COUNT(intervals), phase))->unref(); draw_text_stroked(canvas, p, 10); } diff --git a/gm/textbloblooper.cpp b/gm/textbloblooper.cpp index d54490272c..8d462c9b09 100644 --- a/gm/textbloblooper.cpp +++ b/gm/textbloblooper.cpp @@ -66,18 +66,18 @@ static void mask_filter(SkPaint* paint) { paint->setMaskFilter(mf)->unref(); } -static sk_sp make_tile_effect() { +static SkPathEffect* make_tile_effect() { SkMatrix m; m.setScale(1.f, 1.f); SkPath path; path.addCircle(0, 0, SkIntToScalar(5)); - return SkPath2DPathEffect::Make(m, path); + return SkPath2DPathEffect::Create(m, path); } static void path_effect(SkPaint* paint) { - paint->setPathEffect(make_tile_effect()); + paint->setPathEffect(make_tile_effect())->unref(); } static sk_sp make_shader(const SkRect& bounds) { diff --git a/gm/texteffects.cpp b/gm/texteffects.cpp index aa3d3758ab..6ad3d23bf2 100644 --- a/gm/texteffects.cpp +++ b/gm/texteffects.cpp @@ -77,7 +77,7 @@ static void r4(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { static void r5(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { rastBuilder->addLayer(p); - p.setPathEffect(SkDiscretePathEffect::Make(SK_Scalar1*4, SK_Scalar1*3)); + p.setPathEffect(SkDiscretePathEffect::Create(SK_Scalar1*4, SK_Scalar1*3))->unref(); p.setXfermodeMode(SkXfermode::kSrcOut_Mode); rastBuilder->addLayer(p); } @@ -95,17 +95,17 @@ static void r6(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { #include "Sk2DPathEffect.h" -static sk_sp MakeDotEffect(SkScalar radius, const SkMatrix& matrix) { +static SkPathEffect* MakeDotEffect(SkScalar radius, const SkMatrix& matrix) { SkPath path; path.addCircle(0, 0, radius); - return SkPath2DPathEffect::Make(matrix, path); + return SkPath2DPathEffect::Create(matrix, path); } static void r7(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { SkMatrix lattice; lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0); lattice.postSkew(SK_Scalar1/3, 0, 0, 0); - p.setPathEffect(MakeDotEffect(SK_Scalar1*4, lattice)); + p.setPathEffect(MakeDotEffect(SK_Scalar1*4, lattice))->unref(); rastBuilder->addLayer(p); } @@ -115,7 +115,7 @@ static void r8(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { SkMatrix lattice; lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0); lattice.postSkew(SK_Scalar1/3, 0, 0, 0); - p.setPathEffect(MakeDotEffect(SK_Scalar1*2, lattice)); + p.setPathEffect(MakeDotEffect(SK_Scalar1*2, lattice))->unref(); p.setXfermodeMode(SkXfermode::kClear_Mode); rastBuilder->addLayer(p); @@ -132,7 +132,7 @@ static void r9(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { SkMatrix lattice; lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0); lattice.postRotate(SkIntToScalar(30), 0, 0); - p.setPathEffect(SkLine2DPathEffect::Make(SK_Scalar1*2, lattice)); + p.setPathEffect(SkLine2DPathEffect::Create(SK_Scalar1*2, lattice))->unref(); p.setXfermodeMode(SkXfermode::kClear_Mode); rastBuilder->addLayer(p); -- cgit v1.2.3