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

Side by Side Diff: tests/StrokerTest.cpp

Issue 805963002: There can be only one (SkRandom)! (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase Created 6 years 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/effects/SkDiscretePathEffect.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 #include "PathOpsCubicIntersectionTestData.h" 1 #include "PathOpsCubicIntersectionTestData.h"
2 #include "PathOpsQuadIntersectionTestData.h" 2 #include "PathOpsQuadIntersectionTestData.h"
3 #include "SkCommonFlags.h" 3 #include "SkCommonFlags.h"
4 #include "SkPaint.h" 4 #include "SkPaint.h"
5 #include "SkPath.h" 5 #include "SkPath.h"
6 #include "SkRandom.h" 6 #include "SkRandom.h"
7 #include "SkStrokerPriv.h" 7 #include "SkStrokerPriv.h"
8 #include "SkTime.h" 8 #include "SkTime.h"
9 #include "Test.h" 9 #include "Test.h"
10 10
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 cubicSetTest(pointDegenerates, pointDegenerates_count); 109 cubicSetTest(pointDegenerates, pointDegenerates_count);
110 cubicSetTest(notPointDegenerates, notPointDegenerates_count); 110 cubicSetTest(notPointDegenerates, notPointDegenerates_count);
111 cubicSetTest(lines, lines_count); 111 cubicSetTest(lines, lines_count);
112 cubicSetTest(notLines, notLines_count); 112 cubicSetTest(notLines, notLines_count);
113 cubicSetTest(modEpsilonLines, modEpsilonLines_count); 113 cubicSetTest(modEpsilonLines, modEpsilonLines_count);
114 cubicSetTest(lessEpsilonLines, lessEpsilonLines_count); 114 cubicSetTest(lessEpsilonLines, lessEpsilonLines_count);
115 cubicSetTest(negEpsilonLines, negEpsilonLines_count); 115 cubicSetTest(negEpsilonLines, negEpsilonLines_count);
116 cubicPairSetTest(tests, tests_count); 116 cubicPairSetTest(tests, tests_count);
117 } 117 }
118 118
119 static SkScalar unbounded(SkLCGRandom& r) { 119 static SkScalar unbounded(SkRandom& r) {
120 uint32_t val = r.nextU(); 120 uint32_t val = r.nextU();
121 return SkBits2Float(val); 121 return SkBits2Float(val);
122 } 122 }
123 123
124 static SkScalar unboundedPos(SkLCGRandom& r) { 124 static SkScalar unboundedPos(SkRandom& r) {
125 uint32_t val = r.nextU() & 0x7fffffff; 125 uint32_t val = r.nextU() & 0x7fffffff;
126 return SkBits2Float(val); 126 return SkBits2Float(val);
127 } 127 }
128 128
129 DEF_TEST(QuadStrokerUnbounded, reporter) { 129 DEF_TEST(QuadStrokerUnbounded, reporter) {
130 SkLCGRandom r; 130 SkRandom r;
131 SkPaint p; 131 SkPaint p;
132 p.setStyle(SkPaint::kStroke_Style); 132 p.setStyle(SkPaint::kStroke_Style);
133 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION 133 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
134 int best = 0; 134 int best = 0;
135 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3); 135 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3);
136 #endif 136 #endif
137 SkMSec limit = SkTime::GetMSecs() + MS_TEST_DURATION; 137 SkMSec limit = SkTime::GetMSecs() + MS_TEST_DURATION;
138 for (int i = 0; i < 1000000; ++i) { 138 for (int i = 0; i < 1000000; ++i) {
139 SkPath path, fill; 139 SkPath path, fill;
140 path.moveTo(unbounded(r), unbounded(r)); 140 path.moveTo(unbounded(r), unbounded(r));
(...skipping 17 matching lines...) Expand all
158 } 158 }
159 } 159 }
160 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION 160 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
161 if (FLAGS_veryVerbose) { 161 if (FLAGS_veryVerbose) {
162 SkDebugf("\n%s max quad=%d\n", __FUNCTION__, best); 162 SkDebugf("\n%s max quad=%d\n", __FUNCTION__, best);
163 } 163 }
164 #endif 164 #endif
165 } 165 }
166 166
167 DEF_TEST(CubicStrokerUnbounded, reporter) { 167 DEF_TEST(CubicStrokerUnbounded, reporter) {
168 SkLCGRandom r; 168 SkRandom r;
169 SkPaint p; 169 SkPaint p;
170 p.setStyle(SkPaint::kStroke_Style); 170 p.setStyle(SkPaint::kStroke_Style);
171 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION 171 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
172 int bestTan = 0; 172 int bestTan = 0;
173 int bestCubic = 0; 173 int bestCubic = 0;
174 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3); 174 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3);
175 #endif 175 #endif
176 SkMSec limit = SkTime::GetMSecs() + MS_TEST_DURATION; 176 SkMSec limit = SkTime::GetMSecs() + MS_TEST_DURATION;
177 for (int i = 0; i < 1000000; ++i) { 177 for (int i = 0; i < 1000000; ++i) {
178 SkPath path, fill; 178 SkPath path, fill;
(...skipping 20 matching lines...) Expand all
199 } 199 }
200 } 200 }
201 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION 201 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
202 if (FLAGS_veryVerbose) { 202 if (FLAGS_veryVerbose) {
203 SkDebugf("\n%s max tan=%d cubic=%d\n", __FUNCTION__, bestTan, bestCubic) ; 203 SkDebugf("\n%s max tan=%d cubic=%d\n", __FUNCTION__, bestTan, bestCubic) ;
204 } 204 }
205 #endif 205 #endif
206 } 206 }
207 207
208 DEF_TEST(QuadStrokerConstrained, reporter) { 208 DEF_TEST(QuadStrokerConstrained, reporter) {
209 SkLCGRandom r; 209 SkRandom r;
210 SkPaint p; 210 SkPaint p;
211 p.setStyle(SkPaint::kStroke_Style); 211 p.setStyle(SkPaint::kStroke_Style);
212 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION 212 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
213 int best = 0; 213 int best = 0;
214 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3); 214 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3);
215 #endif 215 #endif
216 SkMSec limit = SkTime::GetMSecs() + MS_TEST_DURATION; 216 SkMSec limit = SkTime::GetMSecs() + MS_TEST_DURATION;
217 for (int i = 0; i < 1000000; ++i) { 217 for (int i = 0; i < 1000000; ++i) {
218 SkPath path, fill; 218 SkPath path, fill;
219 SkPoint quad[3]; 219 SkPoint quad[3];
(...skipping 30 matching lines...) Expand all
250 } 250 }
251 } 251 }
252 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION 252 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
253 if (FLAGS_veryVerbose) { 253 if (FLAGS_veryVerbose) {
254 SkDebugf("\n%s max quad=%d\n", __FUNCTION__, best); 254 SkDebugf("\n%s max quad=%d\n", __FUNCTION__, best);
255 } 255 }
256 #endif 256 #endif
257 } 257 }
258 258
259 DEF_TEST(CubicStrokerConstrained, reporter) { 259 DEF_TEST(CubicStrokerConstrained, reporter) {
260 SkLCGRandom r; 260 SkRandom r;
261 SkPaint p; 261 SkPaint p;
262 p.setStyle(SkPaint::kStroke_Style); 262 p.setStyle(SkPaint::kStroke_Style);
263 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION 263 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
264 int bestTan = 0; 264 int bestTan = 0;
265 int bestCubic = 0; 265 int bestCubic = 0;
266 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3); 266 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3);
267 #endif 267 #endif
268 SkMSec limit = SkTime::GetMSecs() + MS_TEST_DURATION; 268 SkMSec limit = SkTime::GetMSecs() + MS_TEST_DURATION;
269 for (int i = 0; i < 1000000; ++i) { 269 for (int i = 0; i < 1000000; ++i) {
270 SkPath path, fill; 270 SkPath path, fill;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 } 309 }
310 } 310 }
311 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION 311 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
312 if (FLAGS_veryVerbose) { 312 if (FLAGS_veryVerbose) {
313 SkDebugf("\n%s max tan=%d cubic=%d\n", __FUNCTION__, bestTan, bestCubic) ; 313 SkDebugf("\n%s max tan=%d cubic=%d\n", __FUNCTION__, bestTan, bestCubic) ;
314 } 314 }
315 #endif 315 #endif
316 } 316 }
317 317
318 DEF_TEST(QuadStrokerRange, reporter) { 318 DEF_TEST(QuadStrokerRange, reporter) {
319 SkLCGRandom r; 319 SkRandom r;
320 SkPaint p; 320 SkPaint p;
321 p.setStyle(SkPaint::kStroke_Style); 321 p.setStyle(SkPaint::kStroke_Style);
322 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION 322 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
323 int best = 0; 323 int best = 0;
324 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3); 324 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3);
325 #endif 325 #endif
326 SkMSec limit = SkTime::GetMSecs() + MS_TEST_DURATION; 326 SkMSec limit = SkTime::GetMSecs() + MS_TEST_DURATION;
327 for (int i = 0; i < 1000000; ++i) { 327 for (int i = 0; i < 1000000; ++i) {
328 SkPath path, fill; 328 SkPath path, fill;
329 SkPoint quad[3]; 329 SkPoint quad[3];
(...skipping 24 matching lines...) Expand all
354 } 354 }
355 } 355 }
356 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION 356 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
357 if (FLAGS_verbose) { 357 if (FLAGS_verbose) {
358 SkDebugf("\n%s max quad=%d\n", __FUNCTION__, best); 358 SkDebugf("\n%s max quad=%d\n", __FUNCTION__, best);
359 } 359 }
360 #endif 360 #endif
361 } 361 }
362 362
363 DEF_TEST(CubicStrokerRange, reporter) { 363 DEF_TEST(CubicStrokerRange, reporter) {
364 SkLCGRandom r; 364 SkRandom r;
365 SkPaint p; 365 SkPaint p;
366 p.setStyle(SkPaint::kStroke_Style); 366 p.setStyle(SkPaint::kStroke_Style);
367 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION 367 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
368 int best[2] = { 0 }; 368 int best[2] = { 0 };
369 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3); 369 sk_bzero(gMaxRecursion, sizeof(gMaxRecursion[0]) * 3);
370 #endif 370 #endif
371 SkMSec limit = SkTime::GetMSecs() + MS_TEST_DURATION; 371 SkMSec limit = SkTime::GetMSecs() + MS_TEST_DURATION;
372 for (int i = 0; i < 1000000; ++i) { 372 for (int i = 0; i < 1000000; ++i) {
373 SkPath path, fill; 373 SkPath path, fill;
374 path.moveTo(r.nextRangeF(0, 500), r.nextRangeF(0, 500)); 374 path.moveTo(r.nextRangeF(0, 500), r.nextRangeF(0, 500));
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 path.dump(); 443 path.dump();
444 SkDebugf("fill:\n"); 444 SkDebugf("fill:\n");
445 fill.dump(); 445 fill.dump();
446 } 446 }
447 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION 447 #if defined(SK_DEBUG) && QUAD_STROKE_APPROXIMATION
448 if (FLAGS_veryVerbose) { 448 if (FLAGS_veryVerbose) {
449 SkDebugf("max tan=%d cubic=%d\n", gMaxRecursion[0], gMaxRecursion[1]); 449 SkDebugf("max tan=%d cubic=%d\n", gMaxRecursion[0], gMaxRecursion[1]);
450 } 450 }
451 #endif 451 #endif
452 } 452 }
OLDNEW
« no previous file with comments | « src/effects/SkDiscretePathEffect.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698