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
This commit is contained in:
reed 2016-03-18 10:17:27 -07:00 committed by Commit bot
parent 9fbee18f69
commit f28ad89427
48 changed files with 256 additions and 259 deletions

View File

@ -72,7 +72,9 @@ protected:
SkPath path; SkPath path;
this->makePath(&path); this->makePath(&path);
paint.setPathEffect(SkDashPathEffect::Make(fIntervals.begin(), fIntervals.count(), 0)); SkAutoTUnref<SkPathEffect> effect(SkDashPathEffect::Create(fIntervals.begin(),
fIntervals.count(), 0));
paint.setPathEffect(effect);
if (fDoClip) { if (fDoClip) {
SkRect r = path.getBounds(); SkRect r = path.getBounds();
@ -177,7 +179,7 @@ static void make_cubic(SkPath* path) {
class MakeDashBench : public Benchmark { class MakeDashBench : public Benchmark {
SkString fName; SkString fName;
SkPath fPath; SkPath fPath;
sk_sp<SkPathEffect> fPE; SkAutoTUnref<SkPathEffect> fPE;
public: public:
MakeDashBench(void (*proc)(SkPath*), const char name[]) { MakeDashBench(void (*proc)(SkPath*), const char name[]) {
@ -185,7 +187,7 @@ public:
proc(&fPath); proc(&fPath);
SkScalar vals[] = { SkIntToScalar(4), SkIntToScalar(4) }; SkScalar vals[] = { SkIntToScalar(4), SkIntToScalar(4) };
fPE = SkDashPathEffect::Make(vals, 2, 0); fPE.reset(SkDashPathEffect::Create(vals, 2, 0));
} }
protected: protected:
@ -214,7 +216,7 @@ class DashLineBench : public Benchmark {
SkString fName; SkString fName;
SkScalar fStrokeWidth; SkScalar fStrokeWidth;
bool fIsRound; bool fIsRound;
sk_sp<SkPathEffect> fPE; SkAutoTUnref<SkPathEffect> fPE;
public: public:
DashLineBench(SkScalar width, bool isRound) { DashLineBench(SkScalar width, bool isRound) {
@ -223,7 +225,7 @@ public:
fIsRound = isRound; fIsRound = isRound;
SkScalar vals[] = { SK_Scalar1, SK_Scalar1 }; SkScalar vals[] = { SK_Scalar1, SK_Scalar1 };
fPE = SkDashPathEffect::Make(vals, 2, 0); fPE.reset(SkDashPathEffect::Create(vals, 2, 0));
} }
protected: protected:
@ -252,7 +254,7 @@ class DrawPointsDashingBench : public Benchmark {
int fStrokeWidth; int fStrokeWidth;
bool fDoAA; bool fDoAA;
sk_sp<SkPathEffect> fPathEffect; SkAutoTUnref<SkPathEffect> fPathEffect;
public: public:
DrawPointsDashingBench(int dashLength, int strokeWidth, bool doAA) DrawPointsDashingBench(int dashLength, int strokeWidth, bool doAA)
@ -262,7 +264,7 @@ public:
fDoAA = doAA; fDoAA = doAA;
SkScalar vals[] = { SkIntToScalar(dashLength), SkIntToScalar(dashLength) }; SkScalar vals[] = { SkIntToScalar(dashLength), SkIntToScalar(dashLength) };
fPathEffect = SkDashPathEffect::Make(vals, 2, SK_Scalar1); fPathEffect.reset(SkDashPathEffect::Create(vals, 2, SK_Scalar1));
} }
protected: protected:
@ -299,7 +301,7 @@ class GiantDashBench : public Benchmark {
SkString fName; SkString fName;
SkScalar fStrokeWidth; SkScalar fStrokeWidth;
SkPoint fPts[2]; SkPoint fPts[2];
sk_sp<SkPathEffect> fPathEffect; SkAutoTUnref<SkPathEffect> fPathEffect;
public: public:
enum LineType { enum LineType {
@ -322,7 +324,8 @@ public:
// deliberately pick intervals that won't be caught by asPoints(), so // deliberately pick intervals that won't be caught by asPoints(), so
// we can test the filterPath code-path. // we can test the filterPath code-path.
const SkScalar intervals[] = { 20, 10, 10, 10 }; const SkScalar intervals[] = { 20, 10, 10, 10 };
fPathEffect = SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 0); fPathEffect.reset(SkDashPathEffect::Create(intervals,
SK_ARRAY_COUNT(intervals), 0));
SkScalar cx = 640 / 2; // center X SkScalar cx = 640 / 2; // center X
SkScalar cy = 480 / 2; // center Y SkScalar cy = 480 / 2; // center Y
@ -378,7 +381,7 @@ class DashGridBench : public Benchmark {
int fStrokeWidth; int fStrokeWidth;
bool fDoAA; bool fDoAA;
sk_sp<SkPathEffect> fPathEffect; SkAutoTUnref<SkPathEffect> fPathEffect;
public: public:
DashGridBench(int dashLength, int strokeWidth, bool doAA) { DashGridBench(int dashLength, int strokeWidth, bool doAA) {
@ -387,7 +390,7 @@ public:
fDoAA = doAA; fDoAA = doAA;
SkScalar vals[] = { SkIntToScalar(dashLength), SkIntToScalar(dashLength) }; SkScalar vals[] = { SkIntToScalar(dashLength), SkIntToScalar(dashLength) };
fPathEffect = SkDashPathEffect::Make(vals, 2, SK_Scalar1); fPathEffect.reset(SkDashPathEffect::Create(vals, 2, SK_Scalar1));
} }
protected: protected:

View File

@ -223,6 +223,6 @@ DEF_SIMPLE_GM(bug583299, canvas, 300, 300) {
SkScalar length = meas.getLength(); SkScalar length = meas.getLength();
SkScalar intervals[] = {0, length }; SkScalar intervals[] = {0, length };
int intervalCount = (int) SK_ARRAY_COUNT(intervals); 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); canvas->drawPath(path, p);
} }

View File

@ -20,13 +20,13 @@ DEF_SIMPLE_GM(bug530095, canvas, 900, 1200) {
paint.setStrokeWidth(26); paint.setStrokeWidth(26);
SkScalar intervals[] = {700, 700 }; SkScalar intervals[] = {700, 700 };
int intervalCount = (int) SK_ARRAY_COUNT(intervals); 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); canvas->drawPath(path1, paint);
paint.setStrokeWidth(0.26f); paint.setStrokeWidth(0.26f);
SkScalar smIntervals[] = {7, 7 }; SkScalar smIntervals[] = {7, 7 };
int smIntervalCount = (int) SK_ARRAY_COUNT(smIntervals); 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->save();
canvas->scale(100, 100); canvas->scale(100, 100);
canvas->translate(4, 0); canvas->translate(4, 0);
@ -34,14 +34,14 @@ DEF_SIMPLE_GM(bug530095, canvas, 900, 1200) {
canvas->restore(); canvas->restore();
paint.setStrokeWidth(26); paint.setStrokeWidth(26);
paint.setPathEffect(SkDashPathEffect::Make(intervals, intervalCount, 0)); paint.setPathEffect(SkDashPathEffect::Create(intervals, intervalCount, 0))->unref();
canvas->save(); canvas->save();
canvas->translate(0, 400); canvas->translate(0, 400);
canvas->drawPath(path1, paint); canvas->drawPath(path1, paint);
canvas->restore(); canvas->restore();
paint.setStrokeWidth(0.26f); paint.setStrokeWidth(0.26f);
paint.setPathEffect(SkDashPathEffect::Make(smIntervals, smIntervalCount, 0)); paint.setPathEffect(SkDashPathEffect::Create(smIntervals, smIntervalCount, 0))->unref();
canvas->scale(100, 100); canvas->scale(100, 100);
canvas->translate(4, 4); canvas->translate(4, 4);
canvas->drawPath(path2, paint); canvas->drawPath(path2, paint);
@ -54,7 +54,8 @@ DEF_SIMPLE_GM(bug591993, canvas, 40, 140) {
p.setStyle(SkPaint::kStroke_Style); p.setStyle(SkPaint::kStroke_Style);
p.setStrokeCap(SkPaint::kRound_Cap); p.setStrokeCap(SkPaint::kRound_Cap);
p.setStrokeWidth(10); p.setStrokeWidth(10);
const SkScalar intervals[] = { 100, 100 }; SkScalar intervals[] = { 100, 100 };
p.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 100)); SkPathEffect* dash = SkDashPathEffect::Create(intervals, SK_ARRAY_COUNT(intervals), 100);
p.setPathEffect(dash)->unref();
canvas->drawLine(20, 20, 120, 20, p); canvas->drawLine(20, 20, 120, 20, p);
} }

View File

@ -68,7 +68,7 @@ DEF_SIMPLE_GM(dashcircle, canvas, 900, 1200) {
for (int index = 0; index < dashExample.length; ++index) { for (int index = 0; index < dashExample.length; ++index) {
intervals[index] = dashExample.pattern[index] * dashLength; 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->drawPath(circle, p);
canvas->translate(0, radius * 2 + 50); canvas->translate(0, radius * 2 + 50);
} }

View File

@ -14,24 +14,26 @@
/* /*
* Inspired by http://code.google.com/p/chromium/issues/detail?id=112145 * Inspired by http://code.google.com/p/chromium/issues/detail?id=112145
*/ */
static void flower(SkCanvas* canvas, const SkPath& path, SkScalar intervals[2], static void flower(SkCanvas* canvas, const SkPath& path,
SkPaint::Join join) { SkScalar intervals[2], SkPaint::Join join) {
SkPaint paint; SkPathEffect* pe = SkDashPathEffect::Create(intervals, 2, 0);
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeJoin(join);
paint.setStrokeWidth(42);
canvas->drawPath(path, paint);
paint.setColor(SK_ColorRED); SkPaint paint;
paint.setStrokeWidth(21); paint.setAntiAlias(true);
paint.setPathEffect(SkDashPathEffect::Make(intervals, 2, 0)); paint.setStyle(SkPaint::kStroke_Style);
canvas->drawPath(path, paint); paint.setStrokeJoin(join);
paint.setStrokeWidth(42);
canvas->drawPath(path, paint);
paint.setColor(SK_ColorGREEN); paint.setColor(SK_ColorRED);
paint.setPathEffect(nullptr); paint.setStrokeWidth(21);
paint.setStrokeWidth(0); paint.setPathEffect(pe)->unref();
canvas->drawPath(path, paint); 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) { DEF_SIMPLE_GM(dashcubics, canvas, 860, 700) {

View File

@ -21,7 +21,8 @@ static void drawline(SkCanvas* canvas, int on, int off, const SkPaint& paint,
SkIntToScalar(off), SkIntToScalar(off),
}; };
p.setPathEffect(SkDashPathEffect::Make(intervals, 2, phase)); SkAutoTUnref<SkPathEffect> effect(SkDashPathEffect::Create(intervals, 2, phase));
p.setPathEffect(effect);
canvas->drawLine(startX, startY, finalX, finalY, p); canvas->drawLine(startX, startY, finalX, finalY, p);
} }
@ -174,7 +175,7 @@ protected:
vals[i] = SkIntToScalar(*intervals++); vals[i] = SkIntToScalar(*intervals++);
} }
SkScalar phase = vals[0] / 2; 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) { for (size_t x = 0; x < SK_ARRAY_COUNT(gProc); ++x) {
SkPath path; SkPath path;
@ -222,7 +223,7 @@ protected:
SkScalar intervals[2] = { dashLength, dashLength }; SkScalar intervals[2] = { dashLength, dashLength };
p.setPathEffect(SkDashPathEffect::Make(intervals, 2, phase)); p.setPathEffect(SkDashPathEffect::Create(intervals, 2, phase))->unref();
SkPoint pts[2]; SkPoint pts[2];
@ -498,7 +499,7 @@ DEF_SIMPLE_GM(longpathdash, canvas, 512, 512) {
p.setStyle(SkPaint::kStroke_Style); p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(1); p.setStrokeWidth(1);
const SkScalar intervals[] = { 1, 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); canvas->drawPath(lines, p);
} }
@ -509,7 +510,7 @@ DEF_SIMPLE_GM(longlinedash, canvas, 512, 512) {
p.setStrokeWidth(80); p.setStrokeWidth(80);
const SkScalar intervals[] = { 2, 2 }; 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); 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); p.setARGB(0xff, 0xbb, 0x00, 0x00);
sk_tool_utils::set_portable_typeface(&p); sk_tool_utils::set_portable_typeface(&p);
const SkScalar intervals[] = { 12, 12 }; 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->drawText("Sausages", 8, 10, 90, p);
canvas->drawLine(8, 120, 456, 120, p); canvas->drawLine(8, 120, 456, 120, p);
} }

