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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkStroke.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PathTest.cpp
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index d7660a196b012c835011a43385644b2fa8dc691e..6bf28359028470af3fb5e1d7a98f69085e23fee4 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -419,6 +419,68 @@ static void test_crbug_170666() {
surface->getCanvas()->drawPath(path, paint);
}
+
+static void test_tiny_path_convexity(skiatest::Reporter* reporter, const char* pathBug,
+ SkScalar tx, SkScalar ty, SkScalar scale) {
+ SkPath smallPath;
+ SkAssertResult(SkParsePath::FromSVGString(pathBug, &smallPath));
+ bool smallConvex = smallPath.isConvex();
+ SkPath largePath;
+ SkAssertResult(SkParsePath::FromSVGString(pathBug, &largePath));
+ SkMatrix matrix;
+ matrix.reset();
+ matrix.preTranslate(100, 100);
+ matrix.preScale(scale, scale);
+ largePath.transform(matrix);
+ bool largeConvex = largePath.isConvex();
+ REPORTER_ASSERT(reporter, smallConvex == largeConvex);
+}
+
+static void test_crbug_493450(skiatest::Reporter* reporter) {
+ const char reducedCase[] =
+ "M0,0"
+ "L0.0002, 0"
+ "L0.0002, 0.0002"
+ "L0.0001, 0.0001"
+ "L0,0.0002"
+ "Z";
+ test_tiny_path_convexity(reporter, reducedCase, 100, 100, 100000);
+ const char originalFiddleData[] =
+ "M-0.3383152268862998,-0.11217565719203619L-0.33846085183212765,-0.11212264406895281"
+ "L-0.338509393480737,-0.11210607966681395L-0.33857792286700894,-0.1121889121487573"
+ "L-0.3383866116636664,-0.11228834570924921L-0.33842087635680235,-0.11246078673250548"
+ "L-0.33809536177201055,-0.11245415228342878L-0.33797257995493996,-0.11216571641452182"
+ "L-0.33802112160354925,-0.11201996164188659L-0.33819815585141844,-0.11218559834671019Z";
+ test_tiny_path_convexity(reporter, originalFiddleData, 280081.4116670522f, 93268.04618493588f,
+ 826357.3384828606f);
+}
+
+static void test_crbug_495894(skiatest::Reporter* reporter) {
+ const char originalFiddleData[] =
+ "M-0.34004273849857214,-0.11332803232216355L-0.34008271397389744,-0.11324483772714951"
+ "L-0.3401940742265893,-0.11324483772714951L-0.34017694188002134,-0.11329807920275889"
+ "L-0.3402026403998733,-0.11333468903941245L-0.34029972369709194,-0.11334134592705701"
+ "L-0.3403054344792813,-0.11344121970007795L-0.3403140006525653,-0.11351115418399343"
+ "L-0.34024261587519866,-0.11353446986281181L-0.3402197727464413,-0.11360442946144192"
+ "L-0.34013696640469604,-0.11359110237029302L-0.34009128014718143,-0.1135877707043939"
+ "L-0.3400598708451401,-0.11360776134112742L-0.34004273849857214,-0.11355112520064405"
+ "L-0.3400113291965308,-0.11355112520064405L-0.3399970522410575,-0.11359110237029302"
+ "L-0.33997135372120546,-0.11355112520064405L-0.3399627875479215,-0.11353780084493197"
+ "L-0.3399485105924481,-0.11350782354357004L-0.3400027630232468,-0.11346452910331437"
+ "L-0.3399485105924481,-0.11340126558629839L-0.33993994441916414,-0.11340126558629839"
+ "L-0.33988283659727087,-0.11331804756574679L-0.33989140277055485,-0.11324483772714951"
+ "L-0.33997991989448945,-0.11324483772714951L-0.3399856306766788,-0.11324483772714951"
+ "L-0.34002560615200417,-0.11334467443478255ZM-0.3400684370184241,-0.11338461985124307"
+ "L-0.340154098751264,-0.11341791238732665L-0.340162664924548,-0.1134378899559977"
+ "L-0.34017979727111597,-0.11340126558629839L-0.3401655203156427,-0.11338129083212668"
+ "L-0.34012268944922275,-0.11332137577529414L-0.34007414780061346,-0.11334467443478255Z"
+ "M-0.3400027630232468,-0.11290567901106024L-0.3400113291965308,-0.11298876531245433"
+ "L-0.33997991989448945,-0.11301535852306784L-0.33990282433493346,-0.11296217481488612"
+ "L-0.33993994441916414,-0.11288906492739594Z";
+ test_tiny_path_convexity(reporter, originalFiddleData, 22682.240000000005f,7819.72220766405f,
+ 65536);
+}
+
static void test_addrect(skiatest::Reporter* reporter) {
SkPath path;
path.lineTo(0, 0);
@@ -3758,6 +3820,8 @@ DEF_TEST(Paths, reporter) {
test_tricky_cubic();
test_clipped_cubic();
test_crbug_170666();
+ test_crbug_493450(reporter);
+ test_crbug_495894(reporter);
test_bad_cubic_crbug229478();
test_bad_cubic_crbug234190();
test_gen_id(reporter);
« 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