Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Side by Side Diff: tests/DashPathEffectTest.cpp

Issue 1813553005: switch patheffects over to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: try to fix xpsdevice Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/AsADashTest.cpp ('k') | tests/DrawPathTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Test.h" 8 #include "Test.h"
9 9
10 #include "SkDashPathEffect.h" 10 #include "SkDashPathEffect.h"
11 #include "SkWriteBuffer.h" 11 #include "SkWriteBuffer.h"
12 #include "SkStrokeRec.h" 12 #include "SkStrokeRec.h"
13 13
14 // crbug.com/348821 was rooted in SkDashPathEffect refusing to flatten and unfla tten itself when 14 // crbug.com/348821 was rooted in SkDashPathEffect refusing to flatten and unfla tten itself when
15 // the effect is nonsense. Here we test that it fails when passed nonsense para meters. 15 // the effect is nonsense. Here we test that it fails when passed nonsense para meters.
16 16
17 DEF_TEST(DashPathEffectTest_crbug_348821, r) { 17 DEF_TEST(DashPathEffectTest_crbug_348821, r) {
18 SkScalar intervals[] = { 1.76934361e+36f, 2.80259693e-45f }; // Values from bug. 18 SkScalar intervals[] = { 1.76934361e+36f, 2.80259693e-45f }; // Values from bug.
19 const int count = 2; 19 const int count = 2;
20 SkScalar phase = SK_ScalarInfinity; // Used to force a nonsense effect. 20 SkScalar phase = SK_ScalarInfinity; // Used to force a nonsense effect.
21 SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, count, p hase)); 21 sk_sp<SkPathEffect> dash(SkDashPathEffect::Make(intervals, count, phase));
22 22
23 REPORTER_ASSERT(r, dash == nullptr); 23 REPORTER_ASSERT(r, dash == nullptr);
24 } 24 }
25 25
26 // Test out the asPoint culling behavior. 26 // Test out the asPoint culling behavior.
27 DEF_TEST(DashPathEffectTest_asPoints, r) { 27 DEF_TEST(DashPathEffectTest_asPoints, r) {
28 28
29 const SkScalar intervals[] = { 1.0f, 1.0f }; 29 const SkScalar intervals[] = { 1.0f, 1.0f };
30 const int count = 2; 30 const int count = 2;
31 SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, count, 0 .0f)); 31 sk_sp<SkPathEffect> dash(SkDashPathEffect::Make(intervals, count, 0.0f));
32 32
33 SkRect cull = SkRect::MakeWH(1.0f, 1.0f); 33 SkRect cull = SkRect::MakeWH(1.0f, 1.0f);
34 34
35 const struct { 35 const struct {
36 SkPoint fPts[2]; 36 SkPoint fPts[2];
37 bool fExpectedResult; 37 bool fExpectedResult;
38 } testCases[] = { 38 } testCases[] = {
39 { { { -5.0f, 0.5f }, { -4.0f, 0.5f } }, false }, // off to the left 39 { { { -5.0f, 0.5f }, { -4.0f, 0.5f } }, false }, // off to the left
40 { { { 4.0f, 0.5f }, { 5.0f, 0.5f } }, false }, // off to the right 40 { { { 4.0f, 0.5f }, { 5.0f, 0.5f } }, false }, // off to the right
41 { { { 0.5f, 4.0f }, { 0.5f, 5.0f } }, false }, // off the bottom 41 { { { 0.5f, 4.0f }, { 0.5f, 5.0f } }, false }, // off the bottom
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 } 84 }
85 85
86 DEF_TEST(DashPath_bug4871, r) { 86 DEF_TEST(DashPath_bug4871, r) {
87 SkPath path; 87 SkPath path;
88 path.moveTo(30, 24); 88 path.moveTo(30, 24);
89 path.cubicTo(30.002f, 24, 30, 24, 30, 24); 89 path.cubicTo(30.002f, 24, 30, 24, 30, 24);
90 path.close(); 90 path.close();
91 91
92 SkScalar intervals[2] = { 1, 1 }; 92 SkScalar intervals[2] = { 1, 1 };
93 SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, 2, 0)); 93 sk_sp<SkPathEffect> dash(SkDashPathEffect::Make(intervals, 2, 0));
94 94
95 SkPaint paint; 95 SkPaint paint;
96 paint.setStyle(SkPaint::kStroke_Style); 96 paint.setStyle(SkPaint::kStroke_Style);
97 paint.setPathEffect(dash); 97 paint.setPathEffect(dash);
98 98
99 SkPath fill; 99 SkPath fill;
100 paint.getFillPath(path, &fill); 100 paint.getFillPath(path, &fill);
101 } 101 }
OLDNEW
« no previous file with comments | « tests/AsADashTest.cpp ('k') | tests/DrawPathTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698