View File

@ -26,11 +26,14 @@ public:
intervals.push_back(len); intervals.push_back(len);
} }
SkAutoTUnref<SkPathEffect> effect(
SkDashPathEffect::Create(intervals.begin(), intervals.count(), 0));
fDashPaint.setAntiAlias(true); fDashPaint.setAntiAlias(true);
fDashPaint.setStyle(SkPaint::kStroke_Style); fDashPaint.setStyle(SkPaint::kStroke_Style);
fDashPaint.setStrokeWidth(6); fDashPaint.setStrokeWidth(6);
fDashPaint.setColor(0xff008000); fDashPaint.setColor(0xff008000);
fDashPaint.setPathEffect(SkDashPathEffect::Make(intervals.begin(), intervals.count(), 0)); fDashPaint.setPathEffect(effect);
fPointsPaint.setColor(0xff800000); fPointsPaint.setColor(0xff800000);
fPointsPaint.setStrokeWidth(3); fPointsPaint.setStrokeWidth(3);

View File

@ -17,14 +17,15 @@ namespace skiagm {
static void compose_pe(SkPaint* paint) { static void compose_pe(SkPaint* paint) {
SkPathEffect* pe = paint->getPathEffect(); SkPathEffect* pe = paint->getPathEffect();
sk_sp<SkPathEffect> corner = SkCornerPathEffect::Make(25); SkPathEffect* corner = SkCornerPathEffect::Create(25);
sk_sp<SkPathEffect> compose; SkPathEffect* compose;
if (pe) { if (pe) {
compose = SkComposePathEffect::Make(sk_ref_sp(pe), corner); compose = SkComposePathEffect::Create(pe, corner);
corner->unref();
} else { } else {
compose = corner; compose = corner;
} }
paint->setPathEffect(compose); paint->setPathEffect(compose)->unref();
} }
static void hair_pe(SkPaint* paint) { static void hair_pe(SkPaint* paint) {
@ -44,7 +45,8 @@ static void stroke_pe(SkPaint* paint) {
static void dash_pe(SkPaint* paint) { static void dash_pe(SkPaint* paint) {
SkScalar inter[] = { 20, 10, 10, 10 }; SkScalar inter[] = { 20, 10, 10, 10 };
paint->setStrokeWidth(12); 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); compose_pe(paint);
} }
@ -67,8 +69,8 @@ static void one_d_pe(SkPaint* paint) {
path.offset(SkIntToScalar(-6), 0); path.offset(SkIntToScalar(-6), 0);
scale(&path, 1.5f); scale(&path, 1.5f);
paint->setPathEffect(SkPath1DPathEffect::Make(path, SkIntToScalar(21), 0, paint->setPathEffect(SkPath1DPathEffect::Create(path, SkIntToScalar(21), 0,
SkPath1DPathEffect::kRotate_Style)); SkPath1DPathEffect::kRotate_Style))->unref();
compose_pe(paint); compose_pe(paint);
} }
@ -81,21 +83,21 @@ static void fill_pe(SkPaint* paint) {
} }
static void discrete_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; SkMatrix m;
m.setScale(SkIntToScalar(12), SkIntToScalar(12)); m.setScale(SkIntToScalar(12), SkIntToScalar(12));
SkPath path; SkPath path;
path.addCircle(0, 0, SkIntToScalar(5)); path.addCircle(0, 0, SkIntToScalar(5));
return SkPath2DPathEffect::Make(m, path); return SkPath2DPathEffect::Create(m, path);
} }
static void tile_pe(SkPaint* paint) { static void tile_pe(SkPaint* paint) {
paint->setPathEffect(MakeTileEffect()); paint->setPathEffect(MakeTileEffect())->unref();
} }
static const PE_Proc gPE2[] = { fill_pe, discrete_pe, tile_pe }; static const PE_Proc gPE2[] = { fill_pe, discrete_pe, tile_pe };

View File

@ -128,7 +128,7 @@ protected:
canvas->drawPath(fMoveZfPath, strokePaint); canvas->drawPath(fMoveZfPath, strokePaint);
dashPaint = strokePaint; dashPaint = strokePaint;
const SkScalar intervals[] = { 0, 10 }; const SkScalar intervals[] = { 0, 10 };
dashPaint.setPathEffect(SkDashPathEffect::Make(intervals, 2, 0)); dashPaint.setPathEffect(SkDashPathEffect::Create(intervals, 2, 0))->unref();
SkPath fillPath; SkPath fillPath;
dashPaint.getFillPath(fDashedfPath, &fillPath); dashPaint.getFillPath(fDashedfPath, &fillPath);
canvas->translate(0, 20); canvas->translate(0, 20);

View File

@ -55,7 +55,7 @@ static void draw_text_set(SkCanvas* canvas, const SkPaint& paint) {
canvas->translate(200, 0); canvas->translate(200, 0);
SkPaint p(paint); 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); draw_text_stroked(canvas, p, 10);
} }

View File

