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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 uint32_t flags; | 167 uint32_t flags; |
168 }; | 168 }; |
169 | 169 |
170 static PipeFlagComboData gPipeWritingFlagCombos[] = { | 170 static PipeFlagComboData gPipeWritingFlagCombos[] = { |
171 { "", 0 }, | 171 { "", 0 }, |
172 { " cross-process", SkGPipeWriter::kCrossProcess_Flag }, | 172 { " cross-process", SkGPipeWriter::kCrossProcess_Flag }, |
173 { " cross-process, shared address", SkGPipeWriter::kCrossProcess_Flag | 173 { " cross-process, shared address", SkGPipeWriter::kCrossProcess_Flag |
174 | SkGPipeWriter::kSharedAddressSpace_Flag } | 174 | SkGPipeWriter::kSharedAddressSpace_Flag } |
175 }; | 175 }; |
176 | 176 |
177 const static ErrorCombination kDefaultIgnorableErrorTypes = ErrorCombination() | |
178 .plus(kMissingExpectations_ErrorType) | |
179 .plus(kIntentionallySkipped_ErrorType); | |
180 | |
177 class GMMain { | 181 class GMMain { |
178 public: | 182 public: |
179 GMMain() : fUseFileHierarchy(false), fMismatchPath(NULL), fTestsRun(0), | 183 GMMain() : fUseFileHierarchy(false), fIgnorableErrorTypes(kDefaultIgnorableE rrorTypes), |
180 fRenderModesEncountered(1) { | 184 fMismatchPath(NULL), fTestsRun(0), fRenderModesEncountered(1) {} |
181 fIgnorableErrorCombination.add(kMissingExpectations_ErrorType); | |
182 fIgnorableErrorCombination.add(kIntentionallySkipped_ErrorType); | |
183 } | |
184 | 185 |
185 SkString make_name(const char shortName[], const char configName[]) { | 186 SkString make_name(const char shortName[], const char configName[]) { |
186 SkString name; | 187 SkString name; |
187 if (0 == strlen(configName)) { | 188 if (0 == strlen(configName)) { |
188 name.append(shortName); | 189 name.append(shortName); |
189 } else if (fUseFileHierarchy) { | 190 } else if (fUseFileHierarchy) { |
190 name.appendf("%s%c%s", configName, SkPATH_SEPARATOR, shortName); | 191 name.appendf("%s%c%s", configName, SkPATH_SEPARATOR, shortName); |
191 } else { | 192 } else { |
192 name.appendf("%s_%s", shortName, configName); | 193 name.appendf("%s_%s", shortName, configName); |
193 } | 194 } |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
284 } | 285 } |
285 | 286 |
286 /** | 287 /** |
287 * Return the number of significant (non-ignorable) errors we have | 288 * Return the number of significant (non-ignorable) errors we have |
288 * encountered so far. | 289 * encountered so far. |
289 */ | 290 */ |
290 int NumSignificantErrors() { | 291 int NumSignificantErrors() { |
291 int significantErrors = 0; | 292 int significantErrors = 0; |
292 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { | 293 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { |
293 ErrorType type = static_cast<ErrorType>(typeInt); | 294 ErrorType type = static_cast<ErrorType>(typeInt); |
294 if (!fIgnorableErrorCombination.includes(type)) { | 295 if (!fIgnorableErrorTypes.includes(type)) { |
295 significantErrors += fFailedTests[type].count(); | 296 significantErrors += fFailedTests[type].count(); |
296 } | 297 } |
297 } | 298 } |
298 return significantErrors; | 299 return significantErrors; |
299 } | 300 } |
300 | 301 |
301 /** | 302 /** |
302 * Display the summary of results with this ErrorType. | 303 * Display the summary of results with this ErrorType. |
303 * | 304 * |
304 * @param type which ErrorType | 305 * @param type which ErrorType |
305 * @param verbose whether to be all verbose about it | 306 * @param verbose whether to be all verbose about it |
306 */ | 307 */ |
307 void DisplayResultTypeSummary(ErrorType type, bool verbose) { | 308 void DisplayResultTypeSummary(ErrorType type, bool verbose) { |
308 bool isIgnorableType = fIgnorableErrorCombination.includes(type); | 309 bool isIgnorableType = fIgnorableErrorTypes.includes(type); |
309 | 310 |
310 SkString line; | 311 SkString line; |
311 if (isIgnorableType) { | 312 if (isIgnorableType) { |
312 line.append("[ ] "); | 313 line.append("[ ] "); |
313 } else { | 314 } else { |
314 line.append("[*] "); | 315 line.append("[*] "); |
315 } | 316 } |
316 | 317 |
317 SkTArray<SkString> *failedTestsOfThisType = &fFailedTests[type]; | 318 SkTArray<SkString> *failedTestsOfThisType = &fFailedTests[type]; |
318 int count = failedTestsOfThisType->count(); | 319 int count = failedTestsOfThisType->count(); |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1089 } | 1090 } |
1090 return errors; | 1091 return errors; |
1091 } | 1092 } |
1092 | 1093 |
1093 // | 1094 // |
1094 // member variables. | 1095 // member variables. |
1095 // They are public for now, to allow easier setting by tool_main(). | 1096 // They are public for now, to allow easier setting by tool_main(). |
1096 // | 1097 // |
1097 | 1098 |
1098 bool fUseFileHierarchy; | 1099 bool fUseFileHierarchy; |
1099 ErrorCombination fIgnorableErrorCombination; | 1100 ErrorCombination fIgnorableErrorTypes; |
1100 | 1101 |
1101 const char* fMismatchPath; | 1102 const char* fMismatchPath; |
1102 | 1103 |
1103 // collection of tests that have failed with each ErrorType | 1104 // collection of tests that have failed with each ErrorType |
1104 SkTArray<SkString> fFailedTests[kLast_ErrorType+1]; | 1105 SkTArray<SkString> fFailedTests[kLast_ErrorType+1]; |
1105 int fTestsRun; | 1106 int fTestsRun; |
1106 SkTDict<int> fRenderModesEncountered; | 1107 SkTDict<int> fRenderModesEncountered; |
1107 | 1108 |
1108 // Where to read expectations (expected image checksums, etc.) from. | 1109 // Where to read expectations (expected image checksums, etc.) from. |
1109 // If unset, we don't do comparisons. | 1110 // If unset, we don't do comparisons. |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1193 DEFINE_bool(deferred, true, "Exercise the deferred rendering test pass."); | 1194 DEFINE_bool(deferred, true, "Exercise the deferred rendering test pass."); |
1194 DEFINE_string(excludeConfig, "", "Space delimited list of configs to skip."); | 1195 DEFINE_string(excludeConfig, "", "Space delimited list of configs to skip."); |
1195 DEFINE_bool(forceBWtext, false, "Disable text anti-aliasing."); | 1196 DEFINE_bool(forceBWtext, false, "Disable text anti-aliasing."); |
1196 #if SK_SUPPORT_GPU | 1197 #if SK_SUPPORT_GPU |
1197 DEFINE_string(gpuCacheSize, "", "<bytes> <count>: Limit the gpu cache to byte si ze or " | 1198 DEFINE_string(gpuCacheSize, "", "<bytes> <count>: Limit the gpu cache to byte si ze or " |
1198 "object count. " TOSTRING(DEFAULT_CACHE_VALUE) " for either value means " | 1199 "object count. " TOSTRING(DEFAULT_CACHE_VALUE) " for either value means " |
1199 "use the default. 0 for either disables the cache."); | 1200 "use the default. 0 for either disables the cache."); |
1200 #endif | 1201 #endif |
1201 DEFINE_bool(hierarchy, false, "Whether to use multilevel directory structure " | 1202 DEFINE_bool(hierarchy, false, "Whether to use multilevel directory structure " |
1202 "when reading/writing files."); | 1203 "when reading/writing files."); |
1204 // TODO(epoger): Maybe should make SkCommandLineFlags handle default string | |
1205 // values differently, so that the first definition of ignoreErrorTypes worked? | |
borenet
2013/04/12 00:29:45
Good question for scroggo@. I'm not terribly fami
epoger
2013/04/12 02:44:43
Yeah, I wanted to commit this change and then see
scroggo
2013/04/12 15:24:30
Created https://code.google.com/p/skia/issues/deta
| |
1206 #if 0 | |
1207 DEFINE_string(ignoreErrorTypes, kDefaultIgnorableErrorTypes.asString(" ").c_str( ), | |
1208 "Space-separated list of ErrorTypes that should be ignored. If any *other* error " | |
1209 "types are encountered, the tool will exit with a nonzero return v alue."); | |
1210 #else | |
1211 DEFINE_string(ignoreErrorTypes, "", SkString(SkString( | |
1212 "Space-separated list of ErrorTypes that should be ignored. If any *other* error " | |
1213 "types are encountered, the tool will exit with a nonzero return v alue. " | |
1214 "Defaults to: ") += kDefaultIgnorableErrorTypes.asString(" ")).c_s tr()); | |
1215 #endif | |
1203 DEFINE_string(match, "", "Only run tests whose name includes this substring/the se substrings " | 1216 DEFINE_string(match, "", "Only run tests whose name includes this substring/the se substrings " |
1204 "(more than one can be supplied, separated by spaces)."); | 1217 "(more than one can be supplied, separated by spaces)."); |
1205 DEFINE_string(mismatchPath, "", "Write images for tests that failed due to " | 1218 DEFINE_string(mismatchPath, "", "Write images for tests that failed due to " |
1206 "pixel mismatches into this directory."); | 1219 "pixel mismatches into this directory."); |
1207 DEFINE_string(modulo, "", "[--modulo <remainder> <divisor>]: only run tests for which " | 1220 DEFINE_string(modulo, "", "[--modulo <remainder> <divisor>]: only run tests for which " |
1208 "testIndex %% divisor == remainder."); | 1221 "testIndex %% divisor == remainder."); |
1209 DEFINE_bool(pdf, true, "Exercise the pdf rendering test pass."); | 1222 DEFINE_bool(pdf, true, "Exercise the pdf rendering test pass."); |
1210 DEFINE_bool(pipe, true, "Exercise the SkGPipe replay test pass."); | 1223 DEFINE_bool(pipe, true, "Exercise the SkGPipe replay test pass."); |
1211 DEFINE_string2(readPath, r, "", "Read reference images from this dir, and report " | 1224 DEFINE_string2(readPath, r, "", "Read reference images from this dir, and report " |
1212 "any differences between those and the newly generated ones."); | 1225 "any differences between those and the newly generated ones."); |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1623 | 1636 |
1624 if (FLAGS_modulo.count() == 2) { | 1637 if (FLAGS_modulo.count() == 2) { |
1625 moduloRemainder = atoi(FLAGS_modulo[0]); | 1638 moduloRemainder = atoi(FLAGS_modulo[0]); |
1626 moduloDivisor = atoi(FLAGS_modulo[1]); | 1639 moduloDivisor = atoi(FLAGS_modulo[1]); |
1627 if (moduloRemainder < 0 || moduloDivisor <= 0 || moduloRemainder >= modu loDivisor) { | 1640 if (moduloRemainder < 0 || moduloDivisor <= 0 || moduloRemainder >= modu loDivisor) { |
1628 gm_fprintf(stderr, "invalid modulo values."); | 1641 gm_fprintf(stderr, "invalid modulo values."); |
1629 return -1; | 1642 return -1; |
1630 } | 1643 } |
1631 } | 1644 } |
1632 | 1645 |
1646 if (FLAGS_ignoreErrorTypes.count() > 0) { | |
1647 gmmain.fIgnorableErrorTypes = ErrorCombination(); | |
1648 for (int i = 0; i < FLAGS_ignoreErrorTypes.count(); i++) { | |
1649 ErrorType type; | |
1650 const char *name = FLAGS_ignoreErrorTypes[i]; | |
1651 if (!getErrorTypeByName(name, &type)) { | |
1652 gm_fprintf(stderr, "cannot find ErrorType with name '%s'\n", nam e); | |
1653 return -1; | |
1654 } else { | |
1655 gmmain.fIgnorableErrorTypes.add(type); | |
1656 } | |
1657 } | |
1658 } | |
1659 | |
1633 #if SK_SUPPORT_GPU | 1660 #if SK_SUPPORT_GPU |
1634 if (FLAGS_gpuCacheSize.count() > 0) { | 1661 if (FLAGS_gpuCacheSize.count() > 0) { |
1635 if (FLAGS_gpuCacheSize.count() != 2) { | 1662 if (FLAGS_gpuCacheSize.count() != 2) { |
1636 gm_fprintf(stderr, "--gpuCacheSize requires two arguments\n"); | 1663 gm_fprintf(stderr, "--gpuCacheSize requires two arguments\n"); |
1637 return -1; | 1664 return -1; |
1638 } | 1665 } |
1639 gGpuCacheSizeBytes = atoi(FLAGS_gpuCacheSize[0]); | 1666 gGpuCacheSizeBytes = atoi(FLAGS_gpuCacheSize[0]); |
1640 gGpuCacheSizeCount = atoi(FLAGS_gpuCacheSize[1]); | 1667 gGpuCacheSizeCount = atoi(FLAGS_gpuCacheSize[1]); |
1641 } else { | 1668 } else { |
1642 gGpuCacheSizeBytes = DEFAULT_CACHE_VALUE; | 1669 gGpuCacheSizeBytes = DEFAULT_CACHE_VALUE; |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1880 if (FLAGS_forceBWtext) { | 1907 if (FLAGS_forceBWtext) { |
1881 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 1908 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
1882 } | 1909 } |
1883 } | 1910 } |
1884 | 1911 |
1885 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 1912 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
1886 int main(int argc, char * const argv[]) { | 1913 int main(int argc, char * const argv[]) { |
1887 return tool_main(argc, (char**) argv); | 1914 return tool_main(argc, (char**) argv); |
1888 } | 1915 } |
1889 #endif | 1916 #endif |
OLD | NEW |