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 /tests/DrawPathTest.cpp | |
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 'tests/DrawPathTest.cpp')
-rw-r--r-- | tests/DrawPathTest.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/tests/DrawPathTest.cpp b/tests/DrawPathTest.cpp index e7f70057b9..f7f7367983 100644 --- a/tests/DrawPathTest.cpp +++ b/tests/DrawPathTest.cpp @@ -202,7 +202,7 @@ static void test_crbug_140642() { */ 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 @@ 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() { @@ -254,12 +253,12 @@ static void test_infinite_dash(skiatest::Reporter* reporter) { 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 @@ static void test_crbug_165432(skiatest::Reporter* reporter) { 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()); } |