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

Side by Side Diff: gm/gmmain.cpp

Issue 346453002: Refactor how we handle resources path in Tests. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix rebase conflict Created 6 years, 6 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
« no previous file with comments | « gm/gm.cpp ('k') | gyp/SampleApp.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 *
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 "CrashHandler.h" 20 #include "CrashHandler.h"
21 #include "Resources.h"
22 #include "SamplePipeControllers.h"
21 #include "SkBitmap.h" 23 #include "SkBitmap.h"
22 #include "SkColorPriv.h" 24 #include "SkColorPriv.h"
23 #include "SkCommandLineFlags.h" 25 #include "SkCommandLineFlags.h"
24 #include "SkData.h" 26 #include "SkData.h"
25 #include "SkDeferredCanvas.h" 27 #include "SkDeferredCanvas.h"
26 #include "SkDevice.h" 28 #include "SkDevice.h"
27 #include "SkDocument.h" 29 #include "SkDocument.h"
28 #include "SkDrawFilter.h" 30 #include "SkDrawFilter.h"
29 #include "SkForceLinking.h" 31 #include "SkForceLinking.h"
30 #include "SkGPipe.h" 32 #include "SkGPipe.h"
31 #include "SkGraphics.h" 33 #include "SkGraphics.h"
32 #include "SkImageDecoder.h" 34 #include "SkImageDecoder.h"
33 #include "SkImageEncoder.h" 35 #include "SkImageEncoder.h"
34 #include "SkJSONCPP.h" 36 #include "SkJSONCPP.h"
35 #include "SkOSFile.h" 37 #include "SkOSFile.h"
36 #include "SkPDFRasterizer.h" 38 #include "SkPDFRasterizer.h"
37 #include "SkPicture.h" 39 #include "SkPicture.h"
38 #include "SkPictureRecorder.h" 40 #include "SkPictureRecorder.h"
39 #include "SkRefCnt.h" 41 #include "SkRefCnt.h"
40 #include "SkScalar.h" 42 #include "SkScalar.h"
41 #include "SkStream.h" 43 #include "SkStream.h"
42 #include "SkString.h" 44 #include "SkString.h"
43 #include "SkSurface.h" 45 #include "SkSurface.h"
44 #include "SkTArray.h" 46 #include "SkTArray.h"
45 #include "SkTDict.h" 47 #include "SkTDict.h"
46 #include "SamplePipeControllers.h"
47 48
48 #ifdef SK_DEBUG 49 #ifdef SK_DEBUG
49 static const bool kDebugOnly = true; 50 static const bool kDebugOnly = true;
50 #define GR_DUMP_FONT_CACHE 0 51 #define GR_DUMP_FONT_CACHE 0
51 #else 52 #else
52 static const bool kDebugOnly = false; 53 static const bool kDebugOnly = false;
53 #endif 54 #endif
54 55
55 __SK_FORCE_IMAGE_DECODER_LINKING; 56 __SK_FORCE_IMAGE_DECODER_LINKING;
56 57
(...skipping 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 DEFINE_string(modulo, "", "[--modulo <remainder> <divisor>]: only run tests for which " 1452 DEFINE_string(modulo, "", "[--modulo <remainder> <divisor>]: only run tests for which "
1452 "testIndex %% divisor == remainder."); 1453 "testIndex %% divisor == remainder.");
1453 DEFINE_bool(pipe, false, "Exercise the SkGPipe replay test pass."); 1454 DEFINE_bool(pipe, false, "Exercise the SkGPipe replay test pass.");
1454 DEFINE_bool(quadtree, false, "Exercise the QuadTree variant of SkPicture test pa ss."); 1455 DEFINE_bool(quadtree, false, "Exercise the QuadTree variant of SkPicture test pa ss.");
1455 DEFINE_string2(readPath, r, "", "Read reference images from this dir, and report " 1456 DEFINE_string2(readPath, r, "", "Read reference images from this dir, and report "
1456 "any differences between those and the newly generated ones."); 1457 "any differences between those and the newly generated ones.");
1457 DEFINE_bool(replay, false, "Exercise the SkPicture replay test pass."); 1458 DEFINE_bool(replay, false, "Exercise the SkPicture replay test pass.");
1458 #if SK_SUPPORT_GPU 1459 #if SK_SUPPORT_GPU
1459 DEFINE_bool(resetGpuContext, false, "Reset the GrContext prior to running each G M."); 1460 DEFINE_bool(resetGpuContext, false, "Reset the GrContext prior to running each G M.");
1460 #endif 1461 #endif
1461 DEFINE_string2(resourcePath, i, "resources", "Directory that stores image resour ces.");
1462 DEFINE_bool(rtree, false, "Exercise the R-Tree variant of SkPicture test pass.") ; 1462 DEFINE_bool(rtree, false, "Exercise the R-Tree variant of SkPicture test pass.") ;
1463 DEFINE_bool(serialize, false, "Exercise the SkPicture serialization & deserializ ation test pass."); 1463 DEFINE_bool(serialize, false, "Exercise the SkPicture serialization & deserializ ation test pass.");
1464 DEFINE_bool(simulatePipePlaybackFailure, false, "Simulate a rendering failure in pipe mode only."); 1464 DEFINE_bool(simulatePipePlaybackFailure, false, "Simulate a rendering failure in pipe mode only.");
1465 DEFINE_bool(tiledPipe, false, "Exercise tiled SkGPipe replay."); 1465 DEFINE_bool(tiledPipe, false, "Exercise tiled SkGPipe replay.");
1466 DEFINE_bool(tileGrid, false, "Exercise the tile grid variant of SkPicture."); 1466 DEFINE_bool(tileGrid, false, "Exercise the tile grid variant of SkPicture.");
1467 DEFINE_string(tileGridReplayScales, "", "Space separated list of floating-point scale " 1467 DEFINE_string(tileGridReplayScales, "", "Space separated list of floating-point scale "
1468 "factors to be used for tileGrid playback testing. Default value: 1.0"); 1468 "factors to be used for tileGrid playback testing. Default value: 1.0");
1469 DEFINE_bool2(verbose, v, false, "Give more detail (e.g. list all GMs run, more i nfo about " 1469 DEFINE_bool2(verbose, v, false, "Give more detail (e.g. list all GMs run, more i nfo about "
1470 "each test)."); 1470 "each test).");
1471 DEFINE_bool(writeChecksumBasedFilenames, false, "When writing out actual images, use checksum-" 1471 DEFINE_bool(writeChecksumBasedFilenames, false, "When writing out actual images, use checksum-"
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
2196 } else { 2196 } else {
2197 if (FLAGS_verbose) { 2197 if (FLAGS_verbose) {
2198 SkDebugf("reading expectations from JSON summary file %s\n", rea dPath); 2198 SkDebugf("reading expectations from JSON summary file %s\n", rea dPath);
2199 } 2199 }
2200 gmmain->fExpectationsSource.reset(SkNEW_ARGS(JsonExpectationsSource, (readPath))); 2200 gmmain->fExpectationsSource.reset(SkNEW_ARGS(JsonExpectationsSource, (readPath)));
2201 } 2201 }
2202 } 2202 }
2203 return true; 2203 return true;
2204 } 2204 }
2205 2205
2206 static bool parse_flags_resource_path() {
2207 if (FLAGS_resourcePath.count() == 1) {
2208 GM::SetResourcePath(FLAGS_resourcePath[0]);
2209 }
2210 return true;
2211 }
2212
2213 static bool parse_flags_jpeg_quality() { 2206 static bool parse_flags_jpeg_quality() {
2214 if (FLAGS_pdfJpegQuality < -1 || FLAGS_pdfJpegQuality > 100) { 2207 if (FLAGS_pdfJpegQuality < -1 || FLAGS_pdfJpegQuality > 100) {
2215 SkDebugf("%s\n", "pdfJpegQuality must be in [-1 .. 100] range."); 2208 SkDebugf("%s\n", "pdfJpegQuality must be in [-1 .. 100] range.");
2216 return false; 2209 return false;
2217 } 2210 }
2218 return true; 2211 return true;
2219 } 2212 }
2220 2213
2221 int tool_main(int argc, char** argv); 2214 int tool_main(int argc, char** argv);
2222 int tool_main(int argc, char** argv) { 2215 int tool_main(int argc, char** argv) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2254 SkDebugf( "Doing a dry run; no tests will actually be executed.\n"); 2247 SkDebugf( "Doing a dry run; no tests will actually be executed.\n");
2255 } 2248 }
2256 2249
2257 if (!parse_flags_modulo(&moduloRemainder, &moduloDivisor) || 2250 if (!parse_flags_modulo(&moduloRemainder, &moduloDivisor) ||
2258 !parse_flags_ignore_error_types(&gmmain.fIgnorableErrorTypes) || 2251 !parse_flags_ignore_error_types(&gmmain.fIgnorableErrorTypes) ||
2259 !parse_flags_ignore_tests(gmmain.fIgnorableTestNames) || 2252 !parse_flags_ignore_tests(gmmain.fIgnorableTestNames) ||
2260 #if SK_SUPPORT_GPU 2253 #if SK_SUPPORT_GPU
2261 !parse_flags_gpu_cache(&gGpuCacheSizeBytes, &gGpuCacheSizeCount) || 2254 !parse_flags_gpu_cache(&gGpuCacheSizeBytes, &gGpuCacheSizeCount) ||
2262 #endif 2255 #endif
2263 !parse_flags_tile_grid_replay_scales(&tileGridReplayScales) || 2256 !parse_flags_tile_grid_replay_scales(&tileGridReplayScales) ||
2264 !parse_flags_resource_path() ||
2265 !parse_flags_jpeg_quality() || 2257 !parse_flags_jpeg_quality() ||
2266 !parse_flags_configs(&configs, grFactory) || 2258 !parse_flags_configs(&configs, grFactory) ||
2267 !parse_flags_pdf_rasterizers(configs, &pdfRasterizers) || 2259 !parse_flags_pdf_rasterizers(configs, &pdfRasterizers) ||
2268 !parse_flags_gmmain_paths(&gmmain)) { 2260 !parse_flags_gmmain_paths(&gmmain)) {
2269 return -1; 2261 return -1;
2270 } 2262 }
2271 2263
2272 if (FLAGS_verbose) { 2264 if (FLAGS_verbose) {
2273 if (FLAGS_writePath.count() == 1) { 2265 if (FLAGS_writePath.count() == 1) {
2274 SkDebugf("writing to %s\n", FLAGS_writePath[0]); 2266 SkDebugf("writing to %s\n", FLAGS_writePath[0]);
2275 } 2267 }
2276 if (NULL != gmmain.fMismatchPath) { 2268 if (NULL != gmmain.fMismatchPath) {
2277 SkDebugf("writing mismatches to %s\n", gmmain.fMismatchPath); 2269 SkDebugf("writing mismatches to %s\n", gmmain.fMismatchPath);
2278 } 2270 }
2279 if (NULL != gmmain.fMissingExpectationsPath) { 2271 if (NULL != gmmain.fMissingExpectationsPath) {
2280 SkDebugf("writing images without expectations to %s\n", 2272 SkDebugf("writing images without expectations to %s\n",
2281 gmmain.fMissingExpectationsPath); 2273 gmmain.fMissingExpectationsPath);
2282 } 2274 }
2283 if (FLAGS_writePicturePath.count() == 1) { 2275 if (FLAGS_writePicturePath.count() == 1) {
2284 SkDebugf("writing pictures to %s\n", FLAGS_writePicturePath[0]); 2276 SkDebugf("writing pictures to %s\n", FLAGS_writePicturePath[0]);
2285 } 2277 }
2286 if (FLAGS_resourcePath.count() == 1) { 2278 if (!GetResourcePath().isEmpty()) {
2287 SkDebugf("reading resources from %s\n", FLAGS_resourcePath[0]); 2279 SkDebugf("reading resources from %s\n", GetResourcePath().c_str());
2288 } 2280 }
2289 } 2281 }
2290 2282
2291 int gmsRun = 0; 2283 int gmsRun = 0;
2292 int gmIndex = -1; 2284 int gmIndex = -1;
2293 SkString moduloStr; 2285 SkString moduloStr;
2294 2286
2295 if (!FLAGS_dryRun) { 2287 if (!FLAGS_dryRun) {
2296 // If we will be writing out files, prepare subdirectories. 2288 // If we will be writing out files, prepare subdirectories.
2297 if (FLAGS_writePath.count() == 1) { 2289 if (FLAGS_writePath.count() == 1) {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
2453 if (FLAGS_forceBWtext) { 2445 if (FLAGS_forceBWtext) {
2454 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); 2446 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref();
2455 } 2447 }
2456 } 2448 }
2457 2449
2458 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 2450 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
2459 int main(int argc, char * const argv[]) { 2451 int main(int argc, char * const argv[]) {
2460 return tool_main(argc, (char**) argv); 2452 return tool_main(argc, (char**) argv);
2461 } 2453 }
2462 #endif 2454 #endif
OLDNEW
« no previous file with comments | « gm/gm.cpp ('k') | gyp/SampleApp.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698