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 * |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 | 185 |
| 186 const static ErrorCombination kDefaultIgnorableErrorTypes = ErrorCombination() | 186 const static ErrorCombination kDefaultIgnorableErrorTypes = ErrorCombination() |
| 187 .plus(kMissingExpectations_ErrorType) | 187 .plus(kMissingExpectations_ErrorType) |
| 188 .plus(kIntentionallySkipped_ErrorType); | 188 .plus(kIntentionallySkipped_ErrorType); |
| 189 | 189 |
| 190 class GMMain { | 190 class GMMain { |
| 191 public: | 191 public: |
| 192 GMMain() : fUseFileHierarchy(false), fIgnorableErrorTypes(kDefaultIgnorableE rrorTypes), | 192 GMMain() : fUseFileHierarchy(false), fIgnorableErrorTypes(kDefaultIgnorableE rrorTypes), |
| 193 fMismatchPath(NULL), fTestsRun(0), fRenderModesEncountered(1) {} | 193 fMismatchPath(NULL), fTestsRun(0), fRenderModesEncountered(1) {} |
| 194 | 194 |
| 195 SkString make_name(const char shortName[], const char configName[]) { | 195 SkString make_filename(const char *path, |
| 196 const char *renderModeDescriptor, | |
| 197 const char *shortNamePlusConfig, | |
| 198 const char *suffix) { | |
| 199 SkString filename(shortNamePlusConfig); | |
| 200 filename.append(renderModeDescriptor); | |
| 201 filename.appendUnichar('.'); | |
| 202 filename.append(suffix); | |
| 203 return SkPathJoin(path, filename.c_str()); | |
| 204 } | |
| 205 | |
| 206 /** | |
| 207 * Assemble shortNamePlusConfig from (surprise!) shortName and configName. | |
| 208 * | |
| 209 * The method for doing so depends on whether we are using hierarchical nami ng. | |
| 210 * For example, shortName "selftest1" and configName "8888" could be assembl ed into | |
| 211 * either "selftest1_8888" or "8888/selftest1". | |
| 212 */ | |
| 213 SkString make_shortname_plus_config(const char *shortName, const char *confi gName) { | |
|
epoger
2013/05/19 09:00:43
Patchset 2 renames some variables, parameters, and
| |
| 196 SkString name; | 214 SkString name; |
| 197 if (0 == strlen(configName)) { | 215 if (0 == strlen(configName)) { |
| 198 name.append(shortName); | 216 name.append(shortName); |
| 199 } else if (fUseFileHierarchy) { | 217 } else if (fUseFileHierarchy) { |
| 200 name.appendf("%s%c%s", configName, SkPATH_SEPARATOR, shortName); | 218 name.appendf("%s%c%s", configName, SkPATH_SEPARATOR, shortName); |
| 201 } else { | 219 } else { |
| 202 name.appendf("%s_%s", shortName, configName); | 220 name.appendf("%s_%s", shortName, configName); |
| 203 } | 221 } |
| 204 return name; | 222 return name; |
| 205 } | 223 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 } | 280 } |
| 263 } | 281 } |
| 264 } | 282 } |
| 265 | 283 |
| 266 /** | 284 /** |
| 267 * Records the results of this test in fTestsRun and fFailedTests. | 285 * Records the results of this test in fTestsRun and fFailedTests. |
| 268 * | 286 * |
| 269 * We even record successes, and errors that we regard as | 287 * We even record successes, and errors that we regard as |
| 270 * "ignorable"; we can filter them out later. | 288 * "ignorable"; we can filter them out later. |
| 271 */ | 289 */ |
| 272 void RecordTestResults(const ErrorCombination& errorCombination, const SkStr ing& name, | 290 void RecordTestResults(const ErrorCombination& errorCombination, |
| 291 const SkString& shortNamePlusConfig, | |
| 273 const char renderModeDescriptor []) { | 292 const char renderModeDescriptor []) { |
| 274 // Things to do regardless of errorCombination. | 293 // Things to do regardless of errorCombination. |
| 275 fTestsRun++; | 294 fTestsRun++; |
| 276 int renderModeCount = 0; | 295 int renderModeCount = 0; |
| 277 this->fRenderModesEncountered.find(renderModeDescriptor, &renderModeCoun t); | 296 this->fRenderModesEncountered.find(renderModeDescriptor, &renderModeCoun t); |
| 278 renderModeCount++; | 297 renderModeCount++; |
| 279 this->fRenderModesEncountered.set(renderModeDescriptor, renderModeCount) ; | 298 this->fRenderModesEncountered.set(renderModeDescriptor, renderModeCount) ; |
| 280 | 299 |
| 281 if (errorCombination.isEmpty()) { | 300 if (errorCombination.isEmpty()) { |
| 282 return; | 301 return; |
| 283 } | 302 } |
| 284 | 303 |
| 285 // Things to do only if there is some error condition. | 304 // Things to do only if there is some error condition. |
| 286 SkString fullName = name; | 305 SkString fullName = shortNamePlusConfig; |
| 287 fullName.append(renderModeDescriptor); | 306 fullName.append(renderModeDescriptor); |
| 288 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { | 307 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { |
| 289 ErrorType type = static_cast<ErrorType>(typeInt); | 308 ErrorType type = static_cast<ErrorType>(typeInt); |
| 290 if (errorCombination.includes(type)) { | 309 if (errorCombination.includes(type)) { |
| 291 fFailedTests[type].push_back(fullName); | 310 fFailedTests[type].push_back(fullName); |
| 292 } | 311 } |
| 293 } | 312 } |
| 294 } | 313 } |
| 295 | 314 |
| 296 /** | 315 /** |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 596 dev->beginPortfolio(&xps); | 615 dev->beginPortfolio(&xps); |
| 597 dev->beginSheet(unitsPerMeter, pixelsPerMeter, trimSize); | 616 dev->beginSheet(unitsPerMeter, pixelsPerMeter, trimSize); |
| 598 invokeGM(gm, &c, false, false); | 617 invokeGM(gm, &c, false, false); |
| 599 dev->endSheet(); | 618 dev->endSheet(); |
| 600 dev->endPortfolio(); | 619 dev->endPortfolio(); |
| 601 | 620 |
| 602 #endif | 621 #endif |
| 603 } | 622 } |
| 604 | 623 |
| 605 ErrorCombination write_reference_image(const ConfigData& gRec, const char wr itePath [], | 624 ErrorCombination write_reference_image(const ConfigData& gRec, const char wr itePath [], |
| 606 const char renderModeDescriptor [], c onst SkString& name, | 625 const char renderModeDescriptor [], |
| 626 const SkString& shortNamePlusConfig, | |
| 607 SkBitmap& bitmap, SkDynamicMemoryWStr eam* document) { | 627 SkBitmap& bitmap, SkDynamicMemoryWStr eam* document) { |
| 608 SkString path; | 628 SkString path; |
| 609 bool success = false; | 629 bool success = false; |
| 610 if (gRec.fBackend == kRaster_Backend || | 630 if (gRec.fBackend == kRaster_Backend || |
| 611 gRec.fBackend == kGPU_Backend || | 631 gRec.fBackend == kGPU_Backend || |
| 612 (gRec.fBackend == kPDF_Backend && CAN_IMAGE_PDF)) { | 632 (gRec.fBackend == kPDF_Backend && CAN_IMAGE_PDF)) { |
| 613 | 633 |
| 614 path = make_filename(writePath, renderModeDescriptor, name.c_str(), | 634 path = make_filename(writePath, renderModeDescriptor, shortNamePlusC onfig.c_str(), |
| 615 kPNG_FileExtension); | 635 kPNG_FileExtension); |
| 616 success = write_bitmap(path, bitmap); | 636 success = write_bitmap(path, bitmap); |
| 617 } | 637 } |
| 618 if (kPDF_Backend == gRec.fBackend) { | 638 if (kPDF_Backend == gRec.fBackend) { |
| 619 path = make_filename(writePath, renderModeDescriptor, name.c_str(), | 639 path = make_filename(writePath, renderModeDescriptor, shortNamePlusC onfig.c_str(), |
| 620 "pdf"); | 640 "pdf"); |
| 621 success = write_document(path, *document); | 641 success = write_document(path, *document); |
| 622 } | 642 } |
| 623 if (kXPS_Backend == gRec.fBackend) { | 643 if (kXPS_Backend == gRec.fBackend) { |
| 624 path = make_filename(writePath, renderModeDescriptor, name.c_str(), | 644 path = make_filename(writePath, renderModeDescriptor, shortNamePlusC onfig.c_str(), |
| 625 "xps"); | 645 "xps"); |
| 626 success = write_document(path, *document); | 646 success = write_document(path, *document); |
| 627 } | 647 } |
| 628 if (success) { | 648 if (success) { |
| 629 return kEmpty_ErrorCombination; | 649 return kEmpty_ErrorCombination; |
| 630 } else { | 650 } else { |
| 631 gm_fprintf(stderr, "FAILED to write %s\n", path.c_str()); | 651 gm_fprintf(stderr, "FAILED to write %s\n", path.c_str()); |
| 632 ErrorCombination errors(kWritingReferenceImage_ErrorType); | 652 ErrorCombination errors(kWritingReferenceImage_ErrorType); |
| 633 // TODO(epoger): Don't call RecordTestResults() here... | 653 // TODO(epoger): Don't call RecordTestResults() here... |
| 634 // Instead, we should make sure to call RecordTestResults | 654 // Instead, we should make sure to call RecordTestResults |
| 635 // exactly ONCE per test. (Otherwise, gmmain.fTestsRun | 655 // exactly ONCE per test. (Otherwise, gmmain.fTestsRun |
| 636 // will be incremented twice for this test: once in | 656 // will be incremented twice for this test: once in |
| 637 // compare_test_results_to_stored_expectations() before | 657 // compare_test_results_to_stored_expectations() before |
| 638 // that method calls this one, and again here.) | 658 // that method calls this one, and again here.) |
| 639 // | 659 // |
| 640 // When we make that change, we should probably add a | 660 // When we make that change, we should probably add a |
| 641 // WritingReferenceImage test to the gm self-tests.) | 661 // WritingReferenceImage test to the gm self-tests.) |
| 642 RecordTestResults(errors, name, renderModeDescriptor); | 662 RecordTestResults(errors, shortNamePlusConfig, renderModeDescriptor) ; |
| 643 return errors; | 663 return errors; |
| 644 } | 664 } |
| 645 } | 665 } |
| 646 | 666 |
| 647 /** | 667 /** |
| 648 * Log more detail about the mistmatch between expectedBitmap and | 668 * Log more detail about the mistmatch between expectedBitmap and |
| 649 * actualBitmap. | 669 * actualBitmap. |
| 650 */ | 670 */ |
| 651 void report_bitmap_diffs(const SkBitmap& expectedBitmap, const SkBitmap& act ualBitmap, | 671 void report_bitmap_diffs(const SkBitmap& expectedBitmap, const SkBitmap& act ualBitmap, |
| 652 const char *testName) { | 672 const char *testName) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 702 | 722 |
| 703 /** | 723 /** |
| 704 * Compares actual hash digest to expectations, returning the set of errors | 724 * Compares actual hash digest to expectations, returning the set of errors |
| 705 * (if any) that we saw along the way. | 725 * (if any) that we saw along the way. |
| 706 * | 726 * |
| 707 * If fMismatchPath has been set, and there are pixel diffs, then the | 727 * If fMismatchPath has been set, and there are pixel diffs, then the |
| 708 * actual bitmap will be written out to a file within fMismatchPath. | 728 * actual bitmap will be written out to a file within fMismatchPath. |
| 709 * | 729 * |
| 710 * @param expectations what expectations to compare actualBitmap against | 730 * @param expectations what expectations to compare actualBitmap against |
| 711 * @param actualBitmap the image we actually generated | 731 * @param actualBitmap the image we actually generated |
| 712 * @param baseNameString name of test without renderModeDescriptor added | 732 * @param shortNamePlusConfig name of test without renderModeDescriptor adde d |
| 713 * @param renderModeDescriptor e.g., "-rtree", "-deferred" | 733 * @param renderModeDescriptor e.g., "-rtree", "-deferred" |
| 714 * @param addToJsonSummary whether to add these results (both actual and | 734 * @param addToJsonSummary whether to add these results (both actual and |
| 715 * expected) to the JSON summary. Regardless of this setting, if | 735 * expected) to the JSON summary. Regardless of this setting, if |
| 716 * we find an image mismatch in this test, we will write these | 736 * we find an image mismatch in this test, we will write these |
| 717 * results to the JSON summary. (This is so that we will always | 737 * results to the JSON summary. (This is so that we will always |
| 718 * report errors across rendering modes, such as pipe vs tiled. | 738 * report errors across rendering modes, such as pipe vs tiled. |
| 719 * See https://codereview.chromium.org/13650002/ ) | 739 * See https://codereview.chromium.org/13650002/ ) |
| 720 */ | 740 */ |
| 721 ErrorCombination compare_to_expectations(Expectations expectations, | 741 ErrorCombination compare_to_expectations(Expectations expectations, |
| 722 const SkBitmap& actualBitmap, | 742 const SkBitmap& actualBitmap, |
| 723 const SkString& baseNameString, | 743 const SkString& shortNamePlusConfig , |
| 724 const char renderModeDescriptor[], | 744 const char renderModeDescriptor[], |
| 725 bool addToJsonSummary) { | 745 bool addToJsonSummary) { |
| 726 ErrorCombination errors; | 746 ErrorCombination errors; |
| 727 SkHashDigest actualBitmapHash; | 747 SkHashDigest actualBitmapHash; |
| 728 // TODO(epoger): Better handling for error returned by ComputeDigest()? | 748 // TODO(epoger): Better handling for error returned by ComputeDigest()? |
| 729 // For now, we just report a digest of 0 in error cases, like before. | 749 // For now, we just report a digest of 0 in error cases, like before. |
| 730 if (!SkBitmapHasher::ComputeDigest(actualBitmap, &actualBitmapHash)) { | 750 if (!SkBitmapHasher::ComputeDigest(actualBitmap, &actualBitmapHash)) { |
| 731 actualBitmapHash = 0; | 751 actualBitmapHash = 0; |
| 732 } | 752 } |
| 733 SkString completeNameString = baseNameString; | 753 SkString completeNameString = shortNamePlusConfig; |
| 734 completeNameString.append(renderModeDescriptor); | 754 completeNameString.append(renderModeDescriptor); |
| 735 completeNameString.append("."); | 755 completeNameString.append("."); |
| 736 completeNameString.append(kPNG_FileExtension); | 756 completeNameString.append(kPNG_FileExtension); |
| 737 const char* completeName = completeNameString.c_str(); | 757 const char* completeName = completeNameString.c_str(); |
| 738 | 758 |
| 739 if (expectations.empty()) { | 759 if (expectations.empty()) { |
| 740 errors.add(kMissingExpectations_ErrorType); | 760 errors.add(kMissingExpectations_ErrorType); |
| 741 } else if (!expectations.match(actualBitmapHash)) { | 761 } else if (!expectations.match(actualBitmapHash)) { |
| 742 addToJsonSummary = true; | 762 addToJsonSummary = true; |
| 743 // The error mode we record depends on whether this was running | 763 // The error mode we record depends on whether this was running |
| 744 // in a non-standard renderMode. | 764 // in a non-standard renderMode. |
| 745 if ('\0' == *renderModeDescriptor) { | 765 if ('\0' == *renderModeDescriptor) { |
| 746 errors.add(kExpectationsMismatch_ErrorType); | 766 errors.add(kExpectationsMismatch_ErrorType); |
| 747 } else { | 767 } else { |
| 748 errors.add(kRenderModeMismatch_ErrorType); | 768 errors.add(kRenderModeMismatch_ErrorType); |
| 749 } | 769 } |
| 750 | 770 |
| 751 // Write out the "actuals" for any mismatches, if we have | 771 // Write out the "actuals" for any mismatches, if we have |
| 752 // been directed to do so. | 772 // been directed to do so. |
| 753 if (fMismatchPath) { | 773 if (fMismatchPath) { |
| 754 SkString path = | 774 SkString path = |
| 755 make_filename(fMismatchPath, renderModeDescriptor, | 775 make_filename(fMismatchPath, renderModeDescriptor, |
| 756 baseNameString.c_str(), kPNG_FileExtension); | 776 shortNamePlusConfig.c_str(), kPNG_FileExtensio n); |
| 757 write_bitmap(path, actualBitmap); | 777 write_bitmap(path, actualBitmap); |
| 758 } | 778 } |
| 759 | 779 |
| 760 // If we have access to a single expected bitmap, log more | 780 // If we have access to a single expected bitmap, log more |
| 761 // detail about the mismatch. | 781 // detail about the mismatch. |
| 762 const SkBitmap *expectedBitmapPtr = expectations.asBitmap(); | 782 const SkBitmap *expectedBitmapPtr = expectations.asBitmap(); |
| 763 if (NULL != expectedBitmapPtr) { | 783 if (NULL != expectedBitmapPtr) { |
| 764 report_bitmap_diffs(*expectedBitmapPtr, actualBitmap, completeNa me); | 784 report_bitmap_diffs(*expectedBitmapPtr, actualBitmap, completeNa me); |
| 765 } | 785 } |
| 766 } | 786 } |
| 767 RecordTestResults(errors, baseNameString, renderModeDescriptor); | 787 RecordTestResults(errors, shortNamePlusConfig, renderModeDescriptor); |
| 768 | 788 |
| 769 if (addToJsonSummary) { | 789 if (addToJsonSummary) { |
| 770 add_actual_results_to_json_summary(completeName, actualBitmapHash, e rrors, | 790 add_actual_results_to_json_summary(completeName, actualBitmapHash, e rrors, |
| 771 expectations.ignoreFailure()); | 791 expectations.ignoreFailure()); |
| 772 add_expected_results_to_json_summary(completeName, expectations); | 792 add_expected_results_to_json_summary(completeName, expectations); |
| 773 } | 793 } |
| 774 | 794 |
| 775 return errors; | 795 return errors; |
| 776 } | 796 } |
| 777 | 797 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 835 * @param gRec | 855 * @param gRec |
| 836 * @param writePath unless this is NULL, write out actual images into this | 856 * @param writePath unless this is NULL, write out actual images into this |
| 837 * directory | 857 * directory |
| 838 * @param actualBitmap bitmap generated by this run | 858 * @param actualBitmap bitmap generated by this run |
| 839 * @param pdf | 859 * @param pdf |
| 840 */ | 860 */ |
| 841 ErrorCombination compare_test_results_to_stored_expectations( | 861 ErrorCombination compare_test_results_to_stored_expectations( |
| 842 GM* gm, const ConfigData& gRec, const char writePath[], | 862 GM* gm, const ConfigData& gRec, const char writePath[], |
| 843 SkBitmap& actualBitmap, SkDynamicMemoryWStream* pdf) { | 863 SkBitmap& actualBitmap, SkDynamicMemoryWStream* pdf) { |
| 844 | 864 |
| 845 SkString name = make_name(gm->shortName(), gRec.fName); | 865 SkString shortNamePlusConfig = make_shortname_plus_config(gm->shortName( ), gRec.fName); |
| 866 SkString nameWithExtension(shortNamePlusConfig); | |
| 867 nameWithExtension.append("."); | |
| 868 nameWithExtension.append(kPNG_FileExtension); | |
| 869 | |
| 846 ErrorCombination errors; | 870 ErrorCombination errors; |
| 847 | |
| 848 ExpectationsSource *expectationsSource = this->fExpectationsSource.get() ; | 871 ExpectationsSource *expectationsSource = this->fExpectationsSource.get() ; |
| 849 if (expectationsSource && (gRec.fFlags & kRead_ConfigFlag)) { | 872 if (expectationsSource && (gRec.fFlags & kRead_ConfigFlag)) { |
| 850 /* | 873 /* |
| 851 * Get the expected results for this test, as one or more allowed | 874 * Get the expected results for this test, as one or more allowed |
| 852 * hash digests. The current implementation of expectationsSource | 875 * hash digests. The current implementation of expectationsSource |
| 853 * get this by computing the hash digest of a single PNG file on dis k. | 876 * get this by computing the hash digest of a single PNG file on dis k. |
| 854 * | 877 * |
| 855 * TODO(epoger): This relies on the fact that | 878 * TODO(epoger): This relies on the fact that |
| 856 * force_all_opaque() was called on the bitmap before it | 879 * force_all_opaque() was called on the bitmap before it |
| 857 * was written to disk as a PNG in the first place. If | 880 * was written to disk as a PNG in the first place. If |
| 858 * not, the hash digest returned here may not match the | 881 * not, the hash digest returned here may not match the |
| 859 * hash digest of actualBitmap, which *has* been run through | 882 * hash digest of actualBitmap, which *has* been run through |
| 860 * force_all_opaque(). | 883 * force_all_opaque(). |
| 861 * See comments above complete_bitmap() for more detail. | 884 * See comments above complete_bitmap() for more detail. |
| 862 */ | 885 */ |
| 863 SkString nameWithExtension(name); | |
| 864 nameWithExtension.append("."); | |
| 865 nameWithExtension.append(kPNG_FileExtension); | |
| 866 Expectations expectations = expectationsSource->get(nameWithExtensio n.c_str()); | 886 Expectations expectations = expectationsSource->get(nameWithExtensio n.c_str()); |
| 867 errors.add(compare_to_expectations(expectations, actualBitmap, | 887 errors.add(compare_to_expectations(expectations, actualBitmap, |
| 868 name, "", true)); | 888 shortNamePlusConfig, "", true)); |
| 869 } else { | 889 } else { |
| 870 // If we are running without expectations, we still want to | 890 // If we are running without expectations, we still want to |
| 871 // record the actual results. | 891 // record the actual results. |
| 872 SkHashDigest actualBitmapHash; | 892 SkHashDigest actualBitmapHash; |
| 873 // TODO(epoger): Better handling for error returned by ComputeDigest ()? | 893 // TODO(epoger): Better handling for error returned by ComputeDigest ()? |
| 874 // For now, we just report a digest of 0 in error cases, like before . | 894 // For now, we just report a digest of 0 in error cases, like before . |
| 875 if (!SkBitmapHasher::ComputeDigest(actualBitmap, &actualBitmapHash)) { | 895 if (!SkBitmapHasher::ComputeDigest(actualBitmap, &actualBitmapHash)) { |
| 876 actualBitmapHash = 0; | 896 actualBitmapHash = 0; |
| 877 } | 897 } |
| 878 SkString nameWithExtension(name); | |
| 879 nameWithExtension.append("."); | |
| 880 nameWithExtension.append(kPNG_FileExtension); | |
| 881 add_actual_results_to_json_summary(nameWithExtension.c_str(), actual BitmapHash, | 898 add_actual_results_to_json_summary(nameWithExtension.c_str(), actual BitmapHash, |
| 882 ErrorCombination(kMissingExpectat ions_ErrorType), | 899 ErrorCombination(kMissingExpectat ions_ErrorType), |
| 883 false); | 900 false); |
| 884 RecordTestResults(ErrorCombination(kMissingExpectations_ErrorType), name, ""); | 901 RecordTestResults(ErrorCombination(kMissingExpectations_ErrorType), |
| 902 shortNamePlusConfig, ""); | |
| 885 } | 903 } |
| 886 | 904 |
| 887 // TODO: Consider moving this into compare_to_expectations(), | 905 // TODO: Consider moving this into compare_to_expectations(), |
| 888 // similar to fMismatchPath... for now, we don't do that, because | 906 // similar to fMismatchPath... for now, we don't do that, because |
| 889 // we don't want to write out the actual bitmaps for all | 907 // we don't want to write out the actual bitmaps for all |
| 890 // renderModes of all tests! That would be a lot of files. | 908 // renderModes of all tests! That would be a lot of files. |
| 891 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { | 909 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { |
| 892 errors.add(write_reference_image(gRec, writePath, "", | 910 errors.add(write_reference_image(gRec, writePath, "", |
| 893 name, actualBitmap, pdf)); | 911 shortNamePlusConfig, actualBitmap, pdf)); |
| 894 } | 912 } |
| 895 | 913 |
| 896 return errors; | 914 return errors; |
| 897 } | 915 } |
| 898 | 916 |
| 899 /** | 917 /** |
| 900 * Compare actualBitmap to referenceBitmap. | 918 * Compare actualBitmap to referenceBitmap. |
| 901 * | 919 * |
| 902 * @param baseNameString name of test without renderModeDescriptor added | 920 * @param shortNamePlusConfig name of test without renderModeDescriptor adde d |
| 903 * @param renderModeDescriptor | 921 * @param renderModeDescriptor |
| 904 * @param actualBitmap actual bitmap generated by this run | 922 * @param actualBitmap actual bitmap generated by this run |
| 905 * @param referenceBitmap bitmap we expected to be generated | 923 * @param referenceBitmap bitmap we expected to be generated |
| 906 */ | 924 */ |
| 907 ErrorCombination compare_test_results_to_reference_bitmap( | 925 ErrorCombination compare_test_results_to_reference_bitmap( |
| 908 const SkString& baseNameString, const char renderModeDescriptor[], | 926 const SkString& shortNamePlusConfig, const char renderModeDescriptor[], |
| 909 SkBitmap& actualBitmap, const SkBitmap* referenceBitmap) { | 927 SkBitmap& actualBitmap, const SkBitmap* referenceBitmap) { |
| 910 | 928 |
| 911 SkASSERT(referenceBitmap); | 929 SkASSERT(referenceBitmap); |
| 912 Expectations expectations(*referenceBitmap); | 930 Expectations expectations(*referenceBitmap); |
| 913 return compare_to_expectations(expectations, actualBitmap, | 931 return compare_to_expectations(expectations, actualBitmap, |
| 914 baseNameString, renderModeDescriptor, fal se); | 932 shortNamePlusConfig, renderModeDescriptor , false); |
| 915 } | 933 } |
| 916 | 934 |
| 917 static SkPicture* generate_new_picture(GM* gm, BbhType bbhType, uint32_t rec ordFlags, | 935 static SkPicture* generate_new_picture(GM* gm, BbhType bbhType, uint32_t rec ordFlags, |
| 918 SkScalar scale = SK_Scalar1) { | 936 SkScalar scale = SK_Scalar1) { |
| 919 // Pictures are refcounted so must be on heap | 937 // Pictures are refcounted so must be on heap |
| 920 SkPicture* pict; | 938 SkPicture* pict; |
| 921 int width = SkScalarCeilToInt(SkScalarMul(SkIntToScalar(gm->getISize().w idth()), scale)); | 939 int width = SkScalarCeilToInt(SkScalarMul(SkIntToScalar(gm->getISize().w idth()), scale)); |
| 922 int height = SkScalarCeilToInt(SkScalarMul(SkIntToScalar(gm->getISize(). height()), scale)); | 940 int height = SkScalarCeilToInt(SkScalarMul(SkIntToScalar(gm->getISize(). height()), scale)); |
| 923 | 941 |
| 924 if (kTileGrid_BbhType == bbhType) { | 942 if (kTileGrid_BbhType == bbhType) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1021 // https://codereview.chromium.org/12992003/ is unblocked. | 1039 // https://codereview.chromium.org/12992003/ is unblocked. |
| 1022 // | 1040 // |
| 1023 // Filed as https://code.google.com/p/skia/issues/detail?id=1180 | 1041 // Filed as https://code.google.com/p/skia/issues/detail?id=1180 |
| 1024 // ('image-surface gm test is failing in "deferred" mode, | 1042 // ('image-surface gm test is failing in "deferred" mode, |
| 1025 // and gm is not reporting the failure') | 1043 // and gm is not reporting the failure') |
| 1026 if (errors.isEmpty()) { | 1044 if (errors.isEmpty()) { |
| 1027 // TODO(epoger): Report this as a new ErrorType, | 1045 // TODO(epoger): Report this as a new ErrorType, |
| 1028 // something like kImageGeneration_ErrorType? | 1046 // something like kImageGeneration_ErrorType? |
| 1029 return kEmpty_ErrorCombination; | 1047 return kEmpty_ErrorCombination; |
| 1030 } | 1048 } |
| 1031 const SkString name = make_name(gm->shortName(), gRec.fName); | 1049 const SkString shortNamePlusConfig = make_shortname_plus_config(gm-> shortName(), |
| 1050 gRec .fName); | |
| 1032 return compare_test_results_to_reference_bitmap( | 1051 return compare_test_results_to_reference_bitmap( |
| 1033 name, renderModeDescriptor, bitmap, &referenceBitmap); | 1052 shortNamePlusConfig, renderModeDescriptor, bitmap, &referenceBit map); |
| 1034 } | 1053 } |
| 1035 return kEmpty_ErrorCombination; | 1054 return kEmpty_ErrorCombination; |
| 1036 } | 1055 } |
| 1037 | 1056 |
| 1038 ErrorCombination test_pipe_playback(GM* gm, const ConfigData& gRec, | 1057 ErrorCombination test_pipe_playback(GM* gm, const ConfigData& gRec, |
| 1039 const SkBitmap& referenceBitmap, bool si mulateFailure) { | 1058 const SkBitmap& referenceBitmap, bool si mulateFailure) { |
| 1040 const SkString name = make_name(gm->shortName(), gRec.fName); | 1059 const SkString shortNamePlusConfig = make_shortname_plus_config(gm->shor tName(), |
| 1060 gRec.fNa me); | |
| 1041 ErrorCombination errors; | 1061 ErrorCombination errors; |
| 1042 for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) { | 1062 for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) { |
| 1043 SkString renderModeDescriptor("-pipe"); | 1063 SkString renderModeDescriptor("-pipe"); |
| 1044 renderModeDescriptor.append(gPipeWritingFlagCombos[i].name); | 1064 renderModeDescriptor.append(gPipeWritingFlagCombos[i].name); |
| 1045 | 1065 |
| 1046 if (gm->getFlags() & GM::kSkipPipe_Flag) { | 1066 if (gm->getFlags() & GM::kSkipPipe_Flag) { |
| 1047 RecordTestResults(kIntentionallySkipped_ErrorType, name, | 1067 RecordTestResults(kIntentionallySkipped_ErrorType, shortNamePlus Config, |
| 1048 renderModeDescriptor.c_str()); | 1068 renderModeDescriptor.c_str()); |
| 1049 errors.add(kIntentionallySkipped_ErrorType); | 1069 errors.add(kIntentionallySkipped_ErrorType); |
| 1050 } else { | 1070 } else { |
| 1051 SkBitmap bitmap; | 1071 SkBitmap bitmap; |
| 1052 SkISize size = gm->getISize(); | 1072 SkISize size = gm->getISize(); |
| 1053 setup_bitmap(gRec, size, &bitmap); | 1073 setup_bitmap(gRec, size, &bitmap); |
| 1054 SkCanvas canvas(bitmap); | 1074 SkCanvas canvas(bitmap); |
| 1055 installFilter(&canvas); | 1075 installFilter(&canvas); |
| 1056 // Pass a decoding function so the factory GM (which has an SkBi tmap | 1076 // Pass a decoding function so the factory GM (which has an SkBi tmap |
| 1057 // with encoded data) will not fail playback. | 1077 // with encoded data) will not fail playback. |
| 1058 PipeController pipeController(&canvas, &SkImageDecoder::DecodeMe mory); | 1078 PipeController pipeController(&canvas, &SkImageDecoder::DecodeMe mory); |
| 1059 SkGPipeWriter writer; | 1079 SkGPipeWriter writer; |
| 1060 SkCanvas* pipeCanvas = writer.startRecording(&pipeController, | 1080 SkCanvas* pipeCanvas = writer.startRecording(&pipeController, |
| 1061 gPipeWritingFlagCom bos[i].flags, | 1081 gPipeWritingFlagCom bos[i].flags, |
| 1062 size.width(), size. height()); | 1082 size.width(), size. height()); |
| 1063 if (!simulateFailure) { | 1083 if (!simulateFailure) { |
| 1064 invokeGM(gm, pipeCanvas, false, false); | 1084 invokeGM(gm, pipeCanvas, false, false); |
| 1065 } | 1085 } |
| 1066 complete_bitmap(&bitmap); | 1086 complete_bitmap(&bitmap); |
| 1067 writer.endRecording(); | 1087 writer.endRecording(); |
| 1068 errors.add(compare_test_results_to_reference_bitmap( | 1088 errors.add(compare_test_results_to_reference_bitmap( |
| 1069 name, renderModeDescriptor.c_str(), bitmap, &referenceBitmap )); | 1089 shortNamePlusConfig, renderModeDescriptor.c_str(), bitmap, & referenceBitmap)); |
| 1070 if (!errors.isEmpty()) { | 1090 if (!errors.isEmpty()) { |
| 1071 break; | 1091 break; |
| 1072 } | 1092 } |
| 1073 } | 1093 } |
| 1074 } | 1094 } |
| 1075 return errors; | 1095 return errors; |
| 1076 } | 1096 } |
| 1077 | 1097 |
| 1078 ErrorCombination test_tiled_pipe_playback(GM* gm, const ConfigData& gRec, | 1098 ErrorCombination test_tiled_pipe_playback(GM* gm, const ConfigData& gRec, |
| 1079 const SkBitmap& referenceBitmap) { | 1099 const SkBitmap& referenceBitmap) { |
| 1080 const SkString name = make_name(gm->shortName(), gRec.fName); | 1100 const SkString shortNamePlusConfig = make_shortname_plus_config(gm->shor tName(), |
| 1101 gRec.fNa me); | |
| 1081 ErrorCombination errors; | 1102 ErrorCombination errors; |
| 1082 for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) { | 1103 for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) { |
| 1083 SkString renderModeDescriptor("-tiled pipe"); | 1104 SkString renderModeDescriptor("-tiled pipe"); |
| 1084 renderModeDescriptor.append(gPipeWritingFlagCombos[i].name); | 1105 renderModeDescriptor.append(gPipeWritingFlagCombos[i].name); |
| 1085 | 1106 |
| 1086 if ((gm->getFlags() & GM::kSkipPipe_Flag) || | 1107 if ((gm->getFlags() & GM::kSkipPipe_Flag) || |
| 1087 (gm->getFlags() & GM::kSkipTiled_Flag)) { | 1108 (gm->getFlags() & GM::kSkipTiled_Flag)) { |
| 1088 RecordTestResults(kIntentionallySkipped_ErrorType, name, | 1109 RecordTestResults(kIntentionallySkipped_ErrorType, shortNamePlus Config, |
| 1089 renderModeDescriptor.c_str()); | 1110 renderModeDescriptor.c_str()); |
| 1090 errors.add(kIntentionallySkipped_ErrorType); | 1111 errors.add(kIntentionallySkipped_ErrorType); |
| 1091 } else { | 1112 } else { |
| 1092 SkBitmap bitmap; | 1113 SkBitmap bitmap; |
| 1093 SkISize size = gm->getISize(); | 1114 SkISize size = gm->getISize(); |
| 1094 setup_bitmap(gRec, size, &bitmap); | 1115 setup_bitmap(gRec, size, &bitmap); |
| 1095 SkCanvas canvas(bitmap); | 1116 SkCanvas canvas(bitmap); |
| 1096 installFilter(&canvas); | 1117 installFilter(&canvas); |
| 1097 TiledPipeController pipeController(bitmap, &SkImageDecoder::Deco deMemory); | 1118 TiledPipeController pipeController(bitmap, &SkImageDecoder::Deco deMemory); |
| 1098 SkGPipeWriter writer; | 1119 SkGPipeWriter writer; |
| 1099 SkCanvas* pipeCanvas = writer.startRecording(&pipeController, | 1120 SkCanvas* pipeCanvas = writer.startRecording(&pipeController, |
| 1100 gPipeWritingFlagCom bos[i].flags, | 1121 gPipeWritingFlagCom bos[i].flags, |
| 1101 size.width(), size. height()); | 1122 size.width(), size. height()); |
| 1102 invokeGM(gm, pipeCanvas, false, false); | 1123 invokeGM(gm, pipeCanvas, false, false); |
| 1103 complete_bitmap(&bitmap); | 1124 complete_bitmap(&bitmap); |
| 1104 writer.endRecording(); | 1125 writer.endRecording(); |
| 1105 errors.add(compare_test_results_to_reference_bitmap(name, | 1126 errors.add(compare_test_results_to_reference_bitmap(shortNamePlu sConfig, |
| 1106 renderModeDe scriptor.c_str(), | 1127 renderModeDe scriptor.c_str(), |
| 1107 bitmap, &ref erenceBitmap)); | 1128 bitmap, &ref erenceBitmap)); |
| 1108 if (!errors.isEmpty()) { | 1129 if (!errors.isEmpty()) { |
| 1109 break; | 1130 break; |
| 1110 } | 1131 } |
| 1111 } | 1132 } |
| 1112 } | 1133 } |
| 1113 return errors; | 1134 return errors; |
| 1114 } | 1135 } |
| 1115 | 1136 |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1415 ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm, const SkTDArray<si ze_t> &configs, | 1436 ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm, const SkTDArray<si ze_t> &configs, |
| 1416 GrContextFactory *grFactory); | 1437 GrContextFactory *grFactory); |
| 1417 ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm, const SkTDArray<si ze_t> &configs, | 1438 ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm, const SkTDArray<si ze_t> &configs, |
| 1418 GrContextFactory *grFactory) { | 1439 GrContextFactory *grFactory) { |
| 1419 const char renderModeDescriptor[] = ""; | 1440 const char renderModeDescriptor[] = ""; |
| 1420 ErrorCombination errorsForAllConfigs; | 1441 ErrorCombination errorsForAllConfigs; |
| 1421 uint32_t gmFlags = gm->getFlags(); | 1442 uint32_t gmFlags = gm->getFlags(); |
| 1422 | 1443 |
| 1423 for (int i = 0; i < configs.count(); i++) { | 1444 for (int i = 0; i < configs.count(); i++) { |
| 1424 ConfigData config = gRec[configs[i]]; | 1445 ConfigData config = gRec[configs[i]]; |
| 1425 const SkString name = gmmain.make_name(gm->shortName(), config.fName); | 1446 const SkString shortNamePlusConfig = gmmain.make_shortname_plus_config(g m->shortName(), |
| 1447 c onfig.fName); | |
| 1426 | 1448 |
| 1427 // Skip any tests that we don't even need to try. | 1449 // Skip any tests that we don't even need to try. |
| 1428 // If any of these were skipped on a per-GM basis, record them as | 1450 // If any of these were skipped on a per-GM basis, record them as |
| 1429 // kIntentionallySkipped. | 1451 // kIntentionallySkipped. |
| 1430 if (kPDF_Backend == config.fBackend) { | 1452 if (kPDF_Backend == config.fBackend) { |
| 1431 if (!FLAGS_pdf) { | 1453 if (!FLAGS_pdf) { |
| 1432 continue; | 1454 continue; |
| 1433 } | 1455 } |
| 1434 if (gmFlags & GM::kSkipPDF_Flag) { | 1456 if (gmFlags & GM::kSkipPDF_Flag) { |
| 1435 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, name, | 1457 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortN amePlusConfig, |
| 1436 renderModeDescriptor); | 1458 renderModeDescriptor); |
| 1437 errorsForAllConfigs.add(kIntentionallySkipped_ErrorType); | 1459 errorsForAllConfigs.add(kIntentionallySkipped_ErrorType); |
| 1438 continue; | 1460 continue; |
| 1439 } | 1461 } |
| 1440 } | 1462 } |
| 1441 if ((gmFlags & GM::kSkip565_Flag) && | 1463 if ((gmFlags & GM::kSkip565_Flag) && |
| 1442 (kRaster_Backend == config.fBackend) && | 1464 (kRaster_Backend == config.fBackend) && |
| 1443 (SkBitmap::kRGB_565_Config == config.fConfig)) { | 1465 (SkBitmap::kRGB_565_Config == config.fConfig)) { |
| 1444 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, name, | 1466 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNameP lusConfig, |
| 1445 renderModeDescriptor); | 1467 renderModeDescriptor); |
| 1446 errorsForAllConfigs.add(kIntentionallySkipped_ErrorType); | 1468 errorsForAllConfigs.add(kIntentionallySkipped_ErrorType); |
| 1447 continue; | 1469 continue; |
| 1448 } | 1470 } |
| 1449 if ((gmFlags & GM::kSkipGPU_Flag) && | 1471 if ((gmFlags & GM::kSkipGPU_Flag) && |
| 1450 kGPU_Backend == config.fBackend) { | 1472 kGPU_Backend == config.fBackend) { |
| 1451 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, name, | 1473 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNameP lusConfig, |
| 1452 renderModeDescriptor); | 1474 renderModeDescriptor); |
| 1453 errorsForAllConfigs.add(kIntentionallySkipped_ErrorType); | 1475 errorsForAllConfigs.add(kIntentionallySkipped_ErrorType); |
| 1454 continue; | 1476 continue; |
| 1455 } | 1477 } |
| 1456 | 1478 |
| 1457 // Now we know that we want to run this test and record its | 1479 // Now we know that we want to run this test and record its |
| 1458 // success or failure. | 1480 // success or failure. |
| 1459 ErrorCombination errorsForThisConfig; | 1481 ErrorCombination errorsForThisConfig; |
| 1460 GrSurface* gpuTarget = NULL; | 1482 GrSurface* gpuTarget = NULL; |
| 1461 #if SK_SUPPORT_GPU | 1483 #if SK_SUPPORT_GPU |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1528 * Returns all errors encountered while doing so. | 1550 * Returns all errors encountered while doing so. |
| 1529 */ | 1551 */ |
| 1530 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &co mpareConfig, | 1552 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &co mpareConfig, |
| 1531 const SkBitmap &comparisonBitmap, | 1553 const SkBitmap &comparisonBitmap, |
| 1532 const SkTDArray<SkScalar> &tileGridReplaySca les); | 1554 const SkTDArray<SkScalar> &tileGridReplaySca les); |
| 1533 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &co mpareConfig, | 1555 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &co mpareConfig, |
| 1534 const SkBitmap &comparisonBitmap, | 1556 const SkBitmap &comparisonBitmap, |
| 1535 const SkTDArray<SkScalar> &tileGridReplaySca les) { | 1557 const SkTDArray<SkScalar> &tileGridReplaySca les) { |
| 1536 ErrorCombination errorsForAllModes; | 1558 ErrorCombination errorsForAllModes; |
| 1537 uint32_t gmFlags = gm->getFlags(); | 1559 uint32_t gmFlags = gm->getFlags(); |
| 1538 const SkString name = gmmain.make_name(gm->shortName(), compareConfig.fName) ; | 1560 const SkString shortNamePlusConfig = gmmain.make_shortname_plus_config(gm->s hortName(), |
| 1561 compa reConfig.fName); | |
| 1539 | 1562 |
| 1540 SkPicture* pict = gmmain.generate_new_picture(gm, kNone_BbhType, 0); | 1563 SkPicture* pict = gmmain.generate_new_picture(gm, kNone_BbhType, 0); |
| 1541 SkAutoUnref aur(pict); | 1564 SkAutoUnref aur(pict); |
| 1542 if (FLAGS_replay) { | 1565 if (FLAGS_replay) { |
| 1543 const char renderModeDescriptor[] = "-replay"; | 1566 const char renderModeDescriptor[] = "-replay"; |
| 1544 if (gmFlags & GM::kSkipPicture_Flag) { | 1567 if (gmFlags & GM::kSkipPicture_Flag) { |
| 1545 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, name, rend erModeDescriptor); | 1568 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNameP lusConfig, |
| 1569 renderModeDescriptor); | |
| 1546 errorsForAllModes.add(kIntentionallySkipped_ErrorType); | 1570 errorsForAllModes.add(kIntentionallySkipped_ErrorType); |
| 1547 } else { | 1571 } else { |
| 1548 SkBitmap bitmap; | 1572 SkBitmap bitmap; |
| 1549 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap) ; | 1573 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap) ; |
| 1550 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p( | 1574 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p( |
| 1551 name, renderModeDescriptor, bitmap, &comparisonBitmap)); | 1575 shortNamePlusConfig, renderModeDescriptor, bitmap, &comparisonBi tmap)); |
| 1552 } | 1576 } |
| 1553 } | 1577 } |
| 1554 | 1578 |
| 1555 if (FLAGS_serialize) { | 1579 if (FLAGS_serialize) { |
| 1556 const char renderModeDescriptor[] = "-serialize"; | 1580 const char renderModeDescriptor[] = "-serialize"; |
| 1557 if (gmFlags & GM::kSkipPicture_Flag) { | 1581 if (gmFlags & GM::kSkipPicture_Flag) { |
| 1558 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, name, rend erModeDescriptor); | 1582 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNameP lusConfig, |
| 1583 renderModeDescriptor); | |
| 1559 errorsForAllModes.add(kIntentionallySkipped_ErrorType); | 1584 errorsForAllModes.add(kIntentionallySkipped_ErrorType); |
| 1560 } else { | 1585 } else { |
| 1561 SkPicture* repict = gmmain.stream_to_new_picture(*pict); | 1586 SkPicture* repict = gmmain.stream_to_new_picture(*pict); |
| 1562 SkAutoUnref aurr(repict); | 1587 SkAutoUnref aurr(repict); |
| 1563 SkBitmap bitmap; | 1588 SkBitmap bitmap; |
| 1564 gmmain.generate_image_from_picture(gm, compareConfig, repict, &bitma p); | 1589 gmmain.generate_image_from_picture(gm, compareConfig, repict, &bitma p); |
| 1565 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p( | 1590 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p( |
| 1566 name, renderModeDescriptor, bitmap, &comparisonBitmap)); | 1591 shortNamePlusConfig, renderModeDescriptor, bitmap, &comparisonBi tmap)); |
| 1567 } | 1592 } |
| 1568 } | 1593 } |
| 1569 | 1594 |
| 1570 if ((1 == FLAGS_writePicturePath.count()) && | 1595 if ((1 == FLAGS_writePicturePath.count()) && |
| 1571 !(gmFlags & GM::kSkipPicture_Flag)) { | 1596 !(gmFlags & GM::kSkipPicture_Flag)) { |
| 1572 const char* pictureSuffix = "skp"; | 1597 const char* pictureSuffix = "skp"; |
| 1573 SkString path = make_filename(FLAGS_writePicturePath[0], "", | 1598 // TODO(epoger): In this case, we call make_filename() with |
|
epoger
2013/05/19 09:00:43
Any insights on this? I think it's worth looking
| |
| 1574 gm->shortName(), pictureSuffix); | 1599 // just the shortName instead of shortNamePlusConfig. I |
| 1600 // suspect that is incorrect, because runs with different | |
| 1601 // configs will write out to the same filename. | |
| 1602 SkString path = gmmain.make_filename(FLAGS_writePicturePath[0], "", | |
| 1603 gm->shortName(), pictureSuffix); | |
| 1575 SkFILEWStream stream(path.c_str()); | 1604 SkFILEWStream stream(path.c_str()); |
| 1576 pict->serialize(&stream); | 1605 pict->serialize(&stream); |
| 1577 } | 1606 } |
| 1578 | 1607 |
| 1579 if (FLAGS_rtree) { | 1608 if (FLAGS_rtree) { |
| 1580 const char renderModeDescriptor[] = "-rtree"; | 1609 const char renderModeDescriptor[] = "-rtree"; |
| 1581 if (gmFlags & GM::kSkipPicture_Flag) { | 1610 if (gmFlags & GM::kSkipPicture_Flag) { |
| 1582 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, name, rend erModeDescriptor); | 1611 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNameP lusConfig, |
| 1612 renderModeDescriptor); | |
| 1583 errorsForAllModes.add(kIntentionallySkipped_ErrorType); | 1613 errorsForAllModes.add(kIntentionallySkipped_ErrorType); |
| 1584 } else { | 1614 } else { |
| 1585 SkPicture* pict = gmmain.generate_new_picture( | 1615 SkPicture* pict = gmmain.generate_new_picture( |
| 1586 gm, kRTree_BbhType, SkPicture::kUsePathBoundsForClip_RecordingFl ag); | 1616 gm, kRTree_BbhType, SkPicture::kUsePathBoundsForClip_RecordingFl ag); |
| 1587 SkAutoUnref aur(pict); | 1617 SkAutoUnref aur(pict); |
| 1588 SkBitmap bitmap; | 1618 SkBitmap bitmap; |
| 1589 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap) ; | 1619 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap) ; |
| 1590 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p( | 1620 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p( |
| 1591 name, renderModeDescriptor, bitmap, &comparisonBitmap)); | 1621 shortNamePlusConfig, renderModeDescriptor, bitmap, &comparisonBi tmap)); |
| 1592 } | 1622 } |
| 1593 } | 1623 } |
| 1594 | 1624 |
| 1595 if (FLAGS_tileGrid) { | 1625 if (FLAGS_tileGrid) { |
| 1596 for(int scaleIndex = 0; scaleIndex < tileGridReplayScales.count(); ++sca leIndex) { | 1626 for(int scaleIndex = 0; scaleIndex < tileGridReplayScales.count(); ++sca leIndex) { |
| 1597 SkScalar replayScale = tileGridReplayScales[scaleIndex]; | 1627 SkScalar replayScale = tileGridReplayScales[scaleIndex]; |
| 1598 SkString renderModeDescriptor("-tilegrid"); | 1628 SkString renderModeDescriptor("-tilegrid"); |
| 1599 if (SK_Scalar1 != replayScale) { | 1629 if (SK_Scalar1 != replayScale) { |
| 1600 renderModeDescriptor += "-scale-"; | 1630 renderModeDescriptor += "-scale-"; |
| 1601 renderModeDescriptor.appendScalar(replayScale); | 1631 renderModeDescriptor.appendScalar(replayScale); |
| 1602 } | 1632 } |
| 1603 | 1633 |
| 1604 if ((gmFlags & GM::kSkipPicture_Flag) || | 1634 if ((gmFlags & GM::kSkipPicture_Flag) || |
| 1605 ((gmFlags & GM::kSkipScaledReplay_Flag) && replayScale != 1)) { | 1635 ((gmFlags & GM::kSkipScaledReplay_Flag) && replayScale != 1)) { |
| 1606 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, name, | 1636 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortN amePlusConfig, |
| 1607 renderModeDescriptor.c_str()); | 1637 renderModeDescriptor.c_str()); |
| 1608 errorsForAllModes.add(kIntentionallySkipped_ErrorType); | 1638 errorsForAllModes.add(kIntentionallySkipped_ErrorType); |
| 1609 } else { | 1639 } else { |
| 1610 // We record with the reciprocal scale to obtain a replay | 1640 // We record with the reciprocal scale to obtain a replay |
| 1611 // result that can be validated against comparisonBitmap. | 1641 // result that can be validated against comparisonBitmap. |
| 1612 SkScalar recordScale = SkScalarInvert(replayScale); | 1642 SkScalar recordScale = SkScalarInvert(replayScale); |
| 1613 SkPicture* pict = gmmain.generate_new_picture( | 1643 SkPicture* pict = gmmain.generate_new_picture( |
| 1614 gm, kTileGrid_BbhType, SkPicture::kUsePathBoundsForClip_Reco rdingFlag, | 1644 gm, kTileGrid_BbhType, SkPicture::kUsePathBoundsForClip_Reco rdingFlag, |
| 1615 recordScale); | 1645 recordScale); |
| 1616 SkAutoUnref aur(pict); | 1646 SkAutoUnref aur(pict); |
| 1617 SkBitmap bitmap; | 1647 SkBitmap bitmap; |
| 1618 // We cannot yet pass 'true' to generate_image_from_picture to | 1648 // We cannot yet pass 'true' to generate_image_from_picture to |
| 1619 // perform actual tiled rendering (see Issue 1198 - | 1649 // perform actual tiled rendering (see Issue 1198 - |
| 1620 // https://code.google.com/p/skia/issues/detail?id=1198) | 1650 // https://code.google.com/p/skia/issues/detail?id=1198) |
| 1621 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bit map, | 1651 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bit map, |
| 1622 replayScale /*, true */); | 1652 replayScale /*, true */); |
| 1623 errorsForAllModes.add(gmmain.compare_test_results_to_reference_b itmap( | 1653 errorsForAllModes.add(gmmain.compare_test_results_to_reference_b itmap( |
| 1624 name, renderModeDescriptor.c_str(), bitmap, &comparisonBitma p)); | 1654 shortNamePlusConfig, renderModeDescriptor.c_str(), bitmap, & comparisonBitmap)); |
| 1625 } | 1655 } |
| 1626 } | 1656 } |
| 1627 } | 1657 } |
| 1628 | 1658 |
| 1629 // run the pipe centric GM steps | 1659 // run the pipe centric GM steps |
| 1630 if (FLAGS_pipe) { | 1660 if (FLAGS_pipe) { |
| 1631 errorsForAllModes.add(gmmain.test_pipe_playback(gm, compareConfig, compa risonBitmap, | 1661 errorsForAllModes.add(gmmain.test_pipe_playback(gm, compareConfig, compa risonBitmap, |
| 1632 FLAGS_simulatePipePlayba ckFailure)); | 1662 FLAGS_simulatePipePlayba ckFailure)); |
| 1633 if (FLAGS_tiledPipe) { | 1663 if (FLAGS_tiledPipe) { |
| 1634 errorsForAllModes.add(gmmain.test_tiled_pipe_playback(gm, compareCon fig, | 1664 errorsForAllModes.add(gmmain.test_tiled_pipe_playback(gm, compareCon fig, |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2045 if (FLAGS_forceBWtext) { | 2075 if (FLAGS_forceBWtext) { |
| 2046 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 2076 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
| 2047 } | 2077 } |
| 2048 } | 2078 } |
| 2049 | 2079 |
| 2050 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 2080 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 2051 int main(int argc, char * const argv[]) { | 2081 int main(int argc, char * const argv[]) { |
| 2052 return tool_main(argc, (char**) argv); | 2082 return tool_main(argc, (char**) argv); |
| 2053 } | 2083 } |
| 2054 #endif | 2084 #endif |
| OLD | NEW |