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

Side by Side Diff: gm/gmmain.cpp

Issue 15415003: GM: make behavior of make_filename() more late-binding (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: sync_to_r9214 Created 7 years, 7 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 | « gm/gm_expectations.cpp ('k') | no next file » | 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 185
186 const static ErrorCombination kDefaultIgnorableErrorTypes = ErrorCombination() 186 const static ErrorCombination kDefaultIgnorableErrorTypes = ErrorCombination()
187 .plus(kMissingExpectations_ErrorType) 187 .plus(kMissingExpectations_ErrorType)
188 .plus(kIntentionallySkipped_ErrorType); 188 .plus(kIntentionallySkipped_ErrorType);
189 189
190 class GMMain { 190 class GMMain {
191 public: 191 public:
192 GMMain() : fUseFileHierarchy(false), fIgnorableErrorTypes(kDefaultIgnorableE rrorTypes), 192 GMMain() : fUseFileHierarchy(false), fIgnorableErrorTypes(kDefaultIgnorableE rrorTypes),
193 fMismatchPath(NULL), fTestsRun(0), fRenderModesEncountered(1) {} 193 fMismatchPath(NULL), fTestsRun(0), fRenderModesEncountered(1) {}
194 194
195 SkString make_name(const char shortName[], const char configName[]) { 195 /**
196 * Assemble shortNamePlusConfig from (surprise!) shortName and configName.
197 *
198 * The method for doing so depends on whether we are using hierarchical nami ng.
199 * For example, shortName "selftest1" and configName "8888" could be assembl ed into
200 * either "selftest1_8888" or "8888/selftest1".
201 */
202 SkString make_shortname_plus_config(const char *shortName, const char *confi gName) {
196 SkString name; 203 SkString name;
197 if (0 == strlen(configName)) { 204 if (0 == strlen(configName)) {
198 name.append(shortName); 205 name.append(shortName);
199 } else if (fUseFileHierarchy) { 206 } else if (fUseFileHierarchy) {
200 name.appendf("%s%c%s", configName, SkPATH_SEPARATOR, shortName); 207 name.appendf("%s%c%s", configName, SkPATH_SEPARATOR, shortName);
201 } else { 208 } else {
202 name.appendf("%s_%s", shortName, configName); 209 name.appendf("%s_%s", shortName, configName);
203 } 210 }
204 return name; 211 return name;
205 } 212 }
206 213
214 /**
215 * Assemble filename, suitable for writing out the results of a particular t est.
216 */
217 SkString make_filename(const char *path,
218 const char *shortName,
219 const char *configName,
220 const char *renderModeDescriptor,
221 const char *suffix) {
222 SkString filename = make_shortname_plus_config(shortName, configName);
223 filename.append(renderModeDescriptor);
224 filename.appendUnichar('.');
225 filename.append(suffix);
226 return SkPathJoin(path, filename.c_str());
227 }
228
207 /* since PNG insists on unpremultiplying our alpha, we take no 229 /* since PNG insists on unpremultiplying our alpha, we take no
208 precision chances and force all pixels to be 100% opaque, 230 precision chances and force all pixels to be 100% opaque,
209 otherwise on compare we may not get a perfect match. 231 otherwise on compare we may not get a perfect match.
210 */ 232 */
211 static void force_all_opaque(const SkBitmap& bitmap) { 233 static void force_all_opaque(const SkBitmap& bitmap) {
212 SkBitmap::Config config = bitmap.config(); 234 SkBitmap::Config config = bitmap.config();
213 switch (config) { 235 switch (config) {
214 case SkBitmap::kARGB_8888_Config: 236 case SkBitmap::kARGB_8888_Config:
215 force_all_opaque_8888(bitmap); 237 force_all_opaque_8888(bitmap);
216 break; 238 break;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 } 284 }
263 } 285 }
264 } 286 }
265 287
266 /** 288 /**
267 * Records the results of this test in fTestsRun and fFailedTests. 289 * Records the results of this test in fTestsRun and fFailedTests.
268 * 290 *
269 * We even record successes, and errors that we regard as 291 * We even record successes, and errors that we regard as
270 * "ignorable"; we can filter them out later. 292 * "ignorable"; we can filter them out later.
271 */ 293 */
272 void RecordTestResults(const ErrorCombination& errorCombination, const SkStr ing& name, 294 void RecordTestResults(const ErrorCombination& errorCombination,
295 const SkString& shortNamePlusConfig,
273 const char renderModeDescriptor []) { 296 const char renderModeDescriptor []) {
274 // Things to do regardless of errorCombination. 297 // Things to do regardless of errorCombination.
275 fTestsRun++; 298 fTestsRun++;
276 int renderModeCount = 0; 299 int renderModeCount = 0;
277 this->fRenderModesEncountered.find(renderModeDescriptor, &renderModeCoun t); 300 this->fRenderModesEncountered.find(renderModeDescriptor, &renderModeCoun t);
278 renderModeCount++; 301 renderModeCount++;
279 this->fRenderModesEncountered.set(renderModeDescriptor, renderModeCount) ; 302 this->fRenderModesEncountered.set(renderModeDescriptor, renderModeCount) ;
280 303
281 if (errorCombination.isEmpty()) { 304 if (errorCombination.isEmpty()) {
282 return; 305 return;
283 } 306 }
284 307
285 // Things to do only if there is some error condition. 308 // Things to do only if there is some error condition.
286 SkString fullName = name; 309 SkString fullName = shortNamePlusConfig;
287 fullName.append(renderModeDescriptor); 310 fullName.append(renderModeDescriptor);
288 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { 311 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) {
289 ErrorType type = static_cast<ErrorType>(typeInt); 312 ErrorType type = static_cast<ErrorType>(typeInt);
290 if (errorCombination.includes(type)) { 313 if (errorCombination.includes(type)) {
291 fFailedTests[type].push_back(fullName); 314 fFailedTests[type].push_back(fullName);
292 } 315 }
293 } 316 }
294 } 317 }
295 318
296 /** 319 /**
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 dev->beginPortfolio(&xps); 619 dev->beginPortfolio(&xps);
597 dev->beginSheet(unitsPerMeter, pixelsPerMeter, trimSize); 620 dev->beginSheet(unitsPerMeter, pixelsPerMeter, trimSize);
598 invokeGM(gm, &c, false, false); 621 invokeGM(gm, &c, false, false);
599 dev->endSheet(); 622 dev->endSheet();
600 dev->endPortfolio(); 623 dev->endPortfolio();
601 624
602 #endif 625 #endif
603 } 626 }
604 627
605 ErrorCombination write_reference_image(const ConfigData& gRec, const char wr itePath [], 628 ErrorCombination write_reference_image(const ConfigData& gRec, const char wr itePath [],
606 const char renderModeDescriptor [], c onst SkString& name, 629 const char renderModeDescriptor [],
607 SkBitmap& bitmap, SkDynamicMemoryWStr eam* document) { 630 const char *shortName, SkBitmap& bitm ap,
631 SkDynamicMemoryWStream* document) {
608 SkString path; 632 SkString path;
609 bool success = false; 633 bool success = false;
610 if (gRec.fBackend == kRaster_Backend || 634 if (gRec.fBackend == kRaster_Backend ||
611 gRec.fBackend == kGPU_Backend || 635 gRec.fBackend == kGPU_Backend ||
612 (gRec.fBackend == kPDF_Backend && CAN_IMAGE_PDF)) { 636 (gRec.fBackend == kPDF_Backend && CAN_IMAGE_PDF)) {
613 637
614 path = make_filename(writePath, renderModeDescriptor, name.c_str(), 638 path = make_filename(writePath, shortName, gRec.fName, renderModeDes criptor,
615 kPNG_FileExtension); 639 kPNG_FileExtension);
616 success = write_bitmap(path, bitmap); 640 success = write_bitmap(path, bitmap);
617 } 641 }
618 if (kPDF_Backend == gRec.fBackend) { 642 if (kPDF_Backend == gRec.fBackend) {
619 path = make_filename(writePath, renderModeDescriptor, name.c_str(), 643 path = make_filename(writePath, shortName, gRec.fName, renderModeDes criptor,
620 "pdf"); 644 "pdf");
621 success = write_document(path, *document); 645 success = write_document(path, *document);
622 } 646 }
623 if (kXPS_Backend == gRec.fBackend) { 647 if (kXPS_Backend == gRec.fBackend) {
624 path = make_filename(writePath, renderModeDescriptor, name.c_str(), 648 path = make_filename(writePath, shortName, gRec.fName, renderModeDes criptor,
625 "xps"); 649 "xps");
626 success = write_document(path, *document); 650 success = write_document(path, *document);
627 } 651 }
628 if (success) { 652 if (success) {
629 return kEmpty_ErrorCombination; 653 return kEmpty_ErrorCombination;
630 } else { 654 } else {
631 gm_fprintf(stderr, "FAILED to write %s\n", path.c_str()); 655 gm_fprintf(stderr, "FAILED to write %s\n", path.c_str());
632 ErrorCombination errors(kWritingReferenceImage_ErrorType); 656 ErrorCombination errors(kWritingReferenceImage_ErrorType);
633 // TODO(epoger): Don't call RecordTestResults() here... 657 // TODO(epoger): Don't call RecordTestResults() here...
634 // Instead, we should make sure to call RecordTestResults 658 // Instead, we should make sure to call RecordTestResults
635 // exactly ONCE per test. (Otherwise, gmmain.fTestsRun 659 // exactly ONCE per test. (Otherwise, gmmain.fTestsRun
636 // will be incremented twice for this test: once in 660 // will be incremented twice for this test: once in
637 // compare_test_results_to_stored_expectations() before 661 // compare_test_results_to_stored_expectations() before
638 // that method calls this one, and again here.) 662 // that method calls this one, and again here.)
639 // 663 //
640 // When we make that change, we should probably add a 664 // When we make that change, we should probably add a
641 // WritingReferenceImage test to the gm self-tests.) 665 // WritingReferenceImage test to the gm self-tests.)
642 RecordTestResults(errors, name, renderModeDescriptor); 666 RecordTestResults(errors, make_shortname_plus_config(shortName, gRec .fName),
667 renderModeDescriptor);
643 return errors; 668 return errors;
644 } 669 }
645 } 670 }
646 671
647 /** 672 /**
648 * Log more detail about the mistmatch between expectedBitmap and 673 * Log more detail about the mistmatch between expectedBitmap and
649 * actualBitmap. 674 * actualBitmap.
650 */ 675 */
651 void report_bitmap_diffs(const SkBitmap& expectedBitmap, const SkBitmap& act ualBitmap, 676 void report_bitmap_diffs(const SkBitmap& expectedBitmap, const SkBitmap& act ualBitmap,
652 const char *testName) { 677 const char *testName) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 727
703 /** 728 /**
704 * Compares actual hash digest to expectations, returning the set of errors 729 * Compares actual hash digest to expectations, returning the set of errors
705 * (if any) that we saw along the way. 730 * (if any) that we saw along the way.
706 * 731 *
707 * If fMismatchPath has been set, and there are pixel diffs, then the 732 * If fMismatchPath has been set, and there are pixel diffs, then the
708 * actual bitmap will be written out to a file within fMismatchPath. 733 * actual bitmap will be written out to a file within fMismatchPath.
709 * 734 *
710 * @param expectations what expectations to compare actualBitmap against 735 * @param expectations what expectations to compare actualBitmap against
711 * @param actualBitmap the image we actually generated 736 * @param actualBitmap the image we actually generated
712 * @param baseNameString name of test without renderModeDescriptor added 737 * @param shortName name of test, e.g. "selftest1"
738 * @param configName name of config, e.g. "8888"
713 * @param renderModeDescriptor e.g., "-rtree", "-deferred" 739 * @param renderModeDescriptor e.g., "-rtree", "-deferred"
714 * @param addToJsonSummary whether to add these results (both actual and 740 * @param addToJsonSummary whether to add these results (both actual and
715 * expected) to the JSON summary. Regardless of this setting, if 741 * expected) to the JSON summary. Regardless of this setting, if
716 * we find an image mismatch in this test, we will write these 742 * we find an image mismatch in this test, we will write these
717 * results to the JSON summary. (This is so that we will always 743 * results to the JSON summary. (This is so that we will always
718 * report errors across rendering modes, such as pipe vs tiled. 744 * report errors across rendering modes, such as pipe vs tiled.
719 * See https://codereview.chromium.org/13650002/ ) 745 * See https://codereview.chromium.org/13650002/ )
720 */ 746 */
721 ErrorCombination compare_to_expectations(Expectations expectations, 747 ErrorCombination compare_to_expectations(Expectations expectations,
722 const SkBitmap& actualBitmap, 748 const SkBitmap& actualBitmap,
723 const SkString& baseNameString, 749 const char *shortName, const char * configName,
724 const char renderModeDescriptor[], 750 const char *renderModeDescriptor,
725 bool addToJsonSummary) { 751 bool addToJsonSummary) {
726 ErrorCombination errors; 752 ErrorCombination errors;
727 SkHashDigest actualBitmapHash; 753 SkHashDigest actualBitmapHash;
728 // TODO(epoger): Better handling for error returned by ComputeDigest()? 754 // TODO(epoger): Better handling for error returned by ComputeDigest()?
729 // For now, we just report a digest of 0 in error cases, like before. 755 // For now, we just report a digest of 0 in error cases, like before.
730 if (!SkBitmapHasher::ComputeDigest(actualBitmap, &actualBitmapHash)) { 756 if (!SkBitmapHasher::ComputeDigest(actualBitmap, &actualBitmapHash)) {
731 actualBitmapHash = 0; 757 actualBitmapHash = 0;
732 } 758 }
733 SkString completeNameString = baseNameString; 759 SkString shortNamePlusConfig = make_shortname_plus_config(shortName, con figName);
760 SkString completeNameString(shortNamePlusConfig);
734 completeNameString.append(renderModeDescriptor); 761 completeNameString.append(renderModeDescriptor);
735 completeNameString.append("."); 762 completeNameString.append(".");
736 completeNameString.append(kPNG_FileExtension); 763 completeNameString.append(kPNG_FileExtension);
737 const char* completeName = completeNameString.c_str(); 764 const char* completeName = completeNameString.c_str();
738 765
739 if (expectations.empty()) { 766 if (expectations.empty()) {
740 errors.add(kMissingExpectations_ErrorType); 767 errors.add(kMissingExpectations_ErrorType);
741 } else if (!expectations.match(actualBitmapHash)) { 768 } else if (!expectations.match(actualBitmapHash)) {
742 addToJsonSummary = true; 769 addToJsonSummary = true;
743 // The error mode we record depends on whether this was running 770 // The error mode we record depends on whether this was running
744 // in a non-standard renderMode. 771 // in a non-standard renderMode.
745 if ('\0' == *renderModeDescriptor) { 772 if ('\0' == *renderModeDescriptor) {
746 errors.add(kExpectationsMismatch_ErrorType); 773 errors.add(kExpectationsMismatch_ErrorType);
747 } else { 774 } else {
748 errors.add(kRenderModeMismatch_ErrorType); 775 errors.add(kRenderModeMismatch_ErrorType);
749 } 776 }
750 777
751 // Write out the "actuals" for any mismatches, if we have 778 // Write out the "actuals" for any mismatches, if we have
752 // been directed to do so. 779 // been directed to do so.
753 if (fMismatchPath) { 780 if (fMismatchPath) {
754 SkString path = 781 SkString path =
755 make_filename(fMismatchPath, renderModeDescriptor, 782 make_filename(fMismatchPath, shortName, configName, renderMo deDescriptor,
756 baseNameString.c_str(), kPNG_FileExtension); 783 kPNG_FileExtension);
757 write_bitmap(path, actualBitmap); 784 write_bitmap(path, actualBitmap);
758 } 785 }
759 786
760 // If we have access to a single expected bitmap, log more 787 // If we have access to a single expected bitmap, log more
761 // detail about the mismatch. 788 // detail about the mismatch.
762 const SkBitmap *expectedBitmapPtr = expectations.asBitmap(); 789 const SkBitmap *expectedBitmapPtr = expectations.asBitmap();
763 if (NULL != expectedBitmapPtr) { 790 if (NULL != expectedBitmapPtr) {
764 report_bitmap_diffs(*expectedBitmapPtr, actualBitmap, completeNa me); 791 report_bitmap_diffs(*expectedBitmapPtr, actualBitmap, completeNa me);
765 } 792 }
766 } 793 }
767 RecordTestResults(errors, baseNameString, renderModeDescriptor); 794 RecordTestResults(errors, shortNamePlusConfig, renderModeDescriptor);
768 795
769 if (addToJsonSummary) { 796 if (addToJsonSummary) {
770 add_actual_results_to_json_summary(completeName, actualBitmapHash, e rrors, 797 add_actual_results_to_json_summary(completeName, actualBitmapHash, e rrors,
771 expectations.ignoreFailure()); 798 expectations.ignoreFailure());
772 add_expected_results_to_json_summary(completeName, expectations); 799 add_expected_results_to_json_summary(completeName, expectations);
773 } 800 }
774 801
775 return errors; 802 return errors;
776 } 803 }
777 804
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 * @param gRec 862 * @param gRec
836 * @param writePath unless this is NULL, write out actual images into this 863 * @param writePath unless this is NULL, write out actual images into this
837 * directory 864 * directory
838 * @param actualBitmap bitmap generated by this run 865 * @param actualBitmap bitmap generated by this run
839 * @param pdf 866 * @param pdf
840 */ 867 */
841 ErrorCombination compare_test_results_to_stored_expectations( 868 ErrorCombination compare_test_results_to_stored_expectations(
842 GM* gm, const ConfigData& gRec, const char writePath[], 869 GM* gm, const ConfigData& gRec, const char writePath[],
843 SkBitmap& actualBitmap, SkDynamicMemoryWStream* pdf) { 870 SkBitmap& actualBitmap, SkDynamicMemoryWStream* pdf) {
844 871
845 SkString name = make_name(gm->shortName(), gRec.fName); 872 SkString shortNamePlusConfig = make_shortname_plus_config(gm->shortName( ), gRec.fName);
873 SkString nameWithExtension(shortNamePlusConfig);
874 nameWithExtension.append(".");
875 nameWithExtension.append(kPNG_FileExtension);
876
846 ErrorCombination errors; 877 ErrorCombination errors;
847
848 ExpectationsSource *expectationsSource = this->fExpectationsSource.get() ; 878 ExpectationsSource *expectationsSource = this->fExpectationsSource.get() ;
849 if (expectationsSource && (gRec.fFlags & kRead_ConfigFlag)) { 879 if (expectationsSource && (gRec.fFlags & kRead_ConfigFlag)) {
850 /* 880 /*
851 * Get the expected results for this test, as one or more allowed 881 * Get the expected results for this test, as one or more allowed
852 * hash digests. The current implementation of expectationsSource 882 * hash digests. The current implementation of expectationsSource
853 * get this by computing the hash digest of a single PNG file on dis k. 883 * get this by computing the hash digest of a single PNG file on dis k.
854 * 884 *
855 * TODO(epoger): This relies on the fact that 885 * TODO(epoger): This relies on the fact that
856 * force_all_opaque() was called on the bitmap before it 886 * force_all_opaque() was called on the bitmap before it
857 * was written to disk as a PNG in the first place. If 887 * was written to disk as a PNG in the first place. If
858 * not, the hash digest returned here may not match the 888 * not, the hash digest returned here may not match the
859 * hash digest of actualBitmap, which *has* been run through 889 * hash digest of actualBitmap, which *has* been run through
860 * force_all_opaque(). 890 * force_all_opaque().
861 * See comments above complete_bitmap() for more detail. 891 * See comments above complete_bitmap() for more detail.
862 */ 892 */
863 SkString nameWithExtension(name);
864 nameWithExtension.append(".");
865 nameWithExtension.append(kPNG_FileExtension);
866 Expectations expectations = expectationsSource->get(nameWithExtensio n.c_str()); 893 Expectations expectations = expectationsSource->get(nameWithExtensio n.c_str());
867 errors.add(compare_to_expectations(expectations, actualBitmap, 894 errors.add(compare_to_expectations(expectations, actualBitmap,
868 name, "", true)); 895 gm->shortName(), gRec.fName, "", true));
869 } else { 896 } else {
870 // If we are running without expectations, we still want to 897 // If we are running without expectations, we still want to
871 // record the actual results. 898 // record the actual results.
872 SkHashDigest actualBitmapHash; 899 SkHashDigest actualBitmapHash;
873 // TODO(epoger): Better handling for error returned by ComputeDigest ()? 900 // TODO(epoger): Better handling for error returned by ComputeDigest ()?
874 // For now, we just report a digest of 0 in error cases, like before . 901 // For now, we just report a digest of 0 in error cases, like before .
875 if (!SkBitmapHasher::ComputeDigest(actualBitmap, &actualBitmapHash)) { 902 if (!SkBitmapHasher::ComputeDigest(actualBitmap, &actualBitmapHash)) {
876 actualBitmapHash = 0; 903 actualBitmapHash = 0;
877 } 904 }
878 SkString nameWithExtension(name);
879 nameWithExtension.append(".");
880 nameWithExtension.append(kPNG_FileExtension);
881 add_actual_results_to_json_summary(nameWithExtension.c_str(), actual BitmapHash, 905 add_actual_results_to_json_summary(nameWithExtension.c_str(), actual BitmapHash,
882 ErrorCombination(kMissingExpectat ions_ErrorType), 906 ErrorCombination(kMissingExpectat ions_ErrorType),
883 false); 907 false);
884 RecordTestResults(ErrorCombination(kMissingExpectations_ErrorType), name, ""); 908 RecordTestResults(ErrorCombination(kMissingExpectations_ErrorType),
909 shortNamePlusConfig, "");
885 } 910 }
886 911
887 // TODO: Consider moving this into compare_to_expectations(), 912 // TODO: Consider moving this into compare_to_expectations(),
888 // similar to fMismatchPath... for now, we don't do that, because 913 // similar to fMismatchPath... for now, we don't do that, because
889 // we don't want to write out the actual bitmaps for all 914 // we don't want to write out the actual bitmaps for all
890 // renderModes of all tests! That would be a lot of files. 915 // renderModes of all tests! That would be a lot of files.
891 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { 916 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) {
892 errors.add(write_reference_image(gRec, writePath, "", 917 errors.add(write_reference_image(gRec, writePath, "", gm->shortName( ),
893 name, actualBitmap, pdf)); 918 actualBitmap, pdf));
894 } 919 }
895 920
896 return errors; 921 return errors;
897 } 922 }
898 923
899 /** 924 /**
900 * Compare actualBitmap to referenceBitmap. 925 * Compare actualBitmap to referenceBitmap.
901 * 926 *
902 * @param baseNameString name of test without renderModeDescriptor added 927 * @param shortName test name, e.g. "selftest1"
928 * @param configName configuration name, e.g. "8888"
903 * @param renderModeDescriptor 929 * @param renderModeDescriptor
904 * @param actualBitmap actual bitmap generated by this run 930 * @param actualBitmap actual bitmap generated by this run
905 * @param referenceBitmap bitmap we expected to be generated 931 * @param referenceBitmap bitmap we expected to be generated
906 */ 932 */
907 ErrorCombination compare_test_results_to_reference_bitmap( 933 ErrorCombination compare_test_results_to_reference_bitmap(
908 const SkString& baseNameString, const char renderModeDescriptor[], 934 const char *shortName, const char *configName, const char *renderModeDes criptor,
909 SkBitmap& actualBitmap, const SkBitmap* referenceBitmap) { 935 SkBitmap& actualBitmap, const SkBitmap* referenceBitmap) {
910 936
911 SkASSERT(referenceBitmap); 937 SkASSERT(referenceBitmap);
912 Expectations expectations(*referenceBitmap); 938 Expectations expectations(*referenceBitmap);
913 return compare_to_expectations(expectations, actualBitmap, 939 return compare_to_expectations(expectations, actualBitmap, shortName,
914 baseNameString, renderModeDescriptor, fal se); 940 configName, renderModeDescriptor, false);
915 } 941 }
916 942
917 static SkPicture* generate_new_picture(GM* gm, BbhType bbhType, uint32_t rec ordFlags, 943 static SkPicture* generate_new_picture(GM* gm, BbhType bbhType, uint32_t rec ordFlags,
918 SkScalar scale = SK_Scalar1) { 944 SkScalar scale = SK_Scalar1) {
919 // Pictures are refcounted so must be on heap 945 // Pictures are refcounted so must be on heap
920 SkPicture* pict; 946 SkPicture* pict;
921 int width = SkScalarCeilToInt(SkScalarMul(SkIntToScalar(gm->getISize().w idth()), scale)); 947 int width = SkScalarCeilToInt(SkScalarMul(SkIntToScalar(gm->getISize().w idth()), scale));
922 int height = SkScalarCeilToInt(SkScalarMul(SkIntToScalar(gm->getISize(). height()), scale)); 948 int height = SkScalarCeilToInt(SkScalarMul(SkIntToScalar(gm->getISize(). height()), scale));
923 949
924 if (kTileGrid_BbhType == bbhType) { 950 if (kTileGrid_BbhType == bbhType) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 // https://codereview.chromium.org/12992003/ is unblocked. 1047 // https://codereview.chromium.org/12992003/ is unblocked.
1022 // 1048 //
1023 // Filed as https://code.google.com/p/skia/issues/detail?id=1180 1049 // Filed as https://code.google.com/p/skia/issues/detail?id=1180
1024 // ('image-surface gm test is failing in "deferred" mode, 1050 // ('image-surface gm test is failing in "deferred" mode,
1025 // and gm is not reporting the failure') 1051 // and gm is not reporting the failure')
1026 if (errors.isEmpty()) { 1052 if (errors.isEmpty()) {
1027 // TODO(epoger): Report this as a new ErrorType, 1053 // TODO(epoger): Report this as a new ErrorType,
1028 // something like kImageGeneration_ErrorType? 1054 // something like kImageGeneration_ErrorType?
1029 return kEmpty_ErrorCombination; 1055 return kEmpty_ErrorCombination;
1030 } 1056 }
1031 const SkString name = make_name(gm->shortName(), gRec.fName);
1032 return compare_test_results_to_reference_bitmap( 1057 return compare_test_results_to_reference_bitmap(
1033 name, renderModeDescriptor, bitmap, &referenceBitmap); 1058 gm->shortName(), gRec.fName, renderModeDescriptor, bitmap, &refe renceBitmap);
1034 } 1059 }
1035 return kEmpty_ErrorCombination; 1060 return kEmpty_ErrorCombination;
1036 } 1061 }
1037 1062
1038 ErrorCombination test_pipe_playback(GM* gm, const ConfigData& gRec, 1063 ErrorCombination test_pipe_playback(GM* gm, const ConfigData& gRec,
1039 const SkBitmap& referenceBitmap, bool si mulateFailure) { 1064 const SkBitmap& referenceBitmap, bool si mulateFailure) {
1040 const SkString name = make_name(gm->shortName(), gRec.fName); 1065 const SkString shortNamePlusConfig = make_shortname_plus_config(gm->shor tName(),
1066 gRec.fNa me);
1041 ErrorCombination errors; 1067 ErrorCombination errors;
1042 for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) { 1068 for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) {
1043 SkString renderModeDescriptor("-pipe"); 1069 SkString renderModeDescriptor("-pipe");
1044 renderModeDescriptor.append(gPipeWritingFlagCombos[i].name); 1070 renderModeDescriptor.append(gPipeWritingFlagCombos[i].name);
1045 1071
1046 if (gm->getFlags() & GM::kSkipPipe_Flag) { 1072 if (gm->getFlags() & GM::kSkipPipe_Flag) {
1047 RecordTestResults(kIntentionallySkipped_ErrorType, name, 1073 RecordTestResults(kIntentionallySkipped_ErrorType, shortNamePlus Config,
1048 renderModeDescriptor.c_str()); 1074 renderModeDescriptor.c_str());
1049 errors.add(kIntentionallySkipped_ErrorType); 1075 errors.add(kIntentionallySkipped_ErrorType);
1050 } else { 1076 } else {
1051 SkBitmap bitmap; 1077 SkBitmap bitmap;
1052 SkISize size = gm->getISize(); 1078 SkISize size = gm->getISize();
1053 setup_bitmap(gRec, size, &bitmap); 1079 setup_bitmap(gRec, size, &bitmap);
1054 SkCanvas canvas(bitmap); 1080 SkCanvas canvas(bitmap);
1055 installFilter(&canvas); 1081 installFilter(&canvas);
1056 // Pass a decoding function so the factory GM (which has an SkBi tmap 1082 // Pass a decoding function so the factory GM (which has an SkBi tmap
1057 // with encoded data) will not fail playback. 1083 // with encoded data) will not fail playback.
1058 PipeController pipeController(&canvas, &SkImageDecoder::DecodeMe mory); 1084 PipeController pipeController(&canvas, &SkImageDecoder::DecodeMe mory);
1059 SkGPipeWriter writer; 1085 SkGPipeWriter writer;
1060 SkCanvas* pipeCanvas = writer.startRecording(&pipeController, 1086 SkCanvas* pipeCanvas = writer.startRecording(&pipeController,
1061 gPipeWritingFlagCom bos[i].flags, 1087 gPipeWritingFlagCom bos[i].flags,
1062 size.width(), size. height()); 1088 size.width(), size. height());
1063 if (!simulateFailure) { 1089 if (!simulateFailure) {
1064 invokeGM(gm, pipeCanvas, false, false); 1090 invokeGM(gm, pipeCanvas, false, false);
1065 } 1091 }
1066 complete_bitmap(&bitmap); 1092 complete_bitmap(&bitmap);
1067 writer.endRecording(); 1093 writer.endRecording();
1068 errors.add(compare_test_results_to_reference_bitmap( 1094 errors.add(compare_test_results_to_reference_bitmap(
1069 name, renderModeDescriptor.c_str(), bitmap, &referenceBitmap )); 1095 gm->shortName(), gRec.fName, renderModeDescriptor.c_str(), b itmap,
1096 &referenceBitmap));
1070 if (!errors.isEmpty()) { 1097 if (!errors.isEmpty()) {
1071 break; 1098 break;
1072 } 1099 }
1073 } 1100 }
1074 } 1101 }
1075 return errors; 1102 return errors;
1076 } 1103 }
1077 1104
1078 ErrorCombination test_tiled_pipe_playback(GM* gm, const ConfigData& gRec, 1105 ErrorCombination test_tiled_pipe_playback(GM* gm, const ConfigData& gRec,
1079 const SkBitmap& referenceBitmap) { 1106 const SkBitmap& referenceBitmap) {
1080 const SkString name = make_name(gm->shortName(), gRec.fName); 1107 const SkString shortNamePlusConfig = make_shortname_plus_config(gm->shor tName(),
1108 gRec.fNa me);
1081 ErrorCombination errors; 1109 ErrorCombination errors;
1082 for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) { 1110 for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) {
1083 SkString renderModeDescriptor("-tiled pipe"); 1111 SkString renderModeDescriptor("-tiled pipe");
1084 renderModeDescriptor.append(gPipeWritingFlagCombos[i].name); 1112 renderModeDescriptor.append(gPipeWritingFlagCombos[i].name);
1085 1113
1086 if ((gm->getFlags() & GM::kSkipPipe_Flag) || 1114 if ((gm->getFlags() & GM::kSkipPipe_Flag) ||
1087 (gm->getFlags() & GM::kSkipTiled_Flag)) { 1115 (gm->getFlags() & GM::kSkipTiled_Flag)) {
1088 RecordTestResults(kIntentionallySkipped_ErrorType, name, 1116 RecordTestResults(kIntentionallySkipped_ErrorType, shortNamePlus Config,
1089 renderModeDescriptor.c_str()); 1117 renderModeDescriptor.c_str());
1090 errors.add(kIntentionallySkipped_ErrorType); 1118 errors.add(kIntentionallySkipped_ErrorType);
1091 } else { 1119 } else {
1092 SkBitmap bitmap; 1120 SkBitmap bitmap;
1093 SkISize size = gm->getISize(); 1121 SkISize size = gm->getISize();
1094 setup_bitmap(gRec, size, &bitmap); 1122 setup_bitmap(gRec, size, &bitmap);
1095 SkCanvas canvas(bitmap); 1123 SkCanvas canvas(bitmap);
1096 installFilter(&canvas); 1124 installFilter(&canvas);
1097 TiledPipeController pipeController(bitmap, &SkImageDecoder::Deco deMemory); 1125 TiledPipeController pipeController(bitmap, &SkImageDecoder::Deco deMemory);
1098 SkGPipeWriter writer; 1126 SkGPipeWriter writer;
1099 SkCanvas* pipeCanvas = writer.startRecording(&pipeController, 1127 SkCanvas* pipeCanvas = writer.startRecording(&pipeController,
1100 gPipeWritingFlagCom bos[i].flags, 1128 gPipeWritingFlagCom bos[i].flags,
1101 size.width(), size. height()); 1129 size.width(), size. height());
1102 invokeGM(gm, pipeCanvas, false, false); 1130 invokeGM(gm, pipeCanvas, false, false);
1103 complete_bitmap(&bitmap); 1131 complete_bitmap(&bitmap);
1104 writer.endRecording(); 1132 writer.endRecording();
1105 errors.add(compare_test_results_to_reference_bitmap(name, 1133 errors.add(compare_test_results_to_reference_bitmap(gm->shortNam e(), gRec.fName,
1106 renderModeDe scriptor.c_str(), 1134 renderModeDe scriptor.c_str(),
1107 bitmap, &ref erenceBitmap)); 1135 bitmap, &ref erenceBitmap));
1108 if (!errors.isEmpty()) { 1136 if (!errors.isEmpty()) {
1109 break; 1137 break;
1110 } 1138 }
1111 } 1139 }
1112 } 1140 }
1113 return errors; 1141 return errors;
1114 } 1142 }
1115 1143
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1415 ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm, const SkTDArray<si ze_t> &configs, 1443 ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm, const SkTDArray<si ze_t> &configs,
1416 GrContextFactory *grFactory); 1444 GrContextFactory *grFactory);
1417 ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm, const SkTDArray<si ze_t> &configs, 1445 ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm, const SkTDArray<si ze_t> &configs,
1418 GrContextFactory *grFactory) { 1446 GrContextFactory *grFactory) {
1419 const char renderModeDescriptor[] = ""; 1447 const char renderModeDescriptor[] = "";
1420 ErrorCombination errorsForAllConfigs; 1448 ErrorCombination errorsForAllConfigs;
1421 uint32_t gmFlags = gm->getFlags(); 1449 uint32_t gmFlags = gm->getFlags();
1422 1450
1423 for (int i = 0; i < configs.count(); i++) { 1451 for (int i = 0; i < configs.count(); i++) {
1424 ConfigData config = gRec[configs[i]]; 1452 ConfigData config = gRec[configs[i]];
1425 const SkString name = gmmain.make_name(gm->shortName(), config.fName); 1453 const SkString shortNamePlusConfig = gmmain.make_shortname_plus_config(g m->shortName(),
1454 c onfig.fName);
1426 1455
1427 // Skip any tests that we don't even need to try. 1456 // Skip any tests that we don't even need to try.
1428 // If any of these were skipped on a per-GM basis, record them as 1457 // If any of these were skipped on a per-GM basis, record them as
1429 // kIntentionallySkipped. 1458 // kIntentionallySkipped.
1430 if (kPDF_Backend == config.fBackend) { 1459 if (kPDF_Backend == config.fBackend) {
1431 if (!FLAGS_pdf) { 1460 if (!FLAGS_pdf) {
1432 continue; 1461 continue;
1433 } 1462 }
1434 if (gmFlags & GM::kSkipPDF_Flag) { 1463 if (gmFlags & GM::kSkipPDF_Flag) {
1435 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, name, 1464 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortN amePlusConfig,
1436 renderModeDescriptor); 1465 renderModeDescriptor);
1437 errorsForAllConfigs.add(kIntentionallySkipped_ErrorType); 1466 errorsForAllConfigs.add(kIntentionallySkipped_ErrorType);
1438 continue; 1467 continue;
1439 } 1468 }
1440 } 1469 }
1441 if ((gmFlags & GM::kSkip565_Flag) && 1470 if ((gmFlags & GM::kSkip565_Flag) &&
1442 (kRaster_Backend == config.fBackend) && 1471 (kRaster_Backend == config.fBackend) &&
1443 (SkBitmap::kRGB_565_Config == config.fConfig)) { 1472 (SkBitmap::kRGB_565_Config == config.fConfig)) {
1444 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, name, 1473 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNameP lusConfig,
1445 renderModeDescriptor); 1474 renderModeDescriptor);
1446 errorsForAllConfigs.add(kIntentionallySkipped_ErrorType); 1475 errorsForAllConfigs.add(kIntentionallySkipped_ErrorType);
1447 continue; 1476 continue;
1448 } 1477 }
1449 if ((gmFlags & GM::kSkipGPU_Flag) && 1478 if ((gmFlags & GM::kSkipGPU_Flag) &&
1450 kGPU_Backend == config.fBackend) { 1479 kGPU_Backend == config.fBackend) {
1451 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, name, 1480 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNameP lusConfig,
1452 renderModeDescriptor); 1481 renderModeDescriptor);
1453 errorsForAllConfigs.add(kIntentionallySkipped_ErrorType); 1482 errorsForAllConfigs.add(kIntentionallySkipped_ErrorType);
1454 continue; 1483 continue;
1455 } 1484 }
1456 1485
1457 // Now we know that we want to run this test and record its 1486 // Now we know that we want to run this test and record its
1458 // success or failure. 1487 // success or failure.
1459 ErrorCombination errorsForThisConfig; 1488 ErrorCombination errorsForThisConfig;
1460 GrSurface* gpuTarget = NULL; 1489 GrSurface* gpuTarget = NULL;
1461 #if SK_SUPPORT_GPU 1490 #if SK_SUPPORT_GPU
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 * Returns all errors encountered while doing so. 1557 * Returns all errors encountered while doing so.
1529 */ 1558 */
1530 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &co mpareConfig, 1559 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &co mpareConfig,
1531 const SkBitmap &comparisonBitmap, 1560 const SkBitmap &comparisonBitmap,
1532 const SkTDArray<SkScalar> &tileGridReplaySca les); 1561 const SkTDArray<SkScalar> &tileGridReplaySca les);
1533 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &co mpareConfig, 1562 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &co mpareConfig,
1534 const SkBitmap &comparisonBitmap, 1563 const SkBitmap &comparisonBitmap,
1535 const SkTDArray<SkScalar> &tileGridReplaySca les) { 1564 const SkTDArray<SkScalar> &tileGridReplaySca les) {
1536 ErrorCombination errorsForAllModes; 1565 ErrorCombination errorsForAllModes;
1537 uint32_t gmFlags = gm->getFlags(); 1566 uint32_t gmFlags = gm->getFlags();
1538 const SkString name = gmmain.make_name(gm->shortName(), compareConfig.fName) ; 1567 const SkString shortNamePlusConfig = gmmain.make_shortname_plus_config(gm->s hortName(),
1568 compa reConfig.fName);
1539 1569
1540 SkPicture* pict = gmmain.generate_new_picture(gm, kNone_BbhType, 0); 1570 SkPicture* pict = gmmain.generate_new_picture(gm, kNone_BbhType, 0);
1541 SkAutoUnref aur(pict); 1571 SkAutoUnref aur(pict);
1542 if (FLAGS_replay) { 1572 if (FLAGS_replay) {
1543 const char renderModeDescriptor[] = "-replay"; 1573 const char renderModeDescriptor[] = "-replay";
1544 if (gmFlags & GM::kSkipPicture_Flag) { 1574 if (gmFlags & GM::kSkipPicture_Flag) {
1545 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, name, rend erModeDescriptor); 1575 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNameP lusConfig,
1576 renderModeDescriptor);
1546 errorsForAllModes.add(kIntentionallySkipped_ErrorType); 1577 errorsForAllModes.add(kIntentionallySkipped_ErrorType);
1547 } else { 1578 } else {
1548 SkBitmap bitmap; 1579 SkBitmap bitmap;
1549 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap) ; 1580 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap) ;
1550 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p( 1581 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p(
1551 name, renderModeDescriptor, bitmap, &comparisonBitmap)); 1582 gm->shortName(), compareConfig.fName, renderModeDescriptor, bitm ap,
1583 &comparisonBitmap));
1552 } 1584 }
1553 } 1585 }
1554 1586
1555 if (FLAGS_serialize) { 1587 if (FLAGS_serialize) {
1556 const char renderModeDescriptor[] = "-serialize"; 1588 const char renderModeDescriptor[] = "-serialize";
1557 if (gmFlags & GM::kSkipPicture_Flag) { 1589 if (gmFlags & GM::kSkipPicture_Flag) {
1558 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, name, rend erModeDescriptor); 1590 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNameP lusConfig,
1591 renderModeDescriptor);
1559 errorsForAllModes.add(kIntentionallySkipped_ErrorType); 1592 errorsForAllModes.add(kIntentionallySkipped_ErrorType);
1560 } else { 1593 } else {
1561 SkPicture* repict = gmmain.stream_to_new_picture(*pict); 1594 SkPicture* repict = gmmain.stream_to_new_picture(*pict);
1562 SkAutoUnref aurr(repict); 1595 SkAutoUnref aurr(repict);
1563 SkBitmap bitmap; 1596 SkBitmap bitmap;
1564 gmmain.generate_image_from_picture(gm, compareConfig, repict, &bitma p); 1597 gmmain.generate_image_from_picture(gm, compareConfig, repict, &bitma p);
1565 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p( 1598 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p(
1566 name, renderModeDescriptor, bitmap, &comparisonBitmap)); 1599 gm->shortName(), compareConfig.fName, renderModeDescriptor, bitm ap,
1600 &comparisonBitmap));
1567 } 1601 }
1568 } 1602 }
1569 1603
1570 if ((1 == FLAGS_writePicturePath.count()) && 1604 if ((1 == FLAGS_writePicturePath.count()) &&
1571 !(gmFlags & GM::kSkipPicture_Flag)) { 1605 !(gmFlags & GM::kSkipPicture_Flag)) {
1572 const char* pictureSuffix = "skp"; 1606 const char* pictureSuffix = "skp";
1573 SkString path = make_filename(FLAGS_writePicturePath[0], "", 1607 // TODO(epoger): Make sure this still works even though the
1574 gm->shortName(), pictureSuffix); 1608 // filename now contains the config name (it used to contain
1609 // just the shortName). I think this is actually an
1610 // *improvement*, because now runs with different configs will
1611 // write out their SkPictures to separate files rather than
1612 // overwriting each other. But we should make sure it doesn't
1613 // break anybody.
1614 SkString path = gmmain.make_filename(FLAGS_writePicturePath[0], gm->shor tName(),
1615 compareConfig.fName, "", pictureSuf fix);
1575 SkFILEWStream stream(path.c_str()); 1616 SkFILEWStream stream(path.c_str());
1576 pict->serialize(&stream); 1617 pict->serialize(&stream);
1577 } 1618 }
1578 1619
1579 if (FLAGS_rtree) { 1620 if (FLAGS_rtree) {
1580 const char renderModeDescriptor[] = "-rtree"; 1621 const char renderModeDescriptor[] = "-rtree";
1581 if (gmFlags & GM::kSkipPicture_Flag) { 1622 if (gmFlags & GM::kSkipPicture_Flag) {
1582 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, name, rend erModeDescriptor); 1623 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNameP lusConfig,
1624 renderModeDescriptor);
1583 errorsForAllModes.add(kIntentionallySkipped_ErrorType); 1625 errorsForAllModes.add(kIntentionallySkipped_ErrorType);
1584 } else { 1626 } else {
1585 SkPicture* pict = gmmain.generate_new_picture( 1627 SkPicture* pict = gmmain.generate_new_picture(
1586 gm, kRTree_BbhType, SkPicture::kUsePathBoundsForClip_RecordingFl ag); 1628 gm, kRTree_BbhType, SkPicture::kUsePathBoundsForClip_RecordingFl ag);
1587 SkAutoUnref aur(pict); 1629 SkAutoUnref aur(pict);
1588 SkBitmap bitmap; 1630 SkBitmap bitmap;
1589 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap) ; 1631 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap) ;
1590 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p( 1632 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p(
1591 name, renderModeDescriptor, bitmap, &comparisonBitmap)); 1633 gm->shortName(), compareConfig.fName, renderModeDescriptor, bitm ap,
1634 &comparisonBitmap));
1592 } 1635 }
1593 } 1636 }
1594 1637
1595 if (FLAGS_tileGrid) { 1638 if (FLAGS_tileGrid) {
1596 for(int scaleIndex = 0; scaleIndex < tileGridReplayScales.count(); ++sca leIndex) { 1639 for(int scaleIndex = 0; scaleIndex < tileGridReplayScales.count(); ++sca leIndex) {
1597 SkScalar replayScale = tileGridReplayScales[scaleIndex]; 1640 SkScalar replayScale = tileGridReplayScales[scaleIndex];
1598 SkString renderModeDescriptor("-tilegrid"); 1641 SkString renderModeDescriptor("-tilegrid");
1599 if (SK_Scalar1 != replayScale) { 1642 if (SK_Scalar1 != replayScale) {
1600 renderModeDescriptor += "-scale-"; 1643 renderModeDescriptor += "-scale-";
1601 renderModeDescriptor.appendScalar(replayScale); 1644 renderModeDescriptor.appendScalar(replayScale);
1602 } 1645 }
1603 1646
1604 if ((gmFlags & GM::kSkipPicture_Flag) || 1647 if ((gmFlags & GM::kSkipPicture_Flag) ||
1605 ((gmFlags & GM::kSkipScaledReplay_Flag) && replayScale != 1)) { 1648 ((gmFlags & GM::kSkipScaledReplay_Flag) && replayScale != 1)) {
1606 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, name, 1649 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortN amePlusConfig,
1607 renderModeDescriptor.c_str()); 1650 renderModeDescriptor.c_str());
1608 errorsForAllModes.add(kIntentionallySkipped_ErrorType); 1651 errorsForAllModes.add(kIntentionallySkipped_ErrorType);
1609 } else { 1652 } else {
1610 // We record with the reciprocal scale to obtain a replay 1653 // We record with the reciprocal scale to obtain a replay
1611 // result that can be validated against comparisonBitmap. 1654 // result that can be validated against comparisonBitmap.
1612 SkScalar recordScale = SkScalarInvert(replayScale); 1655 SkScalar recordScale = SkScalarInvert(replayScale);
1613 SkPicture* pict = gmmain.generate_new_picture( 1656 SkPicture* pict = gmmain.generate_new_picture(
1614 gm, kTileGrid_BbhType, SkPicture::kUsePathBoundsForClip_Reco rdingFlag, 1657 gm, kTileGrid_BbhType, SkPicture::kUsePathBoundsForClip_Reco rdingFlag,
1615 recordScale); 1658 recordScale);
1616 SkAutoUnref aur(pict); 1659 SkAutoUnref aur(pict);
1617 SkBitmap bitmap; 1660 SkBitmap bitmap;
1618 // We cannot yet pass 'true' to generate_image_from_picture to 1661 // We cannot yet pass 'true' to generate_image_from_picture to
1619 // perform actual tiled rendering (see Issue 1198 - 1662 // perform actual tiled rendering (see Issue 1198 -
1620 // https://code.google.com/p/skia/issues/detail?id=1198) 1663 // https://code.google.com/p/skia/issues/detail?id=1198)
1621 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bit map, 1664 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bit map,
1622 replayScale /*, true */); 1665 replayScale /*, true */);
1623 errorsForAllModes.add(gmmain.compare_test_results_to_reference_b itmap( 1666 errorsForAllModes.add(gmmain.compare_test_results_to_reference_b itmap(
1624 name, renderModeDescriptor.c_str(), bitmap, &comparisonBitma p)); 1667 gm->shortName(), compareConfig.fName, renderModeDescriptor.c _str(), bitmap,
1668 &comparisonBitmap));
1625 } 1669 }
1626 } 1670 }
1627 } 1671 }
1628 1672
1629 // run the pipe centric GM steps 1673 // run the pipe centric GM steps
1630 if (FLAGS_pipe) { 1674 if (FLAGS_pipe) {
1631 errorsForAllModes.add(gmmain.test_pipe_playback(gm, compareConfig, compa risonBitmap, 1675 errorsForAllModes.add(gmmain.test_pipe_playback(gm, compareConfig, compa risonBitmap,
1632 FLAGS_simulatePipePlayba ckFailure)); 1676 FLAGS_simulatePipePlayba ckFailure));
1633 if (FLAGS_tiledPipe) { 1677 if (FLAGS_tiledPipe) {
1634 errorsForAllModes.add(gmmain.test_tiled_pipe_playback(gm, compareCon fig, 1678 errorsForAllModes.add(gmmain.test_tiled_pipe_playback(gm, compareCon fig,
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
2045 if (FLAGS_forceBWtext) { 2089 if (FLAGS_forceBWtext) {
2046 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); 2090 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref();
2047 } 2091 }
2048 } 2092 }
2049 2093
2050 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 2094 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
2051 int main(int argc, char * const argv[]) { 2095 int main(int argc, char * const argv[]) {
2052 return tool_main(argc, (char**) argv); 2096 return tool_main(argc, (char**) argv);
2053 } 2097 }
2054 #endif 2098 #endif
OLDNEW
« no previous file with comments | « gm/gm_expectations.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698