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

Side by Side Diff: gm/gmmain.cpp

Issue 22865029: Fix expectations in GM PDF rendering (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Update comments Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
863 * @param configName configuration name to use in the expectations file,
864 * usually gRec.fName unless using sub-configurations (like indicatin g
865 * PDF renderers)
863 * @param actualBitmapAndDigest ptr to bitmap generated by this run, or NULL 866 * @param actualBitmapAndDigest ptr to bitmap generated by this run, or NULL
864 * if we don't have a usable bitmap representation 867 * if we don't have a usable bitmap representation
865 */ 868 */
866 ErrorCombination compare_test_results_to_stored_expectations( 869 ErrorCombination compare_test_results_to_stored_expectations(
867 GM* gm, const ConfigData& gRec, 870 GM* gm, const ConfigData& gRec, const char* configName,
868 const BitmapAndDigest* actualBitmapAndDigest) { 871 const BitmapAndDigest* actualBitmapAndDigest) {
869 872
870 SkString shortNamePlusConfig = make_shortname_plus_config(gm->shortName( ), gRec.fName); 873 SkString shortNamePlusConfig = make_shortname_plus_config(gm->shortName( ), configName);
871 874
872 ErrorCombination errors; 875 ErrorCombination errors;
873 876
874 if (NULL == actualBitmapAndDigest) { 877 if (NULL == actualBitmapAndDigest) {
875 // Note that we intentionally skipped validating the results for 878 // Note that we intentionally skipped validating the results for
876 // this test, because we don't know how to generate an SkBitmap 879 // this test, because we don't know how to generate an SkBitmap
877 // version of the output. 880 // version of the output.
878 errors.add(ErrorCombination(kIntentionallySkipped_ErrorType)); 881 errors.add(ErrorCombination(kIntentionallySkipped_ErrorType));
879 } else if (!(gRec.fFlags & kWrite_ConfigFlag)) { 882 } else if (!(gRec.fFlags & kWrite_ConfigFlag)) {
880 // We don't record the results for this test or compare them 883 // We don't record the results for this test or compare them
(...skipping 17 matching lines...) Expand all
898 * TODO(epoger): This relies on the fact that 901 * TODO(epoger): This relies on the fact that
899 * force_all_opaque() was called on the bitmap before it 902 * force_all_opaque() was called on the bitmap before it
900 * was written to disk as a PNG in the first place. If 903 * was written to disk as a PNG in the first place. If
901 * not, the hash digest returned here may not match the 904 * not, the hash digest returned here may not match the
902 * hash digest of actualBitmap, which *has* been run through 905 * hash digest of actualBitmap, which *has* been run through
903 * force_all_opaque(). 906 * force_all_opaque().
904 * See comments above complete_bitmap() for more detail. 907 * See comments above complete_bitmap() for more detail.
905 */ 908 */
906 Expectations expectations = expectationsSource->get(nameWithExte nsion.c_str()); 909 Expectations expectations = expectationsSource->get(nameWithExte nsion.c_str());
907 errors.add(compare_to_expectations(expectations, *actualBitmapAn dDigest, 910 errors.add(compare_to_expectations(expectations, *actualBitmapAn dDigest,
908 gm->shortName(), gRec.fName, "", true)); 911 gm->shortName(), configName, "", true));
909 } else { 912 } else {
910 // If we are running without expectations, we still want to 913 // If we are running without expectations, we still want to
911 // record the actual results. 914 // record the actual results.
912 add_actual_results_to_json_summary(nameWithExtension.c_str(), 915 add_actual_results_to_json_summary(nameWithExtension.c_str(),
913 actualBitmapAndDigest->fDiges t, 916 actualBitmapAndDigest->fDiges t,
914 ErrorCombination(kMissingExpe ctations_ErrorType), 917 ErrorCombination(kMissingExpe ctations_ErrorType),
915 false); 918 false);
916 errors.add(ErrorCombination(kMissingExpectations_ErrorType)); 919 errors.add(ErrorCombination(kMissingExpectations_ErrorType));
917 } 920 }
918 } 921 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 // Early exit if we can't generate the image. 1018 // Early exit if we can't generate the image.
1016 errors.add(generate_image(gm, gRec, gpuTarget, bitmap, false)); 1019 errors.add(generate_image(gm, gRec, gpuTarget, bitmap, false));
1017 if (!errors.isEmpty()) { 1020 if (!errors.isEmpty()) {
1018 // TODO: Add a test to exercise what the stdout and 1021 // TODO: Add a test to exercise what the stdout and
1019 // JSON look like if we get an "early error" while 1022 // JSON look like if we get an "early error" while
1020 // trying to generate the image. 1023 // trying to generate the image.
1021 return errors; 1024 return errors;
1022 } 1025 }
1023 BitmapAndDigest bitmapAndDigest(*bitmap); 1026 BitmapAndDigest bitmapAndDigest(*bitmap);
1024 errors.add(compare_test_results_to_stored_expectations( 1027 errors.add(compare_test_results_to_stored_expectations(
1025 gm, gRec, &bitmapAndDigest)); 1028 gm, gRec, gRec.fName, &bitmapAndDigest));
1026 1029
1027 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { 1030 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) {
1028 path = make_bitmap_filename(writePath, gm->shortName(), gRec.fNa me, 1031 path = make_bitmap_filename(writePath, gm->shortName(), gRec.fNa me,
1029 "", bitmapAndDigest.fDigest); 1032 "", bitmapAndDigest.fDigest);
1030 errors.add(write_bitmap(path, bitmapAndDigest.fBitmap)); 1033 errors.add(write_bitmap(path, bitmapAndDigest.fBitmap));
1031 } 1034 }
1032 } else if (gRec.fBackend == kPDF_Backend) { 1035 } else if (gRec.fBackend == kPDF_Backend) {
1033 generate_pdf(gm, document); 1036 generate_pdf(gm, document);
1034 1037
1035 SkAutoTUnref<SkStreamAsset> documentStream(document.detachAsStream() ); 1038 SkAutoTUnref<SkStreamAsset> documentStream(document.detachAsStream() );
1036 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { 1039 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) {
1037 path = make_filename(writePath, gm->shortName(), gRec.fName, "", "pdf"); 1040 path = make_filename(writePath, gm->shortName(), gRec.fName, "", "pdf");
1038 errors.add(write_document(path, documentStream)); 1041 errors.add(write_document(path, documentStream));
1039 } 1042 }
1040 1043
1041 if (!(gm->getFlags() & GM::kSkipPDFRasterization_Flag)) { 1044 if (!(gm->getFlags() & GM::kSkipPDFRasterization_Flag)) {
1042 for (int i = 0; i < pdfRasterizers.count(); i++) { 1045 for (int i = 0; i < pdfRasterizers.count(); i++) {
1043 SkBitmap pdfBitmap; 1046 SkBitmap pdfBitmap;
1044 SkASSERT(documentStream->rewind()); 1047 SkASSERT(documentStream->rewind());
1045 bool success = (*pdfRasterizers[i]->fRasterizerFunction)( 1048 bool success = (*pdfRasterizers[i]->fRasterizerFunction)(
1046 documentStream.get(), &pdfBitmap); 1049 documentStream.get(), &pdfBitmap);
1047 if (!success) { 1050 if (!success) {
1048 gm_fprintf(stderr, "FAILED to render PDF for %s using re nderer %s\n", 1051 gm_fprintf(stderr, "FAILED to render PDF for %s using re nderer %s\n",
1049 gm->shortName(), 1052 gm->shortName(),
1050 pdfRasterizers[i]->fName); 1053 pdfRasterizers[i]->fName);
1051 continue; 1054 continue;
1052 } 1055 }
1053 1056
1057 SkString configName(gRec.fName);
1058 configName.append("-");
1059 configName.append(pdfRasterizers[i]->fName);
1060
1054 BitmapAndDigest bitmapAndDigest(pdfBitmap); 1061 BitmapAndDigest bitmapAndDigest(pdfBitmap);
1055 errors.add(compare_test_results_to_stored_expectations( 1062 errors.add(compare_test_results_to_stored_expectations(
1056 gm, gRec, &bitmapAndDigest)); 1063 gm, gRec, configName.c_str(), &bitmapAndDigest));
1057
1058 SkString configName(gRec.fName);
1059 configName.append("_");
1060 configName.append(pdfRasterizers[i]->fName);
1061 1064
1062 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { 1065 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) {
1063 path = make_bitmap_filename(writePath, gm->shortName(), configName.c_str(), 1066 path = make_bitmap_filename(writePath, gm->shortName(), configName.c_str(),
1064 "", bitmapAndDigest.fDigest) ; 1067 "", bitmapAndDigest.fDigest) ;
1065 errors.add(write_bitmap(path, bitmapAndDigest.fBitmap)); 1068 errors.add(write_bitmap(path, bitmapAndDigest.fBitmap));
1066 } 1069 }
1067 } 1070 }
1068 } else { 1071 } else {
1069 errors.add(kIntentionallySkipped_ErrorType); 1072 errors.add(kIntentionallySkipped_ErrorType);
1070 } 1073 }
1071 } else if (gRec.fBackend == kXPS_Backend) { 1074 } else if (gRec.fBackend == kXPS_Backend) {
1072 generate_xps(gm, document); 1075 generate_xps(gm, document);
1073 SkAutoTUnref<SkStreamAsset> documentStream(document.detachAsStream() ); 1076 SkAutoTUnref<SkStreamAsset> documentStream(document.detachAsStream() );
1074 1077
1075 errors.add(compare_test_results_to_stored_expectations( 1078 errors.add(compare_test_results_to_stored_expectations(
1076 gm, gRec, NULL)); 1079 gm, gRec, gRec.fName, NULL));
1077 1080
1078 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { 1081 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) {
1079 path = make_filename(writePath, gm->shortName(), gRec.fName, "", "xps"); 1082 path = make_filename(writePath, gm->shortName(), gRec.fName, "", "xps");
1080 errors.add(write_document(path, documentStream)); 1083 errors.add(write_document(path, documentStream));
1081 } 1084 }
1082 } else { 1085 } else {
1083 SkASSERT(false); 1086 SkASSERT(false);
1084 } 1087 }
1085 return errors; 1088 return errors;
1086 } 1089 }
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
1818 ConfigData config = gRec[configs[i]]; 1821 ConfigData config = gRec[configs[i]];
1819 SkString subdir; 1822 SkString subdir;
1820 subdir.appendf("%s%c%s", root, SkPATH_SEPARATOR, config.fName); 1823 subdir.appendf("%s%c%s", root, SkPATH_SEPARATOR, config.fName);
1821 if (!sk_mkdir(subdir.c_str())) { 1824 if (!sk_mkdir(subdir.c_str())) {
1822 return false; 1825 return false;
1823 } 1826 }
1824 1827
1825 if (config.fBackend == kPDF_Backend) { 1828 if (config.fBackend == kPDF_Backend) {
1826 for (int j = 0; j < pdfRasterizers.count(); j++) { 1829 for (int j = 0; j < pdfRasterizers.count(); j++) {
1827 SkString pdfSubdir = subdir; 1830 SkString pdfSubdir = subdir;
1828 pdfSubdir.appendf("_%s", pdfRasterizers[j]->fName); 1831 pdfSubdir.appendf("-%s", pdfRasterizers[j]->fName);
1829 if (!sk_mkdir(pdfSubdir.c_str())) { 1832 if (!sk_mkdir(pdfSubdir.c_str())) {
1830 return false; 1833 return false;
1831 } 1834 }
1832 } 1835 }
1833 } 1836 }
1834 } 1837 }
1835 } 1838 }
1836 return true; 1839 return true;
1837 } 1840 }
1838 1841
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
2298 if (FLAGS_forceBWtext) { 2301 if (FLAGS_forceBWtext) {
2299 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); 2302 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref();
2300 } 2303 }
2301 } 2304 }
2302 2305
2303 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 2306 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
2304 int main(int argc, char * const argv[]) { 2307 int main(int argc, char * const argv[]) {
2305 return tool_main(argc, (char**) argv); 2308 return tool_main(argc, (char**) argv);
2306 } 2309 }
2307 #endif 2310 #endif
OLDNEW
« no previous file with comments | « expectations/gm/base-macpro/expected-results.json ('k') | gm/tests/outputs/add-config-pdf/output-expected/json-summary.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698