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

Side by Side Diff: gm/gmmain.cpp

Issue 12851022: gm: display summary of all results by ErrorType (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 #ifdef SK_BUILD_FOR_MAC 80 #ifdef SK_BUILD_FOR_MAC
81 #include "SkCGUtils.h" 81 #include "SkCGUtils.h"
82 #define CAN_IMAGE_PDF 1 82 #define CAN_IMAGE_PDF 1
83 #else 83 #else
84 #define CAN_IMAGE_PDF 0 84 #define CAN_IMAGE_PDF 0
85 #endif 85 #endif
86 86
87 using namespace skiagm; 87 using namespace skiagm;
88 88
89 // EPOGER: we don't need FailRec anymore, just an SkString for each entry?
89 struct FailRec { 90 struct FailRec {
90 SkString fName; 91 SkString fName;
91 bool fIsPixelError; 92 bool fIsPixelError;
92 93
93 FailRec() : fIsPixelError(false) {} 94 FailRec() : fIsPixelError(false) {}
94 FailRec(const SkString& name) : fName(name), fIsPixelError(false) {} 95 FailRec(const SkString& name) : fName(name), fIsPixelError(false) {}
95 }; 96 };
96 97
97 class Iter { 98 class Iter {
98 public: 99 public:
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 }; 184 };
184 185
185 class GMMain { 186 class GMMain {
186 public: 187 public:
187 GMMain() { 188 GMMain() {
188 // Set default values of member variables, which tool_main() 189 // Set default values of member variables, which tool_main()
189 // may override. 190 // may override.
190 fUseFileHierarchy = false; 191 fUseFileHierarchy = false;
191 fIgnorableErrorCombination.add(kMissingExpectations_ErrorType); 192 fIgnorableErrorCombination.add(kMissingExpectations_ErrorType);
192 fMismatchPath = NULL; 193 fMismatchPath = NULL;
194 fTestsRun = 0;
193 } 195 }
194 196
195 SkString make_name(const char shortName[], const char configName[]) { 197 SkString make_name(const char shortName[], const char configName[]) {
196 SkString name; 198 SkString name;
197 if (0 == strlen(configName)) { 199 if (0 == strlen(configName)) {
198 name.append(shortName); 200 name.append(shortName);
199 } else if (fUseFileHierarchy) { 201 } else if (fUseFileHierarchy) {
200 name.appendf("%s%c%s", configName, SkPATH_SEPARATOR, shortName); 202 name.appendf("%s%c%s", configName, SkPATH_SEPARATOR, shortName);
201 } else { 203 } else {
202 name.appendf("%s_%s", shortName, configName); 204 name.appendf("%s_%s", shortName, configName);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 // TODO(epoger): Now that we have removed force_all_opaque() 238 // TODO(epoger): Now that we have removed force_all_opaque()
237 // from this method, we should be able to get rid of the 239 // from this method, we should be able to get rid of the
238 // transformation to 8888 format also. 240 // transformation to 8888 format also.
239 SkBitmap copy; 241 SkBitmap copy;
240 bitmap.copyTo(&copy, SkBitmap::kARGB_8888_Config); 242 bitmap.copyTo(&copy, SkBitmap::kARGB_8888_Config);
241 return SkImageEncoder::EncodeFile(path.c_str(), copy, 243 return SkImageEncoder::EncodeFile(path.c_str(), copy,
242 SkImageEncoder::kPNG_Type, 100); 244 SkImageEncoder::kPNG_Type, 100);
243 } 245 }
244 246
245 /** 247 /**
246 * Records the errors encountered in fFailedTests, except for any error 248 * Records the errors encountered in fFailedTests.
247 * types we want to ignore. 249 *
250 * We even record errors that we regard as "ignorable"; we can filter them
251 * out later.
248 */ 252 */
253 // EPOGER: rename as RecordResult(), because it increments fTestsRun??
249 void RecordError(const ErrorCombination& errorCombination, const SkString& n ame, 254 void RecordError(const ErrorCombination& errorCombination, const SkString& n ame,
250 const char renderModeDescriptor []) { 255 const char renderModeDescriptor []) {
251 // The common case: no error means nothing to record. 256 fTestsRun++;
252 if (errorCombination.isEmpty()) { 257 if (errorCombination.isEmpty()) {
253 return; 258 return;
254 } 259 }
255 260 SkString fullName = make_name(name.c_str(), renderModeDescriptor);
256 // If only certain error type(s) were reported, we know we can ignore th em. 261 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) {
257 if (errorCombination.minus(fIgnorableErrorCombination).isEmpty()) { 262 ErrorType type = static_cast<ErrorType>(typeInt);
258 return; 263 if (errorCombination.includes(type)) {
259 } 264 fFailedTests[type].push_back(fullName);
260
261 FailRec& rec = fFailedTests.push_back(make_name(name.c_str(), renderMode Descriptor));
262 rec.fIsPixelError = errorCombination.includes(kImageMismatch_ErrorType);
263 }
264
265 // List contents of fFailedTests via SkDebug.
266 void ListErrors() {
267 for (int i = 0; i < fFailedTests.count(); ++i) {
268 if (fFailedTests[i].fIsPixelError) {
269 gm_fprintf(stderr, "\t\t%s pixel_error\n", fFailedTests[i].fName .c_str());
270 } else {
271 gm_fprintf(stderr, "\t\t%s\n", fFailedTests[i].fName.c_str());
272 } 265 }
273 } 266 }
274 } 267 }
275 268
269 /**
270 * Return the number of significant (non-ignorable) errors we have
271 * encountered so far.
272 */
273 int NumSignificantErrors() {
274 int significantErrors = 0;
275 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) {
276 ErrorType type = static_cast<ErrorType>(typeInt);
277 if (!fIgnorableErrorCombination.includes(type)) {
278 significantErrors += fFailedTests[type].count();
279 }
280 }
281 return significantErrors;
282 }
283
284 /**
285 * List contents of fFailedTests to stdout.
286 */
287 void ListErrors() {
288 // First, print a single summary line.
289 SkString summary;
290 summary.appendf("Ran %d tests:", fTestsRun);
291 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) {
292 ErrorType type = static_cast<ErrorType>(typeInt);
293 summary.appendf(" %s=%d", getErrorTypeName(type), fFailedTests[type] .count());
294 }
295 gm_fprintf(stdout, "%s\n", summary.c_str());
296
297 // Now, for each failure type, list the tests that failed that way.
298 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) {
299 SkString line;
300 ErrorType type = static_cast<ErrorType>(typeInt);
301 if (fIgnorableErrorCombination.includes(type)) {
302 line.append("[ ] ");
303 } else {
304 line.append("[*] ");
305 }
306
307 SkTArray<FailRec> *failedTestsOfThisType = &fFailedTests[type];
308 int count = failedTestsOfThisType->count();
309 line.appendf("%d %s:", count, getErrorTypeName(type));
310 for (int i = 0; i < count; ++i) {
311 line.append(" ");
312 line.append((*failedTestsOfThisType)[i].fName);
313 }
314 gm_fprintf(stdout, "%s\n", line.c_str());
315 }
316 gm_fprintf(stdout, "(results marked with [*] will cause nonzero return v alue)\n");
317 }
318
276 static bool write_document(const SkString& path, 319 static bool write_document(const SkString& path,
277 const SkDynamicMemoryWStream& document) { 320 const SkDynamicMemoryWStream& document) {
278 SkFILEWStream stream(path.c_str()); 321 SkFILEWStream stream(path.c_str());
279 SkAutoDataUnref data(document.copyToData()); 322 SkAutoDataUnref data(document.copyToData());
280 return stream.writeData(data.get()); 323 return stream.writeData(data.get());
281 } 324 }
282 325
283 /** 326 /**
284 * Prepare an SkBitmap to render a GM into. 327 * Prepare an SkBitmap to render a GM into.
285 * 328 *
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 if (kXPS_Backend == gRec.fBackend) { 546 if (kXPS_Backend == gRec.fBackend) {
504 path = make_filename(writePath, renderModeDescriptor, name.c_str(), 547 path = make_filename(writePath, renderModeDescriptor, name.c_str(),
505 "xps"); 548 "xps");
506 success = write_document(path, *document); 549 success = write_document(path, *document);
507 } 550 }
508 if (success) { 551 if (success) {
509 return kEmpty_ErrorCombination; 552 return kEmpty_ErrorCombination;
510 } else { 553 } else {
511 gm_fprintf(stderr, "FAILED to write %s\n", path.c_str()); 554 gm_fprintf(stderr, "FAILED to write %s\n", path.c_str());
512 ErrorCombination errors(kWritingReferenceImage_ErrorType); 555 ErrorCombination errors(kWritingReferenceImage_ErrorType);
556 // EPOGER: don't call RecordError() here? instead, the caller should call RecordError (or maybe RecordResults) exactly ONCE to properly record one a ttempt, one partial failure.
513 RecordError(errors, name, renderModeDescriptor); 557 RecordError(errors, name, renderModeDescriptor);
514 return errors; 558 return errors;
515 } 559 }
516 } 560 }
517 561
518 /** 562 /**
519 * Log more detail about the mistmatch between expectedBitmap and 563 * Log more detail about the mistmatch between expectedBitmap and
520 * actualBitmap. 564 * actualBitmap.
521 */ 565 */
522 void report_bitmap_diffs(const SkBitmap& expectedBitmap, const SkBitmap& act ualBitmap, 566 void report_bitmap_diffs(const SkBitmap& expectedBitmap, const SkBitmap& act ualBitmap,
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 errors.add(compare_to_expectations(expectations, actualBitmap, 775 errors.add(compare_to_expectations(expectations, actualBitmap,
732 name, "", true)); 776 name, "", true));
733 } else { 777 } else {
734 // If we are running without expectations, we still want to 778 // If we are running without expectations, we still want to
735 // record the actual results. 779 // record the actual results.
736 Checksum actualChecksum = 780 Checksum actualChecksum =
737 SkBitmapChecksummer::Compute64(actualBitmap); 781 SkBitmapChecksummer::Compute64(actualBitmap);
738 add_actual_results_to_json_summary(name.c_str(), actualChecksum, 782 add_actual_results_to_json_summary(name.c_str(), actualChecksum,
739 ErrorCombination(kMissingExpectat ions_ErrorType), 783 ErrorCombination(kMissingExpectat ions_ErrorType),
740 false); 784 false);
785 RecordError(ErrorCombination(kMissingExpectations_ErrorType), name, "");
741 } 786 }
742 787
743 // TODO: Consider moving this into compare_to_expectations(), 788 // TODO: Consider moving this into compare_to_expectations(),
744 // similar to fMismatchPath... for now, we don't do that, because 789 // similar to fMismatchPath... for now, we don't do that, because
745 // we don't want to write out the actual bitmaps for all 790 // we don't want to write out the actual bitmaps for all
746 // renderModes of all tests! That would be a lot of files. 791 // renderModes of all tests! That would be a lot of files.
747 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { 792 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) {
748 errors.add(write_reference_image(gRec, writePath, "", 793 errors.add(write_reference_image(gRec, writePath, "",
749 name, actualBitmap, pdf)); 794 name, actualBitmap, pdf));
750 } 795 }
751 796
752 return errors; 797 return errors;
753 } 798 }
754 799
755 /** 800 /**
756 * Compare actualBitmap to referenceBitmap. 801 * Compare actualBitmap to referenceBitmap.
757 * 802 *
758 * @param gm which test generated the bitmap 803 * @param gm which test generated the bitmap
759 * @param gRec 804 * @param gRec
760 * @param renderModeDescriptor 805 * @param renderModeDescriptor
761 * @param actualBitmap actual bitmap generated by this run 806 * @param actualBitmap actual bitmap generated by this run
762 * @param referenceBitmap bitmap we expected to be generated 807 * @param referenceBitmap bitmap we expected to be generated
763 */ 808 */
809 // EPOGER: since this is separate from compare_test_results_to_stored_expect ations(), that should give me the ability to signal different error types for re nderModeDiscrepancy!
764 ErrorCombination compare_test_results_to_reference_bitmap( 810 ErrorCombination compare_test_results_to_reference_bitmap(
765 GM* gm, const ConfigData& gRec, const char renderModeDescriptor [], 811 GM* gm, const ConfigData& gRec, const char renderModeDescriptor [],
766 SkBitmap& actualBitmap, const SkBitmap* referenceBitmap) { 812 SkBitmap& actualBitmap, const SkBitmap* referenceBitmap) {
767 813
768 SkASSERT(referenceBitmap); 814 SkASSERT(referenceBitmap);
769 SkString name = make_name(gm->shortName(), gRec.fName); 815 SkString name = make_name(gm->shortName(), gRec.fName);
770 Expectations expectations(*referenceBitmap); 816 Expectations expectations(*referenceBitmap);
771 return compare_to_expectations(expectations, actualBitmap, 817 return compare_to_expectations(expectations, actualBitmap,
772 name, renderModeDescriptor); 818 name, renderModeDescriptor);
773 } 819 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 // -deferred image, we exit early! We should fix this 919 // -deferred image, we exit early! We should fix this
874 // ASAP, because it is hiding -deferred errors... but for 920 // ASAP, because it is hiding -deferred errors... but for
875 // now, I'm leaving the logic as it is so that the 921 // now, I'm leaving the logic as it is so that the
876 // refactoring change 922 // refactoring change
877 // https://codereview.chromium.org/12992003/ is unblocked. 923 // https://codereview.chromium.org/12992003/ is unblocked.
878 // 924 //
879 // Filed as https://code.google.com/p/skia/issues/detail?id=1180 925 // Filed as https://code.google.com/p/skia/issues/detail?id=1180
880 // ('image-surface gm test is failing in "deferred" mode, 926 // ('image-surface gm test is failing in "deferred" mode,
881 // and gm is not reporting the failure') 927 // and gm is not reporting the failure')
882 if (errors.isEmpty()) { 928 if (errors.isEmpty()) {
929 // EPOGER: for cases like this, return some new ErrorType (TestS kipped?) so we see that they happened
883 return kEmpty_ErrorCombination; 930 return kEmpty_ErrorCombination;
884 } 931 }
885 return compare_test_results_to_reference_bitmap( 932 return compare_test_results_to_reference_bitmap(
886 gm, gRec, "-deferred", bitmap, &referenceBitmap); 933 gm, gRec, "-deferred", bitmap, &referenceBitmap);
887 } 934 }
888 return kEmpty_ErrorCombination; 935 return kEmpty_ErrorCombination;
889 } 936 }
890 937
891 ErrorCombination test_pipe_playback(GM* gm, 938 ErrorCombination test_pipe_playback(GM* gm,
892 const ConfigData& gRec, 939 const ConfigData& gRec,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 // 993 //
947 // member variables. 994 // member variables.
948 // They are public for now, to allow easier setting by tool_main(). 995 // They are public for now, to allow easier setting by tool_main().
949 // 996 //
950 997
951 bool fUseFileHierarchy; 998 bool fUseFileHierarchy;
952 ErrorCombination fIgnorableErrorCombination; 999 ErrorCombination fIgnorableErrorCombination;
953 1000
954 const char* fMismatchPath; 1001 const char* fMismatchPath;
955 1002
956 // information about all failed tests we have encountered so far 1003 // collection of tests that have failed with each ErrorType
957 SkTArray<FailRec> fFailedTests; 1004 SkTArray<FailRec> fFailedTests[kLast_ErrorType+1];
1005 int fTestsRun;
958 1006
959 // Where to read expectations (expected image checksums, etc.) from. 1007 // Where to read expectations (expected image checksums, etc.) from.
960 // If unset, we don't do comparisons. 1008 // If unset, we don't do comparisons.
961 SkAutoTUnref<ExpectationsSource> fExpectationsSource; 1009 SkAutoTUnref<ExpectationsSource> fExpectationsSource;
962 1010
963 // JSON summaries that we generate as we go (just for output). 1011 // JSON summaries that we generate as we go (just for output).
964 Json::Value fJsonExpectedResults; 1012 Json::Value fJsonExpectedResults;
965 Json::Value fJsonActualResults_Failed; 1013 Json::Value fJsonActualResults_Failed;
966 Json::Value fJsonActualResults_FailureIgnored; 1014 Json::Value fJsonActualResults_FailureIgnored;
967 Json::Value fJsonActualResults_NoComparison; 1015 Json::Value fJsonActualResults_NoComparison;
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &co mpareConfig, 1307 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &co mpareConfig,
1260 const SkBitmap &comparisonBitmap, 1308 const SkBitmap &comparisonBitmap,
1261 const SkTDArray<SkScalar> &tileGridReplaySca les); 1309 const SkTDArray<SkScalar> &tileGridReplaySca les);
1262 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &co mpareConfig, 1310 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &co mpareConfig,
1263 const SkBitmap &comparisonBitmap, 1311 const SkBitmap &comparisonBitmap,
1264 const SkTDArray<SkScalar> &tileGridReplaySca les) { 1312 const SkTDArray<SkScalar> &tileGridReplaySca les) {
1265 ErrorCombination errorsForAllModes; 1313 ErrorCombination errorsForAllModes;
1266 uint32_t gmFlags = gm->getFlags(); 1314 uint32_t gmFlags = gm->getFlags();
1267 1315
1268 // run the picture centric GM steps 1316 // run the picture centric GM steps
1317 // EPOGER: record a different error code if we skipped this mode?
1269 if (!(gmFlags & GM::kSkipPicture_Flag)) { 1318 if (!(gmFlags & GM::kSkipPicture_Flag)) {
1270 1319
1271 ErrorCombination pictErrors; 1320 ErrorCombination pictErrors;
1272 1321
1273 //SkAutoTUnref<SkPicture> pict(generate_new_picture(gm)); 1322 //SkAutoTUnref<SkPicture> pict(generate_new_picture(gm));
1274 SkPicture* pict = gmmain.generate_new_picture(gm, kNone_BbhType, 0); 1323 SkPicture* pict = gmmain.generate_new_picture(gm, kNone_BbhType, 0);
1275 SkAutoUnref aur(pict); 1324 SkAutoUnref aur(pict);
1276 1325
1277 if (FLAGS_replay) { 1326 if (FLAGS_replay) {
1278 SkBitmap bitmap; 1327 SkBitmap bitmap;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1352 if ((pipeErrors.isEmpty()) && 1401 if ((pipeErrors.isEmpty()) &&
1353 FLAGS_tiledPipe && !(gmFlags & GM::kSkipTiled_Flag)) { 1402 FLAGS_tiledPipe && !(gmFlags & GM::kSkipTiled_Flag)) {
1354 pipeErrors.add(gmmain.test_tiled_pipe_playback(gm, compareConfig, co mparisonBitmap)); 1403 pipeErrors.add(gmmain.test_tiled_pipe_playback(gm, compareConfig, co mparisonBitmap));
1355 } 1404 }
1356 1405
1357 errorsForAllModes.add(pipeErrors); 1406 errorsForAllModes.add(pipeErrors);
1358 } 1407 }
1359 return errorsForAllModes; 1408 return errorsForAllModes;
1360 } 1409 }
1361 1410
1411 /**
1412 * Return a list of all entries in an array of strings as a single string
1413 * of this form:
1414 * "item1", "item2", "item3"
1415 */
1416 SkString list_all(const SkTArray<SkString> &stringArray);
1417 SkString list_all(const SkTArray<SkString> &stringArray) {
1418 SkString total;
1419 for (int i = 0; i < stringArray.count(); i++) {
1420 if (i > 0) {
1421 total.append(", ");
1422 }
1423 total.append("\"");
1424 total.append(stringArray[i]);
1425 total.append("\"");
1426 }
1427 return total;
1428 }
1429
1430 /**
1431 * Return a list of configuration names, as a single string of this form:
1432 * "item1", "item2", "item3"
1433 *
1434 * @param configs configurations, as a list of indices into gRec
1435 */
1436 SkString list_all_config_names(const SkTDArray<size_t> &configs);
1437 SkString list_all_config_names(const SkTDArray<size_t> &configs) {
1438 SkString total;
1439 for (int i = 0; i < configs.count(); i++) {
1440 if (i > 0) {
1441 total.append(", ");
1442 }
1443 total.append("\"");
1444 total.append(gRec[configs[i]].fName);
1445 total.append("\"");
1446 }
1447 return total;
1448 }
1449
1362 int tool_main(int argc, char** argv); 1450 int tool_main(int argc, char** argv);
1363 int tool_main(int argc, char** argv) { 1451 int tool_main(int argc, char** argv) {
1364 1452
1365 #if SK_ENABLE_INST_COUNT 1453 #if SK_ENABLE_INST_COUNT
1366 gPrintInstCount = true; 1454 gPrintInstCount = true;
1367 #endif 1455 #endif
1368 1456
1369 SkGraphics::Init(); 1457 SkGraphics::Init();
1370 // we don't need to see this during a run 1458 // we don't need to see this during a run
1371 gSkSuppressFontCachePurgeSpew = true; 1459 gSkSuppressFontCachePurgeSpew = true;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 gm_fprintf(stderr, "reading resources from %s\n", FLAGS_resourcePath[0]) ; 1621 gm_fprintf(stderr, "reading resources from %s\n", FLAGS_resourcePath[0]) ;
1534 } 1622 }
1535 1623
1536 if (moduloDivisor <= 0) { 1624 if (moduloDivisor <= 0) {
1537 moduloRemainder = -1; 1625 moduloRemainder = -1;
1538 } 1626 }
1539 if (moduloRemainder < 0 || moduloRemainder >= moduloDivisor) { 1627 if (moduloRemainder < 0 || moduloRemainder >= moduloDivisor) {
1540 moduloRemainder = -1; 1628 moduloRemainder = -1;
1541 } 1629 }
1542 1630
1543 // Accumulate success of all tests. 1631 int gmsRun = 0;
1544 int testsRun = 0;
1545 int testsPassed = 0;
1546 int testsFailed = 0;
1547 int testsMissingReferenceImages = 0;
1548
1549 int gmIndex = -1; 1632 int gmIndex = -1;
1550 SkString moduloStr; 1633 SkString moduloStr;
1551 1634
1552 // If we will be writing out files, prepare subdirectories. 1635 // If we will be writing out files, prepare subdirectories.
1553 if (FLAGS_writePath.count() == 1) { 1636 if (FLAGS_writePath.count() == 1) {
1554 if (!sk_mkdir(FLAGS_writePath[0])) { 1637 if (!sk_mkdir(FLAGS_writePath[0])) {
1555 return -1; 1638 return -1;
1556 } 1639 }
1557 if (gmmain.fUseFileHierarchy) { 1640 if (gmmain.fUseFileHierarchy) {
1558 for (int i = 0; i < configs.count(); i++) { 1641 for (int i = 0; i < configs.count(); i++) {
(...skipping 19 matching lines...) Expand all
1578 } 1661 }
1579 moduloStr.printf("[%d.%d] ", gmIndex, moduloDivisor); 1662 moduloStr.printf("[%d.%d] ", gmIndex, moduloDivisor);
1580 } 1663 }
1581 1664
1582 const char* shortName = gm->shortName(); 1665 const char* shortName = gm->shortName();
1583 if (skip_name(FLAGS_match, shortName)) { 1666 if (skip_name(FLAGS_match, shortName)) {
1584 SkDELETE(gm); 1667 SkDELETE(gm);
1585 continue; 1668 continue;
1586 } 1669 }
1587 1670
1671 gmsRun++;
1588 SkISize size = gm->getISize(); 1672 SkISize size = gm->getISize();
1589 gm_fprintf(stdout, "%sdrawing... %s [%d %d]\n", moduloStr.c_str(), short Name, 1673 gm_fprintf(stdout, "%sdrawing... %s [%d %d]\n", moduloStr.c_str(), short Name,
1590 size.width(), size.height()); 1674 size.width(), size.height());
1591 1675
1592 ErrorCombination testErrors; 1676 run_multiple_configs(gmmain, gm, configs, grFactory);
1593 testErrors.add(run_multiple_configs(gmmain, gm, configs, grFactory));
1594 1677
1595 SkBitmap comparisonBitmap; 1678 SkBitmap comparisonBitmap;
1596 const ConfigData compareConfig = 1679 const ConfigData compareConfig =
1597 { SkBitmap::kARGB_8888_Config, kRaster_Backend, kDontCare_GLContextT ype, 0, kRW_ConfigFlag, "comparison", false }; 1680 { SkBitmap::kARGB_8888_Config, kRaster_Backend, kDontCare_GLContextT ype, 0, kRW_ConfigFlag, "comparison", false };
1598 testErrors.add(gmmain.generate_image( 1681 gmmain.generate_image(gm, compareConfig, NULL, NULL, &comparisonBitmap, false);
1599 gm, compareConfig, NULL, NULL, &comparisonBitmap, false));
1600 1682
1601 // TODO(epoger): only run this if gmmain.generate_image() succeeded? 1683 // TODO(epoger): only run this if gmmain.generate_image() succeeded?
1602 // Otherwise, what are we comparing against? 1684 // Otherwise, what are we comparing against?
1603 testErrors.add(run_multiple_modes(gmmain, gm, compareConfig, comparisonB itmap, 1685 run_multiple_modes(gmmain, gm, compareConfig, comparisonBitmap, tileGrid ReplayScales);
1604 tileGridReplayScales));
1605
1606 // Update overall results.
1607 // We only tabulate the particular error types that we currently
1608 // care about (e.g., missing reference images). Later on, if we
1609 // want to also tabulate other error types, we can do so.
1610 testsRun++;
1611 if (!gmmain.fExpectationsSource.get() ||
1612 (testErrors.includes(kMissingExpectations_ErrorType))) {
1613 testsMissingReferenceImages++;
1614 }
1615 if (testErrors.minus(gmmain.fIgnorableErrorCombination).isEmpty()) {
1616 testsPassed++;
1617 } else {
1618 testsFailed++;
1619 }
1620 1686
1621 SkDELETE(gm); 1687 SkDELETE(gm);
1622 } 1688 }
1623 gm_fprintf(stdout, "Ran %d tests: %d passed, %d failed, %d missing reference images\n", 1689
1624 testsRun, testsPassed, testsFailed, testsMissingReferenceImages); 1690 // Assemble the list of modes we ran each test through.
1691 //
1692 // TODO(epoger): Instead of assembling this list of modes here,
1693 // can/should we assemble it as we actually run the tests in
1694 // run_multiple_modes()?
1695 SkTArray<SkString> modes;
1696 if (FLAGS_replay) {
1697 modes.push_back(SkString("replay"));
1698 }
1699 if (FLAGS_serialize) {
1700 modes.push_back(SkString("serialize"));
1701 }
1702 if (FLAGS_rtree) {
1703 modes.push_back(SkString("rtree"));
1704 }
1705 if (FLAGS_tileGrid) {
1706 for (int i = 0; i < tileGridReplayScales.count(); i++) {
1707 SkString modeName("tileGrid");
1708 modeName.appendf("%f", tileGridReplayScales[i]);
1709 modes.push_back(modeName);
1710 }
1711 }
1712 if (FLAGS_pipe) {
1713 for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); i++) {
1714 SkString modeName("pipe");
1715 modeName.append(gPipeWritingFlagCombos[i].name);
1716 modes.push_back(modeName);
1717 }
1718 }
1719 if (FLAGS_tiledPipe) {
1720 for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); i++) {
1721 SkString modeName("tiledPipe");
1722 modeName.append(gPipeWritingFlagCombos[i].name);
1723 modes.push_back(modeName);
1724 }
1725 }
1726
1727 // Output summary to stdout.
1728 gm_fprintf(stdout, "Ran %d GMs, each with %d configs [%s] and %d modes [%s], so there should be a total of %d tests\n",
1729 gmsRun, configs.count(), list_all_config_names(configs).c_str(), modes.count(), list_all(modes).c_str(), gmsRun * (configs.count() + modes.count( )));
1730 // EPOGER: what if the expected total number of tests is wrong?
1625 gmmain.ListErrors(); 1731 gmmain.ListErrors();
1626 1732
1627 if (FLAGS_writeJsonSummaryPath.count() == 1) { 1733 if (FLAGS_writeJsonSummaryPath.count() == 1) {
1628 Json::Value actualResults; 1734 Json::Value actualResults;
1629 actualResults[kJsonKey_ActualResults_Failed] = 1735 actualResults[kJsonKey_ActualResults_Failed] =
1630 gmmain.fJsonActualResults_Failed; 1736 gmmain.fJsonActualResults_Failed;
1631 actualResults[kJsonKey_ActualResults_FailureIgnored] = 1737 actualResults[kJsonKey_ActualResults_FailureIgnored] =
1632 gmmain.fJsonActualResults_FailureIgnored; 1738 gmmain.fJsonActualResults_FailureIgnored;
1633 actualResults[kJsonKey_ActualResults_NoComparison] = 1739 actualResults[kJsonKey_ActualResults_NoComparison] =
1634 gmmain.fJsonActualResults_NoComparison; 1740 gmmain.fJsonActualResults_NoComparison;
(...skipping 19 matching lines...) Expand all
1654 gm_fprintf(stdout, "config: %s %x\n", config.fName, gr); 1760 gm_fprintf(stdout, "config: %s %x\n", config.fName, gr);
1655 gr->printCacheStats(); 1761 gr->printCacheStats();
1656 } 1762 }
1657 } 1763 }
1658 #endif 1764 #endif
1659 1765
1660 delete grFactory; 1766 delete grFactory;
1661 #endif 1767 #endif
1662 SkGraphics::Term(); 1768 SkGraphics::Term();
1663 1769
1664 return (0 == testsFailed) ? 0 : -1; 1770 return (0 == gmmain.NumSignificantErrors()) ? 0 : -1;
1665 } 1771 }
1666 1772
1667 void GMMain::installFilter(SkCanvas* canvas) { 1773 void GMMain::installFilter(SkCanvas* canvas) {
1668 if (FLAGS_forceBWtext) { 1774 if (FLAGS_forceBWtext) {
1669 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); 1775 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref();
1670 } 1776 }
1671 } 1777 }
1672 1778
1673 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 1779 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
1674 int main(int argc, char * const argv[]) { 1780 int main(int argc, char * const argv[]) {
1675 return tool_main(argc, (char**) argv); 1781 return tool_main(argc, (char**) argv);
1676 } 1782 }
1677 #endif 1783 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698