diff options
author | reed <reed@google.com> | 2016-03-18 10:17:27 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-18 10:17:27 -0700 |
commit | f28ad894272018fd2855e3f77ea1236ea0cce1c0 (patch) | |
tree | 25dfb6f13e3bbbde1c9d7af7b41ea39b2df78dd4 /samplecode | |
parent | 9fbee18f691a0afed1e38a851048ce06063505ed (diff) |
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
Diffstat (limited to 'samplecode')
-rw-r--r-- | samplecode/ClockFaceView.cpp | 11 | ||||
-rw-r--r-- | samplecode/SampleAll.cpp | 21 | ||||
-rw-r--r-- | samplecode/SampleFilterFuzz.cpp | 34 | ||||
-rw-r--r-- | samplecode/SamplePath.cpp | 4 | ||||
-rw-r--r-- | samplecode/SamplePathEffects.cpp | 37 | ||||
-rw-r--r-- | samplecode/SampleSlides.cpp | 36 |
6 files changed, 79 insertions, 64 deletions
diff --git a/samplecode/ClockFaceView.cpp b/samplecode/ClockFaceView.cpp index f5b43fb82f..11684e11ad 100644 --- a/samplecode/ClockFaceView.cpp +++ b/samplecode/ClockFaceView.cpp @@ -132,16 +132,16 @@ private: SkFlattenable* InverseFillPE::CreateProc(SkReadBuffer& buffer) { return new InverseFillPE; } -static sk_sp<SkPathEffect> makepe(float interp, SkTDArray<SkPoint>* pts) { +static SkPathEffect* makepe(float interp, SkTDArray<SkPoint>* pts) { SkMatrix lattice; SkScalar rad = 3 + SkIntToScalar(4) * (1 - interp); lattice.setScale(rad*2, rad*2, 0, 0); lattice.postSkew(SK_Scalar1/3, 0, 0, 0); - return sk_make_sp<Dot2DPathEffect>(rad, lattice, pts); + return new Dot2DPathEffect(rad, lattice, pts); } static void r7(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p, SkScalar interp) { - p.setPathEffect(makepe(SkScalarToFloat(interp), nullptr)); + p.setPathEffect(makepe(SkScalarToFloat(interp), nullptr))->unref(); rastBuilder->addLayer(p); #if 0 p.setPathEffect(new InverseFillPE())->unref(); @@ -201,7 +201,7 @@ protected: static void drawdots(SkCanvas* canvas, const SkPaint& orig) { SkTDArray<SkPoint> pts; - auto pe = makepe(0, &pts); + SkPathEffect* pe = makepe(0, &pts); SkStrokeRec rec(SkStrokeRec::kFill_InitStyle); SkPath path, dstPath; @@ -212,7 +212,8 @@ protected: p.setAntiAlias(true); p.setStrokeWidth(10); p.setColor(SK_ColorRED); - canvas->drawPoints(SkCanvas::kPoints_PointMode, pts.count(), pts.begin(), p); + canvas->drawPoints(SkCanvas::kPoints_PointMode, pts.count(), pts.begin(), + p); } virtual void onDraw(SkCanvas* canvas) { diff --git a/samplecode/SampleAll.cpp b/samplecode/SampleAll.cpp index 7c0557fc40..90fc5bdb16 100644 --- a/samplecode/SampleAll.cpp +++ b/samplecode/SampleAll.cpp @@ -141,7 +141,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); } @@ -184,7 +184,7 @@ 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(sk_make_sp<Dot2DPathEffect>(SK_Scalar1*4, lattice)); + p.setPathEffect(new Dot2DPathEffect(SK_Scalar1*4, lattice))->unref(); rastBuilder->addLayer(p); } @@ -194,7 +194,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(sk_make_sp<Dot2DPathEffect>(SK_Scalar1*2, lattice)); + p.setPathEffect(new Dot2DPathEffect(SK_Scalar1*2, lattice))->unref(); p.setXfermodeMode(SkXfermode::kClear_Mode); rastBuilder->addLayer(p); @@ -211,7 +211,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); @@ -416,7 +416,7 @@ protected: canvas->translate(SkIntToScalar(50), 0); paint.setColor(SK_ColorYELLOW); paint.setShader(linear); - paint.setPathEffect(pathEffectTest()); + paint.setPathEffect(pathEffectTest())->unref(); canvas->drawRect(rect, paint); paint.setPathEffect(nullptr); @@ -481,7 +481,7 @@ protected: return this->INHERITED::onFindClickHandler(x, y, modi); } - sk_sp<SkPathEffect> pathEffectTest() { + SkPathEffect* pathEffectTest() { static const int gXY[] = { 1, 0, 0, -1, 2, -1, 3, 0, 2, 1, 0, 1 }; SkScalar gPhase = 0; SkPath path; @@ -490,11 +490,14 @@ protected: path.lineTo(SkIntToScalar(gXY[i]), SkIntToScalar(gXY[i+1])); path.close(); path.offset(SkIntToScalar(-6), 0); - auto outer = SkPath1DPathEffect::Make(path, SkIntToScalar(12), + SkPathEffect* outer = SkPath1DPathEffect::Create(path, SkIntToScalar(12), gPhase, SkPath1DPathEffect::kRotate_Style); - auto inner = SkDiscretePathEffect::Make(SkIntToScalar(2), + SkPathEffect* inner = SkDiscretePathEffect::Create(SkIntToScalar(2), SkIntToScalar(1)/10); // SkCornerPathEffect(SkIntToScalar(2)); - return SkComposePathEffect::Make(outer, inner); + SkPathEffect* result = SkComposePathEffect::Create(outer, inner); + outer->unref(); + inner->unref(); + return result; } sk_sp<SkShader> shaderTest() { diff --git a/samplecode/SampleFilterFuzz.cpp b/samplecode/SampleFilterFuzz.cpp index fe2fb0b2ff..0dd01e95b2 100644 --- a/samplecode/SampleFilterFuzz.cpp +++ b/samplecode/SampleFilterFuzz.cpp @@ -422,20 +422,22 @@ static SkPath make_path() { return path; } -static sk_sp<SkPathEffect> make_path_effect(bool canBeNull = true) { - sk_sp<SkPathEffect> pathEffect; +static SkPathEffect* make_path_effect(bool canBeNull = true) { + SkPathEffect* pathEffect = nullptr; if (canBeNull && (R(3) == 1)) { return pathEffect; } switch (R(9)) { case 0: - pathEffect = SkArcToPathEffect::Make(make_scalar(true)); + pathEffect = SkArcToPathEffect::Create(make_scalar(true)); break; - case 1: - pathEffect = SkComposePathEffect::Make(make_path_effect(false), - make_path_effect(false)); + case 1: { + SkAutoTUnref<SkPathEffect> outer(make_path_effect(false)); + SkAutoTUnref<SkPathEffect> inner(make_path_effect(false)); + pathEffect = SkComposePathEffect::Create(outer, inner); break; + } case 2: - pathEffect = SkCornerPathEffect::Make(make_scalar()); + pathEffect = SkCornerPathEffect::Create(make_scalar()); break; case 3: { int count = R(10); @@ -443,26 +445,28 @@ static sk_sp<SkPathEffect> make_path_effect(bool canBeNull = true) { for (int i = 0; i < count; ++i) { intervals[i] = make_scalar(); } - pathEffect = SkDashPathEffect::Make(intervals, count, make_scalar()); + pathEffect = SkDashPathEffect::Create(intervals, count, make_scalar()); break; } case 4: - pathEffect = SkDiscretePathEffect::Make(make_scalar(), make_scalar()); + pathEffect = SkDiscretePathEffect::Create(make_scalar(), make_scalar()); break; case 5: - pathEffect = SkPath1DPathEffect::Make(make_path(), make_scalar(), make_scalar(), - make_path_1d_path_effect_style()); + pathEffect = SkPath1DPathEffect::Create(make_path(), + make_scalar(), + make_scalar(), + make_path_1d_path_effect_style()); break; case 6: - pathEffect = SkLine2DPathEffect::Make(make_scalar(), make_matrix()); + pathEffect = SkLine2DPathEffect::Create(make_scalar(), make_matrix()); break; case 7: - pathEffect = SkPath2DPathEffect::Make(make_matrix(), make_path()); + pathEffect = SkPath2DPathEffect::Create(make_matrix(), make_path()); break; case 8: default: - pathEffect = SkSumPathEffect::Make(make_path_effect(false), - make_path_effect(false)); + pathEffect = SkSumPathEffect::Create(make_path_effect(false), + make_path_effect(false)); break; } return pathEffect; diff --git a/samplecode/SamplePath.cpp b/samplecode/SamplePath.cpp index 9ef1c851d8..c977ca0dc2 100644 --- a/samplecode/SamplePath.cpp +++ b/samplecode/SamplePath.cpp @@ -254,13 +254,13 @@ public: fArcToPaint.setStyle(SkPaint::kStroke_Style); fArcToPaint.setStrokeWidth(9); fArcToPaint.setColor(0x800000FF); - fArcToPaint.setPathEffect(SkArcToPathEffect::Make(rad)); + fArcToPaint.setPathEffect(SkArcToPathEffect::Create(rad))->unref(); fCornerPaint.setAntiAlias(true); fCornerPaint.setStyle(SkPaint::kStroke_Style); fCornerPaint.setStrokeWidth(13); fCornerPaint.setColor(SK_ColorGREEN); - fCornerPaint.setPathEffect(SkCornerPathEffect::Make(rad*2)); + fCornerPaint.setPathEffect(SkCornerPathEffect::Create(rad*2))->unref(); fSkeletonPaint.setAntiAlias(true); fSkeletonPaint.setStyle(SkPaint::kStroke_Style); diff --git a/samplecode/SamplePathEffects.cpp b/samplecode/SamplePathEffects.cpp index 10715f382a..a162cf33ad 100644 --- a/samplecode/SamplePathEffects.cpp +++ b/samplecode/SamplePathEffects.cpp @@ -26,10 +26,9 @@ static const int gXY[] = { 4, 0, 0, -4, 8, -4, 12, 0, 8, 4, 0, 4 }; -static sk_sp<SkPathEffect> make_pe(int flags, SkScalar phase) { - if (flags == 1) { - return SkCornerPathEffect::Make(SkIntToScalar(CORNER_RADIUS)); - } +static SkPathEffect* make_pe(int flags, SkScalar phase) { + if (flags == 1) + return SkCornerPathEffect::Create(SkIntToScalar(CORNER_RADIUS)); SkPath path; path.moveTo(SkIntToScalar(gXY[0]), SkIntToScalar(gXY[1])); @@ -38,30 +37,36 @@ static sk_sp<SkPathEffect> make_pe(int flags, SkScalar phase) { path.close(); path.offset(SkIntToScalar(-6), 0); - auto outer = SkPath1DPathEffect::Make(path, 12, phase, SkPath1DPathEffect::kRotate_Style); + SkPathEffect* outer = SkPath1DPathEffect::Create(path, 12, phase, + SkPath1DPathEffect::kRotate_Style); if (flags == 2) return outer; - auto inner = SkCornerPathEffect::Make(SkIntToScalar(CORNER_RADIUS)); + SkPathEffect* inner = SkCornerPathEffect::Create(SkIntToScalar(CORNER_RADIUS)); - return SkComposePathEffect::Make(outer, inner); + SkPathEffect* pe = SkComposePathEffect::Create(outer, inner); + outer->unref(); + inner->unref(); + return pe; } -static sk_sp<SkPathEffect> make_warp_pe(SkScalar phase) { +static SkPathEffect* make_warp_pe(SkScalar phase) { SkPath path; path.moveTo(SkIntToScalar(gXY[0]), SkIntToScalar(gXY[1])); - for (unsigned i = 2; i < SK_ARRAY_COUNT(gXY); i += 2) { + for (unsigned i = 2; i < SK_ARRAY_COUNT(gXY); i += 2) path.lineTo(SkIntToScalar(gXY[i]), SkIntToScalar(gXY[i+1])); - } path.close(); path.offset(SkIntToScalar(-6), 0); - auto outer = SkPath1DPathEffect::Make( + SkPathEffect* outer = SkPath1DPathEffect::Create( path, 12, phase, SkPath1DPathEffect::kMorph_Style); - auto inner = SkCornerPathEffect::Make(SkIntToScalar(CORNER_RADIUS)); + SkPathEffect* inner = SkCornerPathEffect::Create(SkIntToScalar(CORNER_RADIUS)); - return SkComposePathEffect::Make(outer, inner); + SkPathEffect* pe = SkComposePathEffect::Create(outer, inner); + outer->unref(); + inner->unref(); + return pe; } /////////////////////////////////////////////////////////// @@ -138,19 +143,19 @@ protected: canvas->translate(0, 50); paint.setColor(SK_ColorBLUE); - paint.setPathEffect(make_pe(2, fPhase)); + paint.setPathEffect(make_pe(2, fPhase))->unref(); canvas->drawPath(fPath, paint); canvas->translate(0, 50); paint.setARGB(0xFF, 0, 0xBB, 0); - paint.setPathEffect(make_pe(3, fPhase)); + paint.setPathEffect(make_pe(3, fPhase))->unref(); canvas->drawPath(fPath, paint); canvas->translate(0, 50); paint.setARGB(0xFF, 0, 0, 0); - paint.setPathEffect(make_warp_pe(fPhase)); + paint.setPathEffect(make_warp_pe(fPhase))->unref(); TestRastBuilder testRastBuilder; paint.setRasterizer(testRastBuilder.detachRasterizer())->unref(); canvas->drawPath(fPath, paint); diff --git a/samplecode/SampleSlides.cpp b/samplecode/SampleSlides.cpp index 38fd7402c7..c3cc2bbd6f 100644 --- a/samplecode/SampleSlides.cpp +++ b/samplecode/SampleSlides.cpp @@ -31,14 +31,15 @@ typedef void (*SlideProc)(SkCanvas*); static void compose_pe(SkPaint* paint) { SkPathEffect* pe = paint->getPathEffect(); - sk_sp<SkPathEffect> corner = SkCornerPathEffect::Make(25); - sk_sp<SkPathEffect> 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) { @@ -58,7 +59,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); } @@ -81,8 +83,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); } @@ -95,21 +97,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<SkPathEffect> 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 }; @@ -532,7 +534,7 @@ 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); } @@ -551,10 +553,10 @@ static void r6(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) #include "Sk2DPathEffect.h" -static sk_sp<SkPathEffect> 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) @@ -562,7 +564,7 @@ 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); } @@ -573,7 +575,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); @@ -591,7 +593,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); |