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

Side by Side Diff: tests/PathTest.cpp

Issue 1228383002: compute convexity for very small paths (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix path documentation Created 5 years, 5 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/core/SkStroke.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 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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 412
413 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(1000, 1000)); 413 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(1000, 1000));
414 414
415 build_path_simple_170666(path); 415 build_path_simple_170666(path);
416 surface->getCanvas()->drawPath(path, paint); 416 surface->getCanvas()->drawPath(path, paint);
417 417
418 build_path_170666(path); 418 build_path_170666(path);
419 surface->getCanvas()->drawPath(path, paint); 419 surface->getCanvas()->drawPath(path, paint);
420 } 420 }
421 421
422
423 static void test_tiny_path_convexity(skiatest::Reporter* reporter, const char* p athBug,
424 SkScalar tx, SkScalar ty, SkScalar scale) {
425 SkPath smallPath;
426 SkAssertResult(SkParsePath::FromSVGString(pathBug, &smallPath));
427 bool smallConvex = smallPath.isConvex();
428 SkPath largePath;
429 SkAssertResult(SkParsePath::FromSVGString(pathBug, &largePath));
430 SkMatrix matrix;
431 matrix.reset();
432 matrix.preTranslate(100, 100);
433 matrix.preScale(scale, scale);
434 largePath.transform(matrix);
435 bool largeConvex = largePath.isConvex();
436 REPORTER_ASSERT(reporter, smallConvex == largeConvex);
437 }
438
439 static void test_crbug_493450(skiatest::Reporter* reporter) {
440 const char reducedCase[] =
441 "M0,0"
442 "L0.0002, 0"
443 "L0.0002, 0.0002"
444 "L0.0001, 0.0001"
445 "L0,0.0002"
446 "Z";
447 test_tiny_path_convexity(reporter, reducedCase, 100, 100, 100000);
448 const char originalFiddleData[] =
449 "M-0.3383152268862998,-0.11217565719203619L-0.33846085183212765,-0.11212 264406895281"
450 "L-0.338509393480737,-0.11210607966681395L-0.33857792286700894,-0.112188 9121487573"
451 "L-0.3383866116636664,-0.11228834570924921L-0.33842087635680235,-0.11246 078673250548"
452 "L-0.33809536177201055,-0.11245415228342878L-0.33797257995493996,-0.1121 6571641452182"
453 "L-0.33802112160354925,-0.11201996164188659L-0.33819815585141844,-0.1121 8559834671019Z";
454 test_tiny_path_convexity(reporter, originalFiddleData, 280081.4116670522f, 9 3268.04618493588f,
455 826357.3384828606f);
456 }
457
458 static void test_crbug_495894(skiatest::Reporter* reporter) {
459 const char originalFiddleData[] =
460 "M-0.34004273849857214,-0.11332803232216355L-0.34008271397389744,-0.1132 4483772714951"
461 "L-0.3401940742265893,-0.11324483772714951L-0.34017694188002134,-0.11329 807920275889"
462 "L-0.3402026403998733,-0.11333468903941245L-0.34029972369709194,-0.11334 134592705701"
463 "L-0.3403054344792813,-0.11344121970007795L-0.3403140006525653,-0.113511 15418399343"
464 "L-0.34024261587519866,-0.11353446986281181L-0.3402197727464413,-0.11360 442946144192"
465 "L-0.34013696640469604,-0.11359110237029302L-0.34009128014718143,-0.1135 877707043939"
466 "L-0.3400598708451401,-0.11360776134112742L-0.34004273849857214,-0.11355 112520064405"
467 "L-0.3400113291965308,-0.11355112520064405L-0.3399970522410575,-0.113591 10237029302"
468 "L-0.33997135372120546,-0.11355112520064405L-0.3399627875479215,-0.11353 780084493197"
469 "L-0.3399485105924481,-0.11350782354357004L-0.3400027630232468,-0.113464 52910331437"
470 "L-0.3399485105924481,-0.11340126558629839L-0.33993994441916414,-0.11340 126558629839"
471 "L-0.33988283659727087,-0.11331804756574679L-0.33989140277055485,-0.1132 4483772714951"
472 "L-0.33997991989448945,-0.11324483772714951L-0.3399856306766788,-0.11324 483772714951"
473 "L-0.34002560615200417,-0.11334467443478255ZM-0.3400684370184241,-0.1133 8461985124307"
474 "L-0.340154098751264,-0.11341791238732665L-0.340162664924548,-0.11343788 99559977"
475 "L-0.34017979727111597,-0.11340126558629839L-0.3401655203156427,-0.11338 129083212668"
476 "L-0.34012268944922275,-0.11332137577529414L-0.34007414780061346,-0.1133 4467443478255Z"
477 "M-0.3400027630232468,-0.11290567901106024L-0.3400113291965308,-0.112988 76531245433"
478 "L-0.33997991989448945,-0.11301535852306784L-0.33990282433493346,-0.1129 6217481488612"
479 "L-0.33993994441916414,-0.11288906492739594Z";
480 test_tiny_path_convexity(reporter, originalFiddleData, 22682.240000000005f,7 819.72220766405f,
481 65536);
482 }
483
422 static void test_addrect(skiatest::Reporter* reporter) { 484 static void test_addrect(skiatest::Reporter* reporter) {
423 SkPath path; 485 SkPath path;
424 path.lineTo(0, 0); 486 path.lineTo(0, 0);
425 path.addRect(SkRect::MakeWH(50, 100)); 487 path.addRect(SkRect::MakeWH(50, 100));
426 REPORTER_ASSERT(reporter, path.isRect(NULL)); 488 REPORTER_ASSERT(reporter, path.isRect(NULL));
427 489
428 path.reset(); 490 path.reset();
429 path.lineTo(FLT_EPSILON, FLT_EPSILON); 491 path.lineTo(FLT_EPSILON, FLT_EPSILON);
430 path.addRect(SkRect::MakeWH(50, 100)); 492 path.addRect(SkRect::MakeWH(50, 100));
431 REPORTER_ASSERT(reporter, !path.isRect(NULL)); 493 REPORTER_ASSERT(reporter, !path.isRect(NULL));
(...skipping 3319 matching lines...) Expand 10 before | Expand all | Expand 10 after
3751 test_addPoly(reporter); 3813 test_addPoly(reporter);
3752 test_isfinite(reporter); 3814 test_isfinite(reporter);
3753 test_isfinite_after_transform(reporter); 3815 test_isfinite_after_transform(reporter);
3754 test_arb_round_rect_is_convex(reporter); 3816 test_arb_round_rect_is_convex(reporter);
3755 test_arb_zero_rad_round_rect_is_rect(reporter); 3817 test_arb_zero_rad_round_rect_is_rect(reporter);
3756 test_addrect(reporter); 3818 test_addrect(reporter);
3757 test_addrect_isfinite(reporter); 3819 test_addrect_isfinite(reporter);
3758 test_tricky_cubic(); 3820 test_tricky_cubic();
3759 test_clipped_cubic(); 3821 test_clipped_cubic();
3760 test_crbug_170666(); 3822 test_crbug_170666();
3823 test_crbug_493450(reporter);
3824 test_crbug_495894(reporter);
3761 test_bad_cubic_crbug229478(); 3825 test_bad_cubic_crbug229478();
3762 test_bad_cubic_crbug234190(); 3826 test_bad_cubic_crbug234190();
3763 test_gen_id(reporter); 3827 test_gen_id(reporter);
3764 test_path_close_issue1474(reporter); 3828 test_path_close_issue1474(reporter);
3765 test_path_to_region(reporter); 3829 test_path_to_region(reporter);
3766 test_rrect(reporter); 3830 test_rrect(reporter);
3767 test_arc(reporter); 3831 test_arc(reporter);
3768 test_arcTo(reporter); 3832 test_arcTo(reporter);
3769 test_addPath(reporter); 3833 test_addPath(reporter);
3770 test_addPathMode(reporter, false, false); 3834 test_addPathMode(reporter, false, false);
3771 test_addPathMode(reporter, true, false); 3835 test_addPathMode(reporter, true, false);
3772 test_addPathMode(reporter, false, true); 3836 test_addPathMode(reporter, false, true);
3773 test_addPathMode(reporter, true, true); 3837 test_addPathMode(reporter, true, true);
3774 test_extendClosedPath(reporter); 3838 test_extendClosedPath(reporter);
3775 test_addEmptyPath(reporter, SkPath::kExtend_AddPathMode); 3839 test_addEmptyPath(reporter, SkPath::kExtend_AddPathMode);
3776 test_addEmptyPath(reporter, SkPath::kAppend_AddPathMode); 3840 test_addEmptyPath(reporter, SkPath::kAppend_AddPathMode);
3777 test_conicTo_special_case(reporter); 3841 test_conicTo_special_case(reporter);
3778 test_get_point(reporter); 3842 test_get_point(reporter);
3779 test_contains(reporter); 3843 test_contains(reporter);
3780 PathTest_Private::TestPathTo(reporter); 3844 PathTest_Private::TestPathTo(reporter);
3781 PathRefTest_Private::TestPathRef(reporter); 3845 PathRefTest_Private::TestPathRef(reporter);
3782 test_dump(reporter); 3846 test_dump(reporter);
3783 test_path_crbug389050(reporter); 3847 test_path_crbug389050(reporter);
3784 test_path_crbugskia2820(reporter); 3848 test_path_crbugskia2820(reporter);
3785 test_skbug_3469(reporter); 3849 test_skbug_3469(reporter);
3786 test_skbug_3239(reporter); 3850 test_skbug_3239(reporter);
3787 } 3851 }
OLDNEW
« no previous file with comments | « src/core/SkStroke.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698