@ -66,18 +66,18 @@ static void mask_filter(SkPaint* paint) {
paint->setMaskFilter(mf)->unref(); paint->setMaskFilter(mf)->unref();
} }
static sk_sp<SkPathEffect> make_tile_effect() { static SkPathEffect* make_tile_effect() {
SkMatrix m; SkMatrix m;
m.setScale(1.f, 1.f); m.setScale(1.f, 1.f);
SkPath path; SkPath path;
path.addCircle(0, 0, SkIntToScalar(5)); path.addCircle(0, 0, SkIntToScalar(5));
return SkPath2DPathEffect::Make(m, path); return SkPath2DPathEffect::Create(m, path);
} }
static void path_effect(SkPaint* paint) { static void path_effect(SkPaint* paint) {
paint->setPathEffect(make_tile_effect()); paint->setPathEffect(make_tile_effect())->unref();
} }
static sk_sp<SkShader> make_shader(const SkRect& bounds) { static sk_sp<SkShader> make_shader(const SkRect& bounds) {

View File

@ -77,7 +77,7 @@ static void r4(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
static void r5(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { static void r5(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
rastBuilder->addLayer(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); p.setXfermodeMode(SkXfermode::kSrcOut_Mode);
rastBuilder->addLayer(p); rastBuilder->addLayer(p);
} }
@ -95,17 +95,17 @@ static void r6(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
#include "Sk2DPathEffect.h" #include "Sk2DPathEffect.h"
static sk_sp<SkPathEffect> MakeDotEffect(SkScalar radius, const SkMatrix& matrix) { static SkPathEffect* MakeDotEffect(SkScalar radius, const SkMatrix& matrix) {
SkPath path; SkPath path;
path.addCircle(0, 0, radius); path.addCircle(0, 0, radius);
return SkPath2DPathEffect::Make(matrix, path); return SkPath2DPathEffect::Create(matrix, path);
} }
static void r7(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { static void r7(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
SkMatrix lattice; SkMatrix lattice;
lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0); lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0);
lattice.postSkew(SK_Scalar1/3, 0, 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); rastBuilder->addLayer(p);
} }
@ -115,7 +115,7 @@ static void r8(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
SkMatrix lattice; SkMatrix lattice;
lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0); lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0);
lattice.postSkew(SK_Scalar1/3, 0, 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); p.setXfermodeMode(SkXfermode::kClear_Mode);
rastBuilder->addLayer(p); rastBuilder->addLayer(p);
@ -132,7 +132,7 @@ static void r9(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
SkMatrix lattice; SkMatrix lattice;
lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0); lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0);
lattice.postRotate(SkIntToScalar(30), 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); p.setXfermodeMode(SkXfermode::kClear_Mode);
rastBuilder->addLayer(p); rastBuilder->addLayer(p);

View File

@ -20,7 +20,6 @@
'SK_SUPPORT_LEGACY_GRADIENT_DITHERING', 'SK_SUPPORT_LEGACY_GRADIENT_DITHERING',
'SK_SUPPORT_LEGACY_DRAWFILTER', 'SK_SUPPORT_LEGACY_DRAWFILTER',
'SK_SUPPORT_LEGACY_CREATESHADER_PTR', 'SK_SUPPORT_LEGACY_CREATESHADER_PTR',
'SK_SUPPORT_LEGACY_PATHEFFECT_PTR',
], ],
}, },
} }

View File

