diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-02-20 20:40:19 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-02-20 20:40:19 +0000 |
commit | 0a2bf90dccba3bde188e0386a7f0c60e6dde1ae9 (patch) | |
tree | aa5c4198b4a200d6efe87d1a81964c8c219c1091 /gm | |
parent | 4012ba51a218883daef6c9be142f970b8ef5d0d2 (diff) |
Factory methods for heap-allocated SkPathEffect and SkXfermode objects.
This is part of an effort to ensure that all SkPaint effects can only be
allocated on the heap.
This patch makes the constructors of SkPathEffect, SkXfermode and
their subclasses non-public and instead provides factory methods for
creating these objects on the heap. We temporarily keep the constructors
of the following classes public to not break Chrome/Blink:
SkXfermode
SkCornerPathEffect
SkDashPathEffect
BUG=skia:2187
R=scroggo@google.com, reed@google.com, mtklein@google.com, bungeman@google.com
Author: dominikg@chromium.org
Review URL: https://codereview.chromium.org/166583002
git-svn-id: http://skia.googlecode.com/svn/trunk@13519 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm')
-rw-r--r-- | gm/dashcubics.cpp | 2 | ||||
-rw-r--r-- | gm/dashing.cpp | 6 | ||||
-rw-r--r-- | gm/patheffects.cpp | 14 | ||||
-rw-r--r-- | gm/texteffects.cpp | 6 |
4 files changed, 14 insertions, 14 deletions
diff --git a/gm/dashcubics.cpp b/gm/dashcubics.cpp index 5d874d4dc6..f99c0c34f4 100644 --- a/gm/dashcubics.cpp +++ b/gm/dashcubics.cpp @@ -43,7 +43,7 @@ protected: 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); diff --git a/gm/dashing.cpp b/gm/dashing.cpp index fa88e9e0ab..f690852fbd 100644 --- a/gm/dashing.cpp +++ b/gm/dashing.cpp @@ -19,7 +19,7 @@ static void drawline(SkCanvas* canvas, int on, int off, const SkPaint& paint, 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); } @@ -155,7 +155,7 @@ protected: 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; @@ -202,7 +202,7 @@ protected: 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]; diff --git a/gm/patheffects.cpp b/gm/patheffects.cpp index a1fb675a3c..4c5cd4512a 100644 --- a/gm/patheffects.cpp +++ b/gm/patheffects.cpp @@ -17,10 +17,10 @@ namespace skiagm { 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; @@ -45,8 +45,8 @@ static void stroke_pe(SkPaint* paint) { 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); } @@ -69,7 +69,7 @@ static void one_d_pe(SkPaint* 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); } @@ -83,7 +83,7 @@ static void fill_pe(SkPaint* paint) { } static void discrete_pe(SkPaint* paint) { - paint->setPathEffect(new SkDiscretePathEffect(10, 4))->unref(); + paint->setPathEffect(SkDiscretePathEffect::Create(10, 4))->unref(); } static SkPathEffect* MakeTileEffect() { @@ -93,7 +93,7 @@ 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) { diff --git a/gm/texteffects.cpp b/gm/texteffects.cpp index 094fe7b8a1..cf9ec5accc 100644 --- a/gm/texteffects.cpp +++ b/gm/texteffects.cpp @@ -77,7 +77,7 @@ static void r4(SkLayerRasterizer* rast, SkPaint& p) { 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); } @@ -98,7 +98,7 @@ static void r6(SkLayerRasterizer* rast, SkPaint& 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) { @@ -132,7 +132,7 @@ static void r9(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); |