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

Side by Side Diff: tests/PathOpsExtendedTest.cpp

Issue 272153002: fix bugs found by computing flat clips in 800K skps (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix maybe-uninitialized error in unbuntu Created 6 years, 6 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 | « tests/PathOpsDebug.cpp ('k') | tests/PathOpsLineIntersectionTest.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 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 "PathOpsExtendedTest.h" 8 #include "PathOpsExtendedTest.h"
9 #include "PathOpsThreadedCommon.h" 9 #include "PathOpsThreadedCommon.h"
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 static void showPathData(const SkPath& path) { 149 static void showPathData(const SkPath& path) {
150 SkPath::RawIter iter(path); 150 SkPath::RawIter iter(path);
151 uint8_t verb; 151 uint8_t verb;
152 SkPoint pts[4]; 152 SkPoint pts[4];
153 SkPoint firstPt = {0, 0}, lastPt = {0, 0}; 153 SkPoint firstPt = {0, 0}, lastPt = {0, 0};
154 bool firstPtSet = false; 154 bool firstPtSet = false;
155 bool lastPtSet = true; 155 bool lastPtSet = true;
156 while ((verb = iter.next(pts)) != SkPath::kDone_Verb) { 156 while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
157 switch (verb) { 157 switch (verb) {
158 case SkPath::kMove_Verb: 158 case SkPath::kMove_Verb:
159 if (firstPtSet && lastPtSet && firstPt != lastPt) {
160 SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", lastPt.fX, las tPt.fY,
161 firstPt.fX, firstPt.fY);
162 lastPtSet = false;
163 }
159 firstPt = pts[0]; 164 firstPt = pts[0];
160 firstPtSet = true; 165 firstPtSet = true;
161 continue; 166 continue;
162 case SkPath::kLine_Verb: 167 case SkPath::kLine_Verb:
163 SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", pts[0].fX, pts[0]. fY, 168 SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", pts[0].fX, pts[0]. fY,
164 pts[1].fX, pts[1].fY); 169 pts[1].fX, pts[1].fY);
165 lastPt = pts[1]; 170 lastPt = pts[1];
166 lastPtSet = true; 171 lastPtSet = true;
167 break; 172 break;
168 case SkPath::kQuad_Verb: 173 case SkPath::kQuad_Verb:
(...skipping 14 matching lines...) Expand all
183 SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", lastPt.fX, las tPt.fY, 188 SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", lastPt.fX, las tPt.fY,
184 firstPt.fX, firstPt.fY); 189 firstPt.fX, firstPt.fY);
185 } 190 }
186 firstPtSet = lastPtSet = false; 191 firstPtSet = lastPtSet = false;
187 break; 192 break;
188 default: 193 default:
189 SkDEBUGFAIL("bad verb"); 194 SkDEBUGFAIL("bad verb");
190 return; 195 return;
191 } 196 }
192 } 197 }
198 if (firstPtSet && lastPtSet && firstPt != lastPt) {
199 SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", lastPt.fX, lastPt.fY,
200 firstPt.fX, firstPt.fY);
201 }
193 } 202 }
194 #endif 203 #endif
195 204
196 void showOp(const SkPathOp op) { 205 void showOp(const SkPathOp op) {
197 switch (op) { 206 switch (op) {
198 case kDifference_PathOp: 207 case kDifference_PathOp:
199 SkDebugf("op difference\n"); 208 SkDebugf("op difference\n");
200 break; 209 break;
201 case kIntersect_PathOp: 210 case kIntersect_PathOp:
202 SkDebugf("op intersect\n"); 211 SkDebugf("op intersect\n");
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 const SkPathOp shapeOp, const SkMatrix& scale) { 412 const SkPathOp shapeOp, const SkMatrix& scale) {
404 SkASSERT((unsigned) shapeOp < SK_ARRAY_COUNT(opStrs)); 413 SkASSERT((unsigned) shapeOp < SK_ARRAY_COUNT(opStrs));
405 SkString defaultTestName; 414 SkString defaultTestName;
406 if (!testName) { 415 if (!testName) {
407 defaultTestName.printf("xOp%d%s", gTestNo, opSuffixes[shapeOp]); 416 defaultTestName.printf("xOp%d%s", gTestNo, opSuffixes[shapeOp]);
408 testName = defaultTestName.c_str(); 417 testName = defaultTestName.c_str();
409 } 418 }
410 SkDebugf("static void %s(skiatest::Reporter* reporter, const char* filename) {\n", testName); 419 SkDebugf("static void %s(skiatest::Reporter* reporter, const char* filename) {\n", testName);
411 *gTestOp.append() = shapeOp; 420 *gTestOp.append() = shapeOp;
412 ++gTestNo; 421 ++gTestNo;
413 SkDebugf("\n*** this test fails ***\n");
414 SkDebugf(" SkPath path, pathB;\n"); 422 SkDebugf(" SkPath path, pathB;\n");
415 showPath(a, "path", false); 423 showPath(a, "path", false);
416 showPath(b, "pathB", false); 424 showPath(b, "pathB", false);
417 SkDebugf(" testPathOp(reporter, path, pathB, %s, filename);\n", opStrs[sh apeOp]); 425 SkDebugf(" testPathOp(reporter, path, pathB, %s, filename);\n", opStrs[sh apeOp]);
418 SkDebugf("}\n"); 426 SkDebugf("}\n");
419 drawAsciiPaths(scaledOne, scaledTwo, true); 427 drawAsciiPaths(scaledOne, scaledTwo, true);
420 } 428 }
421 429
422 void ShowTestArray() { 430 void ShowTestArray() {
423 for (int x = gTestFirst; x < gTestNo; ++x) { 431 for (int x = gTestFirst; x < gTestNo; ++x) {
424 SkDebugf(" TEST(xOp%d%s),\n", x, opSuffixes[gTestOp[x - gTestFirst]]) ; 432 SkDebugf(" TEST(xOp%d%s),\n", x, opSuffixes[gTestOp[x - gTestFirst]]) ;
425 } 433 }
426 } 434 }
427 435
428 static int comparePaths(skiatest::Reporter* reporter, const char* testName, cons t SkPath& one, 436 static int comparePaths(skiatest::Reporter* reporter, const char* testName, cons t SkPath& one,
429 const SkPath& scaledOne, const SkPath& two, const SkPath& scaledTwo, SkB itmap& bitmap, 437 const SkPath& scaledOne, const SkPath& two, const SkPath& scaledTwo, SkB itmap& bitmap,
430 const SkPath& a, const SkPath& b, const SkPathOp shapeOp, const SkMatrix & scale) { 438 const SkPath& a, const SkPath& b, const SkPathOp shapeOp, const SkMatrix & scale) {
431 int errors2x2; 439 int errors2x2;
432 (void) pathsDrawTheSame(bitmap, scaledOne, scaledTwo, errors2x2); 440 (void) pathsDrawTheSame(bitmap, scaledOne, scaledTwo, errors2x2);
433 if (errors2x2 == 0) { 441 if (errors2x2 == 0) {
434 if (gShowPath) { 442 if (gShowPath) {
435 showPathOpPath(testName, one, two, a, b, scaledOne, scaledTwo, shape Op, scale); 443 showPathOpPath(testName, one, two, a, b, scaledOne, scaledTwo, shape Op, scale);
436 } 444 }
437 return 0; 445 return 0;
438 } 446 }
439 const int MAX_ERRORS = 8; 447 const int MAX_ERRORS = 8;
440 if (errors2x2 > MAX_ERRORS && gComparePathsAssert) { 448 if (errors2x2 > MAX_ERRORS && gComparePathsAssert) {
441 SK_DECLARE_STATIC_MUTEX(compareDebugOut3); 449 SK_DECLARE_STATIC_MUTEX(compareDebugOut3);
442 SkAutoMutexAcquire autoM(compareDebugOut3); 450 SkAutoMutexAcquire autoM(compareDebugOut3);
451 SkDebugf("\n*** this test fails ***\n");
443 showPathOpPath(testName, one, two, a, b, scaledOne, scaledTwo, shapeOp, scale); 452 showPathOpPath(testName, one, two, a, b, scaledOne, scaledTwo, shapeOp, scale);
444 REPORTER_ASSERT(reporter, 0); 453 REPORTER_ASSERT(reporter, 0);
445 } else if (gShowPath || errors2x2 == MAX_ERRORS || errors2x2 == MAX_ERRORS - 1) { 454 } else if (gShowPath || errors2x2 == MAX_ERRORS || errors2x2 == MAX_ERRORS - 1) {
446 SK_DECLARE_STATIC_MUTEX(compareDebugOut4); 455 SK_DECLARE_STATIC_MUTEX(compareDebugOut4);
447 SkAutoMutexAcquire autoM(compareDebugOut4); 456 SkAutoMutexAcquire autoM(compareDebugOut4);
448 showPathOpPath(testName, one, two, a, b, scaledOne, scaledTwo, shapeOp, scale); 457 showPathOpPath(testName, one, two, a, b, scaledOne, scaledTwo, shapeOp, scale);
449 } 458 }
450 return errors2x2 > MAX_ERRORS ? errors2x2 : 0; 459 return errors2x2 > MAX_ERRORS ? errors2x2 : 0;
451 } 460 }
452 461
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 if (tests[index].fun == stopTest) { 749 if (tests[index].fun == stopTest) {
741 SkDebugf("lastTest\n"); 750 SkDebugf("lastTest\n");
742 break; 751 break;
743 } 752 }
744 if (index == last) { 753 if (index == last) {
745 break; 754 break;
746 } 755 }
747 index += reverse ? -1 : 1; 756 index += reverse ? -1 : 1;
748 } while (true); 757 } while (true);
749 } 758 }
OLDNEW
« no previous file with comments | « tests/PathOpsDebug.cpp ('k') | tests/PathOpsLineIntersectionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698