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

Side by Side Diff: tests/StrokerTest.cpp

Issue 2426173002: fix fuzzers (Closed)
Patch Set: fix dm Created 4 years, 2 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/PathOpsThreeWayTest.cpp ('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 "PathOpsCubicIntersectionTestData.h" 8 #include "PathOpsCubicIntersectionTestData.h"
9 #include "PathOpsQuadIntersectionTestData.h" 9 #include "PathOpsQuadIntersectionTestData.h"
10 #include "SkCommonFlags.h" 10 #include "SkCommonFlags.h"
11 #include "SkPathOpsCubic.h"
11 #include "SkPaint.h" 12 #include "SkPaint.h"
12 #include "SkPath.h" 13 #include "SkPath.h"
13 #include "SkRandom.h" 14 #include "SkRandom.h"
14 #include "SkStrokerPriv.h" 15 #include "SkStrokerPriv.h"
15 #include "SkTime.h" 16 #include "SkTime.h"
16 #include "Test.h" 17 #include "Test.h"
17 18
18 DEFINE_bool(timeout, true, "run until alloted time expires"); 19 DEFINE_bool(timeout, true, "run until alloted time expires");
19 20
20 #define MS_TEST_DURATION 10 21 #define MS_TEST_DURATION 10
(...skipping 21 matching lines...) Expand all
42 pathTest(path); 43 pathTest(path);
43 } 44 }
44 45
45 static void quadTest(const SkPoint c[3]) { 46 static void quadTest(const SkPoint c[3]) {
46 SkPath path; 47 SkPath path;
47 path.moveTo(c[0].fX, c[0].fY); 48 path.moveTo(c[0].fX, c[0].fY);
48 path.quadTo(c[1].fX, c[1].fY, c[2].fX, c[2].fY); 49 path.quadTo(c[1].fX, c[1].fY, c[2].fX, c[2].fY);
49 pathTest(path); 50 pathTest(path);
50 } 51 }
51 52
52 static void cubicSetTest(const SkDCubic* dCubic, size_t count) { 53 static void cubicSetTest(const CubicPts* dCubic, size_t count) {
53 skiatest::Timer timer; 54 skiatest::Timer timer;
54 for (size_t index = 0; index < count; ++index) { 55 for (size_t index = 0; index < count; ++index) {
55 const SkDCubic& d = dCubic[index]; 56 const CubicPts& dPts = dCubic[index];
57 SkDCubic d;
58 d.debugSet(dPts.fPts);
56 SkPoint c[4] = { {(float) d[0].fX, (float) d[0].fY}, {(float) d[1].fX, ( float) d[1].fY}, 59 SkPoint c[4] = { {(float) d[0].fX, (float) d[0].fY}, {(float) d[1].fX, ( float) d[1].fY},
57 {(float) d[2].fX, (float) d[2].fY}, {(float) d[3].fX, ( float) d[3].fY} }; 60 {(float) d[2].fX, (float) d[2].fY}, {(float) d[3].fX, ( float) d[3].fY} };
58 cubicTest(c); 61 cubicTest(c);
59 if (FLAGS_timeout && timer.elapsedMs() > MS_TEST_DURATION) { 62 if (FLAGS_timeout && timer.elapsedMs() > MS_TEST_DURATION) {
60 return; 63 return;
61 } 64 }
62 } 65 }
63 } 66 }
64 67
65 static void cubicPairSetTest(const SkDCubic dCubic[][2], size_t count) { 68 static void cubicPairSetTest(const CubicPts dCubic[][2], size_t count) {
66 skiatest::Timer timer; 69 skiatest::Timer timer;
67 for (size_t index = 0; index < count; ++index) { 70 for (size_t index = 0; index < count; ++index) {
68 for (int pair = 0; pair < 2; ++pair) { 71 for (int pair = 0; pair < 2; ++pair) {
69 const SkDCubic& d = dCubic[index][pair]; 72 const CubicPts& dPts = dCubic[index][pair];
73 SkDCubic d;
74 d.debugSet(dPts.fPts);
70 SkPoint c[4] = { {(float) d[0].fX, (float) d[0].fY}, {(float) d[1].f X, (float) d[1].fY}, 75 SkPoint c[4] = { {(float) d[0].fX, (float) d[0].fY}, {(float) d[1].f X, (float) d[1].fY},
71 {(float) d[2].fX, (float) d[2].fY}, {(float) d[3].f X, (float) d[3].fY} }; 76 {(float) d[2].fX, (float) d[2].fY}, {(float) d[3].f X, (float) d[3].fY} };
72 cubicTest(c); 77 cubicTest(c);
73 if (FLAGS_timeout && timer.elapsedMs() > MS_TEST_DURATION) { 78 if (FLAGS_timeout && timer.elapsedMs() > MS_TEST_DURATION) {
74 return; 79 return;
75 } 80 }
76 } 81 }
77 } 82 }
78 } 83 }
79 84
80 static void quadSetTest(const SkDQuad* dQuad, size_t count) { 85 static void quadSetTest(const QuadPts* dQuad, size_t count) {
81 skiatest::Timer timer; 86 skiatest::Timer timer;
82 for (size_t index = 0; index < count; ++index) { 87 for (size_t index = 0; index < count; ++index) {
83 const SkDQuad& d = dQuad[index]; 88 const QuadPts& dPts = dQuad[index];
89 SkDQuad d;
90 d.debugSet(dPts.fPts);
84 SkPoint c[3] = { {(float) d[0].fX, (float) d[0].fY}, {(float) d[1].fX, ( float) d[1].fY}, 91 SkPoint c[3] = { {(float) d[0].fX, (float) d[0].fY}, {(float) d[1].fX, ( float) d[1].fY},
85 {(float) d[2].fX, (float) d[2].fY} }; 92 {(float) d[2].fX, (float) d[2].fY} };
86 quadTest(c); 93 quadTest(c);
87 if (FLAGS_timeout && timer.elapsedMs() > MS_TEST_DURATION) { 94 if (FLAGS_timeout && timer.elapsedMs() > MS_TEST_DURATION) {
88 return; 95 return;
89 } 96 }
90 } 97 }
91 } 98 }
92 99
93 static void quadPairSetTest(const SkDQuad dQuad[][2], size_t count) { 100 static void quadPairSetTest(const QuadPts dQuad[][2], size_t count) {
94 skiatest::Timer timer; 101 skiatest::Timer timer;
95 for (size_t index = 0; index < count; ++index) { 102 for (size_t index = 0; index < count; ++index) {
96 for (int pair = 0; pair < 2; ++pair) { 103 for (int pair = 0; pair < 2; ++pair) {
97 const SkDQuad& d = dQuad[index][pair]; 104 const QuadPts& dPts = dQuad[index][pair];
105 SkDQuad d;
106 d.debugSet(dPts.fPts);
98 SkPoint c[3] = { {(float) d[0].fX, (float) d[0].fY}, {(float) d[1].f X, (float) d[1].fY}, 107 SkPoint c[3] = { {(float) d[0].fX, (float) d[0].fY}, {(float) d[1].f X, (float) d[1].fY},
99 {(float) d[2].fX, (float) d[2].fY} }; 108 {(float) d[2].fX, (float) d[2].fY} };
100 quadTest(c); 109 quadTest(c);
101 if (FLAGS_timeout && timer.elapsedMs() > MS_TEST_DURATION) { 110 if (FLAGS_timeout && timer.elapsedMs() > MS_TEST_DURATION) {
102 return; 111 return;
103 } 112 }
104 } 113 }
105 } 114 }
106 } 115 }
107 116
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 path.dump(); 459 path.dump();
451 SkDebugf("fill:\n"); 460 SkDebugf("fill:\n");
452 fill.dump(); 461 fill.dump();
453 } 462 }
454 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION 463 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
455 if (FLAGS_veryVerbose) { 464 if (FLAGS_veryVerbose) {
456 SkDebugf("max tan=%d cubic=%d\n", gMaxRecursion[0], gMaxRecursion[1]); 465 SkDebugf("max tan=%d cubic=%d\n", gMaxRecursion[0], gMaxRecursion[1]);
457 } 466 }
458 #endif 467 #endif
459 } 468 }
OLDNEW
« no previous file with comments | « tests/PathOpsThreeWayTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698