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

Side by Side Diff: gm/gmmain.cpp

Issue 17366003: GM: stop recording all *_pdf.png results as "INVALID" on non-Mac platforms (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: reenable_pdf_test Created 7 years, 5 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
« no previous file with comments | « no previous file | gm/tests/outputs/add-config-pdf/output-expected/command_line » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 invokeGM(gm, &c, false, false); 657 invokeGM(gm, &c, false, false);
658 dev->endSheet(); 658 dev->endSheet();
659 dev->endPortfolio(); 659 dev->endPortfolio();
660 660
661 #endif 661 #endif
662 } 662 }
663 663
664 ErrorCombination write_reference_image(const ConfigData& gRec, const char wr itePath [], 664 ErrorCombination write_reference_image(const ConfigData& gRec, const char wr itePath [],
665 const char renderModeDescriptor [], 665 const char renderModeDescriptor [],
666 const char *shortName, 666 const char *shortName,
667 const BitmapAndDigest& bitmapAndDiges t, 667 const BitmapAndDigest* bitmapAndDiges t,
668 SkDynamicMemoryWStream* document) { 668 SkDynamicMemoryWStream* document) {
669 SkString path; 669 SkString path;
670 bool success = false; 670 bool success = false;
671 if (gRec.fBackend == kRaster_Backend || 671 if (gRec.fBackend == kRaster_Backend ||
672 gRec.fBackend == kGPU_Backend || 672 gRec.fBackend == kGPU_Backend ||
673 (gRec.fBackend == kPDF_Backend && CAN_IMAGE_PDF)) { 673 (gRec.fBackend == kPDF_Backend && CAN_IMAGE_PDF)) {
674 674
675 path = make_bitmap_filename(writePath, shortName, gRec.fName, render ModeDescriptor, 675 path = make_bitmap_filename(writePath, shortName, gRec.fName, render ModeDescriptor,
676 bitmapAndDigest.fDigest); 676 bitmapAndDigest->fDigest);
677 success = write_bitmap(path, bitmapAndDigest.fBitmap); 677 success = write_bitmap(path, bitmapAndDigest->fBitmap);
678 } 678 }
679 if (kPDF_Backend == gRec.fBackend) { 679 if (kPDF_Backend == gRec.fBackend) {
680 path = make_filename(writePath, shortName, gRec.fName, renderModeDes criptor, 680 path = make_filename(writePath, shortName, gRec.fName, renderModeDes criptor,
681 "pdf"); 681 "pdf");
682 success = write_document(path, *document); 682 success = write_document(path, *document);
683 } 683 }
684 if (kXPS_Backend == gRec.fBackend) { 684 if (kXPS_Backend == gRec.fBackend) {
685 path = make_filename(writePath, shortName, gRec.fName, renderModeDes criptor, 685 path = make_filename(writePath, shortName, gRec.fName, renderModeDes criptor,
686 "xps"); 686 "xps");
687 success = write_document(path, *document); 687 success = write_document(path, *document);
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 this->fJsonExpectedResults[testName] = expectations.asJsonValue(); 898 this->fJsonExpectedResults[testName] = expectations.asJsonValue();
899 } 899 }
900 900
901 /** 901 /**
902 * Compare actualBitmap to expectations stored in this->fExpectationsSource. 902 * Compare actualBitmap to expectations stored in this->fExpectationsSource.
903 * 903 *
904 * @param gm which test generated the actualBitmap 904 * @param gm which test generated the actualBitmap
905 * @param gRec 905 * @param gRec
906 * @param writePath unless this is NULL, write out actual images into this 906 * @param writePath unless this is NULL, write out actual images into this
907 * directory 907 * directory
908 * @param actualBitmap bitmap generated by this run 908 * @param actualBitmapAndDigest ptr to bitmap generated by this run, or NULL
909 * @param pdf 909 * if we don't have a usable bitmap representation
910 * @param document pdf or xps representation, if appropriate
910 */ 911 */
911 ErrorCombination compare_test_results_to_stored_expectations( 912 ErrorCombination compare_test_results_to_stored_expectations(
912 GM* gm, const ConfigData& gRec, const char writePath[], 913 GM* gm, const ConfigData& gRec, const char writePath[],
913 SkBitmap& actualBitmap, SkDynamicMemoryWStream* pdf) { 914 const BitmapAndDigest* actualBitmapAndDigest, SkDynamicMemoryWStream* do cument) {
914 915
915 BitmapAndDigest actualBitmapAndDigest(actualBitmap);
916 SkString shortNamePlusConfig = make_shortname_plus_config(gm->shortName( ), gRec.fName); 916 SkString shortNamePlusConfig = make_shortname_plus_config(gm->shortName( ), gRec.fName);
917 SkString nameWithExtension(shortNamePlusConfig); 917 SkString nameWithExtension(shortNamePlusConfig);
918 nameWithExtension.append("."); 918 nameWithExtension.append(".");
919 nameWithExtension.append(kPNG_FileExtension); 919 nameWithExtension.append(kPNG_FileExtension);
920 920
921 ErrorCombination errors; 921 ErrorCombination errors;
922 ExpectationsSource *expectationsSource = this->fExpectationsSource.get() ; 922
923 if (expectationsSource && (gRec.fFlags & kRead_ConfigFlag)) { 923 if (NULL == actualBitmapAndDigest) {
924 /* 924 // Note that we intentionally skipped validating the results for
925 * Get the expected results for this test, as one or more allowed 925 // this test, because we don't know how to generate an SkBitmap
926 * hash digests. The current implementation of expectationsSource 926 // version of the output.
927 * get this by computing the hash digest of a single PNG file on dis k. 927 RecordTestResults(ErrorCombination(kIntentionallySkipped_ErrorType),
928 * 928 shortNamePlusConfig, "");
929 * TODO(epoger): This relies on the fact that
930 * force_all_opaque() was called on the bitmap before it
931 * was written to disk as a PNG in the first place. If
932 * not, the hash digest returned here may not match the
933 * hash digest of actualBitmap, which *has* been run through
934 * force_all_opaque().
935 * See comments above complete_bitmap() for more detail.
936 */
937 Expectations expectations = expectationsSource->get(nameWithExtensio n.c_str());
938 errors.add(compare_to_expectations(expectations, actualBitmapAndDige st,
939 gm->shortName(), gRec.fName, "", true));
940 } else { 929 } else {
941 // If we are running without expectations, we still want to 930 ExpectationsSource *expectationsSource = this->fExpectationsSource.g et();
942 // record the actual results. 931 if (expectationsSource && (gRec.fFlags & kRead_ConfigFlag)) {
943 add_actual_results_to_json_summary(nameWithExtension.c_str(), 932 /*
944 actualBitmapAndDigest.fDigest, 933 * Get the expected results for this test, as one or more allowe d
945 ErrorCombination(kMissingExpectat ions_ErrorType), 934 * hash digests. The current implementation of expectationsSourc e
946 false); 935 * get this by computing the hash digest of a single PNG file on disk.
947 RecordTestResults(ErrorCombination(kMissingExpectations_ErrorType), 936 *
948 shortNamePlusConfig, ""); 937 * TODO(epoger): This relies on the fact that
938 * force_all_opaque() was called on the bitmap before it
939 * was written to disk as a PNG in the first place. If
940 * not, the hash digest returned here may not match the
941 * hash digest of actualBitmap, which *has* been run through
942 * force_all_opaque().
943 * See comments above complete_bitmap() for more detail.
944 */
945 Expectations expectations = expectationsSource->get(nameWithExte nsion.c_str());
946 errors.add(compare_to_expectations(expectations, *actualBitmapAn dDigest,
947 gm->shortName(), gRec.fName, "", true));
948 } else {
949 // If we are running without expectations, we still want to
950 // record the actual results.
951 add_actual_results_to_json_summary(nameWithExtension.c_str(),
952 actualBitmapAndDigest->fDiges t,
953 ErrorCombination(kMissingExpe ctations_ErrorType),
954 false);
955 RecordTestResults(ErrorCombination(kMissingExpectations_ErrorTyp e),
956 shortNamePlusConfig, "");
957 }
949 } 958 }
950 959
951 // TODO: Consider moving this into compare_to_expectations(), 960 // TODO: Consider moving this into compare_to_expectations(),
952 // similar to fMismatchPath... for now, we don't do that, because 961 // similar to fMismatchPath... for now, we don't do that, because
953 // we don't want to write out the actual bitmaps for all 962 // we don't want to write out the actual bitmaps for all
954 // renderModes of all tests! That would be a lot of files. 963 // renderModes of all tests! That would be a lot of files.
955 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { 964 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) {
956 errors.add(write_reference_image(gRec, writePath, "", gm->shortName( ), 965 errors.add(write_reference_image(gRec, writePath, "", gm->shortName( ),
957 actualBitmapAndDigest, pdf)); 966 actualBitmapAndDigest, document));
958 } 967 }
959 968
960 return errors; 969 return errors;
961 } 970 }
962 971
963 /** 972 /**
964 * Compare actualBitmap to referenceBitmap. 973 * Compare actualBitmap to referenceBitmap.
965 * 974 *
966 * @param shortName test name, e.g. "selftest1" 975 * @param shortName test name, e.g. "selftest1"
967 * @param configName configuration name, e.g. "8888" 976 * @param configName configuration name, e.g. "8888"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 // JSON look like if we get an "early error" while 1056 // JSON look like if we get an "early error" while
1048 // trying to generate the image. 1057 // trying to generate the image.
1049 return errors; 1058 return errors;
1050 } 1059 }
1051 } else if (gRec.fBackend == kPDF_Backend) { 1060 } else if (gRec.fBackend == kPDF_Backend) {
1052 generate_pdf(gm, document); 1061 generate_pdf(gm, document);
1053 #if CAN_IMAGE_PDF 1062 #if CAN_IMAGE_PDF
1054 SkAutoDataUnref data(document.copyToData()); 1063 SkAutoDataUnref data(document.copyToData());
1055 SkMemoryStream stream(data->data(), data->size()); 1064 SkMemoryStream stream(data->data(), data->size());
1056 SkPDFDocumentToBitmap(&stream, bitmap); 1065 SkPDFDocumentToBitmap(&stream, bitmap);
1066 #else
1067 bitmap = NULL; // we don't generate a bitmap rendering of the PDF f ile
1057 #endif 1068 #endif
1058 } else if (gRec.fBackend == kXPS_Backend) { 1069 } else if (gRec.fBackend == kXPS_Backend) {
1059 generate_xps(gm, document); 1070 generate_xps(gm, document);
1071 bitmap = NULL; // we don't generate a bitmap rendering of the XPS f ile
1060 } 1072 }
1061 return compare_test_results_to_stored_expectations( 1073
1062 gm, gRec, writePath, *bitmap, &document); 1074 if (NULL == bitmap) {
1075 return compare_test_results_to_stored_expectations(
1076 gm, gRec, writePath, NULL, &document);
1077 } else {
1078 BitmapAndDigest bitmapAndDigest(*bitmap);
1079 return compare_test_results_to_stored_expectations(
1080 gm, gRec, writePath, &bitmapAndDigest, &document);
1081 }
1063 } 1082 }
1064 1083
1065 ErrorCombination test_deferred_drawing(GM* gm, 1084 ErrorCombination test_deferred_drawing(GM* gm,
1066 const ConfigData& gRec, 1085 const ConfigData& gRec,
1067 const SkBitmap& referenceBitmap, 1086 const SkBitmap& referenceBitmap,
1068 GrSurface* gpuTarget) { 1087 GrSurface* gpuTarget) {
1069 SkDynamicMemoryWStream document; 1088 SkDynamicMemoryWStream document;
1070 1089
1071 if (gRec.fBackend == kRaster_Backend || 1090 if (gRec.fBackend == kRaster_Backend ||
1072 gRec.fBackend == kGPU_Backend) { 1091 gRec.fBackend == kGPU_Backend) {
(...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after
2146 if (FLAGS_forceBWtext) { 2165 if (FLAGS_forceBWtext) {
2147 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); 2166 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref();
2148 } 2167 }
2149 } 2168 }
2150 2169
2151 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 2170 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
2152 int main(int argc, char * const argv[]) { 2171 int main(int argc, char * const argv[]) {
2153 return tool_main(argc, (char**) argv); 2172 return tool_main(argc, (char**) argv);
2154 } 2173 }
2155 #endif 2174 #endif
OLDNEW
« no previous file with comments | « no previous file | gm/tests/outputs/add-config-pdf/output-expected/command_line » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698