OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #include "CopyTilesRenderer.h" | 8 #include "CopyTilesRenderer.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkDevice.h" | 10 #include "SkDevice.h" |
11 #include "SkCommandLineFlags.h" | 11 #include "SkCommandLineFlags.h" |
12 #include "SkGraphics.h" | 12 #include "SkGraphics.h" |
13 #include "SkImageDecoder.h" | 13 #include "SkImageDecoder.h" |
14 #include "SkImageEncoder.h" | 14 #include "SkImageEncoder.h" |
15 #include "SkMath.h" | 15 #include "SkMath.h" |
16 #include "SkOSFile.h" | 16 #include "SkOSFile.h" |
17 #include "SkPicture.h" | 17 #include "SkPicture.h" |
18 #include "SkStream.h" | 18 #include "SkStream.h" |
19 #include "SkString.h" | 19 #include "SkString.h" |
20 #include "PictureRenderer.h" | 20 #include "PictureRenderer.h" |
21 #include "PictureRenderingFlags.h" | 21 #include "PictureRenderingFlags.h" |
22 #include "picture_utils.h" | 22 #include "picture_utils.h" |
23 | 23 |
24 // Flags used by this file, alphabetically: | 24 // Flags used by this file, alphabetically: |
25 DEFINE_int32(clone, 0, "Clone the picture n times before rendering."); | 25 DEFINE_int32(clone, 0, "Clone the picture n times before rendering."); |
26 DECLARE_bool(deferImageDecoding); | 26 DECLARE_bool(deferImageDecoding); |
27 DEFINE_int32(maxComponentDiff, 256, "Maximum diff on a component, 0 - 256. Compo
nents that differ " | 27 DEFINE_int32(maxComponentDiff, 256, "Maximum diff on a component, 0 - 256. Compo
nents that differ " |
28 "by more than this amount are considered errors, though all diffs a
re reported. " | 28 "by more than this amount are considered errors, though all diffs a
re reported. " |
29 "Requires --validate."); | 29 "Requires --validate."); |
30 DECLARE_string(r); | 30 DECLARE_string(readPath); |
31 DEFINE_string(w, "", "Directory to write the rendered images."); | 31 DEFINE_string2(writePath, w, "", "Directory to write the rendered images."); |
32 DEFINE_bool(writeWholeImage, false, "In tile mode, write the entire rendered ima
ge to a " | 32 DEFINE_bool(writeWholeImage, false, "In tile mode, write the entire rendered ima
ge to a " |
33 "file, instead of an image for each tile."); | 33 "file, instead of an image for each tile."); |
34 DEFINE_bool(validate, false, "Verify that the rendered image contains the same p
ixels as " | 34 DEFINE_bool(validate, false, "Verify that the rendered image contains the same p
ixels as " |
35 "the picture rendered in simple mode. When used in conjunction with
--bbh, results " | 35 "the picture rendered in simple mode. When used in conjunction with
--bbh, results " |
36 "are validated against the picture rendered in the same mode, but wi
thout the bbh."); | 36 "are validated against the picture rendered in the same mode, but wi
thout the bbh."); |
37 | 37 |
38 static void make_output_filepath(SkString* path, const SkString& dir, | 38 static void make_output_filepath(SkString* path, const SkString& dir, |
39 const SkString& name) { | 39 const SkString& name) { |
40 sk_tools::make_filepath(path, dir, name); | 40 sk_tools::make_filepath(path, dir, name); |
41 // Remove ".skp" | 41 // Remove ".skp" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 SkDebugf(warning.c_str()); | 270 SkDebugf(warning.c_str()); |
271 } | 271 } |
272 return failures; | 272 return failures; |
273 } | 273 } |
274 | 274 |
275 int tool_main(int argc, char** argv); | 275 int tool_main(int argc, char** argv); |
276 int tool_main(int argc, char** argv) { | 276 int tool_main(int argc, char** argv) { |
277 SkCommandLineFlags::SetUsage("Render .skp files."); | 277 SkCommandLineFlags::SetUsage("Render .skp files."); |
278 SkCommandLineFlags::Parse(argc, argv); | 278 SkCommandLineFlags::Parse(argc, argv); |
279 | 279 |
280 if (FLAGS_r.isEmpty()) { | 280 if (FLAGS_readPath.isEmpty()) { |
281 SkDebugf(".skp files or directories are required.\n"); | 281 SkDebugf(".skp files or directories are required.\n"); |
282 exit(-1); | 282 exit(-1); |
283 } | 283 } |
284 | 284 |
285 if (FLAGS_maxComponentDiff < 0 || FLAGS_maxComponentDiff > 256) { | 285 if (FLAGS_maxComponentDiff < 0 || FLAGS_maxComponentDiff > 256) { |
286 SkDebugf("--maxComponentDiff must be between 0 and 256\n"); | 286 SkDebugf("--maxComponentDiff must be between 0 and 256\n"); |
287 exit(-1); | 287 exit(-1); |
288 } | 288 } |
289 | 289 |
290 if (FLAGS_maxComponentDiff != 256 && !FLAGS_validate) { | 290 if (FLAGS_maxComponentDiff != 256 && !FLAGS_validate) { |
(...skipping 13 matching lines...) Expand all Loading... |
304 SkDebugf("%s\n", errorString.c_str()); | 304 SkDebugf("%s\n", errorString.c_str()); |
305 } | 305 } |
306 | 306 |
307 if (renderer.get() == NULL) { | 307 if (renderer.get() == NULL) { |
308 exit(-1); | 308 exit(-1); |
309 } | 309 } |
310 | 310 |
311 SkAutoGraphics ag; | 311 SkAutoGraphics ag; |
312 | 312 |
313 SkString outputDir; | 313 SkString outputDir; |
314 if (FLAGS_w.count() == 1) { | 314 if (FLAGS_writePath.count() == 1) { |
315 outputDir.set(FLAGS_w[0]); | 315 outputDir.set(FLAGS_writePath[0]); |
316 } | 316 } |
317 | 317 |
318 int failures = 0; | 318 int failures = 0; |
319 for (int i = 0; i < FLAGS_r.count(); i ++) { | 319 for (int i = 0; i < FLAGS_readPath.count(); i ++) { |
320 failures += process_input(FLAGS_r[i], &outputDir, *renderer.get()); | 320 failures += process_input(FLAGS_readPath[i], &outputDir, *renderer.get()
); |
321 } | 321 } |
322 if (failures != 0) { | 322 if (failures != 0) { |
323 SkDebugf("Failed to render %i pictures.\n", failures); | 323 SkDebugf("Failed to render %i pictures.\n", failures); |
324 return 1; | 324 return 1; |
325 } | 325 } |
326 #if SK_SUPPORT_GPU | 326 #if SK_SUPPORT_GPU |
327 #if GR_CACHE_STATS | 327 #if GR_CACHE_STATS |
328 if (renderer->isUsingGpuDevice()) { | 328 if (renderer->isUsingGpuDevice()) { |
329 GrContext* ctx = renderer->getGrContext(); | 329 GrContext* ctx = renderer->getGrContext(); |
330 | 330 |
331 ctx->printCacheStats(); | 331 ctx->printCacheStats(); |
332 } | 332 } |
333 #endif | 333 #endif |
334 #endif | 334 #endif |
335 return 0; | 335 return 0; |
336 } | 336 } |
337 | 337 |
338 #if !defined SK_BUILD_FOR_IOS | 338 #if !defined SK_BUILD_FOR_IOS |
339 int main(int argc, char * const argv[]) { | 339 int main(int argc, char * const argv[]) { |
340 return tool_main(argc, (char**) argv); | 340 return tool_main(argc, (char**) argv); |
341 } | 341 } |
342 #endif | 342 #endif |
OLD | NEW |