Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 { " cross-process, shared address", SkGPipeWriter::kCrossProcess_Flag | 187 { " cross-process, shared address", SkGPipeWriter::kCrossProcess_Flag |
| 188 | SkGPipeWriter::kSharedAddressSpace_Flag } | 188 | SkGPipeWriter::kSharedAddressSpace_Flag } |
| 189 }; | 189 }; |
| 190 | 190 |
| 191 class GMMain { | 191 class GMMain { |
| 192 public: | 192 public: |
| 193 GMMain() { | 193 GMMain() { |
| 194 // Set default values of member variables, which tool_main() | 194 // Set default values of member variables, which tool_main() |
| 195 // may override. | 195 // may override. |
| 196 fUseFileHierarchy = false; | 196 fUseFileHierarchy = false; |
| 197 fSimulatePipePlaybackFailure = false; | |
|
borenet
2013/03/14 18:48:21
I'm not sure I like the technique of baking test c
epoger
2013/03/14 18:57:12
It rubs me the wrong way too, but I couldn't think
borenet
2013/03/14 19:02:21
Yeah, I guess there's not a good way to force this
rmistry
2013/03/14 19:47:34
Sorry, I may have been able to help for Java or Py
epoger
2013/03/14 22:36:26
I'd rather not require a compile-time flag, becaus
borenet
2013/03/15 20:15:53
Fair enough.
| |
| 197 fMismatchPath = NULL; | 198 fMismatchPath = NULL; |
| 198 } | 199 } |
| 199 | 200 |
| 200 SkString make_name(const char shortName[], const char configName[]) { | 201 SkString make_name(const char shortName[], const char configName[]) { |
| 201 SkString name; | 202 SkString name; |
| 202 if (0 == strlen(configName)) { | 203 if (0 == strlen(configName)) { |
| 203 name.append(shortName); | 204 name.append(shortName); |
| 204 } else if (fUseFileHierarchy) { | 205 } else if (fUseFileHierarchy) { |
| 205 name.appendf("%s%c%s", configName, SkPATH_SEPARATOR, shortName); | 206 name.appendf("%s%c%s", configName, SkPATH_SEPARATOR, shortName); |
| 206 } else { | 207 } else { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 254 // The common case: no error means nothing to record. | 255 // The common case: no error means nothing to record. |
| 255 if (kEmptyErrorBitfield == errorType) { | 256 if (kEmptyErrorBitfield == errorType) { |
| 256 return; | 257 return; |
| 257 } | 258 } |
| 258 | 259 |
| 259 // If only certain error type(s) were reported, we know we can ignore th em. | 260 // If only certain error type(s) were reported, we know we can ignore th em. |
| 260 if (errorType == (errorType & kIgnorable_ErrorBitmask)) { | 261 if (errorType == (errorType & kIgnorable_ErrorBitmask)) { |
| 261 return; | 262 return; |
| 262 } | 263 } |
| 263 | 264 |
| 264 FailRec& rec = fFailedTests.push_back(make_name( | 265 SkString completeName = name; |
| 265 name.c_str(), renderModeDescriptor)); | 266 completeName.append(renderModeDescriptor); |
|
epoger
2013/03/14 17:22:19
fixing a minor discrepancy revealed by this test
| |
| 267 FailRec& rec = fFailedTests.push_back(completeName); | |
| 266 rec.fIsPixelError = | 268 rec.fIsPixelError = |
| 267 (kEmptyErrorBitfield != (errorType & kImageMismatch_ErrorBitmask)); | 269 (kEmptyErrorBitfield != (errorType & kImageMismatch_ErrorBitmask)); |
| 268 } | 270 } |
| 269 | 271 |
| 270 // List contents of fFailedTests via SkDebug. | 272 // List contents of fFailedTests via SkDebug. |
| 271 void ListErrors() { | 273 void ListErrors() { |
| 272 for (int i = 0; i < fFailedTests.count(); ++i) { | 274 for (int i = 0; i < fFailedTests.count(); ++i) { |
| 273 if (fFailedTests[i].fIsPixelError) { | 275 if (fFailedTests[i].fIsPixelError) { |
| 274 gm_fprintf(stderr, "\t\t%s pixel_error\n", fFailedTests[i].fName .c_str()); | 276 gm_fprintf(stderr, "\t\t%s pixel_error\n", fFailedTests[i].fName .c_str()); |
| 275 } else { | 277 } else { |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 898 ErrorBitfield errors = kEmptyErrorBitfield; | 900 ErrorBitfield errors = kEmptyErrorBitfield; |
| 899 for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) { | 901 for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) { |
| 900 SkBitmap bitmap; | 902 SkBitmap bitmap; |
| 901 SkISize size = gm->getISize(); | 903 SkISize size = gm->getISize(); |
| 902 setup_bitmap(gRec, size, &bitmap); | 904 setup_bitmap(gRec, size, &bitmap); |
| 903 SkCanvas canvas(bitmap); | 905 SkCanvas canvas(bitmap); |
| 904 PipeController pipeController(&canvas); | 906 PipeController pipeController(&canvas); |
| 905 SkGPipeWriter writer; | 907 SkGPipeWriter writer; |
| 906 SkCanvas* pipeCanvas = writer.startRecording( | 908 SkCanvas* pipeCanvas = writer.startRecording( |
| 907 &pipeController, gPipeWritingFlagCombos[i].flags); | 909 &pipeController, gPipeWritingFlagCombos[i].flags); |
| 908 invokeGM(gm, pipeCanvas, false, false); | 910 if (!this->fSimulatePipePlaybackFailure) { |
| 911 invokeGM(gm, pipeCanvas, false, false); | |
| 912 } | |
| 909 complete_bitmap(&bitmap); | 913 complete_bitmap(&bitmap); |
| 910 writer.endRecording(); | 914 writer.endRecording(); |
| 911 SkString string("-pipe"); | 915 SkString string("-pipe"); |
| 912 string.append(gPipeWritingFlagCombos[i].name); | 916 string.append(gPipeWritingFlagCombos[i].name); |
| 913 errors |= compare_test_results_to_reference_bitmap( | 917 errors |= compare_test_results_to_reference_bitmap( |
| 914 gm, gRec, string.c_str(), bitmap, &referenceBitmap); | 918 gm, gRec, string.c_str(), bitmap, &referenceBitmap); |
| 915 if (errors != kEmptyErrorBitfield) { | 919 if (errors != kEmptyErrorBitfield) { |
| 916 break; | 920 break; |
| 917 } | 921 } |
| 918 } | 922 } |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 944 } | 948 } |
| 945 return errors; | 949 return errors; |
| 946 } | 950 } |
| 947 | 951 |
| 948 // | 952 // |
| 949 // member variables. | 953 // member variables. |
| 950 // They are public for now, to allow easier setting by tool_main(). | 954 // They are public for now, to allow easier setting by tool_main(). |
| 951 // | 955 // |
| 952 | 956 |
| 953 bool fUseFileHierarchy; | 957 bool fUseFileHierarchy; |
| 958 bool fSimulatePipePlaybackFailure; | |
| 954 | 959 |
| 955 const char* fMismatchPath; | 960 const char* fMismatchPath; |
| 956 | 961 |
| 957 // information about all failed tests we have encountered so far | 962 // information about all failed tests we have encountered so far |
| 958 SkTArray<FailRec> fFailedTests; | 963 SkTArray<FailRec> fFailedTests; |
| 959 | 964 |
| 960 // Where to read expectations (expected image checksums, etc.) from. | 965 // Where to read expectations (expected image checksums, etc.) from. |
| 961 // If unset, we don't do comparisons. | 966 // If unset, we don't do comparisons. |
| 962 SkAutoTUnref<ExpectationsSource> fExpectationsSource; | 967 SkAutoTUnref<ExpectationsSource> fExpectationsSource; |
| 963 | 968 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1047 " [--modulo <remainder> <divisor>]: only run tests for which \n" | 1052 " [--modulo <remainder> <divisor>]: only run tests for which \n" |
| 1048 " testIndex %% divisor == remainder\n" | 1053 " testIndex %% divisor == remainder\n" |
| 1049 " [--nopdf]: skip the pdf rendering test pass\n" | 1054 " [--nopdf]: skip the pdf rendering test pass\n" |
| 1050 " [--nopipe]: Skip SkGPipe replay\n" | 1055 " [--nopipe]: Skip SkGPipe replay\n" |
| 1051 " [--readPath|-r <path>]: read reference images from this dir, and report\n" | 1056 " [--readPath|-r <path>]: read reference images from this dir, and report\n" |
| 1052 " any differences between those and the newly generated ones\n" | 1057 " any differences between those and the newly generated ones\n" |
| 1053 " [--noreplay]: do not exercise SkPicture replay\n" | 1058 " [--noreplay]: do not exercise SkPicture replay\n" |
| 1054 " [--resourcePath|-i <path>]: directory that stores image resources\n" | 1059 " [--resourcePath|-i <path>]: directory that stores image resources\n" |
| 1055 " [--nortree]: Do not exercise the R-Tree variant of SkPicture\n" | 1060 " [--nortree]: Do not exercise the R-Tree variant of SkPicture\n" |
| 1056 " [--noserialize]: do not exercise SkPicture serialization & deserialization\ n" | 1061 " [--noserialize]: do not exercise SkPicture serialization & deserialization\ n" |
| 1062 " [--simulatePipePlaybackFailure]: simulate a rendering failure in pipe mode only\n" | |
| 1057 " [--tiledPipe]: Exercise tiled SkGPipe replay\n" | 1063 " [--tiledPipe]: Exercise tiled SkGPipe replay\n" |
| 1058 " [--notileGrid]: Do not exercise the tile grid variant of SkPicture\n" | 1064 " [--notileGrid]: Do not exercise the tile grid variant of SkPicture\n" |
| 1059 " [--tileGridReplayScales <scales>]: Comma separated list of floating-point s cale\n" | 1065 " [--tileGridReplayScales <scales>]: Comma separated list of floating-point s cale\n" |
| 1060 " factors to be used for tileGrid playback testing. Default value: 1.0\n" | 1066 " factors to be used for tileGrid playback testing. Default value: 1.0\n" |
| 1061 " [--writeJsonSummary <path>]: write a JSON-formatted result summary to this file\n" | 1067 " [--writeJsonSummary <path>]: write a JSON-formatted result summary to this file\n" |
| 1062 " [--verbose] print diagnostics (e.g. list each config to be tested)\n" | 1068 " [--verbose] print diagnostics (e.g. list each config to be tested)\n" |
| 1063 " [--writePath|-w <path>]: write rendered images into this directory\n" | 1069 " [--writePath|-w <path>]: write rendered images into this directory\n" |
| 1064 " [--writePicturePath|-wp <path>]: write .skp files into this directory\n" | 1070 " [--writePicturePath|-wp <path>]: write .skp files into this directory\n" |
| 1065 ); | 1071 ); |
| 1066 } | 1072 } |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1313 } else if ((0 == strcmp(*argv, "--resourcePath")) || | 1319 } else if ((0 == strcmp(*argv, "--resourcePath")) || |
| 1314 (0 == strcmp(*argv, "-i"))) { | 1320 (0 == strcmp(*argv, "-i"))) { |
| 1315 argv++; | 1321 argv++; |
| 1316 if (argv < stop && **argv) { | 1322 if (argv < stop && **argv) { |
| 1317 resourcePath = *argv; | 1323 resourcePath = *argv; |
| 1318 } | 1324 } |
| 1319 } else if (strcmp(*argv, "--serialize") == 0) { | 1325 } else if (strcmp(*argv, "--serialize") == 0) { |
| 1320 doSerialize = true; | 1326 doSerialize = true; |
| 1321 } else if (strcmp(*argv, "--noserialize") == 0) { | 1327 } else if (strcmp(*argv, "--noserialize") == 0) { |
| 1322 doSerialize = false; | 1328 doSerialize = false; |
| 1329 } else if (strcmp(*argv, "--simulatePipePlaybackFailure") == 0) { | |
| 1330 gmmain.fSimulatePipePlaybackFailure = true; | |
| 1323 } else if (strcmp(*argv, "--tiledPipe") == 0) { | 1331 } else if (strcmp(*argv, "--tiledPipe") == 0) { |
| 1324 doTiledPipe = true; | 1332 doTiledPipe = true; |
| 1325 } else if (!strcmp(*argv, "--verbose") || !strcmp(*argv, "-v")) { | 1333 } else if (!strcmp(*argv, "--verbose") || !strcmp(*argv, "-v")) { |
| 1326 doVerbose = true; | 1334 doVerbose = true; |
| 1327 } else if ((0 == strcmp(*argv, "--writePath")) || | 1335 } else if ((0 == strcmp(*argv, "--writePath")) || |
| 1328 (0 == strcmp(*argv, "-w"))) { | 1336 (0 == strcmp(*argv, "-w"))) { |
| 1329 argv++; | 1337 argv++; |
| 1330 if (argv < stop && **argv) { | 1338 if (argv < stop && **argv) { |
| 1331 writePath = *argv; | 1339 writePath = *argv; |
| 1332 } | 1340 } |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1720 SkGraphics::Term(); | 1728 SkGraphics::Term(); |
| 1721 | 1729 |
| 1722 return (0 == testsFailed) ? 0 : -1; | 1730 return (0 == testsFailed) ? 0 : -1; |
| 1723 } | 1731 } |
| 1724 | 1732 |
| 1725 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 1733 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 1726 int main(int argc, char * const argv[]) { | 1734 int main(int argc, char * const argv[]) { |
| 1727 return tool_main(argc, (char**) argv); | 1735 return tool_main(argc, (char**) argv); |
| 1728 } | 1736 } |
| 1729 #endif | 1737 #endif |
| OLD | NEW |