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

Side by Side Diff: tests/PathTest.cpp

Issue 298973004: In convexity checker don't advance last vector when x-product isn't significant. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: remove debugging code Created 6 years, 7 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 | « src/core/SkPath.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 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 1144
1145 SkPath dent; 1145 SkPath dent;
1146 dent.moveTo(0, 0); 1146 dent.moveTo(0, 0);
1147 dent.lineTo(100*SK_Scalar1, 100*SK_Scalar1); 1147 dent.lineTo(100*SK_Scalar1, 100*SK_Scalar1);
1148 dent.lineTo(0, 100*SK_Scalar1); 1148 dent.lineTo(0, 100*SK_Scalar1);
1149 dent.lineTo(-50*SK_Scalar1, 200*SK_Scalar1); 1149 dent.lineTo(-50*SK_Scalar1, 200*SK_Scalar1);
1150 dent.lineTo(-200*SK_Scalar1, 100*SK_Scalar1); 1150 dent.lineTo(-200*SK_Scalar1, 100*SK_Scalar1);
1151 dent.close(); 1151 dent.close();
1152 check_convexity(reporter, dent, SkPath::kConcave_Convexity); 1152 check_convexity(reporter, dent, SkPath::kConcave_Convexity);
1153 check_direction(reporter, dent, SkPath::kCW_Direction); 1153 check_direction(reporter, dent, SkPath::kCW_Direction);
1154
1155 // http://skbug.com/2235
1156 SkPath strokedSin;
1157 for (int i = 0; i < 2000; i++) {
1158 SkScalar x = SkIntToScalar(i) / 2;
1159 SkScalar y = 500 - (x + SkScalarSin(x / 100) * 40) / 3;
1160 if (0 == i) {
1161 strokedSin.moveTo(x, y);
1162 } else {
1163 strokedSin.lineTo(x, y);
1164 }
1165 }
1166 SkStrokeRec stroke(SkStrokeRec::kFill_InitStyle);
1167 stroke.setStrokeStyle(2 * SK_Scalar1);
1168 stroke.applyToPath(&strokedSin, strokedSin);
1169 check_convexity(reporter, strokedSin, SkPath::kConcave_Convexity);
1170 check_direction(reporter, strokedSin, kDontCheckDir);
1154 } 1171 }
1155 1172
1156 static void check_convex_bounds(skiatest::Reporter* reporter, const SkPath& p, 1173 static void check_convex_bounds(skiatest::Reporter* reporter, const SkPath& p,
1157 const SkRect& bounds) { 1174 const SkRect& bounds) {
1158 REPORTER_ASSERT(reporter, p.isConvex()); 1175 REPORTER_ASSERT(reporter, p.isConvex());
1159 REPORTER_ASSERT(reporter, p.getBounds() == bounds); 1176 REPORTER_ASSERT(reporter, p.getBounds() == bounds);
1160 1177
1161 SkPath p2(p); 1178 SkPath p2(p);
1162 REPORTER_ASSERT(reporter, p2.isConvex()); 1179 REPORTER_ASSERT(reporter, p2.isConvex());
1163 REPORTER_ASSERT(reporter, p2.getBounds() == bounds); 1180 REPORTER_ASSERT(reporter, p2.getBounds() == bounds);
(...skipping 2326 matching lines...) Expand 10 before | Expand all | Expand 10 after
3490 test_addPathMode(reporter, true, true); 3507 test_addPathMode(reporter, true, true);
3491 test_extendClosedPath(reporter); 3508 test_extendClosedPath(reporter);
3492 test_addEmptyPath(reporter, SkPath::kExtend_AddPathMode); 3509 test_addEmptyPath(reporter, SkPath::kExtend_AddPathMode);
3493 test_addEmptyPath(reporter, SkPath::kAppend_AddPathMode); 3510 test_addEmptyPath(reporter, SkPath::kAppend_AddPathMode);
3494 test_conicTo_special_case(reporter); 3511 test_conicTo_special_case(reporter);
3495 test_get_point(reporter); 3512 test_get_point(reporter);
3496 test_contains(reporter); 3513 test_contains(reporter);
3497 PathTest_Private::TestPathTo(reporter); 3514 PathTest_Private::TestPathTo(reporter);
3498 PathRefTest_Private::TestPathRef(reporter); 3515 PathRefTest_Private::TestPathRef(reporter);
3499 } 3516 }
OLDNEW
« no previous file with comments | « src/core/SkPath.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698