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

Side by Side Diff: tests/PathTest.cpp

Issue 23576015: Change old PRG to be SkLCGRandom; change new one to SkRandom (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix some spurious SkMWCRandoms Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « tests/PaintTest.cpp ('k') | tests/PathUtilsTest.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "Test.h" 8 #include "Test.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkPaint.h" 10 #include "SkPaint.h"
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 add_corner_arc(path, r, xCorner, yCorner, 90); 419 add_corner_arc(path, r, xCorner, yCorner, 90);
420 add_corner_arc(path, r, xCorner, yCorner, 180); 420 add_corner_arc(path, r, xCorner, yCorner, 180);
421 path->close(); 421 path->close();
422 } 422 }
423 423
424 // Chrome creates its own round rects with each corner possibly being different. 424 // Chrome creates its own round rects with each corner possibly being different.
425 // Performance will suffer if they are not convex. 425 // Performance will suffer if they are not convex.
426 // Note: PathBench::ArbRoundRectBench performs almost exactly 426 // Note: PathBench::ArbRoundRectBench performs almost exactly
427 // the same test (but with drawing) 427 // the same test (but with drawing)
428 static void test_arb_round_rect_is_convex(skiatest::Reporter* reporter) { 428 static void test_arb_round_rect_is_convex(skiatest::Reporter* reporter) {
429 SkMWCRandom rand; 429 SkRandom rand;
430 SkRect r; 430 SkRect r;
431 431
432 for (int i = 0; i < 5000; ++i) { 432 for (int i = 0; i < 5000; ++i) {
433 433
434 SkScalar size = rand.nextUScalar1() * 30; 434 SkScalar size = rand.nextUScalar1() * 30;
435 if (size < SK_Scalar1) { 435 if (size < SK_Scalar1) {
436 continue; 436 continue;
437 } 437 }
438 r.fLeft = rand.nextUScalar1() * 300; 438 r.fLeft = rand.nextUScalar1() * 300;
439 r.fTop = rand.nextUScalar1() * 300; 439 r.fTop = rand.nextUScalar1() * 300;
440 r.fRight = r.fLeft + 2 * size; 440 r.fRight = r.fLeft + 2 * size;
441 r.fBottom = r.fTop + 2 * size; 441 r.fBottom = r.fTop + 2 * size;
442 442
443 SkPath temp; 443 SkPath temp;
444 444
445 make_arb_round_rect(&temp, r, r.width() / 10, r.height() / 15); 445 make_arb_round_rect(&temp, r, r.width() / 10, r.height() / 15);
446 446
447 REPORTER_ASSERT(reporter, temp.isConvex()); 447 REPORTER_ASSERT(reporter, temp.isConvex());
448 } 448 }
449 } 449 }
450 450
451 // Chrome will sometimes create a 0 radius round rect. The degenerate 451 // Chrome will sometimes create a 0 radius round rect. The degenerate
452 // quads prevent the path from being converted to a rect 452 // quads prevent the path from being converted to a rect
453 // Note: PathBench::ArbRoundRectBench performs almost exactly 453 // Note: PathBench::ArbRoundRectBench performs almost exactly
454 // the same test (but with drawing) 454 // the same test (but with drawing)
455 static void test_arb_zero_rad_round_rect_is_rect(skiatest::Reporter* reporter) { 455 static void test_arb_zero_rad_round_rect_is_rect(skiatest::Reporter* reporter) {
456 SkMWCRandom rand; 456 SkRandom rand;
457 SkRect r; 457 SkRect r;
458 458
459 for (int i = 0; i < 5000; ++i) { 459 for (int i = 0; i < 5000; ++i) {
460 460
461 SkScalar size = rand.nextUScalar1() * 30; 461 SkScalar size = rand.nextUScalar1() * 30;
462 if (size < SK_Scalar1) { 462 if (size < SK_Scalar1) {
463 continue; 463 continue;
464 } 464 }
465 r.fLeft = rand.nextUScalar1() * 300; 465 r.fLeft = rand.nextUScalar1() * 300;
466 r.fTop = rand.nextUScalar1() * 300; 466 r.fTop = rand.nextUScalar1() * 300;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 case SkPath::kDone_Verb: 585 case SkPath::kDone_Verb:
586 goto DONE; 586 goto DONE;
587 } 587 }
588 } 588 }
589 DONE: 589 DONE:
590 REPORTER_ASSERT(reporter, foundClose == expectClose); 590 REPORTER_ASSERT(reporter, foundClose == expectClose);
591 } 591 }
592 592
593 static void test_addPoly(skiatest::Reporter* reporter) { 593 static void test_addPoly(skiatest::Reporter* reporter) {
594 SkPoint pts[32]; 594 SkPoint pts[32];
595 SkMWCRandom rand; 595 SkRandom rand;
596 596
597 for (size_t i = 0; i < SK_ARRAY_COUNT(pts); ++i) { 597 for (size_t i = 0; i < SK_ARRAY_COUNT(pts); ++i) {
598 pts[i].fX = rand.nextSScalar1(); 598 pts[i].fX = rand.nextSScalar1();
599 pts[i].fY = rand.nextSScalar1(); 599 pts[i].fY = rand.nextSScalar1();
600 } 600 }
601 601
602 for (int doClose = 0; doClose <= 1; ++doClose) { 602 for (int doClose = 0; doClose <= 1; ++doClose) {
603 for (size_t count = 1; count <= SK_ARRAY_COUNT(pts); ++count) { 603 for (size_t count = 1; count <= SK_ARRAY_COUNT(pts); ++count) {
604 SkPath path; 604 SkPath path;
605 path.addPoly(pts, count, SkToBool(doClose)); 605 path.addPoly(pts, count, SkToBool(doClose));
(...skipping 1422 matching lines...) Expand 10 before | Expand all | Expand 10 after
2028 2028
2029 // Generate random paths and verify 2029 // Generate random paths and verify
2030 SkPoint randomPts[25]; 2030 SkPoint randomPts[25];
2031 for (int i = 0; i < 5; ++i) { 2031 for (int i = 0; i < 5; ++i) {
2032 for (int j = 0; j < 5; ++j) { 2032 for (int j = 0; j < 5; ++j) {
2033 randomPts[i*5+j].set(SK_Scalar1*i, SK_Scalar1*j); 2033 randomPts[i*5+j].set(SK_Scalar1*i, SK_Scalar1*j);
2034 } 2034 }
2035 } 2035 }
2036 2036
2037 // Max of 10 segments, max 3 points per segment 2037 // Max of 10 segments, max 3 points per segment
2038 SkMWCRandom rand(9876543); 2038 SkRandom rand(9876543);
2039 SkPoint expectedPts[31]; // May have leading moveTo 2039 SkPoint expectedPts[31]; // May have leading moveTo
2040 SkPath::Verb expectedVerbs[22]; // May have leading moveTo 2040 SkPath::Verb expectedVerbs[22]; // May have leading moveTo
2041 SkPath::Verb nextVerb; 2041 SkPath::Verb nextVerb;
2042 2042
2043 for (int i = 0; i < 500; ++i) { 2043 for (int i = 0; i < 500; ++i) {
2044 p.reset(); 2044 p.reset();
2045 bool lastWasClose = true; 2045 bool lastWasClose = true;
2046 bool haveMoveTo = false; 2046 bool haveMoveTo = false;
2047 SkPoint lastMoveToPt = { 0, 0 }; 2047 SkPoint lastMoveToPt = { 0, 0 };
2048 int numPoints = 0; 2048 int numPoints = 0;
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
2549 test_clipped_cubic(); 2549 test_clipped_cubic();
2550 test_crbug_170666(); 2550 test_crbug_170666();
2551 test_bad_cubic_crbug229478(); 2551 test_bad_cubic_crbug229478();
2552 test_bad_cubic_crbug234190(); 2552 test_bad_cubic_crbug234190();
2553 test_android_specific_behavior(reporter); 2553 test_android_specific_behavior(reporter);
2554 test_path_close_issue1474(reporter); 2554 test_path_close_issue1474(reporter);
2555 } 2555 }
2556 2556
2557 #include "TestClassDef.h" 2557 #include "TestClassDef.h"
2558 DEFINE_TESTCLASS("Path", PathTestClass, TestPath) 2558 DEFINE_TESTCLASS("Path", PathTestClass, TestPath)
OLDNEW
« no previous file with comments | « tests/PaintTest.cpp ('k') | tests/PathUtilsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698