Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Unified Diff: samplecode/SamplePathEffects.cpp

Issue 1813123003: Reland of "switch patheffects over to sk_sp (patchset #5 id:80001 of https://codereview.chromium.or… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: move flag into sktypes, so it is visible to both paint and other patheffect clients Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samplecode/SamplePath.cpp ('k') | samplecode/SampleSlides.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « samplecode/SamplePath.cpp ('k') | samplecode/SampleSlides.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698