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 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
852 */ | 852 */ |
853 void add_expected_results_to_json_summary(const char testName[], | 853 void add_expected_results_to_json_summary(const char testName[], |
854 Expectations expectations) { | 854 Expectations expectations) { |
855 this->fJsonExpectedResults[testName] = expectations.asJsonValue(); | 855 this->fJsonExpectedResults[testName] = expectations.asJsonValue(); |
856 } | 856 } |
857 | 857 |
858 /** | 858 /** |
859 * Compare actualBitmap to expectations stored in this->fExpectationsSource. | 859 * Compare actualBitmap to expectations stored in this->fExpectationsSource. |
860 * | 860 * |
861 * @param gm which test generated the actualBitmap | 861 * @param gm which test generated the actualBitmap |
862 * @param gRec | 862 * @param gRec |
epoger
2013/08/21 17:55:32
If you make any other changes before committing, p
ducky
2013/08/21 18:01:34
Why not, fixed.
| |
863 * @param actualBitmapAndDigest ptr to bitmap generated by this run, or NULL | 863 * @param actualBitmapAndDigest ptr to bitmap generated by this run, or NULL |
864 * if we don't have a usable bitmap representation | 864 * if we don't have a usable bitmap representation |
865 */ | 865 */ |
866 ErrorCombination compare_test_results_to_stored_expectations( | 866 ErrorCombination compare_test_results_to_stored_expectations( |
867 GM* gm, const ConfigData& gRec, | 867 GM* gm, const ConfigData& gRec, const char* configName, |
868 const BitmapAndDigest* actualBitmapAndDigest) { | 868 const BitmapAndDigest* actualBitmapAndDigest) { |
869 | 869 |
870 SkString shortNamePlusConfig = make_shortname_plus_config(gm->shortName( ), gRec.fName); | 870 SkString shortNamePlusConfig = make_shortname_plus_config(gm->shortName( ), configName); |
871 | 871 |
872 ErrorCombination errors; | 872 ErrorCombination errors; |
873 | 873 |
874 if (NULL == actualBitmapAndDigest) { | 874 if (NULL == actualBitmapAndDigest) { |
875 // Note that we intentionally skipped validating the results for | 875 // Note that we intentionally skipped validating the results for |
876 // this test, because we don't know how to generate an SkBitmap | 876 // this test, because we don't know how to generate an SkBitmap |
877 // version of the output. | 877 // version of the output. |
878 errors.add(ErrorCombination(kIntentionallySkipped_ErrorType)); | 878 errors.add(ErrorCombination(kIntentionallySkipped_ErrorType)); |
879 } else if (!(gRec.fFlags & kWrite_ConfigFlag)) { | 879 } else if (!(gRec.fFlags & kWrite_ConfigFlag)) { |
880 // We don't record the results for this test or compare them | 880 // We don't record the results for this test or compare them |
(...skipping 17 matching lines...) Expand all Loading... | |
898 * TODO(epoger): This relies on the fact that | 898 * TODO(epoger): This relies on the fact that |
899 * force_all_opaque() was called on the bitmap before it | 899 * force_all_opaque() was called on the bitmap before it |
900 * was written to disk as a PNG in the first place. If | 900 * was written to disk as a PNG in the first place. If |
901 * not, the hash digest returned here may not match the | 901 * not, the hash digest returned here may not match the |
902 * hash digest of actualBitmap, which *has* been run through | 902 * hash digest of actualBitmap, which *has* been run through |
903 * force_all_opaque(). | 903 * force_all_opaque(). |
904 * See comments above complete_bitmap() for more detail. | 904 * See comments above complete_bitmap() for more detail. |
905 */ | 905 */ |
906 Expectations expectations = expectationsSource->get(nameWithExte nsion.c_str()); | 906 Expectations expectations = expectationsSource->get(nameWithExte nsion.c_str()); |
907 errors.add(compare_to_expectations(expectations, *actualBitmapAn dDigest, | 907 errors.add(compare_to_expectations(expectations, *actualBitmapAn dDigest, |
908 gm->shortName(), gRec.fName, "", true)); | 908 gm->shortName(), configName, "", true)); |
909 } else { | 909 } else { |
910 // If we are running without expectations, we still want to | 910 // If we are running without expectations, we still want to |
911 // record the actual results. | 911 // record the actual results. |
912 add_actual_results_to_json_summary(nameWithExtension.c_str(), | 912 add_actual_results_to_json_summary(nameWithExtension.c_str(), |
913 actualBitmapAndDigest->fDiges t, | 913 actualBitmapAndDigest->fDiges t, |
914 ErrorCombination(kMissingExpe ctations_ErrorType), | 914 ErrorCombination(kMissingExpe ctations_ErrorType), |
915 false); | 915 false); |
916 errors.add(ErrorCombination(kMissingExpectations_ErrorType)); | 916 errors.add(ErrorCombination(kMissingExpectations_ErrorType)); |
917 } | 917 } |
918 } | 918 } |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1015 // Early exit if we can't generate the image. | 1015 // Early exit if we can't generate the image. |
1016 errors.add(generate_image(gm, gRec, gpuTarget, bitmap, false)); | 1016 errors.add(generate_image(gm, gRec, gpuTarget, bitmap, false)); |
1017 if (!errors.isEmpty()) { | 1017 if (!errors.isEmpty()) { |
1018 // TODO: Add a test to exercise what the stdout and | 1018 // TODO: Add a test to exercise what the stdout and |
1019 // JSON look like if we get an "early error" while | 1019 // JSON look like if we get an "early error" while |
1020 // trying to generate the image. | 1020 // trying to generate the image. |
1021 return errors; | 1021 return errors; |
1022 } | 1022 } |
1023 BitmapAndDigest bitmapAndDigest(*bitmap); | 1023 BitmapAndDigest bitmapAndDigest(*bitmap); |
1024 errors.add(compare_test_results_to_stored_expectations( | 1024 errors.add(compare_test_results_to_stored_expectations( |
1025 gm, gRec, &bitmapAndDigest)); | 1025 gm, gRec, gRec.fName, &bitmapAndDigest)); |
1026 | 1026 |
1027 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { | 1027 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { |
1028 path = make_bitmap_filename(writePath, gm->shortName(), gRec.fNa me, | 1028 path = make_bitmap_filename(writePath, gm->shortName(), gRec.fNa me, |
1029 "", bitmapAndDigest.fDigest); | 1029 "", bitmapAndDigest.fDigest); |
1030 errors.add(write_bitmap(path, bitmapAndDigest.fBitmap)); | 1030 errors.add(write_bitmap(path, bitmapAndDigest.fBitmap)); |
1031 } | 1031 } |
1032 } else if (gRec.fBackend == kPDF_Backend) { | 1032 } else if (gRec.fBackend == kPDF_Backend) { |
1033 generate_pdf(gm, document); | 1033 generate_pdf(gm, document); |
1034 | 1034 |
1035 SkAutoTUnref<SkStreamAsset> documentStream(document.detachAsStream() ); | 1035 SkAutoTUnref<SkStreamAsset> documentStream(document.detachAsStream() ); |
1036 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { | 1036 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { |
1037 path = make_filename(writePath, gm->shortName(), gRec.fName, "", "pdf"); | 1037 path = make_filename(writePath, gm->shortName(), gRec.fName, "", "pdf"); |
1038 errors.add(write_document(path, documentStream)); | 1038 errors.add(write_document(path, documentStream)); |
1039 } | 1039 } |
1040 | 1040 |
1041 if (!(gm->getFlags() & GM::kSkipPDFRasterization_Flag)) { | 1041 if (!(gm->getFlags() & GM::kSkipPDFRasterization_Flag)) { |
1042 for (int i = 0; i < pdfRasterizers.count(); i++) { | 1042 for (int i = 0; i < pdfRasterizers.count(); i++) { |
1043 SkBitmap pdfBitmap; | 1043 SkBitmap pdfBitmap; |
1044 SkASSERT(documentStream->rewind()); | 1044 SkASSERT(documentStream->rewind()); |
1045 bool success = (*pdfRasterizers[i]->fRasterizerFunction)( | 1045 bool success = (*pdfRasterizers[i]->fRasterizerFunction)( |
1046 documentStream.get(), &pdfBitmap); | 1046 documentStream.get(), &pdfBitmap); |
1047 if (!success) { | 1047 if (!success) { |
1048 gm_fprintf(stderr, "FAILED to render PDF for %s using re nderer %s\n", | 1048 gm_fprintf(stderr, "FAILED to render PDF for %s using re nderer %s\n", |
1049 gm->shortName(), | 1049 gm->shortName(), |
1050 pdfRasterizers[i]->fName); | 1050 pdfRasterizers[i]->fName); |
1051 continue; | 1051 continue; |
1052 } | 1052 } |
1053 | 1053 |
1054 SkString configName(gRec.fName); | |
epoger
2013/08/21 17:55:32
I guess it wouldn't work for gRec.fName to return
ducky
2013/08/21 18:01:34
Nope. gRec doesn't have any fields to run arbitrar
epoger
2013/08/21 18:05:20
Gotcha, thanks for the explanation.
Would it make
| |
1055 configName.append("-"); | |
1056 configName.append(pdfRasterizers[i]->fName); | |
1057 | |
1054 BitmapAndDigest bitmapAndDigest(pdfBitmap); | 1058 BitmapAndDigest bitmapAndDigest(pdfBitmap); |
1055 errors.add(compare_test_results_to_stored_expectations( | 1059 errors.add(compare_test_results_to_stored_expectations( |
1056 gm, gRec, &bitmapAndDigest)); | 1060 gm, gRec, configName.c_str(), &bitmapAndDigest)); |
1057 | |
1058 SkString configName(gRec.fName); | |
1059 configName.append("_"); | |
1060 configName.append(pdfRasterizers[i]->fName); | |
1061 | 1061 |
1062 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { | 1062 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { |
1063 path = make_bitmap_filename(writePath, gm->shortName(), configName.c_str(), | 1063 path = make_bitmap_filename(writePath, gm->shortName(), configName.c_str(), |
1064 "", bitmapAndDigest.fDigest) ; | 1064 "", bitmapAndDigest.fDigest) ; |
1065 errors.add(write_bitmap(path, bitmapAndDigest.fBitmap)); | 1065 errors.add(write_bitmap(path, bitmapAndDigest.fBitmap)); |
1066 } | 1066 } |
1067 } | 1067 } |
1068 } else { | 1068 } else { |
1069 errors.add(kIntentionallySkipped_ErrorType); | 1069 errors.add(kIntentionallySkipped_ErrorType); |
1070 } | 1070 } |
1071 } else if (gRec.fBackend == kXPS_Backend) { | 1071 } else if (gRec.fBackend == kXPS_Backend) { |
1072 generate_xps(gm, document); | 1072 generate_xps(gm, document); |
1073 SkAutoTUnref<SkStreamAsset> documentStream(document.detachAsStream() ); | 1073 SkAutoTUnref<SkStreamAsset> documentStream(document.detachAsStream() ); |
1074 | 1074 |
1075 errors.add(compare_test_results_to_stored_expectations( | 1075 errors.add(compare_test_results_to_stored_expectations( |
1076 gm, gRec, NULL)); | 1076 gm, gRec, gRec.fName, NULL)); |
1077 | 1077 |
1078 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { | 1078 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { |
1079 path = make_filename(writePath, gm->shortName(), gRec.fName, "", "xps"); | 1079 path = make_filename(writePath, gm->shortName(), gRec.fName, "", "xps"); |
1080 errors.add(write_document(path, documentStream)); | 1080 errors.add(write_document(path, documentStream)); |
1081 } | 1081 } |
1082 } else { | 1082 } else { |
1083 SkASSERT(false); | 1083 SkASSERT(false); |
1084 } | 1084 } |
1085 return errors; | 1085 return errors; |
1086 } | 1086 } |
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1818 ConfigData config = gRec[configs[i]]; | 1818 ConfigData config = gRec[configs[i]]; |
1819 SkString subdir; | 1819 SkString subdir; |
1820 subdir.appendf("%s%c%s", root, SkPATH_SEPARATOR, config.fName); | 1820 subdir.appendf("%s%c%s", root, SkPATH_SEPARATOR, config.fName); |
1821 if (!sk_mkdir(subdir.c_str())) { | 1821 if (!sk_mkdir(subdir.c_str())) { |
1822 return false; | 1822 return false; |
1823 } | 1823 } |
1824 | 1824 |
1825 if (config.fBackend == kPDF_Backend) { | 1825 if (config.fBackend == kPDF_Backend) { |
1826 for (int j = 0; j < pdfRasterizers.count(); j++) { | 1826 for (int j = 0; j < pdfRasterizers.count(); j++) { |
1827 SkString pdfSubdir = subdir; | 1827 SkString pdfSubdir = subdir; |
1828 pdfSubdir.appendf("_%s", pdfRasterizers[j]->fName); | 1828 pdfSubdir.appendf("-%s", pdfRasterizers[j]->fName); |
1829 if (!sk_mkdir(pdfSubdir.c_str())) { | 1829 if (!sk_mkdir(pdfSubdir.c_str())) { |
1830 return false; | 1830 return false; |
1831 } | 1831 } |
1832 } | 1832 } |
1833 } | 1833 } |
1834 } | 1834 } |
1835 } | 1835 } |
1836 return true; | 1836 return true; |
1837 } | 1837 } |
1838 | 1838 |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2298 if (FLAGS_forceBWtext) { | 2298 if (FLAGS_forceBWtext) { |
2299 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 2299 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
2300 } | 2300 } |
2301 } | 2301 } |
2302 | 2302 |
2303 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 2303 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
2304 int main(int argc, char * const argv[]) { | 2304 int main(int argc, char * const argv[]) { |
2305 return tool_main(argc, (char**) argv); | 2305 return tool_main(argc, (char**) argv); |
2306 } | 2306 } |
2307 #endif | 2307 #endif |
OLD | NEW |