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

Side by Side Diff: tests/PathOpsExtendedTest.cpp

Issue 1029993002: Revert of pathops version two (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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/PathOpsExtendedTest.h ('k') | tests/PathOpsFuzz763Test.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"
11 #include "SkCanvas.h" 11 #include "SkCanvas.h"
12 #include "SkForceLinking.h" 12 #include "SkForceLinking.h"
13 #include "SkMatrix.h" 13 #include "SkMatrix.h"
14 #include "SkPaint.h" 14 #include "SkPaint.h"
15 #include "SkRTConf.h" 15 #include "SkRTConf.h"
16 #include "SkStream.h" 16 #include "SkStream.h"
17 #include "SkTaskGroup.h" 17 #include "SkTaskGroup.h"
18 #include "SkThread.h" 18 #include "SkThread.h"
19 19
20 #ifdef SK_BUILD_FOR_MAC 20 #ifdef SK_BUILD_FOR_MAC
21 #include <sys/sysctl.h> 21 #include <sys/sysctl.h>
22 #endif 22 #endif
23 23
24 __SK_FORCE_IMAGE_DECODER_LINKING; 24 __SK_FORCE_IMAGE_DECODER_LINKING;
25 25
26 DEFINE_bool2(runFail, f, false, "run tests known to fail."); 26 DEFINE_bool2(runFail, f, false, "run tests known to fail.");
27 DEFINE_bool2(runBinary, f, false, "run tests known to fail binary sect.");
28 27
29 static const char marker[] = 28 static const char marker[] =
30 "</div>\n" 29 "</div>\n"
31 "\n" 30 "\n"
32 "<script type=\"text/javascript\">\n" 31 "<script type=\"text/javascript\">\n"
33 "\n" 32 "\n"
34 "var testDivs = [\n"; 33 "var testDivs = [\n";
35 34
36 static const char* opStrs[] = { 35 static const char* opStrs[] = {
37 "kDifference_PathOp", 36 "kDifference_PathOp",
38 "kIntersect_PathOp", 37 "kIntersect_PathOp",
39 "kUnion_PathOp", 38 "kUnion_PathOp",
40 "kXor_PathOp", 39 "kXor_PathOp",
41 "kReverseDifference_PathOp", 40 "kReverseDifference_PathOp",
42 }; 41 };
43 42
44 static const char* opSuffixes[] = { 43 static const char* opSuffixes[] = {
45 "d", 44 "d",
46 "i", 45 "i",
47 "u", 46 "u",
48 "o", 47 "o",
49 }; 48 };
50 49
50 static bool gShowPath = false;
51 static bool gComparePathsAssert = true;
52 static bool gPathStrAssert = true;
53
51 #if DEBUG_SHOW_TEST_NAME 54 #if DEBUG_SHOW_TEST_NAME
52 static void showPathData(const SkPath& path) { 55 static void showPathData(const SkPath& path) {
53 SkPath::RawIter iter(path); 56 SkPath::RawIter iter(path);
54 uint8_t verb; 57 uint8_t verb;
55 SkPoint pts[4]; 58 SkPoint pts[4];
56 SkPoint firstPt = {0, 0}, lastPt = {0, 0}; 59 SkPoint firstPt = {0, 0}, lastPt = {0, 0};
57 bool firstPtSet = false; 60 bool firstPtSet = false;
58 bool lastPtSet = true; 61 bool lastPtSet = true;
59 while ((verb = iter.next(pts)) != SkPath::kDone_Verb) { 62 while ((verb = iter.next(pts)) != SkPath::kDone_Verb) {
60 switch (verb) { 63 switch (verb) {
(...skipping 11 matching lines...) Expand all
72 pts[1].fX, pts[1].fY); 75 pts[1].fX, pts[1].fY);
73 lastPt = pts[1]; 76 lastPt = pts[1];
74 lastPtSet = true; 77 lastPtSet = true;
75 break; 78 break;
76 case SkPath::kQuad_Verb: 79 case SkPath::kQuad_Verb:
77 SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", 80 SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}},\n",
78 pts[0].fX, pts[0].fY, pts[1].fX, pts[1].fY, pts[2].fX, p ts[2].fY); 81 pts[0].fX, pts[0].fY, pts[1].fX, pts[1].fY, pts[2].fX, p ts[2].fY);
79 lastPt = pts[2]; 82 lastPt = pts[2];
80 lastPtSet = true; 83 lastPtSet = true;
81 break; 84 break;
82 case SkPath::kConic_Verb:
83 SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}}, //weig ht=%1.9g\n",
84 pts[0].fX, pts[0].fY, pts[1].fX, pts[1].fY, pts[2].fX, p ts[2].fY,
85 iter.conicWeight());
86 lastPt = pts[2];
87 lastPtSet = true;
88 break;
89 case SkPath::kCubic_Verb: 85 case SkPath::kCubic_Verb:
90 SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,% 1.9g}},\n", 86 SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,% 1.9g}},\n",
91 pts[0].fX, pts[0].fY, pts[1].fX, pts[1].fY, pts[2].fX, p ts[2].fY, 87 pts[0].fX, pts[0].fY, pts[1].fX, pts[1].fY, pts[2].fX, p ts[2].fY,
92 pts[3].fX, pts[3].fY); 88 pts[3].fX, pts[3].fY);
93 lastPt = pts[3]; 89 lastPt = pts[3];
94 lastPtSet = true; 90 lastPtSet = true;
95 break; 91 break;
96 case SkPath::kClose_Verb: 92 case SkPath::kClose_Verb:
97 if (firstPtSet && lastPtSet && firstPt != lastPt) { 93 if (firstPtSet && lastPtSet && firstPt != lastPt) {
98 SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", lastPt.fX, las tPt.fY, 94 SkDebugf("{{%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", lastPt.fX, las tPt.fY,
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 *outPtr++ = '|'; 266 *outPtr++ = '|';
271 for (x = bitWidth; x < bitWidth * 2; ++x) { 267 for (x = bitWidth; x < bitWidth * 2; ++x) {
272 *outPtr++ = addr1[x] == (uint32_t) -1 ? '_' : 'x'; 268 *outPtr++ = addr1[x] == (uint32_t) -1 ? '_' : 'x';
273 } 269 }
274 *outPtr++ = '\0'; 270 *outPtr++ = '\0';
275 SkDebugf("%s\n", out); 271 SkDebugf("%s\n", out);
276 } 272 }
277 return true; 273 return true;
278 } 274 }
279 275
280 int comparePaths(skiatest::Reporter* reporter, const char* filename, const SkPat h& one, 276 static int comparePaths(skiatest::Reporter* reporter, const char* filename, cons t SkPath& one,
281 const SkPath& two, SkBitmap& bitmap) { 277 const SkPath& two, SkBitmap& bitmap) {
282 int errors2x2; 278 int errors2x2;
283 SkPath scaledOne, scaledTwo; 279 SkPath scaledOne, scaledTwo;
284 (void) pathsDrawTheSame(one, two, bitmap, scaledOne, scaledTwo, errors2x2); 280 (void) pathsDrawTheSame(one, two, bitmap, scaledOne, scaledTwo, errors2x2);
285 if (errors2x2 == 0) { 281 if (errors2x2 == 0) {
286 return 0; 282 return 0;
287 } 283 }
288 const int MAX_ERRORS = 9; 284 const int MAX_ERRORS = 9;
285 REPORTER_ASSERT(reporter, errors2x2 <= MAX_ERRORS || !gComparePathsAssert);
289 return errors2x2 > MAX_ERRORS ? errors2x2 : 0; 286 return errors2x2 > MAX_ERRORS ? errors2x2 : 0;
290 } 287 }
291 288
292 const int gTestFirst = 4; 289 const int gTestFirst = 4;
293 static int gTestNo = gTestFirst; 290 static int gTestNo = gTestFirst;
294 static SkTDArray<SkPathOp> gTestOp; 291 static SkTDArray<SkPathOp> gTestOp;
295 292
296 static void showPathOpPath(const char* testName, const SkPath& one, const SkPath & two, 293 static void showPathOpPath(const char* testName, const SkPath& one, const SkPath & two,
297 const SkPath& a, const SkPath& b, const SkPath& scaledOne, const SkPath& scaledTwo, 294 const SkPath& a, const SkPath& b, const SkPath& scaledOne, const SkPath& scaledTwo,
298 const SkPathOp shapeOp, const SkMatrix& scale) { 295 const SkPathOp shapeOp, const SkMatrix& scale) {
299 SkASSERT((unsigned) shapeOp < SK_ARRAY_COUNT(opStrs)); 296 SkASSERT((unsigned) shapeOp < SK_ARRAY_COUNT(opStrs));
300 SkString defaultTestName; 297 SkString defaultTestName;
301 if (!testName) { 298 if (!testName) {
302 defaultTestName.printf("xOp%d%s", gTestNo, opSuffixes[shapeOp]); 299 defaultTestName.printf("xOp%d%s", gTestNo, opSuffixes[shapeOp]);
303 testName = defaultTestName.c_str(); 300 testName = defaultTestName.c_str();
304 } 301 }
305 SkDebugf("static void %s(skiatest::Reporter* reporter, const char* filename) {\n", testName); 302 SkDebugf("static void %s(skiatest::Reporter* reporter, const char* filename) {\n", testName);
306 *gTestOp.append() = shapeOp; 303 *gTestOp.append() = shapeOp;
307 ++gTestNo; 304 ++gTestNo;
308 SkDebugf(" SkPath path, pathB;\n"); 305 SkDebugf(" SkPath path, pathB;\n");
309 #if 0 && DEBUG_SHOW_TEST_NAME 306 #if DEBUG_SHOW_TEST_NAME
310 SkPathOpsDebug::ShowOnePath(a, "path", false); 307 SkPathOpsDebug::ShowOnePath(a, "path", false);
311 SkPathOpsDebug::ShowOnePath(b, "pathB", false); 308 SkPathOpsDebug::ShowOnePath(b, "pathB", false);
312 #endif 309 #endif
313 SkDebugf(" testPathOp(reporter, path, pathB, %s, filename);\n", opStrs[sh apeOp]); 310 SkDebugf(" testPathOp(reporter, path, pathB, %s, filename);\n", opStrs[sh apeOp]);
314 SkDebugf("}\n"); 311 SkDebugf("}\n");
315 drawAsciiPaths(scaledOne, scaledTwo, true); 312 drawAsciiPaths(scaledOne, scaledTwo, true);
316 } 313 }
317 314
318 void ShowTestArray() { 315 void ShowTestArray() {
319 for (int x = gTestFirst; x < gTestNo; ++x) { 316 for (int x = gTestFirst; x < gTestNo; ++x) {
(...skipping 10 matching lines...) Expand all
330 int errors2x2; 327 int errors2x2;
331 const int MAX_ERRORS = 8; 328 const int MAX_ERRORS = 8;
332 (void) pathsDrawTheSame(bitmap, scaledOne, scaledTwo, errors2x2); 329 (void) pathsDrawTheSame(bitmap, scaledOne, scaledTwo, errors2x2);
333 if (!expectSuccess) { 330 if (!expectSuccess) {
334 if (errors2x2 <= MAX_ERRORS) { 331 if (errors2x2 <= MAX_ERRORS) {
335 REPORTER_ASSERT(reporter, 0); 332 REPORTER_ASSERT(reporter, 0);
336 } 333 }
337 return 0; 334 return 0;
338 } 335 }
339 if (errors2x2 == 0) { 336 if (errors2x2 == 0) {
337 if (gShowPath) {
338 showPathOpPath(testName, one, two, a, b, scaledOne, scaledTwo, shape Op, scale);
339 }
340 return 0; 340 return 0;
341 } 341 }
342 if (errors2x2 > MAX_ERRORS) { 342 if (errors2x2 > MAX_ERRORS && gComparePathsAssert) {
343 SkAutoMutexAcquire autoM(compareDebugOut3); 343 SkAutoMutexAcquire autoM(compareDebugOut3);
344 SkDebugf("\n*** this test fails ***\n"); 344 SkDebugf("\n*** this test fails ***\n");
345 showPathOpPath(testName, one, two, a, b, scaledOne, scaledTwo, shapeOp, scale); 345 showPathOpPath(testName, one, two, a, b, scaledOne, scaledTwo, shapeOp, scale);
346 REPORTER_ASSERT(reporter, 0); 346 REPORTER_ASSERT(reporter, 0);
347 } else if (errors2x2 == MAX_ERRORS || errors2x2 == MAX_ERRORS - 1) { 347 } else if (gShowPath || errors2x2 == MAX_ERRORS || errors2x2 == MAX_ERRORS - 1) {
348 SkAutoMutexAcquire autoM(compareDebugOut4); 348 SkAutoMutexAcquire autoM(compareDebugOut4);
349 showPathOpPath(testName, one, two, a, b, scaledOne, scaledTwo, shapeOp, scale); 349 showPathOpPath(testName, one, two, a, b, scaledOne, scaledTwo, shapeOp, scale);
350 } 350 }
351 return errors2x2 > MAX_ERRORS ? errors2x2 : 0; 351 return errors2x2 > MAX_ERRORS ? errors2x2 : 0;
352 } 352 }
353 353
354 // Default values for when reporter->verbose() is false. 354 // Default values for when reporter->verbose() is false.
355 static int testNumber = 55; 355 static int testNumber = 55;
356 static const char* testName = "pathOpTest"; 356 static const char* testName = "pathOpTest";
357 357
358 static void writeTestName(const char* nameSuffix, SkMemoryWStream& outFile) { 358 static void writeTestName(const char* nameSuffix, SkMemoryWStream& outFile) {
359 outFile.writeText(testName); 359 outFile.writeText(testName);
360 outFile.writeDecAsText(testNumber); 360 outFile.writeDecAsText(testNumber);
361 ++testNumber; 361 ++testNumber;
362 if (nameSuffix) { 362 if (nameSuffix) {
363 outFile.writeText(nameSuffix); 363 outFile.writeText(nameSuffix);
364 } 364 }
365 } 365 }
366 366
367 static void outputToStream(const char* pathStr, const char* pathPrefix, const ch ar* nameSuffix, 367 static void outputToStream(const char* pathStr, const char* pathPrefix, const ch ar* nameSuffix,
368 const char* testFunction, bool twoPaths, SkMemoryWStream& outFile) { 368 const char* testFunction, bool twoPaths, SkMemoryWStream& outFile) {
369 #if 0 369 #if 0
370 outFile.writeText("\n<div id=\""); 370 outFile.writeText("<div id=\"");
371 writeTestName(nameSuffix, outFile); 371 writeTestName(nameSuffix, outFile);
372 outFile.writeText("\">\n"); 372 outFile.writeText("\">\n");
373 if (pathPrefix) { 373 if (pathPrefix) {
374 outFile.writeText(pathPrefix); 374 outFile.writeText(pathPrefix);
375 } 375 }
376 outFile.writeText(pathStr); 376 outFile.writeText(pathStr);
377 outFile.writeText("</div>\n\n"); 377 outFile.writeText("</div>\n\n");
378 378
379 outFile.writeText(marker); 379 outFile.writeText(marker);
380 outFile.writeText(" "); 380 outFile.writeText(" ");
(...skipping 24 matching lines...) Expand all
405 outFile.writeText(" const char* str;\n"); 405 outFile.writeText(" const char* str;\n");
406 outFile.writeText("} tests[] = {\n"); 406 outFile.writeText("} tests[] = {\n");
407 outFile.writeText(" TEST("); 407 outFile.writeText(" TEST(");
408 writeTestName(nameSuffix, outFile); 408 writeTestName(nameSuffix, outFile);
409 outFile.writeText("),\n"); 409 outFile.writeText("),\n");
410 #endif 410 #endif
411 outFile.flush(); 411 outFile.flush();
412 } 412 }
413 413
414 SK_DECLARE_STATIC_MUTEX(simplifyDebugOut); 414 SK_DECLARE_STATIC_MUTEX(simplifyDebugOut);
415
416 bool testSimplify(SkPath& path, bool useXor, SkPath& out, PathOpsThreadState& st ate, 415 bool testSimplify(SkPath& path, bool useXor, SkPath& out, PathOpsThreadState& st ate,
417 const char* pathStr) { 416 const char* pathStr) {
418 SkPath::FillType fillType = useXor ? SkPath::kEvenOdd_FillType : SkPath::kWi nding_FillType; 417 SkPath::FillType fillType = useXor ? SkPath::kEvenOdd_FillType : SkPath::kWi nding_FillType;
419 path.setFillType(fillType); 418 path.setFillType(fillType);
420 state.fReporter->bumpTestCount(); 419 #if DEBUG_SHOW_TEST_NAME
420 if (gShowPath) {
421 SkPathOpsDebug::ShowOnePath(path, "path", false);
422 }
423 #endif
421 if (!Simplify(path, &out)) { 424 if (!Simplify(path, &out)) {
422 SkDebugf("%s did not expect failure\n", __FUNCTION__); 425 SkDebugf("%s did not expect failure\n", __FUNCTION__);
423 REPORTER_ASSERT(state.fReporter, 0); 426 REPORTER_ASSERT(state.fReporter, 0);
424 return false; 427 return false;
425 } 428 }
426 if (!state.fReporter->verbose()) { 429 if (!state.fReporter->verbose()) {
427 return true; 430 return true;
428 } 431 }
429 int result = comparePaths(state.fReporter, NULL, path, out, *state.fBitmap); 432 int result = comparePaths(state.fReporter, NULL, path, out, *state.fBitmap);
430 if (result) { 433 if (result && gPathStrAssert) {
431 SkAutoMutexAcquire autoM(simplifyDebugOut); 434 SkAutoMutexAcquire autoM(simplifyDebugOut);
432 char temp[8192]; 435 char temp[8192];
433 sk_bzero(temp, sizeof(temp)); 436 sk_bzero(temp, sizeof(temp));
434 SkMemoryWStream stream(temp, sizeof(temp)); 437 SkMemoryWStream stream(temp, sizeof(temp));
435 const char* pathPrefix = NULL; 438 const char* pathPrefix = NULL;
436 const char* nameSuffix = NULL; 439 const char* nameSuffix = NULL;
437 if (fillType == SkPath::kEvenOdd_FillType) { 440 if (fillType == SkPath::kEvenOdd_FillType) {
438 pathPrefix = " path.setFillType(SkPath::kEvenOdd_FillType);\n"; 441 pathPrefix = " path.setFillType(SkPath::kEvenOdd_FillType);\n";
439 nameSuffix = "x"; 442 nameSuffix = "x";
440 } 443 }
441 const char testFunction[] = "testSimplify(reporter, path);"; 444 const char testFunction[] = "testSimplify(reporter, path);";
442 outputToStream(pathStr, pathPrefix, nameSuffix, testFunction, false, str eam); 445 outputToStream(pathStr, pathPrefix, nameSuffix, testFunction, false, str eam);
443 SkDebugf("%s", temp); 446 SkDebugf("%s", temp);
444 REPORTER_ASSERT(state.fReporter, 0); 447 REPORTER_ASSERT(state.fReporter, 0);
445 } 448 }
446 state.fReporter->bumpTestCount(); 449 state.fReporter->bumpTestCount();
447 return result == 0; 450 return result == 0;
448 } 451 }
449 452
450 static bool inner_simplify(skiatest::Reporter* reporter, const SkPath& path, con st char* filename, 453 bool testSimplify(skiatest::Reporter* reporter, const SkPath& path, const char* filename) {
451 bool checkFail) { 454 #if DEBUG_SHOW_TEST_NAME
452 #if 0 && DEBUG_SHOW_TEST_NAME
453 showPathData(path); 455 showPathData(path);
454 #endif 456 #endif
455 SkPath out; 457 SkPath out;
456 if (!Simplify(path, &out)) { 458 if (!Simplify(path, &out)) {
457 SkDebugf("%s did not expect %s failure\n", __FUNCTION__, filename); 459 SkDebugf("%s did not expect failure\n", __FUNCTION__);
458 REPORTER_ASSERT(reporter, 0); 460 REPORTER_ASSERT(reporter, 0);
459 return false; 461 return false;
460 } 462 }
461 SkBitmap bitmap; 463 SkBitmap bitmap;
462 int errors = comparePaths(reporter, filename, path, out, bitmap); 464 int result = comparePaths(reporter, filename, path, out, bitmap);
463 if (!checkFail) { 465 if (result && gPathStrAssert) {
464 if (!errors) {
465 SkDebugf("%s failing test %s now succeeds\n", __FUNCTION__, filename );
466 REPORTER_ASSERT(reporter, 0);
467 return false;
468 }
469 } else if (errors) {
470 REPORTER_ASSERT(reporter, 0); 466 REPORTER_ASSERT(reporter, 0);
471 } 467 }
472 reporter->bumpTestCount(); 468 reporter->bumpTestCount();
473 return errors == 0; 469 return result == 0;
474 }
475
476 bool testSimplify(skiatest::Reporter* reporter, const SkPath& path, const char* filename) {
477 return inner_simplify(reporter, path, filename, true);
478 }
479
480 bool testSimplifyCheck(skiatest::Reporter* reporter, const SkPath& path, const c har* filename,
481 bool checkFail) {
482 return inner_simplify(reporter, path, filename, checkFail);
483 } 470 }
484 471
485 #if DEBUG_SHOW_TEST_NAME 472 #if DEBUG_SHOW_TEST_NAME
486 static void showName(const SkPath& a, const SkPath& b, const SkPathOp shapeOp) { 473 static void showName(const SkPath& a, const SkPath& b, const SkPathOp shapeOp) {
487 SkDebugf("\n"); 474 SkDebugf("\n");
488 showPathData(a); 475 showPathData(a);
489 showOp(shapeOp); 476 showOp(shapeOp);
490 showPathData(b); 477 showPathData(b);
491 } 478 }
492 #endif 479 #endif
493 480
494 static bool innerPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkP ath& b, 481 static bool innerPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkP ath& b,
495 const SkPathOp shapeOp, const char* testName, bool threaded, bool expect Success) { 482 const SkPathOp shapeOp, const char* testName, bool threaded, bool expect Success) {
496 #if 0 && DEBUG_SHOW_TEST_NAME 483 #if DEBUG_SHOW_TEST_NAME
497 showName(a, b, shapeOp); 484 showName(a, b, shapeOp);
498 #endif 485 #endif
499 SkPath out; 486 SkPath out;
500 if (!Op(a, b, shapeOp, &out) ) { 487 if (!Op(a, b, shapeOp, &out) ) {
501 SkDebugf("%s did not expect failure\n", __FUNCTION__); 488 SkDebugf("%s did not expect failure\n", __FUNCTION__);
502 REPORTER_ASSERT(reporter, 0); 489 REPORTER_ASSERT(reporter, 0);
503 return false; 490 return false;
504 } 491 }
505 if (!reporter->verbose()) { 492 if (threaded && !reporter->verbose()) {
506 return true; 493 return true;
507 } 494 }
508 SkPath pathOut, scaledPathOut; 495 SkPath pathOut, scaledPathOut;
509 SkRegion rgnA, rgnB, openClip, rgnOut; 496 SkRegion rgnA, rgnB, openClip, rgnOut;
510 openClip.setRect(-16000, -16000, 16000, 16000); 497 openClip.setRect(-16000, -16000, 16000, 16000);
511 rgnA.setPath(a, openClip); 498 rgnA.setPath(a, openClip);
512 rgnB.setPath(b, openClip); 499 rgnB.setPath(b, openClip);
513 rgnOut.op(rgnA, rgnB, (SkRegion::Op) shapeOp); 500 rgnOut.op(rgnA, rgnB, (SkRegion::Op) shapeOp);
514 rgnOut.getBoundaryPath(&pathOut); 501 rgnOut.getBoundaryPath(&pathOut);
515 502
516 SkMatrix scale; 503 SkMatrix scale;
517 scaleMatrix(a, b, scale); 504 scaleMatrix(a, b, scale);
518 SkRegion scaledRgnA, scaledRgnB, scaledRgnOut; 505 SkRegion scaledRgnA, scaledRgnB, scaledRgnOut;
519 SkPath scaledA, scaledB; 506 SkPath scaledA, scaledB;
520 scaledA.addPath(a, scale); 507 scaledA.addPath(a, scale);
521 scaledA.setFillType(a.getFillType()); 508 scaledA.setFillType(a.getFillType());
522 scaledB.addPath(b, scale); 509 scaledB.addPath(b, scale);
523 scaledB.setFillType(b.getFillType()); 510 scaledB.setFillType(b.getFillType());
524 scaledRgnA.setPath(scaledA, openClip); 511 scaledRgnA.setPath(scaledA, openClip);
525 scaledRgnB.setPath(scaledB, openClip); 512 scaledRgnB.setPath(scaledB, openClip);
526 scaledRgnOut.op(scaledRgnA, scaledRgnB, (SkRegion::Op) shapeOp); 513 scaledRgnOut.op(scaledRgnA, scaledRgnB, (SkRegion::Op) shapeOp);
527 scaledRgnOut.getBoundaryPath(&scaledPathOut); 514 scaledRgnOut.getBoundaryPath(&scaledPathOut);
528 SkBitmap bitmap; 515 SkBitmap bitmap;
529 SkPath scaledOut; 516 SkPath scaledOut;
530 scaledOut.addPath(out, scale); 517 scaledOut.addPath(out, scale);
531 scaledOut.setFillType(out.getFillType()); 518 scaledOut.setFillType(out.getFillType());
532 int result = comparePaths(reporter, testName, pathOut, scaledPathOut, out, s caledOut, bitmap, 519 int result = comparePaths(reporter, testName, pathOut, scaledPathOut, out, s caledOut, bitmap,
533 a, b, shapeOp, scale, expectSuccess); 520 a, b, shapeOp, scale, expectSuccess);
534 if (result) { 521 if (result && gPathStrAssert) {
535 REPORTER_ASSERT(reporter, 0); 522 REPORTER_ASSERT(reporter, 0);
536 } 523 }
537 reporter->bumpTestCount(); 524 reporter->bumpTestCount();
538 return result == 0; 525 return result == 0;
539 } 526 }
540 527
541 bool testPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b, 528 bool testPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkPath& b,
542 const SkPathOp shapeOp, const char* testName) { 529 const SkPathOp shapeOp, const char* testName) {
543 return innerPathOp(reporter, a, b, shapeOp, testName, false, true); 530 return innerPathOp(reporter, a, b, shapeOp, testName, false, true);
544 } 531 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 void outputProgress(char* ramStr, const char* pathStr, SkPathOp op) { 597 void outputProgress(char* ramStr, const char* pathStr, SkPathOp op) {
611 const char testFunction[] = "testOp(path);"; 598 const char testFunction[] = "testOp(path);";
612 SkASSERT((size_t) op < SK_ARRAY_COUNT(opSuffixes)); 599 SkASSERT((size_t) op < SK_ARRAY_COUNT(opSuffixes));
613 const char* nameSuffix = opSuffixes[op]; 600 const char* nameSuffix = opSuffixes[op];
614 SkMemoryWStream rRamStream(ramStr, PATH_STR_SIZE); 601 SkMemoryWStream rRamStream(ramStr, PATH_STR_SIZE);
615 outputToStream(pathStr, NULL, nameSuffix, testFunction, true, rRamStream); 602 outputToStream(pathStr, NULL, nameSuffix, testFunction, true, rRamStream);
616 } 603 }
617 604
618 void RunTestSet(skiatest::Reporter* reporter, TestDesc tests[], size_t count, 605 void RunTestSet(skiatest::Reporter* reporter, TestDesc tests[], size_t count,
619 void (*firstTest)(skiatest::Reporter* , const char* filename), 606 void (*firstTest)(skiatest::Reporter* , const char* filename),
620 void (*skipTest)(skiatest::Reporter* , const char* filename),
621 void (*stopTest)(skiatest::Reporter* , const char* filename), bo ol reverse) { 607 void (*stopTest)(skiatest::Reporter* , const char* filename), bo ol reverse) {
622 size_t index; 608 size_t index;
623 if (firstTest) { 609 if (firstTest) {
624 index = count - 1; 610 index = count - 1;
625 while (index > 0 && tests[index].fun != firstTest) { 611 while (index > 0 && tests[index].fun != firstTest) {
626 --index; 612 --index;
627 } 613 }
628 #if DEBUG_SHOW_TEST_NAME 614 #if DEBUG_SHOW_TEST_NAME
629 SkDebugf("\n<div id=\"%s\">\n", tests[index].str); 615 SkDebugf("<div id=\"%s\">\n", tests[index].str);
616 SkDebugf(" %s [%s]\n", __FUNCTION__, tests[index].str);
630 #endif 617 #endif
631 (*tests[index].fun)(reporter, tests[index].str); 618 (*tests[index].fun)(reporter, tests[index].str);
632 if (tests[index].fun == stopTest) { 619 if (tests[index].fun == stopTest) {
633 return; 620 return;
634 } 621 }
635 } 622 }
636 index = reverse ? count - 1 : 0; 623 index = reverse ? count - 1 : 0;
637 size_t last = reverse ? 0 : count - 1; 624 size_t last = reverse ? 0 : count - 1;
638 bool foundSkip = !skipTest;
639 do { 625 do {
640 if (tests[index].fun == skipTest) { 626 if (tests[index].fun != firstTest) {
641 foundSkip = true;
642 }
643 if (foundSkip && tests[index].fun != firstTest) {
644 #if DEBUG_SHOW_TEST_NAME 627 #if DEBUG_SHOW_TEST_NAME
645 SkDebugf("\n<div id=\"%s\">\n", tests[index].str); 628 SkDebugf("<div id=\"%s\">\n", tests[index].str);
629 SkDebugf(" %s [%s]\n", __FUNCTION__, tests[index].str);
646 #endif 630 #endif
647 (*tests[index].fun)(reporter, tests[index].str); 631 (*tests[index].fun)(reporter, tests[index].str);
648 } 632 }
649 if (tests[index].fun == stopTest) { 633 if (tests[index].fun == stopTest) {
650 SkDebugf("lastTest\n"); 634 SkDebugf("lastTest\n");
651 break; 635 break;
652 } 636 }
653 if (index == last) { 637 if (index == last) {
654 break; 638 break;
655 } 639 }
656 index += reverse ? -1 : 1; 640 index += reverse ? -1 : 1;
657 } while (true); 641 } while (true);
658 } 642 }
OLDNEW
« no previous file with comments | « tests/PathOpsExtendedTest.h ('k') | tests/PathOpsFuzz763Test.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698