| Index: samplecode/SamplePathEffects.cpp
|
| diff --git a/samplecode/SamplePathEffects.cpp b/samplecode/SamplePathEffects.cpp
|
| index a162cf33ad6a26249e12fdc49dc7645c2e6896fa..10715f382a962101074f19cf3e952444607e1e72 100644
|
| --- a/samplecode/SamplePathEffects.cpp
|
| +++ b/samplecode/SamplePathEffects.cpp
|
| @@ -26,9 +26,10 @@ static const int gXY[] = {
|
| 4, 0, 0, -4, 8, -4, 12, 0, 8, 4, 0, 4
|
| };
|
|
|
| -static SkPathEffect* make_pe(int flags, SkScalar phase) {
|
| - if (flags == 1)
|
| - return SkCornerPathEffect::Create(SkIntToScalar(CORNER_RADIUS));
|
| +static sk_sp<SkPathEffect> make_pe(int flags, SkScalar phase) {
|
| + if (flags == 1) {
|
| + return SkCornerPathEffect::Make(SkIntToScalar(CORNER_RADIUS));
|
| + }
|
|
|
| SkPath path;
|
| path.moveTo(SkIntToScalar(gXY[0]), SkIntToScalar(gXY[1]));
|
| @@ -37,36 +38,30 @@ static SkPathEffect* make_pe(int flags, SkScalar phase) {
|
| path.close();
|
| path.offset(SkIntToScalar(-6), 0);
|
|
|
| - SkPathEffect* outer = SkPath1DPathEffect::Create(path, 12, phase,
|
| - SkPath1DPathEffect::kRotate_Style);
|
| + auto outer = SkPath1DPathEffect::Make(path, 12, phase, SkPath1DPathEffect::kRotate_Style);
|
|
|
| if (flags == 2)
|
| return outer;
|
|
|
| - SkPathEffect* inner = SkCornerPathEffect::Create(SkIntToScalar(CORNER_RADIUS));
|
| + auto inner = SkCornerPathEffect::Make(SkIntToScalar(CORNER_RADIUS));
|
|
|
| - SkPathEffect* pe = SkComposePathEffect::Create(outer, inner);
|
| - outer->unref();
|
| - inner->unref();
|
| - return pe;
|
| + return SkComposePathEffect::Make(outer, inner);
|
| }
|
|
|
| -static SkPathEffect* make_warp_pe(SkScalar phase) {
|
| +static sk_sp<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);
|
|
|
| - SkPathEffect* outer = SkPath1DPathEffect::Create(
|
| + auto outer = SkPath1DPathEffect::Make(
|
| path, 12, phase, SkPath1DPathEffect::kMorph_Style);
|
| - SkPathEffect* inner = SkCornerPathEffect::Create(SkIntToScalar(CORNER_RADIUS));
|
| + auto inner = SkCornerPathEffect::Make(SkIntToScalar(CORNER_RADIUS));
|
|
|
| - SkPathEffect* pe = SkComposePathEffect::Create(outer, inner);
|
| - outer->unref();
|
| - inner->unref();
|
| - return pe;
|
| + return SkComposePathEffect::Make(outer, inner);
|
| }
|
|
|
| ///////////////////////////////////////////////////////////
|
| @@ -143,19 +138,19 @@ protected:
|
| canvas->translate(0, 50);
|
|
|
| paint.setColor(SK_ColorBLUE);
|
| - paint.setPathEffect(make_pe(2, fPhase))->unref();
|
| + paint.setPathEffect(make_pe(2, fPhase));
|
| canvas->drawPath(fPath, paint);
|
|
|
| canvas->translate(0, 50);
|
|
|
| paint.setARGB(0xFF, 0, 0xBB, 0);
|
| - paint.setPathEffect(make_pe(3, fPhase))->unref();
|
| + paint.setPathEffect(make_pe(3, fPhase));
|
| canvas->drawPath(fPath, paint);
|
|
|
| canvas->translate(0, 50);
|
|
|
| paint.setARGB(0xFF, 0, 0, 0);
|
| - paint.setPathEffect(make_warp_pe(fPhase))->unref();
|
| + paint.setPathEffect(make_warp_pe(fPhase));
|
| TestRastBuilder testRastBuilder;
|
| paint.setRasterizer(testRastBuilder.detachRasterizer())->unref();
|
| canvas->drawPath(fPath, paint);
|
|
|