SkPath path;
this->makePath(&path);
- paint.setPathEffect(new SkDashPathEffect(fIntervals.begin(),
- fIntervals.count(), 0))->unref();
+ paint.setPathEffect(SkDashPathEffect::Create(fIntervals.begin(),
+ fIntervals.count(), 0))->unref();
if (fDoClip) {
SkRect r = path.getBounds();
proc(&fPath);
SkScalar vals[] = { SkIntToScalar(4), SkIntToScalar(4) };
- fPE.reset(new SkDashPathEffect(vals, 2, 0));
+ fPE.reset(SkDashPathEffect::Create(vals, 2, 0));
}
protected:
fIsRound = isRound;
SkScalar vals[] = { SK_Scalar1, SK_Scalar1 };
- fPE.reset(new SkDashPathEffect(vals, 2, 0));
+ fPE.reset(SkDashPathEffect::Create(vals, 2, 0));
}
protected:
fDoAA = doAA;
SkScalar vals[] = { SkIntToScalar(dashLength), SkIntToScalar(dashLength) };
- fPathEffect.reset(new SkDashPathEffect(vals, 2, SK_Scalar1, false));
+ fPathEffect.reset(SkDashPathEffect::Create(vals, 2, SK_Scalar1, false));
}
protected:
// deliberately pick intervals that won't be caught by asPoints(), so
// we can test the filterPath code-path.
const SkScalar intervals[] = { 2, 1, 1, 1 };
- fPathEffect.reset(new SkDashPathEffect(intervals,
- SK_ARRAY_COUNT(intervals), 0));
+ fPathEffect.reset(SkDashPathEffect::Create(intervals,
+ SK_ARRAY_COUNT(intervals), 0));
SkScalar cx = 640 / 2; // center X
SkScalar cy = 480 / 2; // center Y
paint->setStrokeWidth(SkDoubleToScalar(fLineWidth));
// TODO(edisonn): perf, avoid allocs of the intervals
if (fDashArrayLength > 0) {
- paint->setPathEffect(new SkDashPathEffect(fDashArray,
- fDashArrayLength,
- fDashPhase))->unref();
+ paint->setPathEffect(SkDashPathEffect::Create(fDashArray,
+ fDashArrayLength,
+ fDashPhase))->unref();
}
}
SkParsePath::FromSVGString(d, &path);
SkScalar intervals[] = { 5, 10 };
- SkPathEffect* pe = new SkDashPathEffect(intervals, 2, 0);
+ SkPathEffect* pe = SkDashPathEffect::Create(intervals, 2, 0);
SkPaint paint;
paint.setAntiAlias(true);
SkIntToScalar(off),
};
- p.setPathEffect(new SkDashPathEffect(intervals, 2, 0))->unref();
+ p.setPathEffect(SkDashPathEffect::Create(intervals, 2, 0))->unref();
canvas->drawLine(0, 0, finalX, 0, p);
}
vals[i] = SkIntToScalar(*intervals++);
}
SkScalar phase = vals[0] / 2;
- paint.setPathEffect(new SkDashPathEffect(vals, count, phase))->unref();
+ paint.setPathEffect(SkDashPathEffect::Create(vals, count, phase))->unref();
for (size_t x = 0; x < SK_ARRAY_COUNT(gProc); ++x) {
SkPath path;
SkScalar intervals[2] = { dashLength, dashLength };
- p.setPathEffect(new SkDashPathEffect(intervals, 2, phase, false))->unref();
+ p.setPathEffect(SkDashPathEffect::Create(intervals, 2, phase, false))->unref();
SkPoint pts[2];
static void compose_pe(SkPaint* paint) {
SkPathEffect* pe = paint->getPathEffect();
- SkPathEffect* corner = new SkCornerPathEffect(25);
+ SkPathEffect* corner = SkCornerPathEffect::Create(25);
SkPathEffect* compose;
if (pe) {
- compose = new SkComposePathEffect(pe, corner);
+ compose = SkComposePathEffect::Create(pe, corner);
corner->unref();
} else {
compose = corner;
static void dash_pe(SkPaint* paint) {
SkScalar inter[] = { 20, 10, 10, 10 };
paint->setStrokeWidth(12);
- paint->setPathEffect(new SkDashPathEffect(inter, SK_ARRAY_COUNT(inter),
- 0))->unref();
+ paint->setPathEffect(SkDashPathEffect::Create(inter, SK_ARRAY_COUNT(inter),
+ 0))->unref();
compose_pe(paint);
}
path.offset(SkIntToScalar(-6), 0);
scale(&path, 1.5f);
- paint->setPathEffect(new SkPath1DPathEffect(path, SkIntToScalar(21), 0,
+ paint->setPathEffect(SkPath1DPathEffect::Create(path, SkIntToScalar(21), 0,
SkPath1DPathEffect::kRotate_Style))->unref();
compose_pe(paint);
}
}
static void discrete_pe(SkPaint* paint) {
- paint->setPathEffect(new SkDiscretePathEffect(10, 4))->unref();
+ paint->setPathEffect(SkDiscretePathEffect::Create(10, 4))->unref();
}
static SkPathEffect* MakeTileEffect() {
SkPath path;
path.addCircle(0, 0, SkIntToScalar(5));
- return new SkPath2DPathEffect(m, path);
+ return SkPath2DPathEffect::Create(m, path);
}
static void tile_pe(SkPaint* paint) {
static void r5(SkLayerRasterizer* rast, SkPaint& p) {
rast->addLayer(p);
- p.setPathEffect(new SkDiscretePathEffect(SK_Scalar1*4, SK_Scalar1*3))->unref();
+ p.setPathEffect(SkDiscretePathEffect::Create(SK_Scalar1*4, SK_Scalar1*3))->unref();
p.setXfermodeMode(SkXfermode::kSrcOut_Mode);
rast->addLayer(p);
}
static SkPathEffect* MakeDotEffect(SkScalar radius, const SkMatrix& matrix) {
SkPath path;
path.addCircle(0, 0, radius);
- return new SkPath2DPathEffect(matrix, path);
+ return SkPath2DPathEffect::Create(matrix, path);
}
static void r7(SkLayerRasterizer* rast, SkPaint& p) {
SkMatrix lattice;
lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0);
lattice.postRotate(SkIntToScalar(30), 0, 0);
- p.setPathEffect(new SkLine2DPathEffect(SK_Scalar1*2, lattice))->unref();
+ p.setPathEffect(SkLine2DPathEffect::Create(SK_Scalar1*2, lattice))->unref();
p.setXfermodeMode(SkXfermode::kClear_Mode);
rast->addLayer(p);
public:
SK_DECLARE_INST_COUNT(SkPathEffect)
- SkPathEffect() {}
-
/**
* Given a src path (input) and a stroke-rec (input and output), apply
* this effect to the src path, returning the new path in dst, and return
SK_DEFINE_FLATTENABLE_TYPE(SkPathEffect)
protected:
+ SkPathEffect() {}
SkPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {}
private:
*/
class SkPairPathEffect : public SkPathEffect {
public:
- SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1);
virtual ~SkPairPathEffect();
protected:
+ SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1);
SkPairPathEffect(SkReadBuffer&);
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
The reference counts for outer and inner are both incremented in the constructor,
and decremented in the destructor.
*/
- SkComposePathEffect(SkPathEffect* outer, SkPathEffect* inner)
- : INHERITED(outer, inner) {}
+ static SkComposePathEffect* Create(SkPathEffect* outer, SkPathEffect* inner) {
+ return SkNEW_ARGS(SkComposePathEffect, (outer, inner));
+ }
virtual bool filterPath(SkPath* dst, const SkPath& src,
SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
protected:
SkComposePathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {}
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ SkComposePathEffect(SkPathEffect* outer, SkPathEffect* inner)
+ : INHERITED(outer, inner) {}
+
private:
// illegal
SkComposePathEffect(const SkComposePathEffect&);
The reference counts for first and second are both incremented in the constructor,
and decremented in the destructor.
*/
- SkSumPathEffect(SkPathEffect* first, SkPathEffect* second)
- : INHERITED(first, second) {}
+ static SkSumPathEffect* Create(SkPathEffect* first, SkPathEffect* second) {
+ return SkNEW_ARGS(SkSumPathEffect, (first, second));
+ }
virtual bool filterPath(SkPath* dst, const SkPath& src,
SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
protected:
SkSumPathEffect(SkReadBuffer& buffer) : INHERITED(buffer) {}
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ SkSumPathEffect(SkPathEffect* first, SkPathEffect* second)
+ : INHERITED(first, second) {}
+
private:
// illegal
SkSumPathEffect(const SkSumPathEffect&);
public:
SK_DECLARE_INST_COUNT(SkXfermode)
- SkXfermode() {}
-
virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
const SkAlpha aa[]) const;
virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count,
*/
virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst) const;
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ SkXfermode() {}
+
private:
enum {
kModeCount = kLastMode + 1
*/
class SkProcXfermode : public SkXfermode {
public:
- SkProcXfermode(SkXfermodeProc proc) : fProc(proc) {}
+ static SkProcXfermode* Create(SkXfermodeProc proc) {
+ return SkNEW_ARGS(SkProcXfermode, (proc));
+ }
// overrides from SkXfermode
virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
return fProc;
}
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ SkProcXfermode(SkXfermodeProc proc) : fProc(proc) {}
+
private:
SkXfermodeProc fProc;
@param style how to transform path at each point (based on the current
position and tangent)
*/
- SkPath1DPathEffect(const SkPath& path, SkScalar advance, SkScalar phase, Style);
+ static SkPath1DPathEffect* Create(const SkPath& path, SkScalar advance, SkScalar phase,
+ Style style) {
+ return SkNEW_ARGS(SkPath1DPathEffect, (path, advance, phase, style));
+ }
virtual bool filterPath(SkPath*, const SkPath&,
SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
virtual SkScalar begin(SkScalar contourLength) const SK_OVERRIDE;
virtual SkScalar next(SkPath*, SkScalar, SkPathMeasure&) const SK_OVERRIDE;
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ SkPath1DPathEffect(const SkPath& path, SkScalar advance, SkScalar phase, Style);
+
private:
SkPath fPath; // copied from constructor
SkScalar fAdvance; // copied from constructor
class SK_API Sk2DPathEffect : public SkPathEffect {
public:
- Sk2DPathEffect(const SkMatrix& mat);
+ static Sk2DPathEffect* Create(const SkMatrix& mat) {
+ return SkNEW_ARGS(Sk2DPathEffect, (mat));
+ }
virtual bool filterPath(SkPath*, const SkPath&,
SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
Sk2DPathEffect(SkReadBuffer&);
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ Sk2DPathEffect(const SkMatrix& mat);
+
private:
SkMatrix fMatrix, fInverse;
bool fMatrixIsInvertible;
class SK_API SkLine2DPathEffect : public Sk2DPathEffect {
public:
- SkLine2DPathEffect(SkScalar width, const SkMatrix& matrix)
- : Sk2DPathEffect(matrix), fWidth(width) {}
+ static SkLine2DPathEffect* Create(SkScalar width, const SkMatrix& matrix) {
+ return SkNEW_ARGS(SkLine2DPathEffect, (width, matrix));
+ }
virtual bool filterPath(SkPath* dst, const SkPath& src,
SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ SkLine2DPathEffect(SkScalar width, const SkMatrix& matrix)
+ : Sk2DPathEffect(matrix), fWidth(width) {}
+
private:
SkScalar fWidth;
* Stamp the specified path to fill the shape, using the matrix to define
* the latice.
*/
- SkPath2DPathEffect(const SkMatrix&, const SkPath&);
+ static SkPath2DPathEffect* Create(const SkMatrix& matrix, const SkPath& path) {
+ return SkNEW_ARGS(SkPath2DPathEffect, (matrix, path));
+ }
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath2DPathEffect)
virtual void next(const SkPoint&, int u, int v, SkPath*) const SK_OVERRIDE;
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ SkPath2DPathEffect(const SkMatrix&, const SkPath&);
+
private:
SkPath fPath;
Tolerance near 0: draw only on colors that are nearly identical to the op-color
Tolerance near 255: draw on any colors even remotely similar to the op-color
*/
- SkAvoidXfermode(SkColor opColor, U8CPU tolerance, Mode mode);
+ static SkAvoidXfermode* Create(SkColor opColor, U8CPU tolerance, Mode mode) {
+ return SkNEW_ARGS(SkAvoidXfermode, (opColor, tolerance, mode));
+ }
// overrides from SkXfermode
virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
SkAvoidXfermode(SkReadBuffer&);
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ SkAvoidXfermode(SkColor opColor, U8CPU tolerance, Mode mode);
+
private:
SkColor fOpColor;
uint32_t fDistMul; // x.14
/** radius must be > 0 to have an effect. It specifies the distance from each corner
that should be "rounded".
*/
- SkCornerPathEffect(SkScalar radius);
+ static SkCornerPathEffect* Create(SkScalar radius) {
+ return SkNEW_ARGS(SkCornerPathEffect, (radius));
+ }
virtual ~SkCornerPathEffect();
virtual bool filterPath(SkPath* dst, const SkPath& src,
SkCornerPathEffect(SkReadBuffer&);
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ SkCornerPathEffect(SkScalar radius);
+
private:
SkScalar fRadius;
Note: only affects stroked paths.
*/
- SkDashPathEffect(const SkScalar intervals[], int count, SkScalar phase,
- bool scaleToFit = false);
+ static SkDashPathEffect* Create(const SkScalar intervals[], int count,
+ SkScalar phase, bool scaleToFit = false) {
+ return SkNEW_ARGS(SkDashPathEffect, (intervals, count, phase, scaleToFit));
+ }
virtual ~SkDashPathEffect();
virtual bool filterPath(SkPath* dst, const SkPath& src,
SkDashPathEffect(SkReadBuffer&);
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ SkDashPathEffect(const SkScalar intervals[], int count, SkScalar phase,
+ bool scaleToFit = false);
+
private:
SkScalar* fIntervals;
int32_t fCount;
away from the original path by a maximum of deviation.
Note: works on filled or framed paths
*/
- SkDiscretePathEffect(SkScalar segLength, SkScalar deviation);
+ static SkDiscretePathEffect* Create(SkScalar segLength, SkScalar deviation) {
+ return SkNEW_ARGS(SkDiscretePathEffect, (segLength, deviation));
+ }
virtual bool filterPath(SkPath* dst, const SkPath& src,
SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
SkDiscretePathEffect(SkReadBuffer&);
virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ SkDiscretePathEffect(SkScalar segLength, SkScalar deviation);
+
private:
SkScalar fSegLength, fPerterb;
*/
class SK_API SkPixelXorXfermode : public SkXfermode {
public:
- SkPixelXorXfermode(SkColor opColor) : fOpColor(opColor) {}
+ static SkPixelXorXfermode* Create(SkColor opColor) {
+ return SkNEW_ARGS(SkPixelXorXfermode, (opColor));
+ }
SK_DEVELOPER_TO_STRING()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPixelXorXfermode)
// override from SkXfermode
virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst) const;
+#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
+public:
+#endif
+ SkPixelXorXfermode(SkColor opColor) : fOpColor(opColor) {}
+
private:
SkColor fOpColor;
static void r5(SkLayerRasterizer* rast, SkPaint& p) {
rast->addLayer(p);
- p.setPathEffect(new SkDiscretePathEffect(SK_Scalar1*4, SK_Scalar1*3))->unref();
+ p.setPathEffect(SkDiscretePathEffect::Create(SK_Scalar1*4, SK_Scalar1*3))->unref();
p.setXfermodeMode(SkXfermode::kSrcOut_Mode);
rast->addLayer(p);
}
SkMatrix lattice;
lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0);
lattice.postRotate(SkIntToScalar(30), 0, 0);
- p.setPathEffect(new SkLine2DPathEffect(SK_Scalar1*2, lattice))->unref();
+ p.setPathEffect(SkLine2DPathEffect::Create(SK_Scalar1*2, lattice))->unref();
p.setXfermodeMode(SkXfermode::kClear_Mode);
rast->addLayer(p);
path.lineTo(SkIntToScalar(gXY[i]), SkIntToScalar(gXY[i+1]));
path.close();
path.offset(SkIntToScalar(-6), 0);
- SkPathEffect* outer = new SkPath1DPathEffect(path, SkIntToScalar(12),
+ SkPathEffect* outer = SkPath1DPathEffect::Create(path, SkIntToScalar(12),
gPhase, SkPath1DPathEffect::kRotate_Style);
- SkPathEffect* inner = new SkDiscretePathEffect(SkIntToScalar(2),
+ SkPathEffect* inner = SkDiscretePathEffect::Create(SkIntToScalar(2),
SkIntToScalar(1)/10); // SkCornerPathEffect(SkIntToScalar(2));
- SkPathEffect* result = new SkComposePathEffect(outer, inner);
+ SkPathEffect* result = SkComposePathEffect::Create(outer, inner);
outer->unref();
inner->unref();
return result;
canvas->restore();
if (1) {
- SkAvoidXfermode mode(SK_ColorWHITE, 0xFF,
- SkAvoidXfermode::kTargetColor_Mode);
+ SkAutoTUnref<SkAvoidXfermode> mode(SkAvoidXfermode::Create(SK_ColorWHITE, 0xFF,
+ SkAvoidXfermode::kTargetColor_Mode));
SkPaint paint;
x += SkIntToScalar(20);
SkRect r = { x, 0, x + SkIntToScalar(360), SkIntToScalar(700) };
- paint.setXfermode(&mode);
+ paint.setXfermode(mode);
paint.setColor(SK_ColorGREEN);
paint.setAntiAlias(true);
canvas->drawOval(r, paint);
frameP.setStyle(SkPaint::kStroke_Style);
for (size_t i = 0; i < SK_ARRAY_COUNT(gData); i++) {
- SkAvoidXfermode mode(SK_ColorGREEN, gData[i].fTolerance,
- gData[i].fMode);
- paint.setXfermode(&mode);
+ SkAutoTUnref<SkAvoidXfermode> mode(SkAvoidXfermode::Create(
+ SK_ColorGREEN, gData[i].fTolerance, gData[i].fMode));
+ paint.setXfermode(mode);
int div = 3;
SkRect rr = { 0, 0, r.width()/div, r.height()/div };
rr.offset(r.width()/4 - rr.width()/2, r.height()/4 - rr.height()/2);
static SkPathEffect* make_pe(int flags) {
if (flags == 1)
- return new SkCornerPathEffect(SkIntToScalar(CORNER_RADIUS));
+ return SkCornerPathEffect::Create(SkIntToScalar(CORNER_RADIUS));
SkPath path;
path.moveTo(SkIntToScalar(gXY[0]), SkIntToScalar(gXY[1]));
path.close();
path.offset(SkIntToScalar(-6), 0);
- SkPathEffect* outer = new SkPath1DPathEffect(path, SkIntToScalar(12), gPhase, SkPath1DPathEffect::kRotate_Style);
+ SkPathEffect* outer = SkPath1DPathEffect::Create(path, SkIntToScalar(12), gPhase, SkPath1DPathEffect::kRotate_Style);
if (flags == 2)
return outer;
- SkPathEffect* inner = new SkCornerPathEffect(SkIntToScalar(CORNER_RADIUS));
+ SkPathEffect* inner = SkCornerPathEffect::Create(SkIntToScalar(CORNER_RADIUS));
- SkPathEffect* pe = new SkComposePathEffect(outer, inner);
+ SkPathEffect* pe = SkComposePathEffect::Create(outer, inner);
outer->unref();
inner->unref();
return pe;
path.close();
path.offset(SkIntToScalar(-6), 0);
- SkPathEffect* outer = new SkPath1DPathEffect(path, SkIntToScalar(12), gPhase, SkPath1DPathEffect::kMorph_Style);
- SkPathEffect* inner = new SkCornerPathEffect(SkIntToScalar(CORNER_RADIUS));
+ SkPathEffect* outer = SkPath1DPathEffect::Create(
+ path, SkIntToScalar(12), gPhase, SkPath1DPathEffect::kMorph_Style);
+ SkPathEffect* inner = SkCornerPathEffect::Create(SkIntToScalar(CORNER_RADIUS));
- SkPathEffect* pe = new SkComposePathEffect(outer, inner);
+ SkPathEffect* pe = SkComposePathEffect::Create(outer, inner);
outer->unref();
inner->unref();
return pe;
virtual void onDrawContent(SkCanvas* canvas) {
SkScalar intervals[8] = { .5f, .3f, .5f, .3f, .5f, .3f, .5f, .3f };
- SkDashPathEffect dash(intervals, 2, fPhase);
- SkCornerPathEffect corner(.25f);
- SkComposePathEffect compose(&dash, &corner);
+ SkAutoTUnref<SkDashPathEffect> dash(SkDashPathEffect::Create(intervals, 2, fPhase));
+ SkAutoTUnref<SkCornerPathEffect> corner(SkCornerPathEffect::Create(.25f));
+ SkAutoTUnref<SkComposePathEffect> compose(SkComposePathEffect::Create(dash, corner));
SkPaint outlinePaint;
outlinePaint.setAntiAlias(true); // dashed paint for bitmap
outlinePaint.setStyle(SkPaint::kStroke_Style);
- outlinePaint.setPathEffect(&compose);
+ outlinePaint.setPathEffect(compose);
canvas->scale(10.0f, 10.0f); // scales up
static void compose_pe(SkPaint* paint) {
SkPathEffect* pe = paint->getPathEffect();
- SkPathEffect* corner = new SkCornerPathEffect(25);
+ SkPathEffect* corner = SkCornerPathEffect::Create(25);
SkPathEffect* compose;
if (pe) {
- compose = new SkComposePathEffect(pe, corner);
+ compose = SkComposePathEffect::Create(pe, corner);
corner->unref();
} else {
compose = corner;
static void dash_pe(SkPaint* paint) {
SkScalar inter[] = { 20, 10, 10, 10 };
paint->setStrokeWidth(12);
- paint->setPathEffect(new SkDashPathEffect(inter, SK_ARRAY_COUNT(inter),
- 0))->unref();
+ paint->setPathEffect(SkDashPathEffect::Create(inter, SK_ARRAY_COUNT(inter),
+ 0))->unref();
compose_pe(paint);
}
path.offset(SkIntToScalar(-6), 0);
scale(&path, 1.5f);
- paint->setPathEffect(new SkPath1DPathEffect(path, SkIntToScalar(21), 0,
- SkPath1DPathEffect::kRotate_Style))->unref();
+ paint->setPathEffect(SkPath1DPathEffect::Create(path, SkIntToScalar(21), 0,
+ SkPath1DPathEffect::kRotate_Style))->unref();
compose_pe(paint);
}
}
static void discrete_pe(SkPaint* paint) {
- paint->setPathEffect(new SkDiscretePathEffect(10, 4))->unref();
+ paint->setPathEffect(SkDiscretePathEffect::Create(10, 4))->unref();
}
static SkPathEffect* MakeTileEffect() {
SkPath path;
path.addCircle(0, 0, SkIntToScalar(5));
- return new SkPath2DPathEffect(m, path);
+ return SkPath2DPathEffect::Create(m, path);
}
static void tile_pe(SkPaint* paint) {
{
rast->addLayer(p);
- p.setPathEffect(new SkDiscretePathEffect(SK_Scalar1*4, SK_Scalar1*3))->unref();
+ p.setPathEffect(SkDiscretePathEffect::Create(SK_Scalar1*4, SK_Scalar1*3))->unref();
p.setXfermodeMode(SkXfermode::kSrcOut_Mode);
rast->addLayer(p);
}
static SkPathEffect* MakeDotEffect(SkScalar radius, const SkMatrix& matrix) {
SkPath path;
path.addCircle(0, 0, radius);
- return new SkPath2DPathEffect(matrix, path);
+ return SkPath2DPathEffect::Create(matrix, path);
}
static void r7(SkLayerRasterizer* rast, SkPaint& p)
SkMatrix lattice;
lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0);
lattice.postRotate(SkIntToScalar(30), 0, 0);
- p.setPathEffect(new SkLine2DPathEffect(SK_Scalar1*2, lattice))->unref();
+ p.setPathEffect(SkLine2DPathEffect::Create(SK_Scalar1*2, lattice))->unref();
p.setXfermodeMode(SkXfermode::kClear_Mode);
rast->addLayer(p);
int count = intervals.count();
if (count == 0)
return NULL;
- return new SkDashPathEffect(intervals.begin(), count, phase);
+ return SkDashPathEffect::Create(intervals.begin(), count, phase);
}
if (deviation <= 0 || segLength <= 0)
return NULL;
else
- return new SkDiscretePathEffect(segLength, deviation);
+ return SkDiscretePathEffect::Create(segLength, deviation);
}
SkPathEffect* SkDrawComposePathEffect::getPathEffect() {
SkPathEffect* e1 = effect1->getPathEffect();
SkPathEffect* e2 = effect2->getPathEffect();
- SkPathEffect* composite = new SkComposePathEffect(e1, e2);
+ SkPathEffect* composite = SkComposePathEffect::Create(e1, e2);
e1->unref();
e2->unref();
return composite;
}
SkPathEffect* SkDrawCornerPathEffect::getPathEffect() {
- return new SkCornerPathEffect(radius);
+ return SkCornerPathEffect::Create(radius);
}
/////////
class SkClearXfermode : public SkProcCoeffXfermode {
public:
- SkClearXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kClear_Mode) {}
+ static SkClearXfermode* Create(const ProcCoeff& rec) {
+ return SkNEW_ARGS(SkClearXfermode, (rec));
+ }
virtual void xfer32(SkPMColor*, const SkPMColor*, int, const SkAlpha*) const SK_OVERRIDE;
virtual void xferA8(SkAlpha*, const SkPMColor*, int, const SkAlpha*) const SK_OVERRIDE;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkClearXfermode)
private:
+ SkClearXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kClear_Mode) {}
SkClearXfermode(SkReadBuffer& buffer)
: SkProcCoeffXfermode(buffer) {}
class SkSrcXfermode : public SkProcCoeffXfermode {
public:
- SkSrcXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kSrc_Mode) {}
+ static SkSrcXfermode* Create(const ProcCoeff& rec) {
+ return SkNEW_ARGS(SkSrcXfermode, (rec));
+ }
virtual void xfer32(SkPMColor*, const SkPMColor*, int, const SkAlpha*) const SK_OVERRIDE;
virtual void xferA8(SkAlpha*, const SkPMColor*, int, const SkAlpha*) const SK_OVERRIDE;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkSrcXfermode)
private:
+ SkSrcXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kSrc_Mode) {}
SkSrcXfermode(SkReadBuffer& buffer)
: SkProcCoeffXfermode(buffer) {}
class SkDstInXfermode : public SkProcCoeffXfermode {
public:
- SkDstInXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kDstIn_Mode) {}
+ static SkDstInXfermode* Create(const ProcCoeff& rec) {
+ return SkNEW_ARGS(SkDstInXfermode, (rec));
+ }
virtual void xfer32(SkPMColor*, const SkPMColor*, int, const SkAlpha*) const SK_OVERRIDE;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDstInXfermode)
private:
+ SkDstInXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kDstIn_Mode) {}
SkDstInXfermode(SkReadBuffer& buffer) : INHERITED(buffer) {}
typedef SkProcCoeffXfermode INHERITED;
class SkDstOutXfermode : public SkProcCoeffXfermode {
public:
- SkDstOutXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kDstOut_Mode) {}
+ static SkDstOutXfermode* Create(const ProcCoeff& rec) {
+ return SkNEW_ARGS(SkDstOutXfermode, (rec));
+ }
virtual void xfer32(SkPMColor*, const SkPMColor*, int, const SkAlpha*) const SK_OVERRIDE;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDstOutXfermode)
private:
+ SkDstOutXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kDstOut_Mode) {}
SkDstOutXfermode(SkReadBuffer& buffer)
: INHERITED(buffer) {}
// commonly used, so we call those out for their own subclasses here.
switch (mode) {
case kClear_Mode:
- xfer = SkNEW_ARGS(SkClearXfermode, (rec));
+ xfer = SkClearXfermode::Create(rec);
break;
case kSrc_Mode:
- xfer = SkNEW_ARGS(SkSrcXfermode, (rec));
+ xfer = SkSrcXfermode::Create(rec);
break;
case kSrcOver_Mode:
SkASSERT(false); // should not land here
break;
case kDstIn_Mode:
- xfer = SkNEW_ARGS(SkDstInXfermode, (rec));
+ xfer = SkDstInXfermode::Create(rec);
break;
case kDstOut_Mode:
- xfer = SkNEW_ARGS(SkDstOutXfermode, (rec));
+ xfer = SkDstOutXfermode::Create(rec);
break;
default:
// no special-case, just rely in the rec and its function-ptrs
- xfer = SkNEW_ARGS(SkProcCoeffXfermode, (rec, mode));
+ xfer = SkProcCoeffXfermode::Create(rec, mode);
break;
}
}
class SkProcCoeffXfermode : public SkProcXfermode {
public:
- SkProcCoeffXfermode(const ProcCoeff& rec, Mode mode)
- : INHERITED(rec.fProc) {
- fMode = mode;
- // these may be valid, or may be CANNOT_USE_COEFF
- fSrcCoeff = rec.fSC;
- fDstCoeff = rec.fDC;
+ static SkProcCoeffXfermode* Create(const ProcCoeff& rec, Mode mode) {
+ return SkNEW_ARGS(SkProcCoeffXfermode, (rec, mode));
}
virtual bool asMode(Mode* mode) const SK_OVERRIDE;
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkProcCoeffXfermode)
protected:
+ SkProcCoeffXfermode(const ProcCoeff& rec, Mode mode)
+ : INHERITED(rec.fProc) {
+ fMode = mode;
+ // these may be valid, or may be CANNOT_USE_COEFF
+ fSrcCoeff = rec.fSC;
+ fDstCoeff = rec.fDC;
+ }
+
SkProcCoeffXfermode(SkReadBuffer& buffer);
virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE;
class SkArithmeticMode_scalar : public SkXfermode {
public:
- SkArithmeticMode_scalar(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4) {
- fK[0] = k1;
- fK[1] = k2;
- fK[2] = k3;
- fK[3] = k4;
+ static SkArithmeticMode_scalar* Create(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4) {
+ return SkNEW_ARGS(SkArithmeticMode_scalar, (k1, k2, k3, k4));
}
virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count,
#endif
private:
+ SkArithmeticMode_scalar(SkScalar k1, SkScalar k2, SkScalar k3, SkScalar k4) {
+ fK[0] = k1;
+ fK[1] = k2;
+ fK[2] = k3;
+ fK[3] = k4;
+ }
+
SkArithmeticMode_scalar(SkReadBuffer& buffer) : INHERITED(buffer) {
fK[0] = buffer.readScalar();
fK[1] = buffer.readScalar();
return SkNEW_ARGS(SkArithmeticMode_linear, (i2, i3, i4));
#endif
}
- return SkNEW_ARGS(SkArithmeticMode_scalar, (k1, k2, k3, k4));
+ return SkArithmeticMode_scalar::Create(k1, k2, k3, k4);
}
class SkOverdrawFilter : public SkDrawFilter {
public:
SkOverdrawFilter() {
- fXferMode = new SkProcXfermode(OverdrawXferModeProc);
+ fXferMode = SkProcXfermode::Create(OverdrawXferModeProc);
}
virtual ~SkOverdrawFilter() {
*/
const SkScalar vals[] = { 27734, 35660, 2157846850.0f, 247 };
- SkDashPathEffect dontAssert(vals, 4, -248.135982067f);
+ SkAutoTUnref<SkDashPathEffect> dontAssert(SkDashPathEffect::Create(vals, 4, -248.135982067f));
}
static void test_crbug_124652() {
large values can "swamp" small ones.
*/
SkScalar intervals[2] = {837099584, 33450};
- SkAutoTUnref<SkDashPathEffect> dash(
- new SkDashPathEffect(intervals, 2, -10, false));
+ SkAutoTUnref<SkDashPathEffect> dash(SkDashPathEffect::Create(intervals, 2, -10, false));
}
static void test_bigcubic() {
path.lineTo(5000000, 0);
SkScalar intervals[] = { 0.2f, 0.2f };
- SkDashPathEffect dash(intervals, 2, 0);
+ SkAutoTUnref<SkDashPathEffect> dash(SkDashPathEffect::Create(intervals, 2, 0));
SkPath filteredPath;
SkPaint paint;
paint.setStyle(SkPaint::kStroke_Style);
- paint.setPathEffect(&dash);
+ paint.setPathEffect(dash);
paint.getFillPath(path, &filteredPath);
// If we reach this, we passed.
path.lineTo(10000000, 0);
SkScalar intervals[] = { 0.5f, 0.5f };
- SkDashPathEffect dash(intervals, 2, 0);
+ SkAutoTUnref<SkDashPathEffect> dash(SkDashPathEffect::Create(intervals, 2, 0));
SkPaint paint;
paint.setStyle(SkPaint::kStroke_Style);
- paint.setPathEffect(&dash);
+ paint.setPathEffect(dash);
SkPath filteredPath;
SkStrokeRec rec(paint);
- REPORTER_ASSERT(reporter, !dash.filterPath(&filteredPath, path, &rec, NULL));
+ REPORTER_ASSERT(reporter, !dash->filterPath(&filteredPath, path, &rec, NULL));
REPORTER_ASSERT(reporter, filteredPath.isEmpty());
}
}
}
- SkXfermode* bogusXfer = new SkProcXfermode(bogusXfermodeProc);
+ SkXfermode* bogusXfer = SkProcXfermode::Create(bogusXfermodeProc);
SkXfermode::Mode reportedMode = ILLEGAL_MODE;
REPORTER_ASSERT(reporter, !bogusXfer->asMode(&reportedMode));
REPORTER_ASSERT(reporter, reportedMode == ILLEGAL_MODE);