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

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: fix Created 7 years, 6 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 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 dev->beginSheet(unitsPerMeter, pixelsPerMeter, trimSize); 627 dev->beginSheet(unitsPerMeter, pixelsPerMeter, trimSize);
628 invokeGM(gm, &c, false, false); 628 invokeGM(gm, &c, false, false);
629 dev->endSheet(); 629 dev->endSheet();
630 dev->endPortfolio(); 630 dev->endPortfolio();
631 631
632 #endif 632 #endif
633 } 633 }
634 634
635 ErrorCombination write_reference_image(const ConfigData& gRec, const char wr itePath [], 635 ErrorCombination write_reference_image(const ConfigData& gRec, const char wr itePath [],
636 const char renderModeDescriptor [], 636 const char renderModeDescriptor [],
637 const char *shortName, SkBitmap& bitm ap, 637 const char *shortName, const SkBitmap * bitmap,
638 SkDynamicMemoryWStream* document) { 638 SkDynamicMemoryWStream* document) {
639 SkString path; 639 SkString path;
640 bool success = false; 640 bool success = false;
641 if (gRec.fBackend == kRaster_Backend || 641 if (gRec.fBackend == kRaster_Backend ||
642 gRec.fBackend == kGPU_Backend || 642 gRec.fBackend == kGPU_Backend ||
643 (gRec.fBackend == kPDF_Backend && CAN_IMAGE_PDF)) { 643 (gRec.fBackend == kPDF_Backend && CAN_IMAGE_PDF)) {
644 644
645 path = make_filename(writePath, shortName, gRec.fName, renderModeDes criptor, 645 path = make_filename(writePath, shortName, gRec.fName, renderModeDes criptor,
646 kPNG_FileExtension); 646 kPNG_FileExtension);
647 success = write_bitmap(path, bitmap); 647 success = write_bitmap(path, *bitmap);
648 } 648 }
649 if (kPDF_Backend == gRec.fBackend) { 649 if (kPDF_Backend == gRec.fBackend) {
650 path = make_filename(writePath, shortName, gRec.fName, renderModeDes criptor, 650 path = make_filename(writePath, shortName, gRec.fName, renderModeDes criptor,
651 "pdf"); 651 "pdf");
652 success = write_document(path, *document); 652 success = write_document(path, *document);
653 } 653 }
654 if (kXPS_Backend == gRec.fBackend) { 654 if (kXPS_Backend == gRec.fBackend) {
655 path = make_filename(writePath, shortName, gRec.fName, renderModeDes criptor, 655 path = make_filename(writePath, shortName, gRec.fName, renderModeDes criptor,
656 "xps"); 656 "xps");
657 success = write_document(path, *document); 657 success = write_document(path, *document);
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 this->fJsonExpectedResults[testName] = expectations.asJsonValue(); 857 this->fJsonExpectedResults[testName] = expectations.asJsonValue();
858 } 858 }
859 859
860 /** 860 /**
861 * Compare actualBitmap to expectations stored in this->fExpectationsSource. 861 * Compare actualBitmap to expectations stored in this->fExpectationsSource.
862 * 862 *
863 * @param gm which test generated the actualBitmap 863 * @param gm which test generated the actualBitmap
864 * @param gRec 864 * @param gRec
865 * @param writePath unless this is NULL, write out actual images into this 865 * @param writePath unless this is NULL, write out actual images into this
866 * directory 866 * directory
867 * @param actualBitmap bitmap generated by this run 867 * @param actualBitmap ptr to bitmap generated by this run, or NULL if we
868 * @param pdf 868 * don't have a usable bitmap representation
869 * @param document pdf or xps representation, if appropriate
869 */ 870 */
870 ErrorCombination compare_test_results_to_stored_expectations( 871 ErrorCombination compare_test_results_to_stored_expectations(
871 GM* gm, const ConfigData& gRec, const char writePath[], 872 GM* gm, const ConfigData& gRec, const char writePath[],
872 SkBitmap& actualBitmap, SkDynamicMemoryWStream* pdf) { 873 const SkBitmap* actualBitmap, SkDynamicMemoryWStream* document) {
873 874
874 SkString shortNamePlusConfig = make_shortname_plus_config(gm->shortName( ), gRec.fName); 875 SkString shortNamePlusConfig = make_shortname_plus_config(gm->shortName( ), gRec.fName);
875 SkString nameWithExtension(shortNamePlusConfig); 876 SkString nameWithExtension(shortNamePlusConfig);
876 nameWithExtension.append("."); 877 nameWithExtension.append(".");
877 nameWithExtension.append(kPNG_FileExtension); 878 nameWithExtension.append(kPNG_FileExtension);
878 879
879 ErrorCombination errors; 880 ErrorCombination errors;
880 ExpectationsSource *expectationsSource = this->fExpectationsSource.get() ; 881
881 if (expectationsSource && (gRec.fFlags & kRead_ConfigFlag)) { 882 if (NULL == actualBitmap) {
882 /* 883 // Note that we intentionally skipped validating the results for
883 * Get the expected results for this test, as one or more allowed 884 // this test, because we don't know how to generate an SkBitmap
884 * hash digests. The current implementation of expectationsSource 885 // version of the output.
885 * get this by computing the hash digest of a single PNG file on dis k. 886 RecordTestResults(ErrorCombination(kIntentionallySkipped_ErrorType),
epoger 2013/06/18 05:20:10 Patchset 3 gives us better behavior... when render
886 * 887 shortNamePlusConfig, "");
887 * TODO(epoger): This relies on the fact that
888 * force_all_opaque() was called on the bitmap before it
889 * was written to disk as a PNG in the first place. If
890 * not, the hash digest returned here may not match the
891 * hash digest of actualBitmap, which *has* been run through
892 * force_all_opaque().
893 * See comments above complete_bitmap() for more detail.
894 */
895 Expectations expectations = expectationsSource->get(nameWithExtensio n.c_str());
896 errors.add(compare_to_expectations(expectations, actualBitmap,
897 gm->shortName(), gRec.fName, "", true));
898 } else { 888 } else {
899 // If we are running without expectations, we still want to 889 ExpectationsSource *expectationsSource = this->fExpectationsSource.g et();
900 // record the actual results. 890 if (expectationsSource && (gRec.fFlags & kRead_ConfigFlag)) {
epoger 2013/06/18 05:20:10 This section is just moved down and tab-indented.
901 GmResultDigest actualResultDigest(actualBitmap); 891 /*
902 add_actual_results_to_json_summary(nameWithExtension.c_str(), actual ResultDigest, 892 * Get the expected results for this test, as one or more allowe d
903 ErrorCombination(kMissingExpectat ions_ErrorType), 893 * hash digests. The current implementation of expectationsSourc e
904 false); 894 * get this by computing the hash digest of a single PNG file on disk.
905 RecordTestResults(ErrorCombination(kMissingExpectations_ErrorType), 895 *
906 shortNamePlusConfig, ""); 896 * TODO(epoger): This relies on the fact that
897 * force_all_opaque() was called on the bitmap before it
898 * was written to disk as a PNG in the first place. If
899 * not, the hash digest returned here may not match the
900 * hash digest of actualBitmap, which *has* been run through
901 * force_all_opaque().
902 * See comments above complete_bitmap() for more detail.
903 */
904 Expectations expectations = expectationsSource->get(nameWithExte nsion.c_str());
905 errors.add(compare_to_expectations(expectations, *actualBitmap,
906 gm->shortName(), gRec.fName, "", true));
907 } else {
908 // If we are running without expectations, we still want to
909 // record the actual results.
910 GmResultDigest actualResultDigest(*actualBitmap);
911 add_actual_results_to_json_summary(nameWithExtension.c_str(), ac tualResultDigest,
912 ErrorCombination(kMissingExpe ctations_ErrorType),
913 false);
914 RecordTestResults(ErrorCombination(kMissingExpectations_ErrorTyp e),
915 shortNamePlusConfig, "");
916 }
907 } 917 }
908 918
909 // TODO: Consider moving this into compare_to_expectations(), 919 // TODO: Consider moving this into compare_to_expectations(),
910 // similar to fMismatchPath... for now, we don't do that, because 920 // similar to fMismatchPath... for now, we don't do that, because
911 // we don't want to write out the actual bitmaps for all 921 // we don't want to write out the actual bitmaps for all
912 // renderModes of all tests! That would be a lot of files. 922 // renderModes of all tests! That would be a lot of files.
913 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { 923 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) {
914 errors.add(write_reference_image(gRec, writePath, "", gm->shortName( ), 924 errors.add(write_reference_image(gRec, writePath, "", gm->shortName( ),
915 actualBitmap, pdf)); 925 actualBitmap, document));
916 } 926 }
917 927
918 return errors; 928 return errors;
919 } 929 }
920 930
921 /** 931 /**
922 * Compare actualBitmap to referenceBitmap. 932 * Compare actualBitmap to referenceBitmap.
923 * 933 *
924 * @param shortName test name, e.g. "selftest1" 934 * @param shortName test name, e.g. "selftest1"
925 * @param configName configuration name, e.g. "8888" 935 * @param configName configuration name, e.g. "8888"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 // JSON look like if we get an "early error" while 1017 // JSON look like if we get an "early error" while
1008 // trying to generate the image. 1018 // trying to generate the image.
1009 return errors; 1019 return errors;
1010 } 1020 }
1011 } else if (gRec.fBackend == kPDF_Backend) { 1021 } else if (gRec.fBackend == kPDF_Backend) {
1012 generate_pdf(gm, document); 1022 generate_pdf(gm, document);
1013 #if CAN_IMAGE_PDF 1023 #if CAN_IMAGE_PDF
1014 SkAutoDataUnref data(document.copyToData()); 1024 SkAutoDataUnref data(document.copyToData());
1015 SkMemoryStream stream(data->data(), data->size()); 1025 SkMemoryStream stream(data->data(), data->size());
1016 SkPDFDocumentToBitmap(&stream, bitmap); 1026 SkPDFDocumentToBitmap(&stream, bitmap);
1027 #else
1028 bitmap = NULL; // we don't generate a bitmap rendering of the PDF f ile
1017 #endif 1029 #endif
1018 } else if (gRec.fBackend == kXPS_Backend) { 1030 } else if (gRec.fBackend == kXPS_Backend) {
1019 generate_xps(gm, document); 1031 generate_xps(gm, document);
1032 bitmap = NULL; // we don't generate a bitmap rendering of the XPS f ile
1020 } 1033 }
1021 return compare_test_results_to_stored_expectations( 1034 return compare_test_results_to_stored_expectations(
1022 gm, gRec, writePath, *bitmap, &document); 1035 gm, gRec, writePath, bitmap, &document);
1023 } 1036 }
1024 1037
1025 ErrorCombination test_deferred_drawing(GM* gm, 1038 ErrorCombination test_deferred_drawing(GM* gm,
1026 const ConfigData& gRec, 1039 const ConfigData& gRec,
1027 const SkBitmap& referenceBitmap, 1040 const SkBitmap& referenceBitmap,
1028 GrSurface* gpuTarget) { 1041 GrSurface* gpuTarget) {
1029 SkDynamicMemoryWStream document; 1042 SkDynamicMemoryWStream document;
1030 1043
1031 if (gRec.fBackend == kRaster_Backend || 1044 if (gRec.fBackend == kRaster_Backend ||
1032 gRec.fBackend == kGPU_Backend) { 1045 gRec.fBackend == kGPU_Backend) {
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
2087 if (FLAGS_forceBWtext) { 2100 if (FLAGS_forceBWtext) {
2088 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); 2101 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref();
2089 } 2102 }
2090 } 2103 }
2091 2104
2092 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 2105 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
2093 int main(int argc, char * const argv[]) { 2106 int main(int argc, char * const argv[]) {
2094 return tool_main(argc, (char**) argv); 2107 return tool_main(argc, (char**) argv);
2095 } 2108 }
2096 #endif 2109 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698