aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode/SamplePathEffects.cpp
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-03-18 10:00:32 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-18 10:00:32 -0700
commit9fbee18f691a0afed1e38a851048ce06063505ed (patch)
treecd647dad4bae251bbbadea7fdd85b8a4b22cecc7 /samplecode/SamplePathEffects.cpp
parent1195260e22fc2e9c92b435491d4d19108a20df5c (diff)
switch patheffects over to sk_sp
Diffstat (limited to 'samplecode/SamplePathEffects.cpp')
-rw-r--r--samplecode/SamplePathEffects.cpp37
1 files changed, 16 insertions, 21 deletions
diff --git a/samplecode/SamplePathEffects.cpp b/samplecode/SamplePathEffects.cpp
index a162cf33ad..10715f382a 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);