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

Side by Side Diff: tests/PathTest.cpp

Issue 1261773002: change getBounds to return 0000 iff there are zero points (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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 | « include/core/SkPathRef.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 2011 Google Inc. 2 * Copyright 2011 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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkPaint.h" 9 #include "SkPaint.h"
10 #include "SkParse.h" 10 #include "SkParse.h"
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 build_big_path(&path, SkToBool(doReducedCase)); 561 build_big_path(&path, SkToBool(doReducedCase));
562 562
563 SkPaint paint; 563 SkPaint paint;
564 for (int doAA = 0; doAA <= 1; ++doAA) { 564 for (int doAA = 0; doAA <= 1; ++doAA) {
565 paint.setAntiAlias(SkToBool(doAA)); 565 paint.setAntiAlias(SkToBool(doAA));
566 surface->getCanvas()->drawPath(path, paint); 566 surface->getCanvas()->drawPath(path, paint);
567 } 567 }
568 } 568 }
569 } 569 }
570 570
571 static void test_bounds_crbug_513799(skiatest::Reporter* reporter) {
572 SkPath path;
573
574 REPORTER_ASSERT(reporter, SkRect::MakeLTRB(0, 0, 0, 0) == path.getBounds());
575
576 path.moveTo(-5, -8);
577 REPORTER_ASSERT(reporter, SkRect::MakeLTRB(-5, -8, -5, -8) == path.getBounds ());
578
579 path.addRect(SkRect::MakeLTRB(1, 2, 3, 4));
580 REPORTER_ASSERT(reporter, SkRect::MakeLTRB(-5, -8, 3, 4) == path.getBounds() );
581
582 path.moveTo(1, 2);
583 REPORTER_ASSERT(reporter, SkRect::MakeLTRB(-5, -8, 3, 4) == path.getBounds() );
584 }
585
571 // Inspired by http://ie.microsoft.com/testdrive/Performance/Chalkboard/ 586 // Inspired by http://ie.microsoft.com/testdrive/Performance/Chalkboard/
572 // which triggered an assert, from a tricky cubic. This test replicates that 587 // which triggered an assert, from a tricky cubic. This test replicates that
573 // example, so we can ensure that we handle it (in SkEdge.cpp), and don't 588 // example, so we can ensure that we handle it (in SkEdge.cpp), and don't
574 // assert in the SK_DEBUG build. 589 // assert in the SK_DEBUG build.
575 static void test_tricky_cubic() { 590 static void test_tricky_cubic() {
576 const SkPoint pts[] = { 591 const SkPoint pts[] = {
577 { SkDoubleToScalar(18.8943768), SkDoubleToScalar(129.121277) }, 592 { SkDoubleToScalar(18.8943768), SkDoubleToScalar(129.121277) },
578 { SkDoubleToScalar(18.8937435), SkDoubleToScalar(129.121689) }, 593 { SkDoubleToScalar(18.8937435), SkDoubleToScalar(129.121689) },
579 { SkDoubleToScalar(18.8950119), SkDoubleToScalar(129.120422) }, 594 { SkDoubleToScalar(18.8950119), SkDoubleToScalar(129.120422) },
580 { SkDoubleToScalar(18.5030727), SkDoubleToScalar(129.13121) }, 595 { SkDoubleToScalar(18.5030727), SkDoubleToScalar(129.13121) },
(...skipping 1770 matching lines...) Expand 10 before | Expand all | Expand 10 after
2351 static const SkPath::Verb resultVerbs12[] = { 2366 static const SkPath::Verb resultVerbs12[] = {
2352 SkPath::kMove_Verb, SkPath::kQuad_Verb, SkPath::kClose_Verb, SkPath::kMo ve_Verb, SkPath::kQuad_Verb, SkPath::kClose_Verb 2367 SkPath::kMove_Verb, SkPath::kQuad_Verb, SkPath::kClose_Verb, SkPath::kMo ve_Verb, SkPath::kQuad_Verb, SkPath::kClose_Verb
2353 }; 2368 };
2354 static const SkPath::Verb resultVerbs13[] = { SkPath::kMove_Verb, SkPath::kC ubic_Verb }; 2369 static const SkPath::Verb resultVerbs13[] = { SkPath::kMove_Verb, SkPath::kC ubic_Verb };
2355 static const SkPath::Verb resultVerbs14[] = { SkPath::kMove_Verb, SkPath::kC ubic_Verb, SkPath::kMove_Verb, SkPath::kCubic_Verb }; 2370 static const SkPath::Verb resultVerbs14[] = { SkPath::kMove_Verb, SkPath::kC ubic_Verb, SkPath::kMove_Verb, SkPath::kCubic_Verb };
2356 static const SkPath::Verb resultVerbs15[] = { SkPath::kMove_Verb, SkPath::kC ubic_Verb, SkPath::kClose_Verb }; 2371 static const SkPath::Verb resultVerbs15[] = { SkPath::kMove_Verb, SkPath::kC ubic_Verb, SkPath::kClose_Verb };
2357 static const SkPath::Verb resultVerbs16[] = { 2372 static const SkPath::Verb resultVerbs16[] = {
2358 SkPath::kMove_Verb, SkPath::kCubic_Verb, SkPath::kClose_Verb, SkPath::kM ove_Verb, SkPath::kCubic_Verb, SkPath::kClose_Verb 2373 SkPath::kMove_Verb, SkPath::kCubic_Verb, SkPath::kClose_Verb, SkPath::kM ove_Verb, SkPath::kCubic_Verb, SkPath::kClose_Verb
2359 }; 2374 };
2360 static const struct zeroPathTestData gZeroLengthTests[] = { 2375 static const struct zeroPathTestData gZeroLengthTests[] = {
2361 { "M 1 1", 1, {0, 0, 0, 0}, resultVerbs1, SK_ARRAY_COUNT(resultVerbs1) } , 2376 { "M 1 1", 1, {1, 1, 1, 1}, resultVerbs1, SK_ARRAY_COUNT(resultVerbs1) } ,
2362 { "M 1 1 M 2 1", 2, {SK_Scalar1, SK_Scalar1, 2*SK_Scalar1, SK_Scalar1}, resultVerbs2, SK_ARRAY_COUNT(resultVerbs2) }, 2377 { "M 1 1 M 2 1", 2, {SK_Scalar1, SK_Scalar1, 2*SK_Scalar1, SK_Scalar1}, resultVerbs2, SK_ARRAY_COUNT(resultVerbs2) },
2363 { "M 1 1 z", 1, {0, 0, 0, 0}, resultVerbs3, SK_ARRAY_COUNT(resultVerbs3) }, 2378 { "M 1 1 z", 1, {1, 1, 1, 1}, resultVerbs3, SK_ARRAY_COUNT(resultVerbs3) },
2364 { "M 1 1 z M 2 1 z", 2, {SK_Scalar1, SK_Scalar1, 2*SK_Scalar1, SK_Scalar 1}, resultVerbs4, SK_ARRAY_COUNT(resultVerbs4) }, 2379 { "M 1 1 z M 2 1 z", 2, {SK_Scalar1, SK_Scalar1, 2*SK_Scalar1, SK_Scalar 1}, resultVerbs4, SK_ARRAY_COUNT(resultVerbs4) },
2365 { "M 1 1 L 1 1", 2, {SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_Scalar1}, re sultVerbs5, SK_ARRAY_COUNT(resultVerbs5) }, 2380 { "M 1 1 L 1 1", 2, {SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_Scalar1}, re sultVerbs5, SK_ARRAY_COUNT(resultVerbs5) },
2366 { "M 1 1 L 1 1 M 2 1 L 2 1", 4, {SK_Scalar1, SK_Scalar1, 2*SK_Scalar1, S K_Scalar1}, resultVerbs6, SK_ARRAY_COUNT(resultVerbs6) }, 2381 { "M 1 1 L 1 1 M 2 1 L 2 1", 4, {SK_Scalar1, SK_Scalar1, 2*SK_Scalar1, S K_Scalar1}, resultVerbs6, SK_ARRAY_COUNT(resultVerbs6) },
2367 { "M 1 1 L 1 1 z", 2, {SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_Scalar1}, resultVerbs7, SK_ARRAY_COUNT(resultVerbs7) }, 2382 { "M 1 1 L 1 1 z", 2, {SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_Scalar1}, resultVerbs7, SK_ARRAY_COUNT(resultVerbs7) },
2368 { "M 1 1 L 1 1 z M 2 1 L 2 1 z", 4, {SK_Scalar1, SK_Scalar1, 2*SK_Scalar 1, SK_Scalar1}, resultVerbs8, SK_ARRAY_COUNT(resultVerbs8) }, 2383 { "M 1 1 L 1 1 z M 2 1 L 2 1 z", 4, {SK_Scalar1, SK_Scalar1, 2*SK_Scalar 1, SK_Scalar1}, resultVerbs8, SK_ARRAY_COUNT(resultVerbs8) },
2369 { "M 1 1 Q 1 1 1 1", 3, {SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_Scalar1} , resultVerbs9, SK_ARRAY_COUNT(resultVerbs9) }, 2384 { "M 1 1 Q 1 1 1 1", 3, {SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_Scalar1} , resultVerbs9, SK_ARRAY_COUNT(resultVerbs9) },
2370 { "M 1 1 Q 1 1 1 1 M 2 1 Q 2 1 2 1", 6, {SK_Scalar1, SK_Scalar1, 2*SK_Sc alar1, SK_Scalar1}, resultVerbs10, SK_ARRAY_COUNT(resultVerbs10) }, 2385 { "M 1 1 Q 1 1 1 1 M 2 1 Q 2 1 2 1", 6, {SK_Scalar1, SK_Scalar1, 2*SK_Sc alar1, SK_Scalar1}, resultVerbs10, SK_ARRAY_COUNT(resultVerbs10) },
2371 { "M 1 1 Q 1 1 1 1 z", 3, {SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_Scalar 1}, resultVerbs11, SK_ARRAY_COUNT(resultVerbs11) }, 2386 { "M 1 1 Q 1 1 1 1 z", 3, {SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_Scalar 1}, resultVerbs11, SK_ARRAY_COUNT(resultVerbs11) },
2372 { "M 1 1 Q 1 1 1 1 z M 2 1 Q 2 1 2 1 z", 6, {SK_Scalar1, SK_Scalar1, 2*S K_Scalar1, SK_Scalar1}, resultVerbs12, SK_ARRAY_COUNT(resultVerbs12) }, 2387 { "M 1 1 Q 1 1 1 1 z M 2 1 Q 2 1 2 1 z", 6, {SK_Scalar1, SK_Scalar1, 2*S K_Scalar1, SK_Scalar1}, resultVerbs12, SK_ARRAY_COUNT(resultVerbs12) },
2373 { "M 1 1 C 1 1 1 1 1 1", 4, {SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_Scal ar1}, resultVerbs13, SK_ARRAY_COUNT(resultVerbs13) }, 2388 { "M 1 1 C 1 1 1 1 1 1", 4, {SK_Scalar1, SK_Scalar1, SK_Scalar1, SK_Scal ar1}, resultVerbs13, SK_ARRAY_COUNT(resultVerbs13) },
(...skipping 1467 matching lines...) Expand 10 before | Expand all | Expand 10 after
3841 test_conicTo_special_case(reporter); 3856 test_conicTo_special_case(reporter);
3842 test_get_point(reporter); 3857 test_get_point(reporter);
3843 test_contains(reporter); 3858 test_contains(reporter);
3844 PathTest_Private::TestPathTo(reporter); 3859 PathTest_Private::TestPathTo(reporter);
3845 PathRefTest_Private::TestPathRef(reporter); 3860 PathRefTest_Private::TestPathRef(reporter);
3846 test_dump(reporter); 3861 test_dump(reporter);
3847 test_path_crbug389050(reporter); 3862 test_path_crbug389050(reporter);
3848 test_path_crbugskia2820(reporter); 3863 test_path_crbugskia2820(reporter);
3849 test_skbug_3469(reporter); 3864 test_skbug_3469(reporter);
3850 test_skbug_3239(reporter); 3865 test_skbug_3239(reporter);
3866 test_bounds_crbug_513799(reporter);
3851 } 3867 }
OLDNEW
« no previous file with comments | « include/core/SkPathRef.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698