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 * |
11 * If you make changes to this, re-run the self-tests at gm/tests/run.sh | 11 * If you make changes to this, re-run the self-tests at gm/tests/run.sh |
12 * to make sure they still pass... you may need to change the expected | 12 * to make sure they still pass... you may need to change the expected |
13 * results of the self-test. | 13 * results of the self-test. |
14 */ | 14 */ |
15 | 15 |
16 #include "gm.h" | 16 #include "gm.h" |
17 #include "gm_error.h" | 17 #include "gm_error.h" |
18 #include "gm_expectations.h" | 18 #include "gm_expectations.h" |
19 #include "system_preferences.h" | 19 #include "system_preferences.h" |
| 20 #include "Resources.h" |
| 21 #include "SamplePipeControllers.h" |
20 #include "SkBitmap.h" | 22 #include "SkBitmap.h" |
21 #include "SkColorPriv.h" | 23 #include "SkColorPriv.h" |
22 #include "SkCommandLineFlags.h" | 24 #include "SkCommandLineFlags.h" |
23 #include "SkData.h" | 25 #include "SkData.h" |
24 #include "SkDeferredCanvas.h" | 26 #include "SkDeferredCanvas.h" |
25 #include "SkDevice.h" | 27 #include "SkDevice.h" |
26 #include "SkDocument.h" | 28 #include "SkDocument.h" |
27 #include "SkDrawFilter.h" | 29 #include "SkDrawFilter.h" |
28 #include "SkForceLinking.h" | 30 #include "SkForceLinking.h" |
29 #include "SkGPipe.h" | 31 #include "SkGPipe.h" |
30 #include "SkGraphics.h" | 32 #include "SkGraphics.h" |
31 #include "SkImageDecoder.h" | 33 #include "SkImageDecoder.h" |
32 #include "SkImageEncoder.h" | 34 #include "SkImageEncoder.h" |
33 #include "SkJSONCPP.h" | 35 #include "SkJSONCPP.h" |
34 #include "SkOSFile.h" | 36 #include "SkOSFile.h" |
35 #include "SkPDFRasterizer.h" | 37 #include "SkPDFRasterizer.h" |
36 #include "SkPicture.h" | 38 #include "SkPicture.h" |
37 #include "SkPictureRecorder.h" | 39 #include "SkPictureRecorder.h" |
38 #include "SkRefCnt.h" | 40 #include "SkRefCnt.h" |
39 #include "SkScalar.h" | 41 #include "SkScalar.h" |
40 #include "SkStream.h" | 42 #include "SkStream.h" |
41 #include "SkString.h" | 43 #include "SkString.h" |
42 #include "SkSurface.h" | 44 #include "SkSurface.h" |
43 #include "SkTArray.h" | 45 #include "SkTArray.h" |
44 #include "SkTDict.h" | 46 #include "SkTDict.h" |
45 #include "SamplePipeControllers.h" | |
46 | 47 |
47 #ifdef SK_DEBUG | 48 #ifdef SK_DEBUG |
48 static const bool kDebugOnly = true; | 49 static const bool kDebugOnly = true; |
49 #define GR_DUMP_FONT_CACHE 0 | 50 #define GR_DUMP_FONT_CACHE 0 |
50 #else | 51 #else |
51 static const bool kDebugOnly = false; | 52 static const bool kDebugOnly = false; |
52 #endif | 53 #endif |
53 | 54 |
54 __SK_FORCE_IMAGE_DECODER_LINKING; | 55 __SK_FORCE_IMAGE_DECODER_LINKING; |
55 | 56 |
(...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1456 DEFINE_string(modulo, "", "[--modulo <remainder> <divisor>]: only run tests for
which " | 1457 DEFINE_string(modulo, "", "[--modulo <remainder> <divisor>]: only run tests for
which " |
1457 "testIndex %% divisor == remainder."); | 1458 "testIndex %% divisor == remainder."); |
1458 DEFINE_bool(pipe, false, "Exercise the SkGPipe replay test pass."); | 1459 DEFINE_bool(pipe, false, "Exercise the SkGPipe replay test pass."); |
1459 DEFINE_bool(quadtree, false, "Exercise the QuadTree variant of SkPicture test pa
ss."); | 1460 DEFINE_bool(quadtree, false, "Exercise the QuadTree variant of SkPicture test pa
ss."); |
1460 DEFINE_string2(readPath, r, "", "Read reference images from this dir, and report
" | 1461 DEFINE_string2(readPath, r, "", "Read reference images from this dir, and report
" |
1461 "any differences between those and the newly generated ones."); | 1462 "any differences between those and the newly generated ones."); |
1462 DEFINE_bool(replay, false, "Exercise the SkPicture replay test pass."); | 1463 DEFINE_bool(replay, false, "Exercise the SkPicture replay test pass."); |
1463 #if SK_SUPPORT_GPU | 1464 #if SK_SUPPORT_GPU |
1464 DEFINE_bool(resetGpuContext, false, "Reset the GrContext prior to running each G
M."); | 1465 DEFINE_bool(resetGpuContext, false, "Reset the GrContext prior to running each G
M."); |
1465 #endif | 1466 #endif |
1466 DEFINE_string2(resourcePath, i, "resources", "Directory that stores image resour
ces."); | |
1467 DEFINE_bool(rtree, false, "Exercise the R-Tree variant of SkPicture test pass.")
; | 1467 DEFINE_bool(rtree, false, "Exercise the R-Tree variant of SkPicture test pass.")
; |
1468 DEFINE_bool(serialize, false, "Exercise the SkPicture serialization & deserializ
ation test pass."); | 1468 DEFINE_bool(serialize, false, "Exercise the SkPicture serialization & deserializ
ation test pass."); |
1469 DEFINE_bool(simulatePipePlaybackFailure, false, "Simulate a rendering failure in
pipe mode only."); | 1469 DEFINE_bool(simulatePipePlaybackFailure, false, "Simulate a rendering failure in
pipe mode only."); |
1470 DEFINE_bool(tiledPipe, false, "Exercise tiled SkGPipe replay."); | 1470 DEFINE_bool(tiledPipe, false, "Exercise tiled SkGPipe replay."); |
1471 DEFINE_bool(tileGrid, false, "Exercise the tile grid variant of SkPicture."); | 1471 DEFINE_bool(tileGrid, false, "Exercise the tile grid variant of SkPicture."); |
1472 DEFINE_string(tileGridReplayScales, "", "Space separated list of floating-point
scale " | 1472 DEFINE_string(tileGridReplayScales, "", "Space separated list of floating-point
scale " |
1473 "factors to be used for tileGrid playback testing. Default value:
1.0"); | 1473 "factors to be used for tileGrid playback testing. Default value:
1.0"); |
1474 DEFINE_bool2(verbose, v, false, "Give more detail (e.g. list all GMs run, more i
nfo about " | 1474 DEFINE_bool2(verbose, v, false, "Give more detail (e.g. list all GMs run, more i
nfo about " |
1475 "each test)."); | 1475 "each test)."); |
1476 DEFINE_bool(writeChecksumBasedFilenames, false, "When writing out actual images,
use checksum-" | 1476 DEFINE_bool(writeChecksumBasedFilenames, false, "When writing out actual images,
use checksum-" |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2205 if (FLAGS_verbose) { | 2205 if (FLAGS_verbose) { |
2206 SkDebugf("reading expectations from JSON summary file %s\n", rea
dPath); | 2206 SkDebugf("reading expectations from JSON summary file %s\n", rea
dPath); |
2207 } | 2207 } |
2208 gmmain->fExpectationsSource.reset(SkNEW_ARGS(JsonExpectationsSource,
(readPath))); | 2208 gmmain->fExpectationsSource.reset(SkNEW_ARGS(JsonExpectationsSource,
(readPath))); |
2209 #endif | 2209 #endif |
2210 } | 2210 } |
2211 } | 2211 } |
2212 return true; | 2212 return true; |
2213 } | 2213 } |
2214 | 2214 |
2215 static bool parse_flags_resource_path() { | |
2216 if (FLAGS_resourcePath.count() == 1) { | |
2217 GM::SetResourcePath(FLAGS_resourcePath[0]); | |
2218 } | |
2219 return true; | |
2220 } | |
2221 | |
2222 static bool parse_flags_jpeg_quality() { | 2215 static bool parse_flags_jpeg_quality() { |
2223 if (FLAGS_pdfJpegQuality < -1 || FLAGS_pdfJpegQuality > 100) { | 2216 if (FLAGS_pdfJpegQuality < -1 || FLAGS_pdfJpegQuality > 100) { |
2224 SkDebugf("%s\n", "pdfJpegQuality must be in [-1 .. 100] range."); | 2217 SkDebugf("%s\n", "pdfJpegQuality must be in [-1 .. 100] range."); |
2225 return false; | 2218 return false; |
2226 } | 2219 } |
2227 return true; | 2220 return true; |
2228 } | 2221 } |
2229 | 2222 |
2230 int tool_main(int argc, char** argv); | 2223 int tool_main(int argc, char** argv); |
2231 int tool_main(int argc, char** argv) { | 2224 int tool_main(int argc, char** argv) { |
2232 | |
2233 SkString usage; | 2225 SkString usage; |
2234 usage.printf("Run the golden master tests.\n"); | 2226 usage.printf("Run the golden master tests.\n"); |
2235 SkCommandLineFlags::SetUsage(usage.c_str()); | 2227 SkCommandLineFlags::SetUsage(usage.c_str()); |
2236 SkCommandLineFlags::Parse(argc, argv); | 2228 SkCommandLineFlags::Parse(argc, argv); |
2237 | 2229 |
2238 #if SK_ENABLE_INST_COUNT | 2230 #if SK_ENABLE_INST_COUNT |
2239 if (FLAGS_leaks) { | 2231 if (FLAGS_leaks) { |
2240 gPrintInstCount = true; | 2232 gPrintInstCount = true; |
2241 } | 2233 } |
2242 #endif | 2234 #endif |
(...skipping 19 matching lines...) Expand all Loading... |
2262 SkDebugf( "Doing a dry run; no tests will actually be executed.\n"); | 2254 SkDebugf( "Doing a dry run; no tests will actually be executed.\n"); |
2263 } | 2255 } |
2264 | 2256 |
2265 if (!parse_flags_modulo(&moduloRemainder, &moduloDivisor) || | 2257 if (!parse_flags_modulo(&moduloRemainder, &moduloDivisor) || |
2266 !parse_flags_ignore_error_types(&gmmain.fIgnorableErrorTypes) || | 2258 !parse_flags_ignore_error_types(&gmmain.fIgnorableErrorTypes) || |
2267 !parse_flags_ignore_tests(gmmain.fIgnorableTestNames) || | 2259 !parse_flags_ignore_tests(gmmain.fIgnorableTestNames) || |
2268 #if SK_SUPPORT_GPU | 2260 #if SK_SUPPORT_GPU |
2269 !parse_flags_gpu_cache(&gGpuCacheSizeBytes, &gGpuCacheSizeCount) || | 2261 !parse_flags_gpu_cache(&gGpuCacheSizeBytes, &gGpuCacheSizeCount) || |
2270 #endif | 2262 #endif |
2271 !parse_flags_tile_grid_replay_scales(&tileGridReplayScales) || | 2263 !parse_flags_tile_grid_replay_scales(&tileGridReplayScales) || |
2272 !parse_flags_resource_path() || | |
2273 !parse_flags_jpeg_quality() || | 2264 !parse_flags_jpeg_quality() || |
2274 !parse_flags_configs(&configs, grFactory) || | 2265 !parse_flags_configs(&configs, grFactory) || |
2275 !parse_flags_pdf_rasterizers(configs, &pdfRasterizers) || | 2266 !parse_flags_pdf_rasterizers(configs, &pdfRasterizers) || |
2276 !parse_flags_gmmain_paths(&gmmain)) { | 2267 !parse_flags_gmmain_paths(&gmmain)) { |
2277 return -1; | 2268 return -1; |
2278 } | 2269 } |
2279 | 2270 |
2280 if (FLAGS_verbose) { | 2271 if (FLAGS_verbose) { |
2281 if (FLAGS_writePath.count() == 1) { | 2272 if (FLAGS_writePath.count() == 1) { |
2282 SkDebugf("writing to %s\n", FLAGS_writePath[0]); | 2273 SkDebugf("writing to %s\n", FLAGS_writePath[0]); |
2283 } | 2274 } |
2284 if (NULL != gmmain.fMismatchPath) { | 2275 if (NULL != gmmain.fMismatchPath) { |
2285 SkDebugf("writing mismatches to %s\n", gmmain.fMismatchPath); | 2276 SkDebugf("writing mismatches to %s\n", gmmain.fMismatchPath); |
2286 } | 2277 } |
2287 if (NULL != gmmain.fMissingExpectationsPath) { | 2278 if (NULL != gmmain.fMissingExpectationsPath) { |
2288 SkDebugf("writing images without expectations to %s\n", | 2279 SkDebugf("writing images without expectations to %s\n", |
2289 gmmain.fMissingExpectationsPath); | 2280 gmmain.fMissingExpectationsPath); |
2290 } | 2281 } |
2291 if (FLAGS_writePicturePath.count() == 1) { | 2282 if (FLAGS_writePicturePath.count() == 1) { |
2292 SkDebugf("writing pictures to %s\n", FLAGS_writePicturePath[0]); | 2283 SkDebugf("writing pictures to %s\n", FLAGS_writePicturePath[0]); |
2293 } | 2284 } |
2294 if (FLAGS_resourcePath.count() == 1) { | 2285 if (!GetResourcePath().isEmpty()) { |
2295 SkDebugf("reading resources from %s\n", FLAGS_resourcePath[0]); | 2286 SkDebugf("reading resources from %s\n", GetResourcePath().c_str()); |
2296 } | 2287 } |
2297 } | 2288 } |
2298 | 2289 |
2299 int gmsRun = 0; | 2290 int gmsRun = 0; |
2300 int gmIndex = -1; | 2291 int gmIndex = -1; |
2301 SkString moduloStr; | 2292 SkString moduloStr; |
2302 | 2293 |
2303 if (!FLAGS_dryRun) { | 2294 if (!FLAGS_dryRun) { |
2304 // If we will be writing out files, prepare subdirectories. | 2295 // If we will be writing out files, prepare subdirectories. |
2305 if (FLAGS_writePath.count() == 1) { | 2296 if (FLAGS_writePath.count() == 1) { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2463 if (FLAGS_forceBWtext) { | 2454 if (FLAGS_forceBWtext) { |
2464 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 2455 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
2465 } | 2456 } |
2466 } | 2457 } |
2467 | 2458 |
2468 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 2459 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
2469 int main(int argc, char * const argv[]) { | 2460 int main(int argc, char * const argv[]) { |
2470 return tool_main(argc, (char**) argv); | 2461 return tool_main(argc, (char**) argv); |
2471 } | 2462 } |
2472 #endif | 2463 #endif |
OLD | NEW |