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

Side by Side Diff: tests/DashPathEffectTest.cpp

Issue 1805963002: allow one zero length dash (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix dash nanobench 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 | « src/utils/SkDashPathPriv.h ('k') | no next file » | 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 // fInitialDashLength < 0 (a signal the effect is nonsense). Here we test that it flattens. 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 the bad fInitialDashLe ngth = -1 path. 20 SkScalar phase = SK_ScalarInfinity; // Used to force a nonsense effect.
21 SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, count, p hase)); 21 SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, count, p hase));
22 22
23 // nullptr -> refuses to work with flattening framework. 23 REPORTER_ASSERT(r, dash == nullptr);
24 REPORTER_ASSERT(r, dash->getFactory() != nullptr);
25
26 SkWriteBuffer buffer;
27 buffer.writeFlattenable(dash);
28 REPORTER_ASSERT(r, buffer.bytesWritten() > 12); // We'd write 12 if broken, >=40 if not.
29 } 24 }
30 25
31 // Test out the asPoint culling behavior. 26 // Test out the asPoint culling behavior.
32 DEF_TEST(DashPathEffectTest_asPoints, r) { 27 DEF_TEST(DashPathEffectTest_asPoints, r) {
33 28
34 const SkScalar intervals[] = { 1.0f, 1.0f }; 29 const SkScalar intervals[] = { 1.0f, 1.0f };
35 const int count = 2; 30 const int count = 2;
36 SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, count, 0 .0f)); 31 SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, count, 0 .0f));
37 32
38 SkRect cull = SkRect::MakeWH(1.0f, 1.0f); 33 SkRect cull = SkRect::MakeWH(1.0f, 1.0f);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 SkScalar intervals[2] = { 1, 1 }; 92 SkScalar intervals[2] = { 1, 1 };
98 SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, 2, 0)); 93 SkAutoTUnref<SkPathEffect> dash(SkDashPathEffect::Create(intervals, 2, 0));
99 94
100 SkPaint paint; 95 SkPaint paint;
101 paint.setStyle(SkPaint::kStroke_Style); 96 paint.setStyle(SkPaint::kStroke_Style);
102 paint.setPathEffect(dash); 97 paint.setPathEffect(dash);
103 98
104 SkPath fill; 99 SkPath fill;
105 paint.getFillPath(path, &fill); 100 paint.getFillPath(path, &fill);
106 } 101 }
OLDNEW
« no previous file with comments | « src/utils/SkDashPathPriv.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698