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
diff --git a/tests/DrawPathTest.cpp b/tests/DrawPathTest.cpp
index e7f7005..f7f7367 100644
--- a/tests/DrawPathTest.cpp
+++ b/tests/DrawPathTest.cpp
@@ -202,7 +202,7 @@
*/
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() {
@@ -212,8 +212,7 @@
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() {
@@ -254,12 +253,12 @@
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.
@@ -274,15 +273,15 @@
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());
}