Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 /* | 8 /* |
| 9 * Code for the "gm" (Golden Master) rendering comparison tool. | 9 * Code for the "gm" (Golden Master) rendering comparison tool. |
| 10 * | 10 * |
| 11 * If you make changes to this, re-run the self-tests at gm/tests/run.sh | 11 * If you make changes to this, re-run the self-tests at gm/tests/run.sh |
| 12 * to make sure they still pass... you may need to change the expected | 12 * to make sure they still pass... you may need to change the expected |
| 13 * results of the self-test. | 13 * results of the self-test. |
| 14 */ | 14 */ |
| 15 | 15 |
| 16 #include "gm.h" | 16 #include "gm.h" |
| 17 #include "gm_error.h" | |
| 17 #include "gm_expectations.h" | 18 #include "gm_expectations.h" |
| 18 #include "system_preferences.h" | 19 #include "system_preferences.h" |
| 19 #include "SkBitmap.h" | 20 #include "SkBitmap.h" |
| 20 #include "SkBitmapChecksummer.h" | 21 #include "SkBitmapChecksummer.h" |
| 21 #include "SkColorPriv.h" | 22 #include "SkColorPriv.h" |
| 22 #include "SkCommandLineFlags.h" | 23 #include "SkCommandLineFlags.h" |
| 23 #include "SkData.h" | 24 #include "SkData.h" |
| 24 #include "SkDeferredCanvas.h" | 25 #include "SkDeferredCanvas.h" |
| 25 #include "SkDevice.h" | 26 #include "SkDevice.h" |
| 26 #include "SkDrawFilter.h" | 27 #include "SkDrawFilter.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 #include "SkXPSDevice.h" | 74 #include "SkXPSDevice.h" |
| 74 #endif | 75 #endif |
| 75 | 76 |
| 76 #ifdef SK_BUILD_FOR_MAC | 77 #ifdef SK_BUILD_FOR_MAC |
| 77 #include "SkCGUtils.h" | 78 #include "SkCGUtils.h" |
| 78 #define CAN_IMAGE_PDF 1 | 79 #define CAN_IMAGE_PDF 1 |
| 79 #else | 80 #else |
| 80 #define CAN_IMAGE_PDF 0 | 81 #define CAN_IMAGE_PDF 0 |
| 81 #endif | 82 #endif |
| 82 | 83 |
| 83 typedef int ErrorBitfield; | |
| 84 // an empty bitfield means no errors: | |
| 85 const static ErrorBitfield kEmptyErrorBitfield = 0x00; | |
| 86 // individual error types: | |
| 87 const static ErrorBitfield kNoGpuContext_ErrorBitmask = 0x01; | |
| 88 const static ErrorBitfield kImageMismatch_ErrorBitmask = 0x02; | |
| 89 const static ErrorBitfield kMissingExpectations_ErrorBitmask = 0x04; | |
| 90 const static ErrorBitfield kWritingReferenceImage_ErrorBitmask = 0x08; | |
| 91 // we typically ignore any errors matching this bitmask: | |
| 92 const static ErrorBitfield kIgnorable_ErrorBitmask = kMissingExpectations_ErrorB itmask; | |
| 93 | |
| 94 using namespace skiagm; | 84 using namespace skiagm; |
| 95 | 85 |
| 96 struct FailRec { | 86 struct FailRec { |
| 97 SkString fName; | 87 SkString fName; |
| 98 bool fIsPixelError; | 88 bool fIsPixelError; |
| 99 | 89 |
| 100 FailRec() : fIsPixelError(false) {} | 90 FailRec() : fIsPixelError(false) {} |
| 101 FailRec(const SkString& name) : fName(name), fIsPixelError(false) {} | 91 FailRec(const SkString& name) : fName(name), fIsPixelError(false) {} |
| 102 }; | 92 }; |
| 103 | 93 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 { " cross-process, shared address", SkGPipeWriter::kCrossProcess_Flag | 178 { " cross-process, shared address", SkGPipeWriter::kCrossProcess_Flag |
| 189 | SkGPipeWriter::kSharedAddressSpace_Flag } | 179 | SkGPipeWriter::kSharedAddressSpace_Flag } |
| 190 }; | 180 }; |
| 191 | 181 |
| 192 class GMMain { | 182 class GMMain { |
| 193 public: | 183 public: |
| 194 GMMain() { | 184 GMMain() { |
| 195 // Set default values of member variables, which tool_main() | 185 // Set default values of member variables, which tool_main() |
| 196 // may override. | 186 // may override. |
| 197 fUseFileHierarchy = false; | 187 fUseFileHierarchy = false; |
| 188 fIgnorableErrorCombination.add(kMissingExpectations_ErrorType); | |
| 198 fMismatchPath = NULL; | 189 fMismatchPath = NULL; |
| 199 } | 190 } |
| 200 | 191 |
| 201 SkString make_name(const char shortName[], const char configName[]) { | 192 SkString make_name(const char shortName[], const char configName[]) { |
| 202 SkString name; | 193 SkString name; |
| 203 if (0 == strlen(configName)) { | 194 if (0 == strlen(configName)) { |
| 204 name.append(shortName); | 195 name.append(shortName); |
| 205 } else if (fUseFileHierarchy) { | 196 } else if (fUseFileHierarchy) { |
| 206 name.appendf("%s%c%s", configName, SkPATH_SEPARATOR, shortName); | 197 name.appendf("%s%c%s", configName, SkPATH_SEPARATOR, shortName); |
| 207 } else { | 198 } else { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 static bool write_bitmap(const SkString& path, const SkBitmap& bitmap) { | 232 static bool write_bitmap(const SkString& path, const SkBitmap& bitmap) { |
| 242 // TODO(epoger): Now that we have removed force_all_opaque() | 233 // TODO(epoger): Now that we have removed force_all_opaque() |
| 243 // from this method, we should be able to get rid of the | 234 // from this method, we should be able to get rid of the |
| 244 // transformation to 8888 format also. | 235 // transformation to 8888 format also. |
| 245 SkBitmap copy; | 236 SkBitmap copy; |
| 246 bitmap.copyTo(©, SkBitmap::kARGB_8888_Config); | 237 bitmap.copyTo(©, SkBitmap::kARGB_8888_Config); |
| 247 return SkImageEncoder::EncodeFile(path.c_str(), copy, | 238 return SkImageEncoder::EncodeFile(path.c_str(), copy, |
| 248 SkImageEncoder::kPNG_Type, 100); | 239 SkImageEncoder::kPNG_Type, 100); |
| 249 } | 240 } |
| 250 | 241 |
| 251 // Records an error in fFailedTests, if we want to record errors | 242 /** |
| 252 // of this type. | 243 * Records the errors encountered in fFailedTests, except for any error |
| 253 void RecordError(ErrorBitfield errorType, const SkString& name, | 244 * types we want to ignore. |
| 245 */ | |
| 246 void RecordError(const ErrorCombination& errorCombination, const SkString& n ame, | |
| 254 const char renderModeDescriptor []) { | 247 const char renderModeDescriptor []) { |
| 255 // The common case: no error means nothing to record. | 248 // The common case: no error means nothing to record. |
| 256 if (kEmptyErrorBitfield == errorType) { | 249 if (errorCombination.isEmpty()) { |
| 257 return; | 250 return; |
| 258 } | 251 } |
| 259 | 252 |
| 260 // If only certain error type(s) were reported, we know we can ignore th em. | 253 // If only certain error type(s) were reported, we know we can ignore th em. |
| 261 if (errorType == (errorType & kIgnorable_ErrorBitmask)) { | 254 if (errorCombination.minus(fIgnorableErrorCombination).isEmpty()) { |
| 262 return; | 255 return; |
| 263 } | 256 } |
| 264 | 257 |
| 265 FailRec& rec = fFailedTests.push_back(make_name( | 258 FailRec& rec = fFailedTests.push_back(make_name(name.c_str(), renderMode Descriptor)); |
| 266 name.c_str(), renderModeDescriptor)); | 259 rec.fIsPixelError = errorCombination.includes(kImageMismatch_ErrorType); |
| 267 rec.fIsPixelError = | |
| 268 (kEmptyErrorBitfield != (errorType & kImageMismatch_ErrorBitmask)); | |
| 269 } | 260 } |
| 270 | 261 |
| 271 // List contents of fFailedTests via SkDebug. | 262 // List contents of fFailedTests via SkDebug. |
| 272 void ListErrors() { | 263 void ListErrors() { |
| 273 for (int i = 0; i < fFailedTests.count(); ++i) { | 264 for (int i = 0; i < fFailedTests.count(); ++i) { |
| 274 if (fFailedTests[i].fIsPixelError) { | 265 if (fFailedTests[i].fIsPixelError) { |
| 275 gm_fprintf(stderr, "\t\t%s pixel_error\n", fFailedTests[i].fName .c_str()); | 266 gm_fprintf(stderr, "\t\t%s pixel_error\n", fFailedTests[i].fName .c_str()); |
| 276 } else { | 267 } else { |
| 277 gm_fprintf(stderr, "\t\t%s\n", fFailedTests[i].fName.c_str()); | 268 gm_fprintf(stderr, "\t\t%s\n", fFailedTests[i].fName.c_str()); |
| 278 } | 269 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 371 | 362 |
| 372 if (!isPDF) { | 363 if (!isPDF) { |
| 373 canvas->concat(gm->getInitialTransform()); | 364 canvas->concat(gm->getInitialTransform()); |
| 374 } | 365 } |
| 375 installFilter(canvas); | 366 installFilter(canvas); |
| 376 gm->setCanvasIsDeferred(isDeferred); | 367 gm->setCanvasIsDeferred(isDeferred); |
| 377 gm->draw(canvas); | 368 gm->draw(canvas); |
| 378 canvas->setDrawFilter(NULL); | 369 canvas->setDrawFilter(NULL); |
| 379 } | 370 } |
| 380 | 371 |
| 381 static ErrorBitfield generate_image(GM* gm, const ConfigData& gRec, | 372 static ErrorCombination generate_image(GM* gm, const ConfigData& gRec, |
| 382 GrContext* context, | 373 GrContext* context, |
| 383 GrRenderTarget* rt, | 374 GrRenderTarget* rt, |
| 384 SkBitmap* bitmap, | 375 SkBitmap* bitmap, |
| 385 bool deferred) { | 376 bool deferred) { |
| 386 SkISize size (gm->getISize()); | 377 SkISize size (gm->getISize()); |
| 387 setup_bitmap(gRec, size, bitmap); | 378 setup_bitmap(gRec, size, bitmap); |
| 388 | 379 |
| 389 SkAutoTUnref<SkCanvas> canvas; | 380 SkAutoTUnref<SkCanvas> canvas; |
| 390 | 381 |
| 391 if (gRec.fBackend == kRaster_Backend) { | 382 if (gRec.fBackend == kRaster_Backend) { |
| 392 SkAutoTUnref<SkDevice> device(new SkDevice(*bitmap)); | 383 SkAutoTUnref<SkDevice> device(new SkDevice(*bitmap)); |
| 393 if (deferred) { | 384 if (deferred) { |
| 394 canvas.reset(new SkDeferredCanvas(device)); | 385 canvas.reset(new SkDeferredCanvas(device)); |
| 395 } else { | 386 } else { |
| 396 canvas.reset(new SkCanvas(device)); | 387 canvas.reset(new SkCanvas(device)); |
| 397 } | 388 } |
| 398 invokeGM(gm, canvas, false, deferred); | 389 invokeGM(gm, canvas, false, deferred); |
| 399 canvas->flush(); | 390 canvas->flush(); |
| 400 } | 391 } |
| 401 #if SK_SUPPORT_GPU | 392 #if SK_SUPPORT_GPU |
| 402 else { // GPU | 393 else { // GPU |
| 403 if (NULL == context) { | 394 if (NULL == context) { |
| 404 return kNoGpuContext_ErrorBitmask; | 395 return kNoGpuContext_ErrorType; |
|
borenet
2013/03/22 13:53:29
Should this be an instance of ErrorCombination, ra
epoger
2013/03/22 14:31:23
The compiler knows how to automatically convert it
borenet
2013/03/22 14:37:12
That would be my personal preference, but I'll lea
epoger
2013/03/22 15:41:37
Done here, and in one other place where it was als
| |
| 405 } | 396 } |
| 406 SkAutoTUnref<SkDevice> device(new SkGpuDevice(context, rt)); | 397 SkAutoTUnref<SkDevice> device(new SkGpuDevice(context, rt)); |
| 407 if (deferred) { | 398 if (deferred) { |
| 408 canvas.reset(new SkDeferredCanvas(device)); | 399 canvas.reset(new SkDeferredCanvas(device)); |
| 409 } else { | 400 } else { |
| 410 canvas.reset(new SkCanvas(device)); | 401 canvas.reset(new SkCanvas(device)); |
| 411 } | 402 } |
| 412 invokeGM(gm, canvas, false, deferred); | 403 invokeGM(gm, canvas, false, deferred); |
| 413 // the device is as large as the current rendertarget, so | 404 // the device is as large as the current rendertarget, so |
| 414 // we explicitly only readback the amount we expect (in | 405 // we explicitly only readback the amount we expect (in |
| 415 // size) overwrite our previous allocation | 406 // size) overwrite our previous allocation |
| 416 bitmap->setConfig(SkBitmap::kARGB_8888_Config, size.fWidth, | 407 bitmap->setConfig(SkBitmap::kARGB_8888_Config, size.fWidth, |
| 417 size.fHeight); | 408 size.fHeight); |
| 418 canvas->readPixels(bitmap, 0, 0); | 409 canvas->readPixels(bitmap, 0, 0); |
| 419 } | 410 } |
| 420 #endif | 411 #endif |
| 421 complete_bitmap(bitmap); | 412 complete_bitmap(bitmap); |
| 422 return kEmptyErrorBitfield; | 413 return kEmpty_ErrorCombination; |
| 423 } | 414 } |
| 424 | 415 |
| 425 static void generate_image_from_picture(GM* gm, const ConfigData& gRec, | 416 static void generate_image_from_picture(GM* gm, const ConfigData& gRec, |
| 426 SkPicture* pict, SkBitmap* bitmap, | 417 SkPicture* pict, SkBitmap* bitmap, |
| 427 SkScalar scale = SK_Scalar1) { | 418 SkScalar scale = SK_Scalar1) { |
| 428 SkISize size = gm->getISize(); | 419 SkISize size = gm->getISize(); |
| 429 setup_bitmap(gRec, size, bitmap); | 420 setup_bitmap(gRec, size, bitmap); |
| 430 SkCanvas canvas(*bitmap); | 421 SkCanvas canvas(*bitmap); |
| 431 installFilter(&canvas); | 422 installFilter(&canvas); |
| 432 canvas.scale(scale, scale); | 423 canvas.scale(scale, scale); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 481 SkCanvas c(dev); | 472 SkCanvas c(dev); |
| 482 dev->beginPortfolio(&xps); | 473 dev->beginPortfolio(&xps); |
| 483 dev->beginSheet(unitsPerMeter, pixelsPerMeter, trimSize); | 474 dev->beginSheet(unitsPerMeter, pixelsPerMeter, trimSize); |
| 484 invokeGM(gm, &c, false, false); | 475 invokeGM(gm, &c, false, false); |
| 485 dev->endSheet(); | 476 dev->endSheet(); |
| 486 dev->endPortfolio(); | 477 dev->endPortfolio(); |
| 487 | 478 |
| 488 #endif | 479 #endif |
| 489 } | 480 } |
| 490 | 481 |
| 491 ErrorBitfield write_reference_image( | 482 ErrorCombination write_reference_image(const ConfigData& gRec, const char wr itePath [], |
| 492 const ConfigData& gRec, const char writePath [], | 483 const char renderModeDescriptor [], c onst SkString& name, |
| 493 const char renderModeDescriptor [], const SkString& name, | 484 SkBitmap& bitmap, SkDynamicMemoryWStr eam* document) { |
| 494 SkBitmap& bitmap, SkDynamicMemoryWStream* document) { | |
| 495 SkString path; | 485 SkString path; |
| 496 bool success = false; | 486 bool success = false; |
| 497 if (gRec.fBackend == kRaster_Backend || | 487 if (gRec.fBackend == kRaster_Backend || |
| 498 gRec.fBackend == kGPU_Backend || | 488 gRec.fBackend == kGPU_Backend || |
| 499 (gRec.fBackend == kPDF_Backend && CAN_IMAGE_PDF)) { | 489 (gRec.fBackend == kPDF_Backend && CAN_IMAGE_PDF)) { |
| 500 | 490 |
| 501 path = make_filename(writePath, renderModeDescriptor, name.c_str(), | 491 path = make_filename(writePath, renderModeDescriptor, name.c_str(), |
| 502 "png"); | 492 "png"); |
| 503 success = write_bitmap(path, bitmap); | 493 success = write_bitmap(path, bitmap); |
| 504 } | 494 } |
| 505 if (kPDF_Backend == gRec.fBackend) { | 495 if (kPDF_Backend == gRec.fBackend) { |
| 506 path = make_filename(writePath, renderModeDescriptor, name.c_str(), | 496 path = make_filename(writePath, renderModeDescriptor, name.c_str(), |
| 507 "pdf"); | 497 "pdf"); |
| 508 success = write_document(path, *document); | 498 success = write_document(path, *document); |
| 509 } | 499 } |
| 510 if (kXPS_Backend == gRec.fBackend) { | 500 if (kXPS_Backend == gRec.fBackend) { |
| 511 path = make_filename(writePath, renderModeDescriptor, name.c_str(), | 501 path = make_filename(writePath, renderModeDescriptor, name.c_str(), |
| 512 "xps"); | 502 "xps"); |
| 513 success = write_document(path, *document); | 503 success = write_document(path, *document); |
| 514 } | 504 } |
| 515 if (success) { | 505 if (success) { |
| 516 return kEmptyErrorBitfield; | 506 return kEmpty_ErrorCombination; |
| 517 } else { | 507 } else { |
| 518 gm_fprintf(stderr, "FAILED to write %s\n", path.c_str()); | 508 gm_fprintf(stderr, "FAILED to write %s\n", path.c_str()); |
| 519 RecordError(kWritingReferenceImage_ErrorBitmask, name, | 509 ErrorCombination errors(kWritingReferenceImage_ErrorType); |
| 520 renderModeDescriptor); | 510 RecordError(errors, name, renderModeDescriptor); |
| 521 return kWritingReferenceImage_ErrorBitmask; | 511 return errors; |
| 522 } | 512 } |
| 523 } | 513 } |
| 524 | 514 |
| 525 /** | 515 /** |
| 526 * Log more detail about the mistmatch between expectedBitmap and | 516 * Log more detail about the mistmatch between expectedBitmap and |
| 527 * actualBitmap. | 517 * actualBitmap. |
| 528 */ | 518 */ |
| 529 void report_bitmap_diffs(const SkBitmap& expectedBitmap, const SkBitmap& act ualBitmap, | 519 void report_bitmap_diffs(const SkBitmap& expectedBitmap, const SkBitmap& act ualBitmap, |
| 530 const char *testName) { | 520 const char *testName) { |
| 531 const int expectedWidth = expectedBitmap.width(); | 521 const int expectedWidth = expectedBitmap.width(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 572 (int)SkGetPackedA32(actualPixel ))); | 562 (int)SkGetPackedA32(actualPixel ))); |
| 573 } | 563 } |
| 574 } | 564 } |
| 575 } | 565 } |
| 576 gm_fprintf(stderr, "---- %s: %d (of %d) differing pixels," | 566 gm_fprintf(stderr, "---- %s: %d (of %d) differing pixels," |
| 577 " max per-channel mismatch R=%d G=%d B=%d A=%d\n", | 567 " max per-channel mismatch R=%d G=%d B=%d A=%d\n", |
| 578 testName, differingPixels, width*height, errR, errG, errB, er rA); | 568 testName, differingPixels, width*height, errR, errG, errB, er rA); |
| 579 } | 569 } |
| 580 | 570 |
| 581 /** | 571 /** |
| 582 * Compares actual checksum to expectations. Returns | 572 * Compares actual checksum to expectations, returning the set of errors |
| 583 * kEmptyErrorBitfield if they match, or some combination of | 573 * (if any) that we saw along the way. |
| 584 * _ErrorBitmask values otherwise. | |
| 585 * | 574 * |
| 586 * If fMismatchPath has been set, and there are pixel diffs, then the | 575 * If fMismatchPath has been set, and there are pixel diffs, then the |
| 587 * actual bitmap will be written out to a file within fMismatchPath. | 576 * actual bitmap will be written out to a file within fMismatchPath. |
| 588 * | 577 * |
| 589 * @param expectations what expectations to compare actualBitmap against | 578 * @param expectations what expectations to compare actualBitmap against |
| 590 * @param actualBitmap the image we actually generated | 579 * @param actualBitmap the image we actually generated |
| 591 * @param baseNameString name of test without renderModeDescriptor added | 580 * @param baseNameString name of test without renderModeDescriptor added |
| 592 * @param renderModeDescriptor e.g., "-rtree", "-deferred" | 581 * @param renderModeDescriptor e.g., "-rtree", "-deferred" |
| 593 * @param addToJsonSummary whether to add these results (both actual and | 582 * @param addToJsonSummary whether to add these results (both actual and |
| 594 * expected) to the JSON summary | 583 * expected) to the JSON summary |
| 595 * | 584 * |
| 596 * TODO: For now, addToJsonSummary is only set to true within | 585 * TODO: For now, addToJsonSummary is only set to true within |
| 597 * compare_test_results_to_stored_expectations(), so results of our | 586 * compare_test_results_to_stored_expectations(), so results of our |
| 598 * in-memory comparisons (Rtree vs regular, etc.) are not written to the | 587 * in-memory comparisons (Rtree vs regular, etc.) are not written to the |
| 599 * JSON summary. We may wish to change that. | 588 * JSON summary. We may wish to change that. |
| 600 */ | 589 */ |
| 601 ErrorBitfield compare_to_expectations(Expectations expectations, | 590 ErrorCombination compare_to_expectations(Expectations expectations, |
| 602 const SkBitmap& actualBitmap, | 591 const SkBitmap& actualBitmap, |
| 603 const SkString& baseNameString, | 592 const SkString& baseNameString, |
| 604 const char renderModeDescriptor[], | 593 const char renderModeDescriptor[], |
| 605 bool addToJsonSummary=false) { | 594 bool addToJsonSummary=false) { |
| 606 ErrorBitfield retval; | 595 ErrorCombination errors; |
| 607 Checksum actualChecksum = SkBitmapChecksummer::Compute64(actualBitmap); | 596 Checksum actualChecksum = SkBitmapChecksummer::Compute64(actualBitmap); |
| 608 SkString completeNameString = baseNameString; | 597 SkString completeNameString = baseNameString; |
| 609 completeNameString.append(renderModeDescriptor); | 598 completeNameString.append(renderModeDescriptor); |
| 610 const char* completeName = completeNameString.c_str(); | 599 const char* completeName = completeNameString.c_str(); |
| 611 | 600 |
| 612 if (expectations.empty()) { | 601 if (expectations.empty()) { |
| 613 retval = kMissingExpectations_ErrorBitmask; | 602 errors.add(kMissingExpectations_ErrorType); |
| 614 } else if (expectations.match(actualChecksum)) { | 603 } else if (!expectations.match(actualChecksum)) { |
| 615 retval = kEmptyErrorBitfield; | 604 errors.add(kImageMismatch_ErrorType); |
| 616 } else { | |
| 617 retval = kImageMismatch_ErrorBitmask; | |
| 618 | 605 |
| 619 // Write out the "actuals" for any mismatches, if we have | 606 // Write out the "actuals" for any mismatches, if we have |
| 620 // been directed to do so. | 607 // been directed to do so. |
| 621 if (fMismatchPath) { | 608 if (fMismatchPath) { |
| 622 SkString path = | 609 SkString path = |
| 623 make_filename(fMismatchPath, renderModeDescriptor, | 610 make_filename(fMismatchPath, renderModeDescriptor, |
| 624 baseNameString.c_str(), "png"); | 611 baseNameString.c_str(), "png"); |
| 625 write_bitmap(path, actualBitmap); | 612 write_bitmap(path, actualBitmap); |
| 626 } | 613 } |
| 627 | 614 |
| 628 // If we have access to a single expected bitmap, log more | 615 // If we have access to a single expected bitmap, log more |
| 629 // detail about the mismatch. | 616 // detail about the mismatch. |
| 630 const SkBitmap *expectedBitmapPtr = expectations.asBitmap(); | 617 const SkBitmap *expectedBitmapPtr = expectations.asBitmap(); |
| 631 if (NULL != expectedBitmapPtr) { | 618 if (NULL != expectedBitmapPtr) { |
| 632 report_bitmap_diffs(*expectedBitmapPtr, actualBitmap, completeNa me); | 619 report_bitmap_diffs(*expectedBitmapPtr, actualBitmap, completeNa me); |
| 633 } | 620 } |
| 634 } | 621 } |
| 635 RecordError(retval, baseNameString, renderModeDescriptor); | 622 RecordError(errors, baseNameString, renderModeDescriptor); |
| 636 | 623 |
| 637 if (addToJsonSummary) { | 624 if (addToJsonSummary) { |
| 638 add_actual_results_to_json_summary(completeName, actualChecksum, | 625 add_actual_results_to_json_summary(completeName, actualChecksum, err ors, |
| 639 retval, | |
| 640 expectations.ignoreFailure()); | 626 expectations.ignoreFailure()); |
| 641 add_expected_results_to_json_summary(completeName, expectations); | 627 add_expected_results_to_json_summary(completeName, expectations); |
| 642 } | 628 } |
| 643 | 629 |
| 644 return retval; | 630 return errors; |
| 645 } | 631 } |
| 646 | 632 |
| 647 /** | 633 /** |
| 648 * Add this result to the appropriate JSON collection of actual results, | 634 * Add this result to the appropriate JSON collection of actual results, |
| 649 * depending on status. | 635 * depending on status. |
| 650 */ | 636 */ |
| 651 void add_actual_results_to_json_summary(const char testName[], | 637 void add_actual_results_to_json_summary(const char testName[], |
| 652 Checksum actualChecksum, | 638 Checksum actualChecksum, |
| 653 ErrorBitfield result, | 639 ErrorCombination result, |
| 654 bool ignoreFailure) { | 640 bool ignoreFailure) { |
| 655 Json::Value actualResults; | 641 Json::Value actualResults; |
| 656 actualResults[kJsonKey_ActualResults_AnyStatus_Checksum] = | 642 actualResults[kJsonKey_ActualResults_AnyStatus_Checksum] = |
| 657 asJsonValue(actualChecksum); | 643 asJsonValue(actualChecksum); |
| 658 if (kEmptyErrorBitfield == result) { | 644 if (result.isEmpty()) { |
| 659 this->fJsonActualResults_Succeeded[testName] = actualResults; | 645 this->fJsonActualResults_Succeeded[testName] = actualResults; |
| 660 } else { | 646 } else { |
| 661 if (ignoreFailure) { | 647 if (ignoreFailure) { |
| 662 // TODO: Once we have added the ability to compare | 648 // TODO: Once we have added the ability to compare |
| 663 // actual results against expectations in a JSON file | 649 // actual results against expectations in a JSON file |
| 664 // (where we can set ignore-failure to either true or | 650 // (where we can set ignore-failure to either true or |
| 665 // false), add test cases that exercise ignored | 651 // false), add test cases that exercise ignored |
| 666 // failures (both for kMissingExpectations_ErrorBitmask | 652 // failures (both for kMissingExpectations_ErrorType |
| 667 // and kImageMismatch_ErrorBitmask). | 653 // and kImageMismatch_ErrorType). |
| 668 this->fJsonActualResults_FailureIgnored[testName] = | 654 this->fJsonActualResults_FailureIgnored[testName] = |
| 669 actualResults; | 655 actualResults; |
| 670 } else { | 656 } else { |
| 671 if (kEmptyErrorBitfield != (result & kMissingExpectations_ErrorB itmask)) { | 657 if (result.includes(kMissingExpectations_ErrorType)) { |
| 672 // TODO: What about the case where there IS an | 658 // TODO: What about the case where there IS an |
| 673 // expected image checksum, but that gm test | 659 // expected image checksum, but that gm test |
| 674 // doesn't actually run? For now, those cases | 660 // doesn't actually run? For now, those cases |
| 675 // will always be ignored, because gm only looks | 661 // will always be ignored, because gm only looks |
| 676 // at expectations that correspond to gm tests | 662 // at expectations that correspond to gm tests |
| 677 // that were actually run. | 663 // that were actually run. |
| 678 // | 664 // |
| 679 // Once we have the ability to express | 665 // Once we have the ability to express |
| 680 // expectations as a JSON file, we should fix this | 666 // expectations as a JSON file, we should fix this |
| 681 // (and add a test case for which an expectation | 667 // (and add a test case for which an expectation |
| 682 // is given but the test is never run). | 668 // is given but the test is never run). |
| 683 this->fJsonActualResults_NoComparison[testName] = | 669 this->fJsonActualResults_NoComparison[testName] = |
| 684 actualResults; | 670 actualResults; |
| 685 } | 671 } |
| 686 if (kEmptyErrorBitfield != (result & kImageMismatch_ErrorBitmask )) { | 672 if (result.includes(kImageMismatch_ErrorType)) { |
| 687 this->fJsonActualResults_Failed[testName] = actualResults; | 673 this->fJsonActualResults_Failed[testName] = actualResults; |
| 688 } | 674 } |
| 689 } | 675 } |
| 690 } | 676 } |
| 691 } | 677 } |
| 692 | 678 |
| 693 /** | 679 /** |
| 694 * Add this test to the JSON collection of expected results. | 680 * Add this test to the JSON collection of expected results. |
| 695 */ | 681 */ |
| 696 void add_expected_results_to_json_summary(const char testName[], | 682 void add_expected_results_to_json_summary(const char testName[], |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 709 /** | 695 /** |
| 710 * Compare actualBitmap to expectations stored in this->fExpectationsSource. | 696 * Compare actualBitmap to expectations stored in this->fExpectationsSource. |
| 711 * | 697 * |
| 712 * @param gm which test generated the actualBitmap | 698 * @param gm which test generated the actualBitmap |
| 713 * @param gRec | 699 * @param gRec |
| 714 * @param writePath unless this is NULL, write out actual images into this | 700 * @param writePath unless this is NULL, write out actual images into this |
| 715 * directory | 701 * directory |
| 716 * @param actualBitmap bitmap generated by this run | 702 * @param actualBitmap bitmap generated by this run |
| 717 * @param pdf | 703 * @param pdf |
| 718 */ | 704 */ |
| 719 ErrorBitfield compare_test_results_to_stored_expectations( | 705 ErrorCombination compare_test_results_to_stored_expectations( |
| 720 GM* gm, const ConfigData& gRec, const char writePath[], | 706 GM* gm, const ConfigData& gRec, const char writePath[], |
| 721 SkBitmap& actualBitmap, SkDynamicMemoryWStream* pdf) { | 707 SkBitmap& actualBitmap, SkDynamicMemoryWStream* pdf) { |
| 722 | 708 |
| 723 SkString name = make_name(gm->shortName(), gRec.fName); | 709 SkString name = make_name(gm->shortName(), gRec.fName); |
| 724 ErrorBitfield retval = kEmptyErrorBitfield; | 710 ErrorCombination errors; |
| 725 | 711 |
| 726 ExpectationsSource *expectationsSource = | 712 ExpectationsSource *expectationsSource = this->fExpectationsSource.get() ; |
| 727 this->fExpectationsSource.get(); | |
| 728 if (expectationsSource && (gRec.fFlags & kRead_ConfigFlag)) { | 713 if (expectationsSource && (gRec.fFlags & kRead_ConfigFlag)) { |
| 729 /* | 714 /* |
| 730 * Get the expected results for this test, as one or more allowed | 715 * Get the expected results for this test, as one or more allowed |
| 731 * checksums. The current implementation of expectationsSource | 716 * checksums. The current implementation of expectationsSource |
| 732 * get this by computing the checksum of a single PNG file on disk. | 717 * get this by computing the checksum of a single PNG file on disk. |
| 733 * | 718 * |
| 734 * TODO(epoger): This relies on the fact that | 719 * TODO(epoger): This relies on the fact that |
| 735 * force_all_opaque() was called on the bitmap before it | 720 * force_all_opaque() was called on the bitmap before it |
| 736 * was written to disk as a PNG in the first place. If | 721 * was written to disk as a PNG in the first place. If |
| 737 * not, the checksum returned here may not match the | 722 * not, the checksum returned here may not match the |
| 738 * checksum of actualBitmap, which *has* been run through | 723 * checksum of actualBitmap, which *has* been run through |
| 739 * force_all_opaque(). | 724 * force_all_opaque(). |
| 740 * See comments above complete_bitmap() for more detail. | 725 * See comments above complete_bitmap() for more detail. |
| 741 */ | 726 */ |
| 742 Expectations expectations = expectationsSource->get(name.c_str()); | 727 Expectations expectations = expectationsSource->get(name.c_str()); |
| 743 retval |= compare_to_expectations(expectations, actualBitmap, | 728 errors.add(compare_to_expectations(expectations, actualBitmap, |
| 744 name, "", true); | 729 name, "", true)); |
| 745 } else { | 730 } else { |
| 746 // If we are running without expectations, we still want to | 731 // If we are running without expectations, we still want to |
| 747 // record the actual results. | 732 // record the actual results. |
| 748 Checksum actualChecksum = | 733 Checksum actualChecksum = |
| 749 SkBitmapChecksummer::Compute64(actualBitmap); | 734 SkBitmapChecksummer::Compute64(actualBitmap); |
| 750 add_actual_results_to_json_summary(name.c_str(), actualChecksum, | 735 add_actual_results_to_json_summary(name.c_str(), actualChecksum, |
| 751 kMissingExpectations_ErrorBitmask , | 736 kMissingExpectations_ErrorType, |
| 752 false); | 737 false); |
| 753 } | 738 } |
| 754 | 739 |
| 755 // TODO: Consider moving this into compare_to_expectations(), | 740 // TODO: Consider moving this into compare_to_expectations(), |
| 756 // similar to fMismatchPath... for now, we don't do that, because | 741 // similar to fMismatchPath... for now, we don't do that, because |
| 757 // we don't want to write out the actual bitmaps for all | 742 // we don't want to write out the actual bitmaps for all |
| 758 // renderModes of all tests! That would be a lot of files. | 743 // renderModes of all tests! That would be a lot of files. |
| 759 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { | 744 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { |
| 760 retval |= write_reference_image(gRec, writePath, "", | 745 errors.add(write_reference_image(gRec, writePath, "", |
| 761 name, actualBitmap, pdf); | 746 name, actualBitmap, pdf)); |
| 762 } | 747 } |
| 763 | 748 |
| 764 return retval; | 749 return errors; |
| 765 } | 750 } |
| 766 | 751 |
| 767 /** | 752 /** |
| 768 * Compare actualBitmap to referenceBitmap. | 753 * Compare actualBitmap to referenceBitmap. |
| 769 * | 754 * |
| 770 * @param gm which test generated the bitmap | 755 * @param gm which test generated the bitmap |
| 771 * @param gRec | 756 * @param gRec |
| 772 * @param renderModeDescriptor | 757 * @param renderModeDescriptor |
| 773 * @param actualBitmap actual bitmap generated by this run | 758 * @param actualBitmap actual bitmap generated by this run |
| 774 * @param referenceBitmap bitmap we expected to be generated | 759 * @param referenceBitmap bitmap we expected to be generated |
| 775 */ | 760 */ |
| 776 ErrorBitfield compare_test_results_to_reference_bitmap( | 761 ErrorCombination compare_test_results_to_reference_bitmap( |
| 777 GM* gm, const ConfigData& gRec, const char renderModeDescriptor [], | 762 GM* gm, const ConfigData& gRec, const char renderModeDescriptor [], |
| 778 SkBitmap& actualBitmap, const SkBitmap* referenceBitmap) { | 763 SkBitmap& actualBitmap, const SkBitmap* referenceBitmap) { |
| 779 | 764 |
| 780 SkASSERT(referenceBitmap); | 765 SkASSERT(referenceBitmap); |
| 781 SkString name = make_name(gm->shortName(), gRec.fName); | 766 SkString name = make_name(gm->shortName(), gRec.fName); |
| 782 Expectations expectations(*referenceBitmap); | 767 Expectations expectations(*referenceBitmap); |
| 783 return compare_to_expectations(expectations, actualBitmap, | 768 return compare_to_expectations(expectations, actualBitmap, |
| 784 name, renderModeDescriptor); | 769 name, renderModeDescriptor); |
| 785 } | 770 } |
| 786 | 771 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 828 //char* dst = new char [streamSize]; | 813 //char* dst = new char [streamSize]; |
| 829 //@todo thudson 22 April 2011 when can we safely delete [] dst? | 814 //@todo thudson 22 April 2011 when can we safely delete [] dst? |
| 830 storage.copyTo(dst); | 815 storage.copyTo(dst); |
| 831 SkMemoryStream pictReadback(dst, streamSize); | 816 SkMemoryStream pictReadback(dst, streamSize); |
| 832 SkPicture* retval = new SkPicture (&pictReadback); | 817 SkPicture* retval = new SkPicture (&pictReadback); |
| 833 return retval; | 818 return retval; |
| 834 } | 819 } |
| 835 | 820 |
| 836 // Test: draw into a bitmap or pdf. | 821 // Test: draw into a bitmap or pdf. |
| 837 // Depending on flags, possibly compare to an expected image. | 822 // Depending on flags, possibly compare to an expected image. |
| 838 ErrorBitfield test_drawing(GM* gm, | 823 ErrorCombination test_drawing(GM* gm, |
| 839 const ConfigData& gRec, | 824 const ConfigData& gRec, |
| 840 const char writePath [], | 825 const char writePath [], |
| 841 GrContext* context, | 826 GrContext* context, |
| 842 GrRenderTarget* rt, | 827 GrRenderTarget* rt, |
| 843 SkBitmap* bitmap) { | 828 SkBitmap* bitmap) { |
| 844 SkDynamicMemoryWStream document; | 829 SkDynamicMemoryWStream document; |
| 845 | 830 |
| 846 if (gRec.fBackend == kRaster_Backend || | 831 if (gRec.fBackend == kRaster_Backend || |
| 847 gRec.fBackend == kGPU_Backend) { | 832 gRec.fBackend == kGPU_Backend) { |
| 848 // Early exit if we can't generate the image. | 833 // Early exit if we can't generate the image. |
| 849 ErrorBitfield errors = generate_image(gm, gRec, context, rt, bitmap, | 834 ErrorCombination errors = generate_image(gm, gRec, context, rt, bitm ap, false); |
| 850 false); | 835 if (!errors.isEmpty()) { |
| 851 if (kEmptyErrorBitfield != errors) { | |
| 852 // TODO: Add a test to exercise what the stdout and | 836 // TODO: Add a test to exercise what the stdout and |
| 853 // JSON look like if we get an "early error" while | 837 // JSON look like if we get an "early error" while |
| 854 // trying to generate the image. | 838 // trying to generate the image. |
| 855 return errors; | 839 return errors; |
| 856 } | 840 } |
| 857 } else if (gRec.fBackend == kPDF_Backend) { | 841 } else if (gRec.fBackend == kPDF_Backend) { |
| 858 generate_pdf(gm, document); | 842 generate_pdf(gm, document); |
| 859 #if CAN_IMAGE_PDF | 843 #if CAN_IMAGE_PDF |
| 860 SkAutoDataUnref data(document.copyToData()); | 844 SkAutoDataUnref data(document.copyToData()); |
| 861 SkMemoryStream stream(data->data(), data->size()); | 845 SkMemoryStream stream(data->data(), data->size()); |
| 862 SkPDFDocumentToBitmap(&stream, bitmap); | 846 SkPDFDocumentToBitmap(&stream, bitmap); |
| 863 #endif | 847 #endif |
| 864 } else if (gRec.fBackend == kXPS_Backend) { | 848 } else if (gRec.fBackend == kXPS_Backend) { |
| 865 generate_xps(gm, document); | 849 generate_xps(gm, document); |
| 866 } | 850 } |
| 867 return compare_test_results_to_stored_expectations( | 851 return compare_test_results_to_stored_expectations( |
| 868 gm, gRec, writePath, *bitmap, &document); | 852 gm, gRec, writePath, *bitmap, &document); |
| 869 } | 853 } |
| 870 | 854 |
| 871 ErrorBitfield test_deferred_drawing(GM* gm, | 855 ErrorCombination test_deferred_drawing(GM* gm, |
| 872 const ConfigData& gRec, | 856 const ConfigData& gRec, |
| 873 const SkBitmap& referenceBitmap, | 857 const SkBitmap& referenceBitmap, |
| 874 GrContext* context, | 858 GrContext* context, |
| 875 GrRenderTarget* rt) { | 859 GrRenderTarget* rt) { |
| 876 SkDynamicMemoryWStream document; | 860 SkDynamicMemoryWStream document; |
| 877 | 861 |
| 878 if (gRec.fBackend == kRaster_Backend || | 862 if (gRec.fBackend == kRaster_Backend || |
| 879 gRec.fBackend == kGPU_Backend) { | 863 gRec.fBackend == kGPU_Backend) { |
| 880 SkBitmap bitmap; | 864 SkBitmap bitmap; |
| 881 // Early exit if we can't generate the image, but this is | 865 // Early exit if we can't generate the image, but this is |
| 882 // expected in some cases, so don't report a test failure. | 866 // expected in some cases, so don't report a test failure. |
| 883 if (!generate_image(gm, gRec, context, rt, &bitmap, true)) { | 867 ErrorCombination errors = generate_image(gm, gRec, context, rt, &bit map, true); |
| 884 return kEmptyErrorBitfield; | 868 // TODO(epoger): This logic is the opposite of what is |
| 869 // described above... if we succeeded in generating the | |
| 870 // -deferred image, we exit early! We should fix this | |
| 871 // ASAP, because it is hiding -deferred errors... but for | |
| 872 // now, I'm leaving the logic as it is so that the | |
| 873 // refactoring change | |
| 874 // https://codereview.chromium.org/12992003/ is unblocked. | |
| 875 if (errors.isEmpty()) { | |
|
epoger
2013/03/22 02:39:44
Yikes, this "fixes" the "problem" revealed by the
borenet
2013/03/22 13:53:29
File bugs!
epoger
2013/03/22 14:31:23
Filed... I will update that bug, and assign it, on
| |
| 876 return kEmpty_ErrorCombination; | |
| 885 } | 877 } |
| 886 return compare_test_results_to_reference_bitmap( | 878 return compare_test_results_to_reference_bitmap( |
| 887 gm, gRec, "-deferred", bitmap, &referenceBitmap); | 879 gm, gRec, "-deferred", bitmap, &referenceBitmap); |
| 888 } | 880 } |
| 889 return kEmptyErrorBitfield; | 881 return kEmpty_ErrorCombination; |
| 890 } | 882 } |
| 891 | 883 |
| 892 ErrorBitfield test_pipe_playback(GM* gm, | 884 ErrorCombination test_pipe_playback(GM* gm, |
| 893 const ConfigData& gRec, | 885 const ConfigData& gRec, |
| 894 const SkBitmap& referenceBitmap) { | 886 const SkBitmap& referenceBitmap) { |
| 895 ErrorBitfield errors = kEmptyErrorBitfield; | 887 ErrorCombination errors; |
| 896 for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) { | 888 for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) { |
| 897 SkBitmap bitmap; | 889 SkBitmap bitmap; |
| 898 SkISize size = gm->getISize(); | 890 SkISize size = gm->getISize(); |
| 899 setup_bitmap(gRec, size, &bitmap); | 891 setup_bitmap(gRec, size, &bitmap); |
| 900 SkCanvas canvas(bitmap); | 892 SkCanvas canvas(bitmap); |
| 901 installFilter(&canvas); | 893 installFilter(&canvas); |
| 902 PipeController pipeController(&canvas); | 894 PipeController pipeController(&canvas); |
| 903 SkGPipeWriter writer; | 895 SkGPipeWriter writer; |
| 904 SkCanvas* pipeCanvas = writer.startRecording( | 896 SkCanvas* pipeCanvas = writer.startRecording( |
| 905 &pipeController, gPipeWritingFlagCombos[i].flags); | 897 &pipeController, gPipeWritingFlagCombos[i].flags); |
| 906 invokeGM(gm, pipeCanvas, false, false); | 898 invokeGM(gm, pipeCanvas, false, false); |
| 907 complete_bitmap(&bitmap); | 899 complete_bitmap(&bitmap); |
| 908 writer.endRecording(); | 900 writer.endRecording(); |
| 909 SkString string("-pipe"); | 901 SkString string("-pipe"); |
| 910 string.append(gPipeWritingFlagCombos[i].name); | 902 string.append(gPipeWritingFlagCombos[i].name); |
| 911 errors |= compare_test_results_to_reference_bitmap( | 903 errors.add(compare_test_results_to_reference_bitmap( |
| 912 gm, gRec, string.c_str(), bitmap, &referenceBitmap); | 904 gm, gRec, string.c_str(), bitmap, &referenceBitmap)); |
| 913 if (errors != kEmptyErrorBitfield) { | 905 if (!errors.isEmpty()) { |
| 914 break; | 906 break; |
| 915 } | 907 } |
| 916 } | 908 } |
| 917 return errors; | 909 return errors; |
| 918 } | 910 } |
| 919 | 911 |
| 920 ErrorBitfield test_tiled_pipe_playback( | 912 ErrorCombination test_tiled_pipe_playback(GM* gm, const ConfigData& gRec, |
| 921 GM* gm, const ConfigData& gRec, const SkBitmap& referenceBitmap) { | 913 const SkBitmap& referenceBitmap) { |
| 922 ErrorBitfield errors = kEmptyErrorBitfield; | 914 ErrorCombination errors; |
| 923 for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) { | 915 for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) { |
| 924 SkBitmap bitmap; | 916 SkBitmap bitmap; |
| 925 SkISize size = gm->getISize(); | 917 SkISize size = gm->getISize(); |
| 926 setup_bitmap(gRec, size, &bitmap); | 918 setup_bitmap(gRec, size, &bitmap); |
| 927 SkCanvas canvas(bitmap); | 919 SkCanvas canvas(bitmap); |
| 928 installFilter(&canvas); | 920 installFilter(&canvas); |
| 929 TiledPipeController pipeController(bitmap); | 921 TiledPipeController pipeController(bitmap); |
| 930 SkGPipeWriter writer; | 922 SkGPipeWriter writer; |
| 931 SkCanvas* pipeCanvas = writer.startRecording( | 923 SkCanvas* pipeCanvas = writer.startRecording( |
| 932 &pipeController, gPipeWritingFlagCombos[i].flags); | 924 &pipeController, gPipeWritingFlagCombos[i].flags); |
| 933 invokeGM(gm, pipeCanvas, false, false); | 925 invokeGM(gm, pipeCanvas, false, false); |
| 934 complete_bitmap(&bitmap); | 926 complete_bitmap(&bitmap); |
| 935 writer.endRecording(); | 927 writer.endRecording(); |
| 936 SkString string("-tiled pipe"); | 928 SkString string("-tiled pipe"); |
| 937 string.append(gPipeWritingFlagCombos[i].name); | 929 string.append(gPipeWritingFlagCombos[i].name); |
| 938 errors |= compare_test_results_to_reference_bitmap( | 930 errors.add(compare_test_results_to_reference_bitmap( |
| 939 gm, gRec, string.c_str(), bitmap, &referenceBitmap); | 931 gm, gRec, string.c_str(), bitmap, &referenceBitmap)); |
| 940 if (errors != kEmptyErrorBitfield) { | 932 if (!errors.isEmpty()) { |
| 941 break; | 933 break; |
| 942 } | 934 } |
| 943 } | 935 } |
| 944 return errors; | 936 return errors; |
| 945 } | 937 } |
| 946 | 938 |
| 947 // | 939 // |
| 948 // member variables. | 940 // member variables. |
| 949 // They are public for now, to allow easier setting by tool_main(). | 941 // They are public for now, to allow easier setting by tool_main(). |
| 950 // | 942 // |
| 951 | 943 |
| 952 bool fUseFileHierarchy; | 944 bool fUseFileHierarchy; |
| 945 ErrorCombination fIgnorableErrorCombination; | |
| 953 | 946 |
| 954 const char* fMismatchPath; | 947 const char* fMismatchPath; |
| 955 | 948 |
| 956 // information about all failed tests we have encountered so far | 949 // information about all failed tests we have encountered so far |
| 957 SkTArray<FailRec> fFailedTests; | 950 SkTArray<FailRec> fFailedTests; |
| 958 | 951 |
| 959 // Where to read expectations (expected image checksums, etc.) from. | 952 // Where to read expectations (expected image checksums, etc.) from. |
| 960 // If unset, we don't do comparisons. | 953 // If unset, we don't do comparisons. |
| 961 SkAutoTUnref<ExpectationsSource> fExpectationsSource; | 954 SkAutoTUnref<ExpectationsSource> fExpectationsSource; |
| 962 | 955 |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1142 } | 1135 } |
| 1143 } | 1136 } |
| 1144 | 1137 |
| 1145 /** | 1138 /** |
| 1146 * Run this test in a number of different configs (8888, 565, PDF, | 1139 * Run this test in a number of different configs (8888, 565, PDF, |
| 1147 * etc.), confirming that the resulting bitmaps match expectations | 1140 * etc.), confirming that the resulting bitmaps match expectations |
| 1148 * (which may be different for each config). | 1141 * (which may be different for each config). |
| 1149 * | 1142 * |
| 1150 * Returns all errors encountered while doing so. | 1143 * Returns all errors encountered while doing so. |
| 1151 */ | 1144 */ |
| 1152 ErrorBitfield run_multiple_configs(GMMain &gmmain, GM *gm, const SkTDArray<size_ t> &configs, | 1145 ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm, const SkTDArray<si ze_t> &configs, |
| 1153 GrContextFactory *grFactory); | 1146 GrContextFactory *grFactory, int gpuCacheS izeBytes, |
| 1154 ErrorBitfield run_multiple_configs(GMMain &gmmain, GM *gm, const SkTDArray<size_ t> &configs, | 1147 int gpuCacheSizeCount); |
|
borenet
2013/03/22 13:53:29
This was previously hidden behind SK_SUPPORT_GPU.
epoger
2013/03/22 14:31:23
The problem: now that these values are passed as a
borenet
2013/03/22 14:37:12
That IS ugly.
epoger
2013/03/22 15:41:37
I went with globals, because creating the new GpuC
| |
| 1155 GrContextFactory *grFactory) { | 1148 ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm, const SkTDArray<si ze_t> &configs, |
| 1156 ErrorBitfield errorsForAllConfigs = kEmptyErrorBitfield; | 1149 GrContextFactory *grFactory, int gpuCacheS izeBytes, |
| 1150 int gpuCacheSizeCount) { | |
| 1151 ErrorCombination errorsForAllConfigs; | |
| 1157 uint32_t gmFlags = gm->getFlags(); | 1152 uint32_t gmFlags = gm->getFlags(); |
| 1158 | 1153 |
| 1159 #if SK_SUPPORT_GPU | |
| 1160 struct { | |
| 1161 int fBytes; | |
| 1162 int fCount; | |
| 1163 } gpuCacheSize = { -1, -1 }; // -1s mean use the default | |
| 1164 | |
| 1165 if (FLAGS_gpuCacheSize.count() > 0) { | |
| 1166 if (FLAGS_gpuCacheSize.count() != 2) { | |
| 1167 gm_fprintf(stderr, "--gpuCacheSize requires two arguments\n"); | |
| 1168 return -1; | |
| 1169 } | |
| 1170 gpuCacheSize.fBytes = atoi(FLAGS_gpuCacheSize[0]); | |
| 1171 gpuCacheSize.fCount = atoi(FLAGS_gpuCacheSize[1]); | |
| 1172 } | |
| 1173 #endif | |
| 1174 | |
| 1175 for (int i = 0; i < configs.count(); i++) { | 1154 for (int i = 0; i < configs.count(); i++) { |
| 1176 ConfigData config = gRec[configs[i]]; | 1155 ConfigData config = gRec[configs[i]]; |
| 1177 | 1156 |
| 1178 // Skip any tests that we don't even need to try. | 1157 // Skip any tests that we don't even need to try. |
| 1179 if ((kPDF_Backend == config.fBackend) && | 1158 if ((kPDF_Backend == config.fBackend) && |
| 1180 (!FLAGS_pdf|| (gmFlags & GM::kSkipPDF_Flag))) { | 1159 (!FLAGS_pdf|| (gmFlags & GM::kSkipPDF_Flag))) { |
| 1181 continue; | 1160 continue; |
| 1182 } | 1161 } |
| 1183 if ((gmFlags & GM::kSkip565_Flag) && | 1162 if ((gmFlags & GM::kSkip565_Flag) && |
| 1184 (kRaster_Backend == config.fBackend) && | 1163 (kRaster_Backend == config.fBackend) && |
| 1185 (SkBitmap::kRGB_565_Config == config.fConfig)) { | 1164 (SkBitmap::kRGB_565_Config == config.fConfig)) { |
| 1186 continue; | 1165 continue; |
| 1187 } | 1166 } |
| 1188 if ((gmFlags & GM::kSkipGPU_Flag) && | 1167 if ((gmFlags & GM::kSkipGPU_Flag) && |
| 1189 kGPU_Backend == config.fBackend) { | 1168 kGPU_Backend == config.fBackend) { |
| 1190 continue; | 1169 continue; |
| 1191 } | 1170 } |
| 1192 | 1171 |
| 1193 // Now we know that we want to run this test and record its | 1172 // Now we know that we want to run this test and record its |
| 1194 // success or failure. | 1173 // success or failure. |
| 1195 ErrorBitfield errorsForThisConfig = kEmptyErrorBitfield; | 1174 ErrorCombination errorsForThisConfig; |
| 1196 GrRenderTarget* renderTarget = NULL; | 1175 GrRenderTarget* renderTarget = NULL; |
| 1197 #if SK_SUPPORT_GPU | 1176 #if SK_SUPPORT_GPU |
| 1198 SkAutoTUnref<GrRenderTarget> rt; | 1177 SkAutoTUnref<GrRenderTarget> rt; |
| 1199 AutoResetGr autogr; | 1178 AutoResetGr autogr; |
| 1200 if ((kEmptyErrorBitfield == errorsForThisConfig) && (kGPU_Backend == con fig.fBackend)) { | 1179 if ((errorsForThisConfig.isEmpty()) && (kGPU_Backend == config.fBackend) ) { |
| 1201 GrContext* gr = grFactory->get(config.fGLContextType); | 1180 GrContext* gr = grFactory->get(config.fGLContextType); |
| 1202 bool grSuccess = false; | 1181 bool grSuccess = false; |
| 1203 if (gr) { | 1182 if (gr) { |
| 1204 // create a render target to back the device | 1183 // create a render target to back the device |
| 1205 GrTextureDesc desc; | 1184 GrTextureDesc desc; |
| 1206 desc.fConfig = kSkia8888_GrPixelConfig; | 1185 desc.fConfig = kSkia8888_GrPixelConfig; |
| 1207 desc.fFlags = kRenderTarget_GrTextureFlagBit; | 1186 desc.fFlags = kRenderTarget_GrTextureFlagBit; |
| 1208 desc.fWidth = gm->getISize().width(); | 1187 desc.fWidth = gm->getISize().width(); |
| 1209 desc.fHeight = gm->getISize().height(); | 1188 desc.fHeight = gm->getISize().height(); |
| 1210 desc.fSampleCnt = config.fSampleCnt; | 1189 desc.fSampleCnt = config.fSampleCnt; |
| 1211 GrTexture* tex = gr->createUncachedTexture(desc, NULL, 0); | 1190 GrTexture* tex = gr->createUncachedTexture(desc, NULL, 0); |
| 1212 if (tex) { | 1191 if (tex) { |
| 1213 rt.reset(tex->asRenderTarget()); | 1192 rt.reset(tex->asRenderTarget()); |
| 1214 rt.get()->ref(); | 1193 rt.get()->ref(); |
| 1215 tex->unref(); | 1194 tex->unref(); |
| 1216 autogr.set(gr); | 1195 autogr.set(gr); |
| 1217 renderTarget = rt.get(); | 1196 renderTarget = rt.get(); |
| 1218 grSuccess = NULL != renderTarget; | 1197 grSuccess = NULL != renderTarget; |
| 1219 } | 1198 } |
| 1220 // Set the user specified cache limits if non-default. | 1199 // Set the user specified cache limits if non-default. |
| 1221 size_t bytes; | 1200 size_t bytes; |
| 1222 int count; | 1201 int count; |
| 1223 gr->getTextureCacheLimits(&count, &bytes); | 1202 gr->getTextureCacheLimits(&count, &bytes); |
| 1224 if (-1 != gpuCacheSize.fBytes) { | 1203 if (-1 != gpuCacheSizeBytes) { |
| 1225 bytes = static_cast<size_t>(gpuCacheSize.fBytes); | 1204 bytes = static_cast<size_t>(gpuCacheSizeBytes); |
| 1226 } | 1205 } |
| 1227 if (-1 != gpuCacheSize.fCount) { | 1206 if (-1 != gpuCacheSizeCount) { |
| 1228 count = gpuCacheSize.fCount; | 1207 count = gpuCacheSizeCount; |
| 1229 } | 1208 } |
| 1230 gr->setTextureCacheLimits(count, bytes); | 1209 gr->setTextureCacheLimits(count, bytes); |
| 1231 } | 1210 } |
| 1232 if (!grSuccess) { | 1211 if (!grSuccess) { |
| 1233 errorsForThisConfig |= kNoGpuContext_ErrorBitmask; | 1212 errorsForThisConfig.add(kNoGpuContext_ErrorType); |
| 1234 } | 1213 } |
| 1235 } | 1214 } |
| 1236 #endif | 1215 #endif |
| 1237 | 1216 |
| 1238 SkBitmap comparisonBitmap; | 1217 SkBitmap comparisonBitmap; |
| 1239 | 1218 |
| 1240 const char* writePath; | 1219 const char* writePath; |
| 1241 if (FLAGS_writePath.count() == 1) { | 1220 if (FLAGS_writePath.count() == 1) { |
| 1242 writePath = FLAGS_writePath[0]; | 1221 writePath = FLAGS_writePath[0]; |
| 1243 } else { | 1222 } else { |
| 1244 writePath = NULL; | 1223 writePath = NULL; |
| 1245 } | 1224 } |
| 1246 if (kEmptyErrorBitfield == errorsForThisConfig) { | 1225 if (errorsForThisConfig.isEmpty()) { |
| 1247 errorsForThisConfig |= gmmain.test_drawing(gm, config, writePath, Ge tGr(), | 1226 errorsForThisConfig.add(gmmain.test_drawing(gm, config, writePath, G etGr(), |
| 1248 renderTarget, &comparison Bitmap); | 1227 renderTarget, &compariso nBitmap)); |
| 1249 } | 1228 } |
| 1250 | 1229 |
| 1251 if (FLAGS_deferred && !errorsForThisConfig && | 1230 if (FLAGS_deferred && errorsForThisConfig.isEmpty() && |
| 1252 (kGPU_Backend == config.fBackend || | 1231 (kGPU_Backend == config.fBackend || kRaster_Backend == config.fBacke nd)) { |
| 1253 kRaster_Backend == config.fBackend)) { | 1232 errorsForThisConfig.add(gmmain.test_deferred_drawing(gm, config, com parisonBitmap, |
| 1254 errorsForThisConfig |= gmmain.test_deferred_drawing(gm, config, comp arisonBitmap, | 1233 GetGr(), render Target)); |
| 1255 GetGr(), renderT arget); | |
| 1256 } | 1234 } |
| 1257 | 1235 |
| 1258 errorsForAllConfigs |= errorsForThisConfig; | 1236 errorsForAllConfigs.add(errorsForThisConfig); |
| 1259 } | 1237 } |
| 1260 return errorsForAllConfigs; | 1238 return errorsForAllConfigs; |
| 1261 } | 1239 } |
| 1262 | 1240 |
| 1263 /** | 1241 /** |
| 1264 * Run this test in a number of different drawing modes (pipe, | 1242 * Run this test in a number of different drawing modes (pipe, |
| 1265 * deferred, tiled, etc.), confirming that the resulting bitmaps all | 1243 * deferred, tiled, etc.), confirming that the resulting bitmaps all |
| 1266 * *exactly* match comparisonBitmap. | 1244 * *exactly* match comparisonBitmap. |
| 1267 * | 1245 * |
| 1268 * Returns all errors encountered while doing so. | 1246 * Returns all errors encountered while doing so. |
| 1269 */ | 1247 */ |
| 1270 ErrorBitfield run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &compa reConfig, | 1248 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &co mpareConfig, |
| 1271 const SkBitmap &comparisonBitmap); | 1249 const SkBitmap &comparisonBitmap, |
| 1272 ErrorBitfield run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &compa reConfig, | 1250 const SkTDArray<SkScalar> &tileGridReplaySca les); |
| 1273 const SkBitmap &comparisonBitmap) { | 1251 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &co mpareConfig, |
| 1274 SkTDArray<SkScalar> tileGridReplayScales; | 1252 const SkBitmap &comparisonBitmap, |
| 1275 *tileGridReplayScales.append() = SK_Scalar1; // By default only test at scal e 1.0 | 1253 const SkTDArray<SkScalar> &tileGridReplaySca les) { |
| 1276 if (FLAGS_tileGridReplayScales.count() > 0) { | 1254 ErrorCombination errorsForAllModes; |
| 1277 tileGridReplayScales.reset(); | |
| 1278 for (int i = 0; i < FLAGS_tileGridReplayScales.count(); i++) { | |
| 1279 double val = atof(FLAGS_tileGridReplayScales[i]); | |
| 1280 if (0 < val) { | |
| 1281 *tileGridReplayScales.append() = SkDoubleToScalar(val); | |
| 1282 } | |
| 1283 } | |
| 1284 if (0 == tileGridReplayScales.count()) { | |
| 1285 // Should have at least one scale | |
| 1286 gm_fprintf(stderr, "--tileGridReplayScales requires at least one sca le.\n"); | |
| 1287 return -1; | |
| 1288 } | |
| 1289 } | |
| 1290 | |
| 1291 ErrorBitfield errorsForAllModes = kEmptyErrorBitfield; | |
| 1292 uint32_t gmFlags = gm->getFlags(); | 1255 uint32_t gmFlags = gm->getFlags(); |
| 1293 | 1256 |
| 1294 // run the picture centric GM steps | 1257 // run the picture centric GM steps |
| 1295 if (!(gmFlags & GM::kSkipPicture_Flag)) { | 1258 if (!(gmFlags & GM::kSkipPicture_Flag)) { |
| 1296 | 1259 |
| 1297 ErrorBitfield pictErrors = kEmptyErrorBitfield; | 1260 ErrorCombination pictErrors; |
| 1298 | 1261 |
| 1299 //SkAutoTUnref<SkPicture> pict(generate_new_picture(gm)); | 1262 //SkAutoTUnref<SkPicture> pict(generate_new_picture(gm)); |
| 1300 SkPicture* pict = gmmain.generate_new_picture(gm, kNone_BbhType, 0); | 1263 SkPicture* pict = gmmain.generate_new_picture(gm, kNone_BbhType, 0); |
| 1301 SkAutoUnref aur(pict); | 1264 SkAutoUnref aur(pict); |
| 1302 | 1265 |
| 1303 if (FLAGS_replay) { | 1266 if (FLAGS_replay) { |
| 1304 SkBitmap bitmap; | 1267 SkBitmap bitmap; |
| 1305 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap) ; | 1268 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap) ; |
| 1306 pictErrors |= gmmain.compare_test_results_to_reference_bitmap( | 1269 pictErrors.add(gmmain.compare_test_results_to_reference_bitmap( |
| 1307 gm, compareConfig, "-replay", bitmap, &comparisonBitmap); | 1270 gm, compareConfig, "-replay", bitmap, &comparisonBitmap)); |
| 1308 } | 1271 } |
| 1309 | 1272 |
| 1310 if ((kEmptyErrorBitfield == pictErrors) && FLAGS_serialize) { | 1273 if ((pictErrors.isEmpty()) && FLAGS_serialize) { |
| 1311 SkPicture* repict = gmmain.stream_to_new_picture(*pict); | 1274 SkPicture* repict = gmmain.stream_to_new_picture(*pict); |
| 1312 SkAutoUnref aurr(repict); | 1275 SkAutoUnref aurr(repict); |
| 1313 | 1276 |
| 1314 SkBitmap bitmap; | 1277 SkBitmap bitmap; |
| 1315 gmmain.generate_image_from_picture(gm, compareConfig, repict, &bitma p); | 1278 gmmain.generate_image_from_picture(gm, compareConfig, repict, &bitma p); |
| 1316 pictErrors |= gmmain.compare_test_results_to_reference_bitmap( | 1279 pictErrors.add(gmmain.compare_test_results_to_reference_bitmap( |
| 1317 gm, compareConfig, "-serialize", bitmap, &comparisonBitmap); | 1280 gm, compareConfig, "-serialize", bitmap, &comparisonBitmap)); |
| 1318 } | 1281 } |
| 1319 | 1282 |
| 1320 if (FLAGS_writePicturePath.count() == 1) { | 1283 if (FLAGS_writePicturePath.count() == 1) { |
| 1321 const char* pictureSuffix = "skp"; | 1284 const char* pictureSuffix = "skp"; |
| 1322 SkString path = make_filename(FLAGS_writePicturePath[0], "", | 1285 SkString path = make_filename(FLAGS_writePicturePath[0], "", |
| 1323 gm->shortName(), pictureSuffix); | 1286 gm->shortName(), pictureSuffix); |
| 1324 SkFILEWStream stream(path.c_str()); | 1287 SkFILEWStream stream(path.c_str()); |
| 1325 pict->serialize(&stream); | 1288 pict->serialize(&stream); |
| 1326 } | 1289 } |
| 1327 | 1290 |
| 1328 errorsForAllModes |= pictErrors; | 1291 errorsForAllModes.add(pictErrors); |
| 1329 } | 1292 } |
| 1330 | 1293 |
| 1331 // TODO: add a test in which the RTree rendering results in a | 1294 // TODO: add a test in which the RTree rendering results in a |
| 1332 // different bitmap than the standard rendering. It should | 1295 // different bitmap than the standard rendering. It should |
| 1333 // show up as failed in the JSON summary, and should be listed | 1296 // show up as failed in the JSON summary, and should be listed |
| 1334 // in the stdout also. | 1297 // in the stdout also. |
| 1335 if (!(gmFlags & GM::kSkipPicture_Flag) && FLAGS_rtree) { | 1298 if (!(gmFlags & GM::kSkipPicture_Flag) && FLAGS_rtree) { |
| 1336 SkPicture* pict = gmmain.generate_new_picture( | 1299 SkPicture* pict = gmmain.generate_new_picture( |
| 1337 gm, kRTree_BbhType, SkPicture::kUsePathBoundsForClip_RecordingFlag); | 1300 gm, kRTree_BbhType, SkPicture::kUsePathBoundsForClip_RecordingFlag); |
| 1338 SkAutoUnref aur(pict); | 1301 SkAutoUnref aur(pict); |
| 1339 SkBitmap bitmap; | 1302 SkBitmap bitmap; |
| 1340 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap); | 1303 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap); |
| 1341 errorsForAllModes |= gmmain.compare_test_results_to_reference_bitmap( | 1304 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitmap( |
| 1342 gm, compareConfig, "-rtree", bitmap, &comparisonBitmap); | 1305 gm, compareConfig, "-rtree", bitmap, &comparisonBitmap)); |
| 1343 } | 1306 } |
| 1344 | 1307 |
| 1345 if (!(gmFlags & GM::kSkipPicture_Flag) && FLAGS_tileGrid) { | 1308 if (!(gmFlags & GM::kSkipPicture_Flag) && FLAGS_tileGrid) { |
| 1346 for(int scaleIndex = 0; scaleIndex < tileGridReplayScales.count(); ++sca leIndex) { | 1309 for(int scaleIndex = 0; scaleIndex < tileGridReplayScales.count(); ++sca leIndex) { |
| 1347 SkScalar replayScale = tileGridReplayScales[scaleIndex]; | 1310 SkScalar replayScale = tileGridReplayScales[scaleIndex]; |
| 1348 if ((gmFlags & GM::kSkipScaledReplay_Flag) && replayScale != 1) { | 1311 if ((gmFlags & GM::kSkipScaledReplay_Flag) && replayScale != 1) { |
| 1349 continue; | 1312 continue; |
| 1350 } | 1313 } |
| 1351 // We record with the reciprocal scale to obtain a replay | 1314 // We record with the reciprocal scale to obtain a replay |
| 1352 // result that can be validated against comparisonBitmap. | 1315 // result that can be validated against comparisonBitmap. |
| 1353 SkScalar recordScale = SkScalarInvert(replayScale); | 1316 SkScalar recordScale = SkScalarInvert(replayScale); |
| 1354 SkPicture* pict = gmmain.generate_new_picture( | 1317 SkPicture* pict = gmmain.generate_new_picture( |
| 1355 gm, kTileGrid_BbhType, SkPicture::kUsePathBoundsForClip_Recordin gFlag, recordScale); | 1318 gm, kTileGrid_BbhType, SkPicture::kUsePathBoundsForClip_Recordin gFlag, recordScale); |
| 1356 SkAutoUnref aur(pict); | 1319 SkAutoUnref aur(pict); |
| 1357 SkBitmap bitmap; | 1320 SkBitmap bitmap; |
| 1358 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap, replayScale); | 1321 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap, replayScale); |
| 1359 SkString suffix("-tilegrid"); | 1322 SkString suffix("-tilegrid"); |
| 1360 if (SK_Scalar1 != replayScale) { | 1323 if (SK_Scalar1 != replayScale) { |
| 1361 suffix += "-scale-"; | 1324 suffix += "-scale-"; |
| 1362 suffix.appendScalar(replayScale); | 1325 suffix.appendScalar(replayScale); |
| 1363 } | 1326 } |
| 1364 errorsForAllModes |= gmmain.compare_test_results_to_reference_bitmap ( | 1327 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p( |
| 1365 gm, compareConfig, suffix.c_str(), bitmap, &comparisonBitmap); | 1328 gm, compareConfig, suffix.c_str(), bitmap, &comparisonBitmap)); |
| 1366 } | 1329 } |
| 1367 } | 1330 } |
| 1368 | 1331 |
| 1369 // run the pipe centric GM steps | 1332 // run the pipe centric GM steps |
| 1370 if (!(gmFlags & GM::kSkipPipe_Flag)) { | 1333 if (!(gmFlags & GM::kSkipPipe_Flag)) { |
| 1371 | 1334 |
| 1372 ErrorBitfield pipeErrors = kEmptyErrorBitfield; | 1335 ErrorCombination pipeErrors; |
| 1373 | 1336 |
| 1374 if (FLAGS_pipe) { | 1337 if (FLAGS_pipe) { |
| 1375 pipeErrors |= gmmain.test_pipe_playback(gm, compareConfig, compariso nBitmap); | 1338 pipeErrors.add(gmmain.test_pipe_playback(gm, compareConfig, comparis onBitmap)); |
| 1376 } | 1339 } |
| 1377 | 1340 |
| 1378 if ((kEmptyErrorBitfield == pipeErrors) && | 1341 if ((pipeErrors.isEmpty()) && |
| 1379 FLAGS_tiledPipe && !(gmFlags & GM::kSkipTiled_Flag)) { | 1342 FLAGS_tiledPipe && !(gmFlags & GM::kSkipTiled_Flag)) { |
| 1380 pipeErrors |= gmmain.test_tiled_pipe_playback(gm, compareConfig, com parisonBitmap); | 1343 pipeErrors.add(gmmain.test_tiled_pipe_playback(gm, compareConfig, co mparisonBitmap)); |
| 1381 } | 1344 } |
| 1382 | 1345 |
| 1383 errorsForAllModes |= pipeErrors; | 1346 errorsForAllModes.add(pipeErrors); |
| 1384 } | 1347 } |
| 1385 return errorsForAllModes; | 1348 return errorsForAllModes; |
| 1386 } | 1349 } |
| 1387 | 1350 |
| 1388 int tool_main(int argc, char** argv); | 1351 int tool_main(int argc, char** argv); |
| 1389 int tool_main(int argc, char** argv) { | 1352 int tool_main(int argc, char** argv) { |
| 1390 | 1353 |
| 1391 #if SK_ENABLE_INST_COUNT | 1354 #if SK_ENABLE_INST_COUNT |
| 1392 gPrintInstCount = true; | 1355 gPrintInstCount = true; |
| 1393 #endif | 1356 #endif |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1439 | 1402 |
| 1440 if (FLAGS_modulo.count() == 2) { | 1403 if (FLAGS_modulo.count() == 2) { |
| 1441 moduloRemainder = atoi(FLAGS_modulo[0]); | 1404 moduloRemainder = atoi(FLAGS_modulo[0]); |
| 1442 moduloDivisor = atoi(FLAGS_modulo[1]); | 1405 moduloDivisor = atoi(FLAGS_modulo[1]); |
| 1443 if (moduloRemainder < 0 || moduloDivisor <= 0 || moduloRemainder >= modu loDivisor) { | 1406 if (moduloRemainder < 0 || moduloDivisor <= 0 || moduloRemainder >= modu loDivisor) { |
| 1444 gm_fprintf(stderr, "invalid modulo values."); | 1407 gm_fprintf(stderr, "invalid modulo values."); |
| 1445 return -1; | 1408 return -1; |
| 1446 } | 1409 } |
| 1447 } | 1410 } |
| 1448 | 1411 |
| 1412 int gpuCacheSizeBytes = -1; // -1 means use the default | |
| 1413 int gpuCacheSizeCount = -1; // -1 means use the default | |
|
borenet
2013/03/22 13:53:29
To me, it feels like these are "escaping" their if
epoger
2013/03/22 14:31:23
There's plenty not to like here, including the mag
| |
| 1414 #if SK_SUPPORT_GPU | |
| 1415 if (FLAGS_gpuCacheSize.count() > 0) { | |
| 1416 if (FLAGS_gpuCacheSize.count() != 2) { | |
| 1417 gm_fprintf(stderr, "--gpuCacheSize requires two arguments\n"); | |
| 1418 return -1; | |
| 1419 } | |
| 1420 gpuCacheSizeBytes = atoi(FLAGS_gpuCacheSize[0]); | |
| 1421 gpuCacheSizeCount = atoi(FLAGS_gpuCacheSize[1]); | |
| 1422 } | |
| 1423 #endif | |
| 1424 | |
| 1425 SkTDArray<SkScalar> tileGridReplayScales; | |
| 1426 *tileGridReplayScales.append() = SK_Scalar1; // By default only test at scal e 1.0 | |
| 1427 if (FLAGS_tileGridReplayScales.count() > 0) { | |
| 1428 tileGridReplayScales.reset(); | |
| 1429 for (int i = 0; i < FLAGS_tileGridReplayScales.count(); i++) { | |
| 1430 double val = atof(FLAGS_tileGridReplayScales[i]); | |
| 1431 if (0 < val) { | |
| 1432 *tileGridReplayScales.append() = SkDoubleToScalar(val); | |
| 1433 } | |
| 1434 } | |
| 1435 if (0 == tileGridReplayScales.count()) { | |
| 1436 // Should have at least one scale | |
| 1437 gm_fprintf(stderr, "--tileGridReplayScales requires at least one sca le.\n"); | |
| 1438 return -1; | |
| 1439 } | |
| 1440 } | |
| 1441 | |
| 1449 if (!userConfig) { | 1442 if (!userConfig) { |
| 1450 // if no config is specified by user, add the defaults | 1443 // if no config is specified by user, add the defaults |
| 1451 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { | 1444 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { |
| 1452 if (gRec[i].fRunByDefault) { | 1445 if (gRec[i].fRunByDefault) { |
| 1453 *configs.append() = i; | 1446 *configs.append() = i; |
| 1454 } | 1447 } |
| 1455 } | 1448 } |
| 1456 } | 1449 } |
| 1457 // now remove any explicitly excluded configs | 1450 // now remove any explicitly excluded configs |
| 1458 for (int i = 0; i < excludeConfigs.count(); ++i) { | 1451 for (int i = 0; i < excludeConfigs.count(); ++i) { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1577 const char* shortName = gm->shortName(); | 1570 const char* shortName = gm->shortName(); |
| 1578 if (skip_name(FLAGS_match, shortName)) { | 1571 if (skip_name(FLAGS_match, shortName)) { |
| 1579 SkDELETE(gm); | 1572 SkDELETE(gm); |
| 1580 continue; | 1573 continue; |
| 1581 } | 1574 } |
| 1582 | 1575 |
| 1583 SkISize size = gm->getISize(); | 1576 SkISize size = gm->getISize(); |
| 1584 gm_fprintf(stdout, "%sdrawing... %s [%d %d]\n", moduloStr.c_str(), short Name, | 1577 gm_fprintf(stdout, "%sdrawing... %s [%d %d]\n", moduloStr.c_str(), short Name, |
| 1585 size.width(), size.height()); | 1578 size.width(), size.height()); |
| 1586 | 1579 |
| 1587 ErrorBitfield testErrors = kEmptyErrorBitfield; | 1580 ErrorCombination testErrors; |
| 1588 testErrors |= run_multiple_configs(gmmain, gm, configs, grFactory); | 1581 testErrors.add(run_multiple_configs(gmmain, gm, configs, grFactory, |
| 1582 gpuCacheSizeBytes, gpuCacheSizeCount )); | |
| 1589 | 1583 |
| 1590 SkBitmap comparisonBitmap; | 1584 SkBitmap comparisonBitmap; |
| 1591 const ConfigData compareConfig = | 1585 const ConfigData compareConfig = |
| 1592 { SkBitmap::kARGB_8888_Config, kRaster_Backend, kDontCare_GLContextT ype, 0, kRW_ConfigFlag, "comparison", false }; | 1586 { SkBitmap::kARGB_8888_Config, kRaster_Backend, kDontCare_GLContextT ype, 0, kRW_ConfigFlag, "comparison", false }; |
| 1593 testErrors |= gmmain.generate_image(gm, compareConfig, NULL, NULL, &comp arisonBitmap, false); | 1587 testErrors.add(gmmain.generate_image( |
| 1588 gm, compareConfig, NULL, NULL, &comparisonBitmap, false)); | |
| 1594 | 1589 |
| 1595 // TODO(epoger): only run this if gmmain.generate_image() succeeded? | 1590 // TODO(epoger): only run this if gmmain.generate_image() succeeded? |
| 1596 // Otherwise, what are we comparing against? | 1591 // Otherwise, what are we comparing against? |
| 1597 testErrors |= run_multiple_modes(gmmain, gm, compareConfig, comparisonBi tmap); | 1592 testErrors.add(run_multiple_modes(gmmain, gm, compareConfig, comparisonB itmap, |
| 1593 tileGridReplayScales)); | |
| 1598 | 1594 |
| 1599 // Update overall results. | 1595 // Update overall results. |
| 1600 // We only tabulate the particular error types that we currently | 1596 // We only tabulate the particular error types that we currently |
| 1601 // care about (e.g., missing reference images). Later on, if we | 1597 // care about (e.g., missing reference images). Later on, if we |
| 1602 // want to also tabulate other error types, we can do so. | 1598 // want to also tabulate other error types, we can do so. |
| 1603 testsRun++; | 1599 testsRun++; |
| 1604 if (!gmmain.fExpectationsSource.get() || | 1600 if (!gmmain.fExpectationsSource.get() || |
| 1605 (kEmptyErrorBitfield != (kMissingExpectations_ErrorBitmask & testErr ors))) { | 1601 (testErrors.includes(kMissingExpectations_ErrorType))) { |
| 1606 testsMissingReferenceImages++; | 1602 testsMissingReferenceImages++; |
| 1607 } | 1603 } |
| 1608 if (testErrors == (testErrors & kIgnorable_ErrorBitmask)) { | 1604 if (testErrors.minus(gmmain.fIgnorableErrorCombination).isEmpty()) { |
| 1609 testsPassed++; | 1605 testsPassed++; |
| 1610 } else { | 1606 } else { |
| 1611 testsFailed++; | 1607 testsFailed++; |
| 1612 } | 1608 } |
| 1613 | 1609 |
| 1614 SkDELETE(gm); | 1610 SkDELETE(gm); |
| 1615 } | 1611 } |
| 1616 gm_fprintf(stdout, "Ran %d tests: %d passed, %d failed, %d missing reference images\n", | 1612 gm_fprintf(stdout, "Ran %d tests: %d passed, %d failed, %d missing reference images\n", |
| 1617 testsRun, testsPassed, testsFailed, testsMissingReferenceImages); | 1613 testsRun, testsPassed, testsFailed, testsMissingReferenceImages); |
| 1618 gmmain.ListErrors(); | 1614 gmmain.ListErrors(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1661 if (FLAGS_forceBWtext) { | 1657 if (FLAGS_forceBWtext) { |
| 1662 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 1658 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
| 1663 } | 1659 } |
| 1664 } | 1660 } |
| 1665 | 1661 |
| 1666 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 1662 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 1667 int main(int argc, char * const argv[]) { | 1663 int main(int argc, char * const argv[]) { |
| 1668 return tool_main(argc, (char**) argv); | 1664 return tool_main(argc, (char**) argv); |
| 1669 } | 1665 } |
| 1670 #endif | 1666 #endif |
| OLD | NEW |