@ -561,13 +561,8 @@ public:
paint paint
@return effect @return effect
*/ */
SkPathEffect* setPathEffect(SkPathEffect* effect);
void setPathEffect(sk_sp<SkPathEffect>); void setPathEffect(sk_sp<SkPathEffect>);
#ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR
SkPathEffect* setPathEffect(SkPathEffect* effect) {
this->setPathEffect(sk_ref_sp(effect));
return effect;
}
#endif
/** Get the paint's maskfilter object. /** Get the paint's maskfilter object.
<p /> <p />

View File

@ -18,10 +18,6 @@
class SkPath; class SkPath;
class SkStrokeRec; class SkStrokeRec;
#ifndef SK_SUPPORT_LEGACY_PATHEFFECT_PTR
#define SK_SUPPORT_LEGACY_PATHEFFECT_PTR
#endif
/** \class SkPathEffect /** \class SkPathEffect
SkPathEffect is the base class for objects in the SkPaint that affect SkPathEffect is the base class for objects in the SkPaint that affect
@ -158,14 +154,16 @@ private:
for managing the lifetimes of its two arguments. for managing the lifetimes of its two arguments.
*/ */
class SkPairPathEffect : public SkPathEffect { class SkPairPathEffect : public SkPathEffect {
public:
virtual ~SkPairPathEffect();
protected: protected:
SkPairPathEffect(sk_sp<SkPathEffect> pe0, sk_sp<SkPathEffect> pe1); SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1);
void flatten(SkWriteBuffer&) const override; void flatten(SkWriteBuffer&) const override;
// these are visible to our subclasses // these are visible to our subclasses
sk_sp<SkPathEffect> fPE0; SkPathEffect* fPE0, *fPE1;
sk_sp<SkPathEffect> fPE1;
SK_TO_STRING_OVERRIDE() SK_TO_STRING_OVERRIDE()
@ -185,22 +183,16 @@ public:
The reference counts for outer and inner are both incremented in the constructor, The reference counts for outer and inner are both incremented in the constructor,
and decremented in the destructor. and decremented in the destructor.
*/ */
static sk_sp<SkPathEffect> Make(sk_sp<SkPathEffect> outer, sk_sp<SkPathEffect> inner) { static SkPathEffect* Create(SkPathEffect* outer, SkPathEffect* inner) {
if (!outer) { if (!outer) {
return inner; return SkSafeRef(inner);
} }
if (!inner) { if (!inner) {
return outer; return SkSafeRef(outer);
} }
return sk_sp<SkPathEffect>(new SkComposePathEffect(outer, inner)); return new SkComposePathEffect(outer, inner);
} }
#ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR
static SkPathEffect* Create(SkPathEffect* outer, SkPathEffect* inner) {
return Make(sk_ref_sp(outer), sk_ref_sp(inner)).release();
}
#endif
virtual bool filterPath(SkPath* dst, const SkPath& src, virtual bool filterPath(SkPath* dst, const SkPath& src,
SkStrokeRec*, const SkRect*) const override; SkStrokeRec*, const SkRect*) const override;
@ -212,8 +204,7 @@ public:
#endif #endif
protected: protected:
SkComposePathEffect(sk_sp<SkPathEffect> outer, sk_sp<SkPathEffect> inner) SkComposePathEffect(SkPathEffect* outer, SkPathEffect* inner) : INHERITED(outer, inner) {}
: INHERITED(outer, inner) {}
private: private:
// illegal // illegal
@ -235,21 +226,16 @@ public:
The reference counts for first and second are both incremented in the constructor, The reference counts for first and second are both incremented in the constructor,
and decremented in the destructor. and decremented in the destructor.
*/ */
static sk_sp<SkPathEffect> Make(sk_sp<SkPathEffect> first, sk_sp<SkPathEffect> second) { static SkPathEffect* Create(SkPathEffect* first, SkPathEffect* second) {
if (!first) { if (!first) {
return second; return SkSafeRef(second);
} }
if (!second) { if (!second) {
return first; return SkSafeRef(first);
} }
return sk_sp<SkPathEffect>(new SkSumPathEffect(first, second)); return new SkSumPathEffect(first, second);
} }
#ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR
static SkPathEffect* Create(SkPathEffect* first, SkPathEffect* second) {
return Make(sk_ref_sp(first), sk_ref_sp(second)).release();
}
#endif
virtual bool filterPath(SkPath* dst, const SkPath& src, virtual bool filterPath(SkPath* dst, const SkPath& src,
SkStrokeRec*, const SkRect*) const override; SkStrokeRec*, const SkRect*) const override;
@ -261,8 +247,7 @@ public:
#endif #endif
protected: protected:
SkSumPathEffect(sk_sp<SkPathEffect> first, sk_sp<SkPathEffect> second) SkSumPathEffect(SkPathEffect* first, SkPathEffect* second) : INHERITED(first, second) {}
: INHERITED(first, second) {}
private: private:
// illegal // illegal

View File

@ -56,13 +56,7 @@ public:
@param style how to transform path at each point (based on the current @param style how to transform path at each point (based on the current
position and tangent) position and tangent)
*/ */
static sk_sp<SkPathEffect> Make(const SkPath& path, SkScalar advance, SkScalar phase, Style); static SkPathEffect* Create(const SkPath& path, SkScalar advance, SkScalar phase, Style);
#ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR
static SkPathEffect* Create(const SkPath& path, SkScalar advance, SkScalar phase, Style s) {
return Make(path, advance, phase, s).release();
}
#endif
virtual bool filterPath(SkPath*, const SkPath&, virtual bool filterPath(SkPath*, const SkPath&,
SkStrokeRec*, const SkRect*) const override; SkStrokeRec*, const SkRect*) const override;

View File

@ -55,8 +55,8 @@ private:
class SK_API SkLine2DPathEffect : public Sk2DPathEffect { class SK_API SkLine2DPathEffect : public Sk2DPathEffect {
public: public:
static sk_sp<SkPathEffect> Make(SkScalar width, const SkMatrix& matrix) { static SkPathEffect* Create(SkScalar width, const SkMatrix& matrix) {
return sk_sp<SkPathEffect>(new SkLine2DPathEffect(width, matrix)); return new SkLine2DPathEffect(width, matrix);
} }
virtual bool filterPath(SkPath* dst, const SkPath& src, virtual bool filterPath(SkPath* dst, const SkPath& src,
@ -84,8 +84,8 @@ public:
* Stamp the specified path to fill the shape, using the matrix to define * Stamp the specified path to fill the shape, using the matrix to define
* the latice. * the latice.
*/ */
static sk_sp<SkPathEffect> Make(const SkMatrix& matrix, const SkPath& path) { static SkPathEffect* Create(const SkMatrix& matrix, const SkPath& path) {
return sk_sp<SkPathEffect>(new SkPath2DPathEffect(matrix, path)); return new SkPath2DPathEffect(matrix, path);
} }
SK_TO_STRING_OVERRIDE() SK_TO_STRING_OVERRIDE()

View File

@ -15,11 +15,11 @@ public:
/** radius must be > 0 to have an effect. It specifies the distance from each corner /** radius must be > 0 to have an effect. It specifies the distance from each corner
that should be "rounded". that should be "rounded".
*/ */
static sk_sp<SkPathEffect> Make(SkScalar radius) { static SkPathEffect* Create(SkScalar radius) {
if (radius <= 0) { if (radius <= 0) {
return NULL; return NULL;
} }
return sk_sp<SkPathEffect>(new SkArcToPathEffect(radius)); return new SkArcToPathEffect(radius);
} }
bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override; bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;

View File

@ -20,15 +20,7 @@ public:
/** radius must be > 0 to have an effect. It specifies the distance from each corner /** radius must be > 0 to have an effect. It specifies the distance from each corner
that should be "rounded". that should be "rounded".
*/ */
static sk_sp<SkPathEffect> Make(SkScalar radius) { static SkPathEffect* Create(SkScalar radius) { return new SkCornerPathEffect(radius); }
return sk_sp<SkPathEffect>(new SkCornerPathEffect(radius));
}
#ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR
static SkPathEffect* Create(SkScalar radius) {
return Make(radius).release();
}
#endif
virtual bool filterPath(SkPath* dst, const SkPath& src, virtual bool filterPath(SkPath* dst, const SkPath& src,
SkStrokeRec*, const SkRect*) const override; SkStrokeRec*, const SkRect*) const override;

View File

@ -36,13 +36,7 @@ public:
Note: only affects stroked paths. Note: only affects stroked paths.
*/ */
static sk_sp<SkPathEffect> Make(const SkScalar intervals[], int count, SkScalar phase); static SkPathEffect* Create(const SkScalar intervals[], int count, SkScalar phase);
#ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR
static SkPathEffect* Create(const SkScalar intervals[], int count, SkScalar phase) {
return Make(intervals, count, phase).release();
}
#endif
virtual bool filterPath(SkPath* dst, const SkPath& src, virtual bool filterPath(SkPath* dst, const SkPath& src,
SkStrokeRec*, const SkRect*) const override; SkStrokeRec*, const SkRect*) const override;

View File

@ -29,13 +29,9 @@ public:
they can pass in a different seedAssist to get a they can pass in a different seedAssist to get a
different set of path segments. different set of path segments.
*/ */
static sk_sp<SkPathEffect> Make(SkScalar segLength, SkScalar dev, uint32_t seedAssist = 0);
#ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR
static SkPathEffect* Create(SkScalar segLength, SkScalar deviation, uint32_t seedAssist = 0) { static SkPathEffect* Create(SkScalar segLength, SkScalar deviation, uint32_t seedAssist = 0) {
return Make(segLength, deviation, seedAssist).release(); return new SkDiscretePathEffect(segLength, deviation, seedAssist);
} }
#endif
virtual bool filterPath(SkPath* dst, const SkPath& src, virtual bool filterPath(SkPath* dst, const SkPath& src,
SkStrokeRec*, const SkRect*) const override; SkStrokeRec*, const SkRect*) const override;

View File

@ -132,16 +132,16 @@ private:
SkFlattenable* InverseFillPE::CreateProc(SkReadBuffer& buffer) { return new InverseFillPE; } 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; SkMatrix lattice;
SkScalar rad = 3 + SkIntToScalar(4) * (1 - interp); SkScalar rad = 3 + SkIntToScalar(4) * (1 - interp);
lattice.setScale(rad*2, rad*2, 0, 0); lattice.setScale(rad*2, rad*2, 0, 0);
lattice.postSkew(SK_Scalar1/3, 0, 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) { 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); rastBuilder->addLayer(p);
#if 0 #if 0
p.setPathEffect(new InverseFillPE())->unref(); p.setPathEffect(new InverseFillPE())->unref();
@ -201,7 +201,7 @@ protected:
static void drawdots(SkCanvas* canvas, const SkPaint& orig) { static void drawdots(SkCanvas* canvas, const SkPaint& orig) {
SkTDArray<SkPoint> pts; SkTDArray<SkPoint> pts;
auto pe = makepe(0, &pts); SkPathEffect* pe = makepe(0, &pts);
SkStrokeRec rec(SkStrokeRec::kFill_InitStyle); SkStrokeRec rec(SkStrokeRec::kFill_InitStyle);
SkPath path, dstPath; SkPath path, dstPath;
@ -212,7 +212,8 @@ protected:
p.setAntiAlias(true); p.setAntiAlias(true);
p.setStrokeWidth(10); p.setStrokeWidth(10);
p.setColor(SK_ColorRED); 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) { virtual void onDraw(SkCanvas* canvas) {

View File

@ -141,7 +141,7 @@ static void r4(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
static void r5(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { static void r5(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
rastBuilder->addLayer(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); p.setXfermodeMode(SkXfermode::kSrcOut_Mode);
rastBuilder->addLayer(p); rastBuilder->addLayer(p);
} }
@ -184,7 +184,7 @@ static void r7(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
SkMatrix lattice; SkMatrix lattice;
lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0); lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0);
lattice.postSkew(SK_Scalar1/3, 0, 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); rastBuilder->addLayer(p);
} }
@ -194,7 +194,7 @@ static void r8(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
SkMatrix lattice; SkMatrix lattice;
lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0); lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0);
lattice.postSkew(SK_Scalar1/3, 0, 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); p.setXfermodeMode(SkXfermode::kClear_Mode);
rastBuilder->addLayer(p); rastBuilder->addLayer(p);
@ -211,7 +211,7 @@ static void r9(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
SkMatrix lattice; SkMatrix lattice;
lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0); lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0);
lattice.postRotate(SkIntToScalar(30), 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); p.setXfermodeMode(SkXfermode::kClear_Mode);
rastBuilder->addLayer(p); rastBuilder->addLayer(p);
@ -416,7 +416,7 @@ protected:
canvas->translate(SkIntToScalar(50), 0); canvas->translate(SkIntToScalar(50), 0);
paint.setColor(SK_ColorYELLOW); paint.setColor(SK_ColorYELLOW);
paint.setShader(linear); paint.setShader(linear);
paint.setPathEffect(pathEffectTest()); paint.setPathEffect(pathEffectTest())->unref();
canvas->drawRect(rect, paint); canvas->drawRect(rect, paint);
paint.setPathEffect(nullptr); paint.setPathEffect(nullptr);
@ -481,7 +481,7 @@ protected:
return this->INHERITED::onFindClickHandler(x, y, modi); 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 }; static const int gXY[] = { 1, 0, 0, -1, 2, -1, 3, 0, 2, 1, 0, 1 };
SkScalar gPhase = 0; SkScalar gPhase = 0;
SkPath path; SkPath path;
@ -490,11 +490,14 @@ protected:
path.lineTo(SkIntToScalar(gXY[i]), SkIntToScalar(gXY[i+1])); path.lineTo(SkIntToScalar(gXY[i]), SkIntToScalar(gXY[i+1]));
path.close(); path.close();
path.offset(SkIntToScalar(-6), 0); path.offset(SkIntToScalar(-6), 0);
auto outer = SkPath1DPathEffect::Make(path, SkIntToScalar(12), SkPathEffect* outer = SkPath1DPathEffect::Create(path, SkIntToScalar(12),
gPhase, SkPath1DPathEffect::kRotate_Style); gPhase, SkPath1DPathEffect::kRotate_Style);
auto inner = SkDiscretePathEffect::Make(SkIntToScalar(2), SkPathEffect* inner = SkDiscretePathEffect::Create(SkIntToScalar(2),
SkIntToScalar(1)/10); // SkCornerPathEffect(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() { sk_sp<SkShader> shaderTest() {

View File

@ -422,20 +422,22 @@ static SkPath make_path() {
return path; return path;
} }
static sk_sp<SkPathEffect> make_path_effect(bool canBeNull = true) { static SkPathEffect* make_path_effect(bool canBeNull = true) {
sk_sp<SkPathEffect> pathEffect; SkPathEffect* pathEffect = nullptr;
if (canBeNull && (R(3) == 1)) { return pathEffect; } if (canBeNull && (R(3) == 1)) { return pathEffect; }
switch (R(9)) { switch (R(9)) {
case 0: case 0:
pathEffect = SkArcToPathEffect::Make(make_scalar(true)); pathEffect = SkArcToPathEffect::Create(make_scalar(true));
break; break;
case 1: case 1: {
pathEffect = SkComposePathEffect::Make(make_path_effect(false), SkAutoTUnref<SkPathEffect> outer(make_path_effect(false));
make_path_effect(false)); SkAutoTUnref<SkPathEffect> inner(make_path_effect(false));
pathEffect = SkComposePathEffect::Create(outer, inner);
break; break;
}
case 2: case 2:
pathEffect = SkCornerPathEffect::Make(make_scalar()); pathEffect = SkCornerPathEffect::Create(make_scalar());
break; break;
case 3: { case 3: {
int count = R(10); 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) { for (int i = 0; i < count; ++i) {
intervals[i] = make_scalar(); intervals[i] = make_scalar();
} }
pathEffect = SkDashPathEffect::Make(intervals, count, make_scalar()); pathEffect = SkDashPathEffect::Create(intervals, count, make_scalar());
break; break;
} }
case 4: case 4:
pathEffect = SkDiscretePathEffect::Make(make_scalar(), make_scalar()); pathEffect = SkDiscretePathEffect::Create(make_scalar(), make_scalar());
break; break;
case 5: case 5:
pathEffect = SkPath1DPathEffect::Make(make_path(), make_scalar(), make_scalar(), pathEffect = SkPath1DPathEffect::Create(make_path(),
make_path_1d_path_effect_style()); make_scalar(),
make_scalar(),
make_path_1d_path_effect_style());
break; break;
case 6: case 6:
pathEffect = SkLine2DPathEffect::Make(make_scalar(), make_matrix()); pathEffect = SkLine2DPathEffect::Create(make_scalar(), make_matrix());
break; break;
case 7: case 7:
pathEffect = SkPath2DPathEffect::Make(make_matrix(), make_path()); pathEffect = SkPath2DPathEffect::Create(make_matrix(), make_path());
break; break;
case 8: case 8:
default: default:
pathEffect = SkSumPathEffect::Make(make_path_effect(false), pathEffect = SkSumPathEffect::Create(make_path_effect(false),
make_path_effect(false)); make_path_effect(false));
break; break;
} }
return pathEffect; return pathEffect;

View File

@ -254,13 +254,13 @@ public:
fArcToPaint.setStyle(SkPaint::kStroke_Style); fArcToPaint.setStyle(SkPaint::kStroke_Style);
fArcToPaint.setStrokeWidth(9); fArcToPaint.setStrokeWidth(9);
fArcToPaint.setColor(0x800000FF); fArcToPaint.setColor(0x800000FF);
fArcToPaint.setPathEffect(SkArcToPathEffect::Make(rad)); fArcToPaint.setPathEffect(SkArcToPathEffect::Create(rad))->unref();
fCornerPaint.setAntiAlias(true); fCornerPaint.setAntiAlias(true);
fCornerPaint.setStyle(SkPaint::kStroke_Style); fCornerPaint.setStyle(SkPaint::kStroke_Style);
fCornerPaint.setStrokeWidth(13); fCornerPaint.setStrokeWidth(13);
fCornerPaint.setColor(SK_ColorGREEN); fCornerPaint.setColor(SK_ColorGREEN);
fCornerPaint.setPathEffect(SkCornerPathEffect::Make(rad*2)); fCornerPaint.setPathEffect(SkCornerPathEffect::Create(rad*2))->unref();
fSkeletonPaint.setAntiAlias(true); fSkeletonPaint.setAntiAlias(true);
fSkeletonPaint.setStyle(SkPaint::kStroke_Style); fSkeletonPaint.setStyle(SkPaint::kStroke_Style);

View File

@ -26,10 +26,9 @@ static const int gXY[] = {
4, 0, 0, -4, 8, -4, 12, 0, 8, 4, 0, 4 4, 0, 0, -4, 8, -4, 12, 0, 8, 4, 0, 4
}; };
static sk_sp<SkPathEffect> make_pe(int flags, SkScalar phase) { static SkPathEffect* make_pe(int flags, SkScalar phase) {
if (flags == 1) { if (flags == 1)
return SkCornerPathEffect::Make(SkIntToScalar(CORNER_RADIUS)); return SkCornerPathEffect::Create(SkIntToScalar(CORNER_RADIUS));
}
SkPath path; SkPath path;
path.moveTo(SkIntToScalar(gXY[0]), SkIntToScalar(gXY[1])); 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.close();
path.offset(SkIntToScalar(-6), 0); 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) if (flags == 2)
return outer; 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; SkPath path;
path.moveTo(SkIntToScalar(gXY[0]), SkIntToScalar(gXY[1])); 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.lineTo(SkIntToScalar(gXY[i]), SkIntToScalar(gXY[i+1]));
}
path.close(); path.close();
path.offset(SkIntToScalar(-6), 0); path.offset(SkIntToScalar(-6), 0);
auto outer = SkPath1DPathEffect::Make( SkPathEffect* outer = SkPath1DPathEffect::Create(
path, 12, phase, SkPath1DPathEffect::kMorph_Style); 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); canvas->translate(0, 50);
paint.setColor(SK_ColorBLUE); paint.setColor(SK_ColorBLUE);
paint.setPathEffect(make_pe(2, fPhase)); paint.setPathEffect(make_pe(2, fPhase))->unref();
canvas->drawPath(fPath, paint); canvas->drawPath(fPath, paint);
canvas->translate(0, 50); canvas->translate(0, 50);
paint.setARGB(0xFF, 0, 0xBB, 0); paint.setARGB(0xFF, 0, 0xBB, 0);
paint.setPathEffect(make_pe(3, fPhase)); paint.setPathEffect(make_pe(3, fPhase))->unref();
canvas->drawPath(fPath, paint); canvas->drawPath(fPath, paint);
canvas->translate(0, 50); canvas->translate(0, 50);
paint.setARGB(0xFF, 0, 0, 0); paint.setARGB(0xFF, 0, 0, 0);
paint.setPathEffect(make_warp_pe(fPhase)); paint.setPathEffect(make_warp_pe(fPhase))->unref();
TestRastBuilder testRastBuilder; TestRastBuilder testRastBuilder;
paint.setRasterizer(testRastBuilder.detachRasterizer())->unref(); paint.setRasterizer(testRastBuilder.detachRasterizer())->unref();
canvas->drawPath(fPath, paint); canvas->drawPath(fPath, paint);

View File

@ -31,14 +31,15 @@ typedef void (*SlideProc)(SkCanvas*);
static void compose_pe(SkPaint* paint) { static void compose_pe(SkPaint* paint) {
SkPathEffect* pe = paint->getPathEffect(); SkPathEffect* pe = paint->getPathEffect();
sk_sp<SkPathEffect> corner = SkCornerPathEffect::Make(25); SkPathEffect* corner = SkCornerPathEffect::Create(25);
sk_sp<SkPathEffect> compose; SkPathEffect* compose;
if (pe) { if (pe) {
compose = SkComposePathEffect::Make(sk_ref_sp(pe), corner); compose = SkComposePathEffect::Create(pe, corner);
corner->unref();
} else { } else {
compose = corner; compose = corner;
} }
paint->setPathEffect(compose); paint->setPathEffect(compose)->unref();
} }
static void hair_pe(SkPaint* paint) { static void hair_pe(SkPaint* paint) {
@ -58,7 +59,8 @@ static void stroke_pe(SkPaint* paint) {
static void dash_pe(SkPaint* paint) { static void dash_pe(SkPaint* paint) {
SkScalar inter[] = { 20, 10, 10, 10 }; SkScalar inter[] = { 20, 10, 10, 10 };
paint->setStrokeWidth(12); 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); compose_pe(paint);
} }
@ -81,8 +83,8 @@ static void one_d_pe(SkPaint* paint) {
path.offset(SkIntToScalar(-6), 0); path.offset(SkIntToScalar(-6), 0);
scale(&path, 1.5f); scale(&path, 1.5f);
paint->setPathEffect(SkPath1DPathEffect::Make(path, SkIntToScalar(21), 0, paint->setPathEffect(SkPath1DPathEffect::Create(path, SkIntToScalar(21), 0,
SkPath1DPathEffect::kRotate_Style)); SkPath1DPathEffect::kRotate_Style))->unref();
compose_pe(paint); compose_pe(paint);
} }
@ -95,21 +97,21 @@ static void fill_pe(SkPaint* paint) {
} }
static void discrete_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; SkMatrix m;
m.setScale(SkIntToScalar(12), SkIntToScalar(12)); m.setScale(SkIntToScalar(12), SkIntToScalar(12));
SkPath path; SkPath path;
path.addCircle(0, 0, SkIntToScalar(5)); path.addCircle(0, 0, SkIntToScalar(5));
return SkPath2DPathEffect::Make(m, path); return SkPath2DPathEffect::Create(m, path);
} }
static void tile_pe(SkPaint* paint) { static void tile_pe(SkPaint* paint) {
paint->setPathEffect(MakeTileEffect()); paint->setPathEffect(MakeTileEffect())->unref();
} }
static const PE_Proc gPE2[] = { fill_pe, discrete_pe, tile_pe }; 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); 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); p.setXfermodeMode(SkXfermode::kSrcOut_Mode);
rastBuilder->addLayer(p); rastBuilder->addLayer(p);
} }
@ -551,10 +553,10 @@ static void r6(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
#include "Sk2DPathEffect.h" #include "Sk2DPathEffect.h"
static sk_sp<SkPathEffect> MakeDotEffect(SkScalar radius, const SkMatrix& matrix) { static SkPathEffect* MakeDotEffect(SkScalar radius, const SkMatrix& matrix) {
SkPath path; SkPath path;
path.addCircle(0, 0, radius); path.addCircle(0, 0, radius);
return SkPath2DPathEffect::Make(matrix, path); return SkPath2DPathEffect::Create(matrix, path);
} }
static void r7(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) static void r7(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
@ -562,7 +564,7 @@ static void r7(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
SkMatrix lattice; SkMatrix lattice;
lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0); lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0);
lattice.postSkew(SK_Scalar1/3, 0, 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); rastBuilder->addLayer(p);
} }
@ -573,7 +575,7 @@ static void r8(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
SkMatrix lattice; SkMatrix lattice;
lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0); lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0);
lattice.postSkew(SK_Scalar1/3, 0, 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); p.setXfermodeMode(SkXfermode::kClear_Mode);
rastBuilder->addLayer(p); rastBuilder->addLayer(p);
@ -591,7 +593,7 @@ static void r9(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p)
SkMatrix lattice; SkMatrix lattice;
lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0); lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0);
lattice.postRotate(SkIntToScalar(30), 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); p.setXfermodeMode(SkXfermode::kClear_Mode);
rastBuilder->addLayer(p); rastBuilder->addLayer(p);

