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 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1414 // Macro magic to convert a numeric preprocessor token into a string. | 1414 // Macro magic to convert a numeric preprocessor token into a string. |
1415 // Adapted from http://stackoverflow.com/questions/240353/convert-a-preprocessor
-token-to-a-string | 1415 // Adapted from http://stackoverflow.com/questions/240353/convert-a-preprocessor
-token-to-a-string |
1416 // This should probably be moved into one of our common headers... | 1416 // This should probably be moved into one of our common headers... |
1417 #define TOSTRING_INTERNAL(x) #x | 1417 #define TOSTRING_INTERNAL(x) #x |
1418 #define TOSTRING(x) TOSTRING_INTERNAL(x) | 1418 #define TOSTRING(x) TOSTRING_INTERNAL(x) |
1419 | 1419 |
1420 // Alphabetized ignoring "no" prefix ("readPath", "noreplay", "resourcePath"). | 1420 // Alphabetized ignoring "no" prefix ("readPath", "noreplay", "resourcePath"). |
1421 DEFINE_string(config, "", configUsage().c_str()); | 1421 DEFINE_string(config, "", configUsage().c_str()); |
1422 DEFINE_string(pdfRasterizers, "default", pdfRasterizerUsage().c_str()); | 1422 DEFINE_string(pdfRasterizers, "default", pdfRasterizerUsage().c_str()); |
1423 DEFINE_bool(deferred, false, "Exercise the deferred rendering test pass."); | 1423 DEFINE_bool(deferred, false, "Exercise the deferred rendering test pass."); |
| 1424 DEFINE_bool(dryRun, false, "Don't actually run the tests, just print what would
have been done."); |
1424 DEFINE_string(excludeConfig, "", "Space delimited list of configs to skip."); | 1425 DEFINE_string(excludeConfig, "", "Space delimited list of configs to skip."); |
1425 DEFINE_bool(forceBWtext, false, "Disable text anti-aliasing."); | 1426 DEFINE_bool(forceBWtext, false, "Disable text anti-aliasing."); |
1426 #if SK_SUPPORT_GPU | 1427 #if SK_SUPPORT_GPU |
1427 DEFINE_string(gpuCacheSize, "", "<bytes> <count>: Limit the gpu cache to byte si
ze or " | 1428 DEFINE_string(gpuCacheSize, "", "<bytes> <count>: Limit the gpu cache to byte si
ze or " |
1428 "object count. " TOSTRING(DEFAULT_CACHE_VALUE) " for either value
means " | 1429 "object count. " TOSTRING(DEFAULT_CACHE_VALUE) " for either value
means " |
1429 "use the default. 0 for either disables the cache."); | 1430 "use the default. 0 for either disables the cache."); |
1430 #endif | 1431 #endif |
1431 DEFINE_bool(hierarchy, false, "Whether to use multilevel directory structure " | 1432 DEFINE_bool(hierarchy, false, "Whether to use multilevel directory structure " |
1432 "when reading/writing files."); | 1433 "when reading/writing files."); |
1433 DEFINE_string(ignoreErrorTypes, kDefaultIgnorableErrorTypes.asString(" ").c_str(
), | 1434 DEFINE_string(ignoreErrorTypes, kDefaultIgnorableErrorTypes.asString(" ").c_str(
), |
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2230 int moduloRemainder = -1; | 2231 int moduloRemainder = -1; |
2231 int moduloDivisor = -1; | 2232 int moduloDivisor = -1; |
2232 SkTDArray<const PDFRasterizerData*> pdfRasterizers; | 2233 SkTDArray<const PDFRasterizerData*> pdfRasterizers; |
2233 SkTDArray<SkScalar> tileGridReplayScales; | 2234 SkTDArray<SkScalar> tileGridReplayScales; |
2234 #if SK_SUPPORT_GPU | 2235 #if SK_SUPPORT_GPU |
2235 GrContextFactory* grFactory = new GrContextFactory; | 2236 GrContextFactory* grFactory = new GrContextFactory; |
2236 #else | 2237 #else |
2237 GrContextFactory* grFactory = NULL; | 2238 GrContextFactory* grFactory = NULL; |
2238 #endif | 2239 #endif |
2239 | 2240 |
| 2241 if (FLAGS_dryRun) { |
| 2242 SkDebugf( "Doing a dry run; no tests will actually be executed.\n"); |
| 2243 } |
| 2244 |
2240 if (!parse_flags_modulo(&moduloRemainder, &moduloDivisor) || | 2245 if (!parse_flags_modulo(&moduloRemainder, &moduloDivisor) || |
2241 !parse_flags_ignore_error_types(&gmmain.fIgnorableErrorTypes) || | 2246 !parse_flags_ignore_error_types(&gmmain.fIgnorableErrorTypes) || |
2242 !parse_flags_ignore_tests(gmmain.fIgnorableTestNames) || | 2247 !parse_flags_ignore_tests(gmmain.fIgnorableTestNames) || |
2243 #if SK_SUPPORT_GPU | 2248 #if SK_SUPPORT_GPU |
2244 !parse_flags_gpu_cache(&gGpuCacheSizeBytes, &gGpuCacheSizeCount) || | 2249 !parse_flags_gpu_cache(&gGpuCacheSizeBytes, &gGpuCacheSizeCount) || |
2245 #endif | 2250 #endif |
2246 !parse_flags_tile_grid_replay_scales(&tileGridReplayScales) || | 2251 !parse_flags_tile_grid_replay_scales(&tileGridReplayScales) || |
2247 !parse_flags_resource_path() || | 2252 !parse_flags_resource_path() || |
2248 !parse_flags_jpeg_quality() || | 2253 !parse_flags_jpeg_quality() || |
2249 !parse_flags_configs(&configs, grFactory) || | 2254 !parse_flags_configs(&configs, grFactory) || |
(...skipping 18 matching lines...) Expand all Loading... |
2268 } | 2273 } |
2269 if (FLAGS_resourcePath.count() == 1) { | 2274 if (FLAGS_resourcePath.count() == 1) { |
2270 SkDebugf("reading resources from %s\n", FLAGS_resourcePath[0]); | 2275 SkDebugf("reading resources from %s\n", FLAGS_resourcePath[0]); |
2271 } | 2276 } |
2272 } | 2277 } |
2273 | 2278 |
2274 int gmsRun = 0; | 2279 int gmsRun = 0; |
2275 int gmIndex = -1; | 2280 int gmIndex = -1; |
2276 SkString moduloStr; | 2281 SkString moduloStr; |
2277 | 2282 |
2278 // If we will be writing out files, prepare subdirectories. | 2283 if (!FLAGS_dryRun) { |
2279 if (FLAGS_writePath.count() == 1) { | 2284 // If we will be writing out files, prepare subdirectories. |
2280 if (!prepare_subdirectories(FLAGS_writePath[0], gmmain.fUseFileHierarchy
, | 2285 if (FLAGS_writePath.count() == 1) { |
2281 configs, pdfRasterizers)) { | 2286 if (!prepare_subdirectories(FLAGS_writePath[0], gmmain.fUseFileHiera
rchy, |
2282 return -1; | 2287 configs, pdfRasterizers)) { |
| 2288 return -1; |
| 2289 } |
| 2290 } |
| 2291 if (NULL != gmmain.fMismatchPath) { |
| 2292 if (!prepare_subdirectories(gmmain.fMismatchPath, gmmain.fUseFileHie
rarchy, |
| 2293 configs, pdfRasterizers)) { |
| 2294 return -1; |
| 2295 } |
| 2296 } |
| 2297 if (NULL != gmmain.fMissingExpectationsPath) { |
| 2298 if (!prepare_subdirectories(gmmain.fMissingExpectationsPath, gmmain.
fUseFileHierarchy, |
| 2299 configs, pdfRasterizers)) { |
| 2300 return -1; |
| 2301 } |
2283 } | 2302 } |
2284 } | 2303 } |
2285 if (NULL != gmmain.fMismatchPath) { | |
2286 if (!prepare_subdirectories(gmmain.fMismatchPath, gmmain.fUseFileHierarc
hy, | |
2287 configs, pdfRasterizers)) { | |
2288 return -1; | |
2289 } | |
2290 } | |
2291 if (NULL != gmmain.fMissingExpectationsPath) { | |
2292 if (!prepare_subdirectories(gmmain.fMissingExpectationsPath, gmmain.fUse
FileHierarchy, | |
2293 configs, pdfRasterizers)) { | |
2294 return -1; | |
2295 } | |
2296 } | |
2297 | |
2298 Iter iter; | 2304 Iter iter; |
2299 GM* gm; | 2305 GM* gm; |
2300 while ((gm = iter.next()) != NULL) { | 2306 while ((gm = iter.next()) != NULL) { |
2301 if (FLAGS_forcePerspectiveMatrix) { | 2307 if (FLAGS_forcePerspectiveMatrix) { |
2302 SkMatrix perspective; | 2308 SkMatrix perspective; |
2303 perspective.setIdentity(); | 2309 perspective.setIdentity(); |
2304 perspective.setPerspY(SkScalarDiv(SK_Scalar1, SkIntToScalar(1000))); | 2310 perspective.setPerspY(SkScalarDiv(SK_Scalar1, SkIntToScalar(1000))); |
2305 perspective.setSkewX(SkScalarDiv(SkIntToScalar(8), | 2311 perspective.setSkewX(SkScalarDiv(SkIntToScalar(8), |
2306 SkIntToScalar(25))); | 2312 SkIntToScalar(25))); |
2307 | 2313 |
(...skipping 11 matching lines...) Expand all Loading... |
2319 const char* shortName = gm->getName(); | 2325 const char* shortName = gm->getName(); |
2320 | 2326 |
2321 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, shortName)) { | 2327 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, shortName)) { |
2322 continue; | 2328 continue; |
2323 } | 2329 } |
2324 | 2330 |
2325 gmsRun++; | 2331 gmsRun++; |
2326 SkISize size = gm->getISize(); | 2332 SkISize size = gm->getISize(); |
2327 SkDebugf("%sdrawing... %s [%d %d]\n", moduloStr.c_str(), shortName, | 2333 SkDebugf("%sdrawing... %s [%d %d]\n", moduloStr.c_str(), shortName, |
2328 size.width(), size.height()); | 2334 size.width(), size.height()); |
| 2335 if (!FLAGS_dryRun) |
| 2336 run_multiple_configs(gmmain, gm, configs, pdfRasterizers, tileGridRe
playScales, grFactory); |
| 2337 } |
2329 | 2338 |
2330 run_multiple_configs(gmmain, gm, configs, pdfRasterizers, tileGridReplay
Scales, grFactory); | 2339 if (FLAGS_dryRun) |
2331 } | 2340 return 0; |
2332 | 2341 |
2333 SkTArray<SkString> modes; | 2342 SkTArray<SkString> modes; |
2334 gmmain.GetRenderModesEncountered(modes); | 2343 gmmain.GetRenderModesEncountered(modes); |
2335 int modeCount = modes.count(); | 2344 int modeCount = modes.count(); |
2336 | 2345 |
2337 // Now that we have run all the tests and thus know the full set of renderMo
des that we | 2346 // Now that we have run all the tests and thus know the full set of renderMo
des that we |
2338 // tried to run, we can call RecordTestResults() to record the cases in whic
h we skipped | 2347 // tried to run, we can call RecordTestResults() to record the cases in whic
h we skipped |
2339 // ALL renderModes. | 2348 // ALL renderModes. |
2340 // See http://skbug.com/1994 and https://codereview.chromium.org/129203002/ | 2349 // See http://skbug.com/1994 and https://codereview.chromium.org/129203002/ |
2341 int testCount = gmmain.fTestsSkippedOnAllRenderModes.count(); | 2350 int testCount = gmmain.fTestsSkippedOnAllRenderModes.count(); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2432 if (FLAGS_forceBWtext) { | 2441 if (FLAGS_forceBWtext) { |
2433 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 2442 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
2434 } | 2443 } |
2435 } | 2444 } |
2436 | 2445 |
2437 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 2446 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
2438 int main(int argc, char * const argv[]) { | 2447 int main(int argc, char * const argv[]) { |
2439 return tool_main(argc, (char**) argv); | 2448 return tool_main(argc, (char**) argv); |
2440 } | 2449 } |
2441 #endif | 2450 #endif |
OLD | NEW |