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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 }; | 181 }; |
| 182 | 182 |
| 183 static bool encode_to_dct_stream(SkWStream* stream, const SkBitmap& bitmap, cons t SkIRect& rect); | 183 static bool encode_to_dct_stream(SkWStream* stream, const SkBitmap& bitmap, cons t SkIRect& rect); |
| 184 | 184 |
| 185 const static ErrorCombination kDefaultIgnorableErrorTypes = ErrorCombination() | 185 const static ErrorCombination kDefaultIgnorableErrorTypes = ErrorCombination() |
| 186 .plus(kMissingExpectations_ErrorType) | 186 .plus(kMissingExpectations_ErrorType) |
| 187 .plus(kIntentionallySkipped_ErrorType); | 187 .plus(kIntentionallySkipped_ErrorType); |
| 188 | 188 |
| 189 class GMMain { | 189 class GMMain { |
| 190 public: | 190 public: |
| 191 GMMain() : fUseFileHierarchy(false), fIgnorableErrorTypes(kDefaultIgnorableE rrorTypes), | 191 GMMain() : fUseFileHierarchy(false), fWriteChecksumBasedFilenames(false), |
| 192 fIgnorableErrorTypes(kDefaultIgnorableErrorTypes), | |
| 192 fMismatchPath(NULL), fTestsRun(0), fRenderModesEncountered(1) {} | 193 fMismatchPath(NULL), fTestsRun(0), fRenderModesEncountered(1) {} |
| 193 | 194 |
| 194 /** | 195 /** |
| 195 * Assemble shortNamePlusConfig from (surprise!) shortName and configName. | 196 * Assemble shortNamePlusConfig from (surprise!) shortName and configName. |
| 196 * | 197 * |
| 197 * The method for doing so depends on whether we are using hierarchical nami ng. | 198 * The method for doing so depends on whether we are using hierarchical nami ng. |
| 198 * For example, shortName "selftest1" and configName "8888" could be assembl ed into | 199 * For example, shortName "selftest1" and configName "8888" could be assembl ed into |
| 199 * either "selftest1_8888" or "8888/selftest1". | 200 * either "selftest1_8888" or "8888/selftest1". |
| 200 */ | 201 */ |
| 201 SkString make_shortname_plus_config(const char *shortName, const char *confi gName) { | 202 SkString make_shortname_plus_config(const char *shortName, const char *confi gName) { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 218 const char *configName, | 219 const char *configName, |
| 219 const char *renderModeDescriptor, | 220 const char *renderModeDescriptor, |
| 220 const char *suffix) { | 221 const char *suffix) { |
| 221 SkString filename = make_shortname_plus_config(shortName, configName); | 222 SkString filename = make_shortname_plus_config(shortName, configName); |
| 222 filename.append(renderModeDescriptor); | 223 filename.append(renderModeDescriptor); |
| 223 filename.appendUnichar('.'); | 224 filename.appendUnichar('.'); |
| 224 filename.append(suffix); | 225 filename.append(suffix); |
| 225 return SkOSPath::SkPathJoin(path, filename.c_str()); | 226 return SkOSPath::SkPathJoin(path, filename.c_str()); |
| 226 } | 227 } |
| 227 | 228 |
| 229 /** | |
| 230 * Assemble filename suitable for writing out an SkBitmap. | |
| 231 */ | |
| 232 SkString make_bitmap_filename(const char *path, | |
| 233 const char *shortName, | |
| 234 const char *configName, | |
| 235 const char *renderModeDescriptor, | |
| 236 const GmResultDigest &bitmapDigest) { | |
| 237 if (fWriteChecksumBasedFilenames) { | |
|
epoger
2013/06/18 06:58:38
At patchset 3, we are assembling the desired outpu
| |
| 238 SkString completePath(path); | |
| 239 completePath.appendUnichar(SkPATH_SEPARATOR); | |
| 240 completePath.append(bitmapDigest.getHashType()); | |
| 241 completePath.appendUnichar(SkPATH_SEPARATOR); | |
| 242 completePath.append(shortName); | |
| 243 completePath.appendUnichar(SkPATH_SEPARATOR); | |
| 244 completePath.append(bitmapDigest.getDigestValue()); | |
| 245 completePath.appendUnichar('.'); | |
| 246 completePath.append(kPNG_FileExtension); | |
| 247 return completePath; | |
| 248 } else { | |
| 249 return make_filename(path, shortName, configName, renderModeDescript or, | |
| 250 kPNG_FileExtension); | |
| 251 } | |
| 252 } | |
| 253 | |
| 228 /* since PNG insists on unpremultiplying our alpha, we take no | 254 /* since PNG insists on unpremultiplying our alpha, we take no |
| 229 precision chances and force all pixels to be 100% opaque, | 255 precision chances and force all pixels to be 100% opaque, |
| 230 otherwise on compare we may not get a perfect match. | 256 otherwise on compare we may not get a perfect match. |
| 231 */ | 257 */ |
| 232 static void force_all_opaque(const SkBitmap& bitmap) { | 258 static void force_all_opaque(const SkBitmap& bitmap) { |
| 233 SkBitmap::Config config = bitmap.config(); | 259 SkBitmap::Config config = bitmap.config(); |
| 234 switch (config) { | 260 switch (config) { |
| 235 case SkBitmap::kARGB_8888_Config: | 261 case SkBitmap::kARGB_8888_Config: |
| 236 force_all_opaque_8888(bitmap); | 262 force_all_opaque_8888(bitmap); |
| 237 break; | 263 break; |
| 238 case SkBitmap::kRGB_565_Config: | 264 case SkBitmap::kRGB_565_Config: |
| 239 // nothing to do here; 565 bitmaps are inherently opaque | 265 // nothing to do here; 565 bitmaps are inherently opaque |
| 240 break; | 266 break; |
| 241 default: | 267 default: |
| 242 gm_fprintf(stderr, "unsupported bitmap config %d\n", config); | 268 gm_fprintf(stderr, "unsupported bitmap config %d\n", config); |
| 243 DEBUGFAIL_SEE_STDERR; | 269 DEBUGFAIL_SEE_STDERR; |
| 244 } | 270 } |
| 245 } | 271 } |
| 246 | 272 |
| 247 static void force_all_opaque_8888(const SkBitmap& bitmap) { | 273 static void force_all_opaque_8888(const SkBitmap& bitmap) { |
| 248 SkAutoLockPixels lock(bitmap); | 274 SkAutoLockPixels lock(bitmap); |
| 249 for (int y = 0; y < bitmap.height(); y++) { | 275 for (int y = 0; y < bitmap.height(); y++) { |
| 250 for (int x = 0; x < bitmap.width(); x++) { | 276 for (int x = 0; x < bitmap.width(); x++) { |
| 251 *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT); | 277 *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT); |
| 252 } | 278 } |
| 253 } | 279 } |
| 254 } | 280 } |
| 255 | 281 |
| 282 // EPOGER: make sure to create any directories needed along the path | |
| 283 // EPOGER: make sure this works even if the destination file already exists -- just overwrite it | |
| 256 static bool write_bitmap(const SkString& path, const SkBitmap& bitmap) { | 284 static bool write_bitmap(const SkString& path, const SkBitmap& bitmap) { |
| 257 // TODO(epoger): Now that we have removed force_all_opaque() | 285 // TODO(epoger): Now that we have removed force_all_opaque() |
| 258 // from this method, we should be able to get rid of the | 286 // from this method, we should be able to get rid of the |
| 259 // transformation to 8888 format also. | 287 // transformation to 8888 format also. |
| 260 SkBitmap copy; | 288 SkBitmap copy; |
| 261 bitmap.copyTo(©, SkBitmap::kARGB_8888_Config); | 289 bitmap.copyTo(©, SkBitmap::kARGB_8888_Config); |
| 262 return SkImageEncoder::EncodeFile(path.c_str(), copy, | 290 return SkImageEncoder::EncodeFile(path.c_str(), copy, |
| 263 SkImageEncoder::kPNG_Type, 100); | 291 SkImageEncoder::kPNG_Type, 100); |
| 264 } | 292 } |
| 265 | 293 |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 628 invokeGM(gm, &c, false, false); | 656 invokeGM(gm, &c, false, false); |
| 629 dev->endSheet(); | 657 dev->endSheet(); |
| 630 dev->endPortfolio(); | 658 dev->endPortfolio(); |
| 631 | 659 |
| 632 #endif | 660 #endif |
| 633 } | 661 } |
| 634 | 662 |
| 635 ErrorCombination write_reference_image(const ConfigData& gRec, const char wr itePath [], | 663 ErrorCombination write_reference_image(const ConfigData& gRec, const char wr itePath [], |
| 636 const char renderModeDescriptor [], | 664 const char renderModeDescriptor [], |
| 637 const char *shortName, SkBitmap& bitm ap, | 665 const char *shortName, SkBitmap& bitm ap, |
| 666 GmResultDigest& bitmapDigest, | |
| 638 SkDynamicMemoryWStream* document) { | 667 SkDynamicMemoryWStream* document) { |
| 639 SkString path; | 668 SkString path; |
| 640 bool success = false; | 669 bool success = false; |
| 641 if (gRec.fBackend == kRaster_Backend || | 670 if (gRec.fBackend == kRaster_Backend || |
| 642 gRec.fBackend == kGPU_Backend || | 671 gRec.fBackend == kGPU_Backend || |
| 643 (gRec.fBackend == kPDF_Backend && CAN_IMAGE_PDF)) { | 672 (gRec.fBackend == kPDF_Backend && CAN_IMAGE_PDF)) { |
| 644 | 673 |
| 645 path = make_filename(writePath, shortName, gRec.fName, renderModeDes criptor, | 674 path = make_bitmap_filename(writePath, shortName, gRec.fName, render ModeDescriptor, |
| 646 kPNG_FileExtension); | 675 bitmapDigest); |
| 647 success = write_bitmap(path, bitmap); | 676 success = write_bitmap(path, bitmap); |
| 648 } | 677 } |
| 649 if (kPDF_Backend == gRec.fBackend) { | 678 if (kPDF_Backend == gRec.fBackend) { |
| 650 path = make_filename(writePath, shortName, gRec.fName, renderModeDes criptor, | 679 path = make_filename(writePath, shortName, gRec.fName, renderModeDes criptor, |
| 651 "pdf"); | 680 "pdf"); |
| 652 success = write_document(path, *document); | 681 success = write_document(path, *document); |
| 653 } | 682 } |
| 654 if (kXPS_Backend == gRec.fBackend) { | 683 if (kXPS_Backend == gRec.fBackend) { |
| 655 path = make_filename(writePath, shortName, gRec.fName, renderModeDes criptor, | 684 path = make_filename(writePath, shortName, gRec.fName, renderModeDes criptor, |
| 656 "xps"); | 685 "xps"); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 734 | 763 |
| 735 /** | 764 /** |
| 736 * Compares actual hash digest to expectations, returning the set of errors | 765 * Compares actual hash digest to expectations, returning the set of errors |
| 737 * (if any) that we saw along the way. | 766 * (if any) that we saw along the way. |
| 738 * | 767 * |
| 739 * If fMismatchPath has been set, and there are pixel diffs, then the | 768 * If fMismatchPath has been set, and there are pixel diffs, then the |
| 740 * actual bitmap will be written out to a file within fMismatchPath. | 769 * actual bitmap will be written out to a file within fMismatchPath. |
| 741 * | 770 * |
| 742 * @param expectations what expectations to compare actualBitmap against | 771 * @param expectations what expectations to compare actualBitmap against |
| 743 * @param actualBitmap the image we actually generated | 772 * @param actualBitmap the image we actually generated |
| 773 * @param actualResultDigest GmResultDigest of actualBitmap | |
| 744 * @param shortName name of test, e.g. "selftest1" | 774 * @param shortName name of test, e.g. "selftest1" |
| 745 * @param configName name of config, e.g. "8888" | 775 * @param configName name of config, e.g. "8888" |
| 746 * @param renderModeDescriptor e.g., "-rtree", "-deferred" | 776 * @param renderModeDescriptor e.g., "-rtree", "-deferred" |
| 747 * @param addToJsonSummary whether to add these results (both actual and | 777 * @param addToJsonSummary whether to add these results (both actual and |
| 748 * expected) to the JSON summary. Regardless of this setting, if | 778 * expected) to the JSON summary. Regardless of this setting, if |
| 749 * we find an image mismatch in this test, we will write these | 779 * we find an image mismatch in this test, we will write these |
| 750 * results to the JSON summary. (This is so that we will always | 780 * results to the JSON summary. (This is so that we will always |
| 751 * report errors across rendering modes, such as pipe vs tiled. | 781 * report errors across rendering modes, such as pipe vs tiled. |
| 752 * See https://codereview.chromium.org/13650002/ ) | 782 * See https://codereview.chromium.org/13650002/ ) |
| 753 */ | 783 */ |
| 754 ErrorCombination compare_to_expectations(Expectations expectations, | 784 ErrorCombination compare_to_expectations(Expectations expectations, |
| 755 const SkBitmap& actualBitmap, | 785 const SkBitmap& actualBitmap, |
| 786 const GmResultDigest& actualResultD igest, | |
| 756 const char *shortName, const char * configName, | 787 const char *shortName, const char * configName, |
| 757 const char *renderModeDescriptor, | 788 const char *renderModeDescriptor, |
| 758 bool addToJsonSummary) { | 789 bool addToJsonSummary) { |
| 759 ErrorCombination errors; | 790 ErrorCombination errors; |
| 760 GmResultDigest actualResultDigest(actualBitmap); | |
| 761 SkString shortNamePlusConfig = make_shortname_plus_config(shortName, con figName); | 791 SkString shortNamePlusConfig = make_shortname_plus_config(shortName, con figName); |
| 762 SkString completeNameString(shortNamePlusConfig); | 792 SkString completeNameString(shortNamePlusConfig); |
| 763 completeNameString.append(renderModeDescriptor); | 793 completeNameString.append(renderModeDescriptor); |
| 764 completeNameString.append("."); | 794 completeNameString.append("."); |
| 765 completeNameString.append(kPNG_FileExtension); | 795 completeNameString.append(kPNG_FileExtension); |
| 766 const char* completeName = completeNameString.c_str(); | 796 const char* completeName = completeNameString.c_str(); |
| 767 | 797 |
| 768 if (expectations.empty()) { | 798 if (expectations.empty()) { |
| 769 errors.add(kMissingExpectations_ErrorType); | 799 errors.add(kMissingExpectations_ErrorType); |
| 770 } else if (!expectations.match(actualResultDigest)) { | 800 } else if (!expectations.match(actualResultDigest)) { |
| 771 addToJsonSummary = true; | 801 addToJsonSummary = true; |
| 772 // The error mode we record depends on whether this was running | 802 // The error mode we record depends on whether this was running |
| 773 // in a non-standard renderMode. | 803 // in a non-standard renderMode. |
| 774 if ('\0' == *renderModeDescriptor) { | 804 if ('\0' == *renderModeDescriptor) { |
| 775 errors.add(kExpectationsMismatch_ErrorType); | 805 errors.add(kExpectationsMismatch_ErrorType); |
| 776 } else { | 806 } else { |
| 777 errors.add(kRenderModeMismatch_ErrorType); | 807 errors.add(kRenderModeMismatch_ErrorType); |
| 778 } | 808 } |
| 779 | 809 |
| 780 // Write out the "actuals" for any mismatches, if we have | 810 // Write out the "actuals" for any mismatches, if we have |
| 781 // been directed to do so. | 811 // been directed to do so. |
| 782 if (fMismatchPath) { | 812 if (fMismatchPath) { |
| 783 SkString path = | 813 SkString path = make_bitmap_filename(fMismatchPath, shortName, c onfigName, |
| 784 make_filename(fMismatchPath, shortName, configName, renderMo deDescriptor, | 814 renderModeDescriptor, actua lResultDigest); |
| 785 kPNG_FileExtension); | |
| 786 write_bitmap(path, actualBitmap); | 815 write_bitmap(path, actualBitmap); |
| 787 } | 816 } |
| 788 | 817 |
| 789 // If we have access to a single expected bitmap, log more | 818 // If we have access to a single expected bitmap, log more |
| 790 // detail about the mismatch. | 819 // detail about the mismatch. |
| 791 const SkBitmap *expectedBitmapPtr = expectations.asBitmap(); | 820 const SkBitmap *expectedBitmapPtr = expectations.asBitmap(); |
| 792 if (NULL != expectedBitmapPtr) { | 821 if (NULL != expectedBitmapPtr) { |
| 793 report_bitmap_diffs(*expectedBitmapPtr, actualBitmap, completeNa me); | 822 report_bitmap_diffs(*expectedBitmapPtr, actualBitmap, completeNa me); |
| 794 } | 823 } |
| 795 } | 824 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 864 * @param gRec | 893 * @param gRec |
| 865 * @param writePath unless this is NULL, write out actual images into this | 894 * @param writePath unless this is NULL, write out actual images into this |
| 866 * directory | 895 * directory |
| 867 * @param actualBitmap bitmap generated by this run | 896 * @param actualBitmap bitmap generated by this run |
| 868 * @param pdf | 897 * @param pdf |
| 869 */ | 898 */ |
| 870 ErrorCombination compare_test_results_to_stored_expectations( | 899 ErrorCombination compare_test_results_to_stored_expectations( |
| 871 GM* gm, const ConfigData& gRec, const char writePath[], | 900 GM* gm, const ConfigData& gRec, const char writePath[], |
| 872 SkBitmap& actualBitmap, SkDynamicMemoryWStream* pdf) { | 901 SkBitmap& actualBitmap, SkDynamicMemoryWStream* pdf) { |
| 873 | 902 |
| 903 GmResultDigest actualResultDigest(actualBitmap); | |
| 874 SkString shortNamePlusConfig = make_shortname_plus_config(gm->shortName( ), gRec.fName); | 904 SkString shortNamePlusConfig = make_shortname_plus_config(gm->shortName( ), gRec.fName); |
| 875 SkString nameWithExtension(shortNamePlusConfig); | 905 SkString nameWithExtension(shortNamePlusConfig); |
| 876 nameWithExtension.append("."); | 906 nameWithExtension.append("."); |
| 877 nameWithExtension.append(kPNG_FileExtension); | 907 nameWithExtension.append(kPNG_FileExtension); |
| 878 | 908 |
| 879 ErrorCombination errors; | 909 ErrorCombination errors; |
| 880 ExpectationsSource *expectationsSource = this->fExpectationsSource.get() ; | 910 ExpectationsSource *expectationsSource = this->fExpectationsSource.get() ; |
| 881 if (expectationsSource && (gRec.fFlags & kRead_ConfigFlag)) { | 911 if (expectationsSource && (gRec.fFlags & kRead_ConfigFlag)) { |
| 882 /* | 912 /* |
| 883 * Get the expected results for this test, as one or more allowed | 913 * Get the expected results for this test, as one or more allowed |
| 884 * hash digests. The current implementation of expectationsSource | 914 * hash digests. The current implementation of expectationsSource |
| 885 * get this by computing the hash digest of a single PNG file on dis k. | 915 * get this by computing the hash digest of a single PNG file on dis k. |
| 886 * | 916 * |
| 887 * TODO(epoger): This relies on the fact that | 917 * TODO(epoger): This relies on the fact that |
| 888 * force_all_opaque() was called on the bitmap before it | 918 * force_all_opaque() was called on the bitmap before it |
| 889 * was written to disk as a PNG in the first place. If | 919 * was written to disk as a PNG in the first place. If |
| 890 * not, the hash digest returned here may not match the | 920 * not, the hash digest returned here may not match the |
| 891 * hash digest of actualBitmap, which *has* been run through | 921 * hash digest of actualBitmap, which *has* been run through |
| 892 * force_all_opaque(). | 922 * force_all_opaque(). |
| 893 * See comments above complete_bitmap() for more detail. | 923 * See comments above complete_bitmap() for more detail. |
| 894 */ | 924 */ |
| 895 Expectations expectations = expectationsSource->get(nameWithExtensio n.c_str()); | 925 Expectations expectations = expectationsSource->get(nameWithExtensio n.c_str()); |
| 896 errors.add(compare_to_expectations(expectations, actualBitmap, | 926 errors.add(compare_to_expectations(expectations, actualBitmap, actua lResultDigest, |
| 897 gm->shortName(), gRec.fName, "", true)); | 927 gm->shortName(), gRec.fName, "", true)); |
| 898 } else { | 928 } else { |
| 899 // If we are running without expectations, we still want to | 929 // If we are running without expectations, we still want to |
| 900 // record the actual results. | 930 // record the actual results. |
| 901 GmResultDigest actualResultDigest(actualBitmap); | |
| 902 add_actual_results_to_json_summary(nameWithExtension.c_str(), actual ResultDigest, | 931 add_actual_results_to_json_summary(nameWithExtension.c_str(), actual ResultDigest, |
| 903 ErrorCombination(kMissingExpectat ions_ErrorType), | 932 ErrorCombination(kMissingExpectat ions_ErrorType), |
| 904 false); | 933 false); |
| 905 RecordTestResults(ErrorCombination(kMissingExpectations_ErrorType), | 934 RecordTestResults(ErrorCombination(kMissingExpectations_ErrorType), |
| 906 shortNamePlusConfig, ""); | 935 shortNamePlusConfig, ""); |
| 907 } | 936 } |
| 908 | 937 |
| 909 // TODO: Consider moving this into compare_to_expectations(), | 938 // TODO: Consider moving this into compare_to_expectations(), |
| 910 // similar to fMismatchPath... for now, we don't do that, because | 939 // similar to fMismatchPath... for now, we don't do that, because |
| 911 // we don't want to write out the actual bitmaps for all | 940 // we don't want to write out the actual bitmaps for all |
| 912 // renderModes of all tests! That would be a lot of files. | 941 // renderModes of all tests! That would be a lot of files. |
| 913 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { | 942 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { |
| 914 errors.add(write_reference_image(gRec, writePath, "", gm->shortName( ), | 943 errors.add(write_reference_image(gRec, writePath, "", gm->shortName( ), |
| 915 actualBitmap, pdf)); | 944 actualBitmap, actualResultDigest, p df)); |
| 916 } | 945 } |
| 917 | 946 |
| 918 return errors; | 947 return errors; |
| 919 } | 948 } |
| 920 | 949 |
| 921 /** | 950 /** |
| 922 * Compare actualBitmap to referenceBitmap. | 951 * Compare actualBitmap to referenceBitmap. |
| 923 * | 952 * |
| 924 * @param shortName test name, e.g. "selftest1" | 953 * @param shortName test name, e.g. "selftest1" |
| 925 * @param configName configuration name, e.g. "8888" | 954 * @param configName configuration name, e.g. "8888" |
| 926 * @param renderModeDescriptor | 955 * @param renderModeDescriptor |
| 927 * @param actualBitmap actual bitmap generated by this run | 956 * @param actualBitmap actual bitmap generated by this run |
| 928 * @param referenceBitmap bitmap we expected to be generated | 957 * @param referenceBitmap bitmap we expected to be generated |
| 929 */ | 958 */ |
| 930 ErrorCombination compare_test_results_to_reference_bitmap( | 959 ErrorCombination compare_test_results_to_reference_bitmap( |
| 931 const char *shortName, const char *configName, const char *renderModeDes criptor, | 960 const char *shortName, const char *configName, const char *renderModeDes criptor, |
| 932 SkBitmap& actualBitmap, const SkBitmap* referenceBitmap) { | 961 SkBitmap& actualBitmap, const SkBitmap* referenceBitmap) { |
| 933 | 962 |
| 934 SkASSERT(referenceBitmap); | 963 SkASSERT(referenceBitmap); |
| 935 Expectations expectations(*referenceBitmap); | 964 Expectations expectations(*referenceBitmap); |
| 936 return compare_to_expectations(expectations, actualBitmap, shortName, | 965 GmResultDigest actualResultDigest(actualBitmap); |
| 966 return compare_to_expectations(expectations, actualBitmap, actualResultD igest, shortName, | |
| 937 configName, renderModeDescriptor, false); | 967 configName, renderModeDescriptor, false); |
| 938 } | 968 } |
| 939 | 969 |
| 940 static SkPicture* generate_new_picture(GM* gm, BbhType bbhType, uint32_t rec ordFlags, | 970 static SkPicture* generate_new_picture(GM* gm, BbhType bbhType, uint32_t rec ordFlags, |
| 941 SkScalar scale = SK_Scalar1) { | 971 SkScalar scale = SK_Scalar1) { |
| 942 // Pictures are refcounted so must be on heap | 972 // Pictures are refcounted so must be on heap |
| 943 SkPicture* pict; | 973 SkPicture* pict; |
| 944 int width = SkScalarCeilToInt(SkScalarMul(SkIntToScalar(gm->getISize().w idth()), scale)); | 974 int width = SkScalarCeilToInt(SkScalarMul(SkIntToScalar(gm->getISize().w idth()), scale)); |
| 945 int height = SkScalarCeilToInt(SkScalarMul(SkIntToScalar(gm->getISize(). height()), scale)); | 975 int height = SkScalarCeilToInt(SkScalarMul(SkIntToScalar(gm->getISize(). height()), scale)); |
| 946 | 976 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1136 } | 1166 } |
| 1137 } | 1167 } |
| 1138 return errors; | 1168 return errors; |
| 1139 } | 1169 } |
| 1140 | 1170 |
| 1141 // | 1171 // |
| 1142 // member variables. | 1172 // member variables. |
| 1143 // They are public for now, to allow easier setting by tool_main(). | 1173 // They are public for now, to allow easier setting by tool_main(). |
| 1144 // | 1174 // |
| 1145 | 1175 |
| 1146 bool fUseFileHierarchy; | 1176 bool fUseFileHierarchy, fWriteChecksumBasedFilenames; |
| 1147 ErrorCombination fIgnorableErrorTypes; | 1177 ErrorCombination fIgnorableErrorTypes; |
| 1148 | 1178 |
| 1149 const char* fMismatchPath; | 1179 const char* fMismatchPath; |
| 1150 | 1180 |
| 1151 // collection of tests that have failed with each ErrorType | 1181 // collection of tests that have failed with each ErrorType |
| 1152 SkTArray<SkString> fFailedTests[kLast_ErrorType+1]; | 1182 SkTArray<SkString> fFailedTests[kLast_ErrorType+1]; |
| 1153 int fTestsRun; | 1183 int fTestsRun; |
| 1154 SkTDict<int> fRenderModesEncountered; | 1184 SkTDict<int> fRenderModesEncountered; |
| 1155 | 1185 |
| 1156 // Where to read expectations (expected image hash digests, etc.) from. | 1186 // Where to read expectations (expected image hash digests, etc.) from. |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1296 "any differences between those and the newly generated ones."); | 1326 "any differences between those and the newly generated ones."); |
| 1297 DEFINE_bool(replay, true, "Exercise the SkPicture replay test pass."); | 1327 DEFINE_bool(replay, true, "Exercise the SkPicture replay test pass."); |
| 1298 DEFINE_string2(resourcePath, i, "", "Directory that stores image resources."); | 1328 DEFINE_string2(resourcePath, i, "", "Directory that stores image resources."); |
| 1299 DEFINE_bool(rtree, true, "Exercise the R-Tree variant of SkPicture test pass."); | 1329 DEFINE_bool(rtree, true, "Exercise the R-Tree variant of SkPicture test pass."); |
| 1300 DEFINE_bool(serialize, true, "Exercise the SkPicture serialization & deserializa tion test pass."); | 1330 DEFINE_bool(serialize, true, "Exercise the SkPicture serialization & deserializa tion test pass."); |
| 1301 DEFINE_bool(simulatePipePlaybackFailure, false, "Simulate a rendering failure in pipe mode only."); | 1331 DEFINE_bool(simulatePipePlaybackFailure, false, "Simulate a rendering failure in pipe mode only."); |
| 1302 DEFINE_bool(tiledPipe, false, "Exercise tiled SkGPipe replay."); | 1332 DEFINE_bool(tiledPipe, false, "Exercise tiled SkGPipe replay."); |
| 1303 DEFINE_bool(tileGrid, true, "Exercise the tile grid variant of SkPicture."); | 1333 DEFINE_bool(tileGrid, true, "Exercise the tile grid variant of SkPicture."); |
| 1304 DEFINE_string(tileGridReplayScales, "", "Space separated list of floating-point scale " | 1334 DEFINE_string(tileGridReplayScales, "", "Space separated list of floating-point scale " |
| 1305 "factors to be used for tileGrid playback testing. Default value: 1.0"); | 1335 "factors to be used for tileGrid playback testing. Default value: 1.0"); |
| 1306 DEFINE_string(writeJsonSummaryPath, "", "Write a JSON-formatted result summary t o this file."); | |
| 1307 DEFINE_bool2(verbose, v, false, "Give more detail (e.g. list all GMs run, more i nfo about " | 1336 DEFINE_bool2(verbose, v, false, "Give more detail (e.g. list all GMs run, more i nfo about " |
| 1308 "each test)."); | 1337 "each test)."); |
| 1338 DEFINE_bool(writeChecksumBasedFilenames, false, "When writing out actual images, use checksum-" | |
| 1339 "based filenames, as rebaseline.py will use when downloading them fr om Google Storage"); | |
| 1340 DEFINE_string(writeJsonSummaryPath, "", "Write a JSON-formatted result summary t o this file."); | |
| 1309 DEFINE_string2(writePath, w, "", "Write rendered images into this directory."); | 1341 DEFINE_string2(writePath, w, "", "Write rendered images into this directory."); |
| 1310 DEFINE_string2(writePicturePath, p, "", "Write .skp files into this directory.") ; | 1342 DEFINE_string2(writePicturePath, p, "", "Write .skp files into this directory.") ; |
| 1311 DEFINE_int32(pdfJpegQuality, -1, "Encodes images in JPEG at quality level N, " | 1343 DEFINE_int32(pdfJpegQuality, -1, "Encodes images in JPEG at quality level N, " |
| 1312 "which can be in range 0-100). N = -1 will disable JPEG compression . " | 1344 "which can be in range 0-100). N = -1 will disable JPEG compression . " |
| 1313 "Default is N = 100, maximum quality."); | 1345 "Default is N = 100, maximum quality."); |
| 1314 | 1346 |
| 1315 static bool encode_to_dct_stream(SkWStream* stream, const SkBitmap& bitmap, cons t SkIRect& rect) { | 1347 static bool encode_to_dct_stream(SkWStream* stream, const SkBitmap& bitmap, cons t SkIRect& rect) { |
| 1316 // Filter output of warnings that JPEG is not available for the image. | 1348 // Filter output of warnings that JPEG is not available for the image. |
| 1317 if (bitmap.width() >= 65500 || bitmap.height() >= 65500) return false; | 1349 if (bitmap.width() >= 65500 || bitmap.height() >= 65500) return false; |
| 1318 if (FLAGS_pdfJpegQuality == -1) return false; | 1350 if (FLAGS_pdfJpegQuality == -1) return false; |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1755 SkTDArray<size_t> configs; | 1787 SkTDArray<size_t> configs; |
| 1756 SkTDArray<size_t> excludeConfigs; | 1788 SkTDArray<size_t> excludeConfigs; |
| 1757 bool userConfig = false; | 1789 bool userConfig = false; |
| 1758 | 1790 |
| 1759 SkString usage; | 1791 SkString usage; |
| 1760 usage.printf("Run the golden master tests.\n"); | 1792 usage.printf("Run the golden master tests.\n"); |
| 1761 SkCommandLineFlags::SetUsage(usage.c_str()); | 1793 SkCommandLineFlags::SetUsage(usage.c_str()); |
| 1762 SkCommandLineFlags::Parse(argc, argv); | 1794 SkCommandLineFlags::Parse(argc, argv); |
| 1763 | 1795 |
| 1764 gmmain.fUseFileHierarchy = FLAGS_hierarchy; | 1796 gmmain.fUseFileHierarchy = FLAGS_hierarchy; |
| 1797 gmmain.fWriteChecksumBasedFilenames = FLAGS_writeChecksumBasedFilenames; | |
| 1765 if (FLAGS_mismatchPath.count() == 1) { | 1798 if (FLAGS_mismatchPath.count() == 1) { |
| 1766 gmmain.fMismatchPath = FLAGS_mismatchPath[0]; | 1799 gmmain.fMismatchPath = FLAGS_mismatchPath[0]; |
| 1767 } | 1800 } |
| 1768 | 1801 |
| 1769 for (int i = 0; i < FLAGS_config.count(); i++) { | 1802 for (int i = 0; i < FLAGS_config.count(); i++) { |
| 1770 const char* config = FLAGS_config[i]; | 1803 const char* config = FLAGS_config[i]; |
| 1771 userConfig = true; | 1804 userConfig = true; |
| 1772 bool exclude = false; | 1805 bool exclude = false; |
| 1773 if (*config == kExcludeConfigChar) { | 1806 if (*config == kExcludeConfigChar) { |
| 1774 exclude = true; | 1807 exclude = true; |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2086 if (FLAGS_forceBWtext) { | 2119 if (FLAGS_forceBWtext) { |
| 2087 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 2120 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
| 2088 } | 2121 } |
| 2089 } | 2122 } |
| 2090 | 2123 |
| 2091 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 2124 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 2092 int main(int argc, char * const argv[]) { | 2125 int main(int argc, char * const argv[]) { |
| 2093 return tool_main(argc, (char**) argv); | 2126 return tool_main(argc, (char**) argv); |
| 2094 } | 2127 } |
| 2095 #endif | 2128 #endif |
| OLD | NEW |