View File

@ -233,7 +233,7 @@ void SkDrawPaint::setupPaint(SkPaint* paint) const {
if (pathEffect == nullptr) if (pathEffect == nullptr)
paint->setPathEffect(nullptr); paint->setPathEffect(nullptr);
else if (pathEffect != (SkDrawPathEffect*) -1) else if (pathEffect != (SkDrawPathEffect*) -1)
paint->setPathEffect(sk_ref_sp(pathEffect->getPathEffect())); SkSafeUnref(paint->setPathEffect(pathEffect->getPathEffect()));
if (shader == nullptr) if (shader == nullptr)
paint->setShader(nullptr); paint->setShader(nullptr);
else if (shader != (SkDrawShader*) -1) else if (shader != (SkDrawShader*) -1)

View File

@ -1615,7 +1615,7 @@ void SkDraw::drawPosText_asPaths(const char text[], size_t byteLength,
// Now restore the original settings, so we "draw" with whatever style/stroking. // Now restore the original settings, so we "draw" with whatever style/stroking.
paint.setStyle(origPaint.getStyle()); paint.setStyle(origPaint.getStyle());
paint.setPathEffect(sk_ref_sp(origPaint.getPathEffect())); paint.setPathEffect(origPaint.getPathEffect());
while (text < stop) { while (text < stop) {
const SkGlyph& glyph = glyphCacheProc(cache.get(), &text); const SkGlyph& glyph = glyphCacheProc(cache.get(), &text);

View File

@ -375,6 +375,7 @@ SET_PTR(ImageFilter)
SET_PTR(Shader) SET_PTR(Shader)
SET_PTR(ColorFilter) SET_PTR(ColorFilter)
SET_PTR(Xfermode) SET_PTR(Xfermode)
SET_PTR(PathEffect)
SET_PTR(MaskFilter) SET_PTR(MaskFilter)
#undef SET_PTR #undef SET_PTR
@ -1929,7 +1930,7 @@ void SkPaint::unflatten(SkReadBuffer& buffer) {
} }
if (flatFlags & kHasEffects_FlatFlag) { if (flatFlags & kHasEffects_FlatFlag) {
this->setPathEffect(buffer.readPathEffect()); SkSafeUnref(this->setPathEffect(buffer.readPathEffect()));
this->setShader(buffer.readShader()); this->setShader(buffer.readShader());
SkSafeUnref(this->setXfermode(buffer.readXfermode())); SkSafeUnref(this->setXfermode(buffer.readXfermode()));
SkSafeUnref(this->setMaskFilter(buffer.readMaskFilter())); SkSafeUnref(this->setMaskFilter(buffer.readMaskFilter()));
@ -2249,11 +2250,11 @@ SkTextBaseIter::SkTextBaseIter(const char text[], size_t length,
fCache = fPaint.detachCache(nullptr, SkPaint::FakeGamma::On, nullptr); fCache = fPaint.detachCache(nullptr, SkPaint::FakeGamma::On, nullptr);
SkPaint::Style style = SkPaint::kFill_Style; SkPaint::Style style = SkPaint::kFill_Style;
sk_sp<SkPathEffect> pe; SkPathEffect* pe = nullptr;
if (!applyStrokeAndPathEffects) { if (!applyStrokeAndPathEffects) {
style = paint.getStyle(); // restore style = paint.getStyle(); // restore
pe = sk_ref_sp(paint.getPathEffect()); // restore pe = paint.getPathEffect(); // restore
} }
fPaint.setStyle(style); fPaint.setStyle(style);
fPaint.setPathEffect(pe); fPaint.setPathEffect(pe);

View File

@ -1,3 +1,4 @@
/* /*
* Copyright 2006 The Android Open Source Project * Copyright 2006 The Android Open Source Project
* *
@ -27,19 +28,25 @@ SkPathEffect::DashType SkPathEffect::asADash(DashInfo* info) const {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
SkPairPathEffect::SkPairPathEffect(sk_sp<SkPathEffect> pe0, sk_sp<SkPathEffect> pe1) SkPairPathEffect::SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1)
: fPE0(std::move(pe0)), fPE1(std::move(pe1)) : fPE0(pe0), fPE1(pe1) {
{ SkASSERT(pe0);
SkASSERT(fPE0.get()); SkASSERT(pe1);
SkASSERT(fPE1.get()); fPE0->ref();
fPE1->ref();
}
SkPairPathEffect::~SkPairPathEffect() {
SkSafeUnref(fPE0);
SkSafeUnref(fPE1);
} }
/* /*
Format: [oe0-factory][pe1-factory][pe0-size][pe0-data][pe1-data] Format: [oe0-factory][pe1-factory][pe0-size][pe0-data][pe1-data]
*/ */
void SkPairPathEffect::flatten(SkWriteBuffer& buffer) const { void SkPairPathEffect::flatten(SkWriteBuffer& buffer) const {
buffer.writeFlattenable(fPE0.get()); buffer.writeFlattenable(fPE0);
buffer.writeFlattenable(fPE1.get()); buffer.writeFlattenable(fPE1);
} }
#ifndef SK_IGNORE_TO_STRING #ifndef SK_IGNORE_TO_STRING
@ -58,13 +65,22 @@ void SkPairPathEffect::toString(SkString* str) const {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
SkFlattenable* SkComposePathEffect::CreateProc(SkReadBuffer& buffer) { SkFlattenable* SkComposePathEffect::CreateProc(SkReadBuffer& buffer) {
sk_sp<SkPathEffect> pe0(buffer.readPathEffect()); SkAutoTUnref<SkPathEffect> pe0(buffer.readPathEffect());
sk_sp<SkPathEffect> pe1(buffer.readPathEffect()); SkAutoTUnref<SkPathEffect> pe1(buffer.readPathEffect());
return SkComposePathEffect::Make(std::move(pe0), std::move(pe1)).release(); if (pe0 && pe1) {
return SkComposePathEffect::Create(pe0, pe1);
} else {
return nullptr;
}
} }
bool SkComposePathEffect::filterPath(SkPath* dst, const SkPath& src, bool SkComposePathEffect::filterPath(SkPath* dst, const SkPath& src,
SkStrokeRec* rec, const SkRect* cullRect) const { SkStrokeRec* rec, const SkRect* cullRect) const {
// we may have failed to unflatten these, so we have to check
if (!fPE0 || !fPE1) {
return false;
}
SkPath tmp; SkPath tmp;
const SkPath* ptr = &src; const SkPath* ptr = &src;
@ -86,9 +102,13 @@ void SkComposePathEffect::toString(SkString* str) const {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
SkFlattenable* SkSumPathEffect::CreateProc(SkReadBuffer& buffer) { SkFlattenable* SkSumPathEffect::CreateProc(SkReadBuffer& buffer) {
sk_sp<SkPathEffect> pe0(buffer.readPathEffect()); SkAutoTUnref<SkPathEffect> pe0(buffer.readPathEffect());
sk_sp<SkPathEffect> pe1(buffer.readPathEffect()); SkAutoTUnref<SkPathEffect> pe1(buffer.readPathEffect());
return SkSumPathEffect::Make(pe0, pe1).release(); if (pe0 && pe1) {
return SkSumPathEffect::Create(pe0, pe1);
} else {
return nullptr;
}
} }
bool SkSumPathEffect::filterPath(SkPath* dst, const SkPath& src, bool SkSumPathEffect::filterPath(SkPath* dst, const SkPath& src,

View File

@ -134,9 +134,7 @@ public:
SkDrawLooper* readDrawLooper() { return this->readFlattenable<SkDrawLooper>(); } SkDrawLooper* readDrawLooper() { return this->readFlattenable<SkDrawLooper>(); }
SkImageFilter* readImageFilter() { return this->readFlattenable<SkImageFilter>(); } SkImageFilter* readImageFilter() { return this->readFlattenable<SkImageFilter>(); }
SkMaskFilter* readMaskFilter() { return this->readFlattenable<SkMaskFilter>(); } SkMaskFilter* readMaskFilter() { return this->readFlattenable<SkMaskFilter>(); }
sk_sp<SkPathEffect> readPathEffect() { SkPathEffect* readPathEffect() { return this->readFlattenable<SkPathEffect>(); }
return sk_sp<SkPathEffect>(this->readFlattenable<SkPathEffect>());
}
SkRasterizer* readRasterizer() { return this->readFlattenable<SkRasterizer>(); } SkRasterizer* readRasterizer() { return this->readFlattenable<SkRasterizer>(); }
sk_sp<SkShader> readShader() { return sk_sp<SkShader>(this->readFlattenable<SkShader>()); } sk_sp<SkShader> readShader() { return sk_sp<SkShader>(this->readFlattenable<SkShader>()); }
SkXfermode* readXfermode() { return this->readFlattenable<SkXfermode>(); } SkXfermode* readXfermode() { return this->readFlattenable<SkXfermode>(); }

View File

@ -153,7 +153,7 @@ SkFlattenable* SkPath1DPathEffect::CreateProc(SkReadBuffer& buffer) {
buffer.readPath(&path); buffer.readPath(&path);
SkScalar phase = buffer.readScalar(); SkScalar phase = buffer.readScalar();
Style style = (Style)buffer.readUInt(); Style style = (Style)buffer.readUInt();
return SkPath1DPathEffect::Make(path, advance, phase, style).release(); return SkPath1DPathEffect::Create(path, advance, phase, style);
} }
return nullptr; return nullptr;
} }
@ -204,10 +204,10 @@ void SkPath1DPathEffect::toString(SkString* str) const {
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
sk_sp<SkPathEffect> SkPath1DPathEffect::Make(const SkPath& path, SkScalar advance, SkScalar phase, SkPathEffect* SkPath1DPathEffect::Create(const SkPath& path, SkScalar advance, SkScalar phase,
Style style) { Style style) {
if (advance <= 0 || path.isEmpty()) { if (advance <= 0 || path.isEmpty()) {
return nullptr; return nullptr;
} }
return sk_sp<SkPathEffect>(new SkPath1DPathEffect(path, advance, phase, style)); return new SkPath1DPathEffect(path, advance, phase, style);
} }

View File

@ -111,7 +111,7 @@ SkFlattenable* SkLine2DPathEffect::CreateProc(SkReadBuffer& buffer) {
SkMatrix matrix; SkMatrix matrix;
buffer.readMatrix(&matrix); buffer.readMatrix(&matrix);
SkScalar width = buffer.readScalar(); SkScalar width = buffer.readScalar();
return SkLine2DPathEffect::Make(width, matrix).release(); return SkLine2DPathEffect::Create(width, matrix);
} }
void SkLine2DPathEffect::flatten(SkWriteBuffer &buffer) const { void SkLine2DPathEffect::flatten(SkWriteBuffer &buffer) const {
@ -140,7 +140,7 @@ SkFlattenable* SkPath2DPathEffect::CreateProc(SkReadBuffer& buffer) {
buffer.readMatrix(&matrix); buffer.readMatrix(&matrix);
SkPath path; SkPath path;
buffer.readPath(&path); buffer.readPath(&path);
return SkPath2DPathEffect::Make(matrix, path).release(); return SkPath2DPathEffect::Create(matrix, path);
} }
void SkPath2DPathEffect::flatten(SkWriteBuffer& buffer) const { void SkPath2DPathEffect::flatten(SkWriteBuffer& buffer) const {

View File

@ -62,7 +62,7 @@ DONE:
} }
SkFlattenable* SkArcToPathEffect::CreateProc(SkReadBuffer& buffer) { SkFlattenable* SkArcToPathEffect::CreateProc(SkReadBuffer& buffer) {
return SkArcToPathEffect::Make(buffer.readScalar()).release(); return SkArcToPathEffect::Create(buffer.readScalar());
} }
void SkArcToPathEffect::flatten(SkWriteBuffer& buffer) const { void SkArcToPathEffect::flatten(SkWriteBuffer& buffer) const {

View File

@ -140,7 +140,7 @@ DONE:
} }
SkFlattenable* SkCornerPathEffect::CreateProc(SkReadBuffer& buffer) { SkFlattenable* SkCornerPathEffect::CreateProc(SkReadBuffer& buffer) {
return SkCornerPathEffect::Make(buffer.readScalar()).release(); return SkCornerPathEffect::Create(buffer.readScalar());
} }
void SkCornerPathEffect::flatten(SkWriteBuffer& buffer) const { void SkCornerPathEffect::flatten(SkWriteBuffer& buffer) const {

View File

@ -365,7 +365,7 @@ SkFlattenable* SkDashPathEffect::CreateProc(SkReadBuffer& buffer) {
uint32_t count = buffer.getArrayCount(); uint32_t count = buffer.getArrayCount();
SkAutoSTArray<32, SkScalar> intervals(count); SkAutoSTArray<32, SkScalar> intervals(count);
if (buffer.readScalarArray(intervals.get(), count)) { if (buffer.readScalarArray(intervals.get(), count)) {
return Make(intervals.get(), SkToInt(count), phase).release(); return Create(intervals.get(), SkToInt(count), phase);
} }
return nullptr; return nullptr;
} }
@ -386,9 +386,9 @@ void SkDashPathEffect::toString(SkString* str) const {
////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////
sk_sp<SkPathEffect> SkDashPathEffect::Make(const SkScalar intervals[], int count, SkScalar phase) { SkPathEffect* SkDashPathEffect::Create(const SkScalar intervals[], int count, SkScalar phase) {
if (!SkDashPath::ValidDashPath(phase, intervals, count)) { if (!SkDashPath::ValidDashPath(phase, intervals, count)) {
return nullptr; return nullptr;
} }
return sk_sp<SkPathEffect>(new SkDashPathEffect(intervals, count, phase)); return new SkDashPathEffect(intervals, count, phase);
} }

View File

@ -13,11 +13,6 @@
#include "SkPathMeasure.h" #include "SkPathMeasure.h"
#include "SkStrokeRec.h" #include "SkStrokeRec.h"
sk_sp<SkPathEffect> SkDiscretePathEffect::Make(SkScalar segLength, SkScalar deviation,
uint32_t seedAssist) {
return sk_sp<SkPathEffect>(new SkDiscretePathEffect(segLength, deviation, seedAssist));
}
static void Perterb(SkPoint* p, const SkVector& tangent, SkScalar scale) { static void Perterb(SkPoint* p, const SkVector& tangent, SkScalar scale) {
SkVector normal = tangent; SkVector normal = tangent;
normal.rotateCCW(); normal.rotateCCW();
@ -126,7 +121,7 @@ SkFlattenable* SkDiscretePathEffect::CreateProc(SkReadBuffer& buffer) {
SkScalar segLength = buffer.readScalar(); SkScalar segLength = buffer.readScalar();
SkScalar perterb = buffer.readScalar(); SkScalar perterb = buffer.readScalar();
uint32_t seed = buffer.readUInt(); uint32_t seed = buffer.readUInt();
return Make(segLength, perterb, seed).release(); return Create(segLength, perterb, seed);
} }
void SkDiscretePathEffect::flatten(SkWriteBuffer& buffer) const { void SkDiscretePathEffect::flatten(SkWriteBuffer& buffer) const {

View File

@ -93,7 +93,7 @@ void SkLayerDrawLooper::LayerDrawLooperContext::ApplyInfo(
} }
if (bits & kPathEffect_Bit) { if (bits & kPathEffect_Bit) {
dst->setPathEffect(sk_ref_sp(src.getPathEffect())); dst->setPathEffect(src.getPathEffect());
} }
if (bits & kMaskFilter_Bit) { if (bits & kMaskFilter_Bit) {
dst->setMaskFilter(src.getMaskFilter()); dst->setMaskFilter(src.getMaskFilter());

View File

@ -517,7 +517,7 @@ void GrTextUtils::DrawPosTextAsPath(GrContext* context,
// Now restore the original settings, so we "draw" with whatever style/stroking. // Now restore the original settings, so we "draw" with whatever style/stroking.
paint.setStyle(origPaint.getStyle()); paint.setStyle(origPaint.getStyle());
paint.setPathEffect(sk_ref_sp(origPaint.getPathEffect())); paint.setPathEffect(origPaint.getPathEffect());
while (text < stop) { while (text < stop) {
const SkGlyph& glyph = glyphCacheProc(cache, &text); const SkGlyph& glyph = glyphCacheProc(cache, &text);

View File

@ -15,7 +15,6 @@
#include "SkGlyphCache.h" #include "SkGlyphCache.h"
#include "SkPaint.h" #include "SkPaint.h"
#include "SkPath.h" #include "SkPath.h"
#include "SkPathEffect.h"
#include "SkPathOps.h" #include "SkPathOps.h"
#include "SkPDFBitmap.h" #include "SkPDFBitmap.h"
#include "SkPDFCanon.h" #include "SkPDFCanon.h"

View File

@ -32,7 +32,6 @@
#include "SkIStream.h" #include "SkIStream.h"
#include "SkMaskFilter.h" #include "SkMaskFilter.h"
#include "SkPaint.h" #include "SkPaint.h"
#include "SkPathEffect.h"
#include "SkPathOps.h" #include "SkPathOps.h"
#include "SkPoint.h" #include "SkPoint.h"
#include "SkRasterizer.h" #include "SkRasterizer.h"

View File

@ -12,7 +12,7 @@
#include "SkCornerPathEffect.h" #include "SkCornerPathEffect.h"
DEF_TEST(AsADashTest_noneDash, reporter) { DEF_TEST(AsADashTest_noneDash, reporter) {
sk_sp<SkPathEffect> pe(SkCornerPathEffect::Make(1.0)); SkAutoTUnref<SkPathEffect> pe(SkCornerPathEffect::Create(1.0));
SkPathEffect::DashInfo info; SkPathEffect::DashInfo info;
SkPathEffect::DashType dashType = pe->asADash(&info); SkPathEffect::DashType dashType = pe->asADash(&info);
@ -22,7 +22,7 @@ DEF_TEST(AsADashTest_noneDash, reporter) {
DEF_TEST(AsADashTest_nullInfo, reporter) { DEF_TEST(AsADashTest_nullInfo, reporter) {
SkScalar inIntervals[] = { 4.0, 2.0, 1.0, 3.0 }; SkScalar inIntervals[] = { 4.0, 2.0, 1.0, 3.0 };
const SkScalar phase = 2.0; const SkScalar phase = 2.0;
sk_sp<SkPathEffect> pe(SkDashPathEffect::Make(inIntervals, 4, phase)); SkAutoTUnref<SkPathEffect> pe(SkDashPathEffect::Create(inIntervals, 4, phase));
SkPathEffect::DashType dashType = pe->asADash(nullptr); SkPathEffect::DashType dashType = pe->asADash(nullptr);
REPORTER_ASSERT(reporter, SkPathEffect::kDash_DashType == dashType); REPORTER_ASSERT(reporter, SkPathEffect::kDash_DashType == dashType);
@ -33,7 +33,7 @@ DEF_TEST(AsADashTest_usingDash, reporter) {
SkScalar totalIntSum = 10.0; SkScalar totalIntSum = 10.0;
const SkScalar phase = 2.0; const SkScalar phase = 2.0;
sk_sp<SkPathEffect> pe(SkDashPathEffect::Make(inIntervals, 4, phase)); SkAutoTUnref<SkPathEffect> pe(SkDashPathEffect::Create(inIntervals, 4, phase));
SkPathEffect::DashInfo info; SkPathEffect::DashInfo info;

View File

@ -18,7 +18,7 @@ DEF_TEST(DashPathEffectTest_crbug_348821, r) {
SkScalar intervals[] = { 1.76934361e+36f, 2.80259693e-45f }; // Values from bug. SkScalar intervals[] = { 1.76934361e+36f, 2.80259693e-45f }; // Values from bug.
const int count = 2; const int count = 2;
SkScalar phase = SK_ScalarInfinity; // Used to force a nonsense effect. SkScalar phase = SK_ScalarInfinity; // Used to force a nonsense effect.
sk_sp<SkPathEffect> dash(SkDashPathEffect::Make(intervals, count, phase)); SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, count, phase));
REPORTER_ASSERT(r, dash == nullptr); REPORTER_ASSERT(r, dash == nullptr);
} }
@ -28,7 +28,7 @@ DEF_TEST(DashPathEffectTest_asPoints, r) {
const SkScalar intervals[] = { 1.0f, 1.0f }; const SkScalar intervals[] = { 1.0f, 1.0f };
const int count = 2; const int count = 2;
sk_sp<SkPathEffect> dash(SkDashPathEffect::Make(intervals, count, 0.0f)); SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, count, 0.0f));
SkRect cull = SkRect::MakeWH(1.0f, 1.0f); SkRect cull = SkRect::MakeWH(1.0f, 1.0f);
@ -90,7 +90,7 @@ DEF_TEST(DashPath_bug4871, r) {
path.close(); path.close();
SkScalar intervals[2] = { 1, 1 }; SkScalar intervals[2] = { 1, 1 };
sk_sp<SkPathEffect> dash(SkDashPathEffect::Make(intervals, 2, 0)); SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, 2, 0));
SkPaint paint; SkPaint paint;
paint.setStyle(SkPaint::kStroke_Style); paint.setStyle(SkPaint::kStroke_Style);

View File

@ -192,7 +192,7 @@ static void test_crbug_140642() {
*/ */
const SkScalar vals[] = { 27734, 35660, 2157846850.0f, 247 }; const SkScalar vals[] = { 27734, 35660, 2157846850.0f, 247 };
auto dontAssert = SkDashPathEffect::Make(vals, 4, -248.135982067f); SkAutoTUnref<SkPathEffect> dontAssert(SkDashPathEffect::Create(vals, 4, -248.135982067f));
} }
static void test_crbug_124652() { static void test_crbug_124652() {
@ -202,7 +202,7 @@ static void test_crbug_124652() {
large values can "swamp" small ones. large values can "swamp" small ones.
*/ */
SkScalar intervals[2] = {837099584, 33450}; SkScalar intervals[2] = {837099584, 33450};
auto dontAssert = SkDashPathEffect::Make(intervals, 2, -10); SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, 2, -10));
} }
static void test_bigcubic() { static void test_bigcubic() {
@ -281,7 +281,7 @@ static void test_infinite_dash(skiatest::Reporter* reporter) {
path.lineTo(5000000, 0); path.lineTo(5000000, 0);
SkScalar intervals[] = { 0.2f, 0.2f }; SkScalar intervals[] = { 0.2f, 0.2f };
sk_sp<SkPathEffect> dash(SkDashPathEffect::Make(intervals, 2, 0)); SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, 2, 0));
SkPath filteredPath; SkPath filteredPath;
SkPaint paint; SkPaint paint;
@ -301,7 +301,7 @@ static void test_crbug_165432(skiatest::Reporter* reporter) {
path.lineTo(10000000, 0); path.lineTo(10000000, 0);
SkScalar intervals[] = { 0.5f, 0.5f }; SkScalar intervals[] = { 0.5f, 0.5f };
sk_sp<SkPathEffect> dash(SkDashPathEffect::Make(intervals, 2, 0)); SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, 2, 0));
SkPaint paint; SkPaint paint;
paint.setStyle(SkPaint::kStroke_Style); paint.setStyle(SkPaint::kStroke_Style);

View File

@ -49,7 +49,7 @@ static void test_drawPathEmpty(skiatest::Reporter*, SkCanvas* canvas) {
} }
static void fill_and_stroke(SkCanvas* canvas, const SkPath& p1, const SkPath& p2, static void fill_and_stroke(SkCanvas* canvas, const SkPath& p1, const SkPath& p2,
sk_sp<SkPathEffect> effect) { SkPathEffect* effect) {
SkPaint paint; SkPaint paint;
paint.setAntiAlias(true); paint.setAntiAlias(true);
paint.setPathEffect(effect); paint.setPathEffect(effect);
@ -73,7 +73,8 @@ static void test_drawSameRectOvals(skiatest::Reporter*, SkCanvas* canvas) {
fill_and_stroke(canvas, oval1, oval2, nullptr); fill_and_stroke(canvas, oval1, oval2, nullptr);
const SkScalar intervals[] = { 1, 1 }; const SkScalar intervals[] = { 1, 1 };
fill_and_stroke(canvas, oval1, oval2, SkDashPathEffect::Make(intervals, 2, 0)); SkAutoTUnref<SkPathEffect> dashEffect(SkDashPathEffect::Create(intervals, 2, 0));
fill_and_stroke(canvas, oval1, oval2, dashEffect);
} }
DEF_GPUTEST_FOR_ALL_CONTEXTS(GpuDrawPath, reporter, context) { DEF_GPUTEST_FOR_ALL_CONTEXTS(GpuDrawPath, reporter, context) {

View File

@ -144,7 +144,7 @@ static void test_gpu_veto(skiatest::Reporter* reporter) {
path.lineTo(50, 50); path.lineTo(50, 50);
SkScalar intervals[] = { 1.0f, 1.0f }; SkScalar intervals[] = { 1.0f, 1.0f };
sk_sp<SkPathEffect> dash(SkDashPathEffect::Make(intervals, 2, 0)); SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, 2, 0));
SkPaint paint; SkPaint paint;
paint.setStyle(SkPaint::kStroke_Style); paint.setStyle(SkPaint::kStroke_Style);
@ -233,7 +233,8 @@ static void test_gpu_veto(skiatest::Reporter* reporter) {
{ {
SkPaint paint; SkPaint paint;
SkScalar intervals [] = { 10, 20 }; SkScalar intervals [] = { 10, 20 };
paint.setPathEffect(SkDashPathEffect::Make(intervals, 2, 25)); SkPathEffect* pe = SkDashPathEffect::Create(intervals, 2, 25);
paint.setPathEffect(pe)->unref();
SkPoint points [2] = { { 0, 0 }, { 100, 0 } }; SkPoint points [2] = { { 0, 0 }, { 100, 0 } };
@ -249,7 +250,8 @@ static void test_gpu_veto(skiatest::Reporter* reporter) {
{ {
SkPaint paint; SkPaint paint;
SkScalar intervals [] = { 10, 20 }; SkScalar intervals [] = { 10, 20 };
paint.setPathEffect(SkDashPathEffect::Make(intervals, 2, 25)); SkPathEffect* pe = SkDashPathEffect::Create(intervals, 2, 25);
paint.setPathEffect(pe)->unref();
for (int i = 0; i < 50; ++i) { for (int i = 0; i < 50; ++i) {
canvas->drawRect(SkRect::MakeWH(10, 10), paint); canvas->drawRect(SkRect::MakeWH(10, 10), paint);

View File

@ -1106,10 +1106,10 @@ static void extract_json_paint_patheffect(Json::Value& jsonPaint, UrlDataManager
SkPaint* target) { SkPaint* target) {
if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_PATHEFFECT)) { if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_PATHEFFECT)) {
Json::Value jsonPathEffect = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_PATHEFFECT]; Json::Value jsonPathEffect = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_PATHEFFECT];
sk_sp<SkPathEffect> pathEffect((SkPathEffect*)load_flattenable(jsonPathEffect, SkPathEffect* pathEffect = (SkPathEffect*) load_flattenable(jsonPathEffect, urlDataManager);
urlDataManager));
if (pathEffect != nullptr) { if (pathEffect != nullptr) {
target->setPathEffect(pathEffect); target->setPathEffect(pathEffect);
pathEffect->unref();
} }
} }
} }
@ -1329,7 +1329,7 @@ static void extract_json_paint_dashing(Json::Value& jsonPaint, SkPaint* target)
intervals[i] = jsonIntervals[i].asFloat(); intervals[i] = jsonIntervals[i].asFloat();
} }
SkScalar phase = dash[SKDEBUGCANVAS_ATTRIBUTE_PHASE].asFloat(); SkScalar phase = dash[SKDEBUGCANVAS_ATTRIBUTE_PHASE].asFloat();
target->setPathEffect(SkDashPathEffect::Make(intervals, count, phase)); target->setPathEffect(SkDashPathEffect::Create(intervals, count, phase));
sk_free(intervals); sk_free(intervals);
} }
} }