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 "LazyDecodeBitmap.h" | 8 #include "LazyDecodeBitmap.h" |
9 #include "CopyTilesRenderer.h" | 9 #include "CopyTilesRenderer.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "PictureRenderer.h" | 22 #include "PictureRenderer.h" |
23 #include "PictureRenderingFlags.h" | 23 #include "PictureRenderingFlags.h" |
24 #include "picture_utils.h" | 24 #include "picture_utils.h" |
25 | 25 |
26 // Flags used by this file, alphabetically: | 26 // Flags used by this file, alphabetically: |
27 DEFINE_int32(clone, 0, "Clone the picture n times before rendering."); | 27 DEFINE_int32(clone, 0, "Clone the picture n times before rendering."); |
28 DECLARE_bool(deferImageDecoding); | 28 DECLARE_bool(deferImageDecoding); |
29 DEFINE_int32(maxComponentDiff, 256, "Maximum diff on a component, 0 - 256. Compo
nents that differ " | 29 DEFINE_int32(maxComponentDiff, 256, "Maximum diff on a component, 0 - 256. Compo
nents that differ " |
30 "by more than this amount are considered errors, though all diffs a
re reported. " | 30 "by more than this amount are considered errors, though all diffs a
re reported. " |
31 "Requires --validate."); | 31 "Requires --validate."); |
| 32 DEFINE_string(readJsonSummaryPath, "", "JSON file to read image expectations fro
m."); |
32 DECLARE_string(readPath); | 33 DECLARE_string(readPath); |
33 DEFINE_bool(writeChecksumBasedFilenames, false, | 34 DEFINE_bool(writeChecksumBasedFilenames, false, |
34 "When writing out images, use checksum-based filenames."); | 35 "When writing out images, use checksum-based filenames."); |
35 DEFINE_bool(writeEncodedImages, false, "Any time the skp contains an encoded ima
ge, write it to a " | 36 DEFINE_bool(writeEncodedImages, false, "Any time the skp contains an encoded ima
ge, write it to a " |
36 "file rather than decoding it. Requires writePath to be set. Skips d
rawing the full " | 37 "file rather than decoding it. Requires writePath to be set. Skips d
rawing the full " |
37 "skp to a file. Not compatible with deferImageDecoding."); | 38 "skp to a file. Not compatible with deferImageDecoding."); |
38 DEFINE_string(writeJsonSummaryPath, "", "File to write a JSON summary of image r
esults to."); | 39 DEFINE_string(writeJsonSummaryPath, "", "File to write a JSON summary of image r
esults to."); |
39 DEFINE_string2(writePath, w, "", "Directory to write the rendered images into.")
; | 40 DEFINE_string2(writePath, w, "", "Directory to write the rendered images into.")
; |
40 DEFINE_bool(writeWholeImage, false, "In tile mode, write the entire rendered ima
ge to a " | 41 DEFINE_bool(writeWholeImage, false, "In tile mode, write the entire rendered ima
ge to a " |
41 "file, instead of an image for each tile."); | 42 "file, instead of an image for each tile."); |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 if (FLAGS_writeWholeImage) { | 340 if (FLAGS_writeWholeImage) { |
340 sk_tools::force_all_opaque(*bitmap); | 341 sk_tools::force_all_opaque(*bitmap); |
341 | 342 |
342 SkString inputFilename, outputPath; | 343 SkString inputFilename, outputPath; |
343 sk_tools::get_basename(&inputFilename, inputPath); | 344 sk_tools::get_basename(&inputFilename, inputPath); |
344 sk_tools::make_filepath(&outputPath, *outputDir, inputFilename); | 345 sk_tools::make_filepath(&outputPath, *outputDir, inputFilename); |
345 sk_tools::replace_char(&outputPath, '.', '_'); | 346 sk_tools::replace_char(&outputPath, '.', '_'); |
346 outputPath.append(".png"); | 347 outputPath.append(".png"); |
347 | 348 |
348 if (NULL != jsonSummaryPtr) { | 349 if (NULL != jsonSummaryPtr) { |
| 350 sk_tools::ImageDigest imageDigest(*bitmap); |
349 SkString outputFileBasename; | 351 SkString outputFileBasename; |
350 sk_tools::get_basename(&outputFileBasename, outputPath); | 352 sk_tools::get_basename(&outputFileBasename, outputPath); |
351 jsonSummaryPtr->add(inputFilename.c_str(), outputFileBasename.c_str(
), *bitmap); | 353 jsonSummaryPtr->add(inputFilename.c_str(), outputFileBasename.c_str(
), imageDigest); |
352 } | 354 } |
353 | 355 |
354 if (NULL != outputDir) { | 356 if (NULL != outputDir) { |
355 if (!SkImageEncoder::EncodeFile(outputPath.c_str(), *bitmap, | 357 if (!SkImageEncoder::EncodeFile(outputPath.c_str(), *bitmap, |
356 SkImageEncoder::kPNG_Type, 100)) { | 358 SkImageEncoder::kPNG_Type, 100)) { |
357 SkDebugf("Failed to draw the picture.\n"); | 359 SkDebugf("Failed to draw the picture.\n"); |
358 success = false; | 360 success = false; |
359 } | 361 } |
360 } | 362 } |
361 } | 363 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 SkAutoGraphics ag; | 446 SkAutoGraphics ag; |
445 | 447 |
446 SkString outputDir; | 448 SkString outputDir; |
447 if (FLAGS_writePath.count() == 1) { | 449 if (FLAGS_writePath.count() == 1) { |
448 outputDir.set(FLAGS_writePath[0]); | 450 outputDir.set(FLAGS_writePath[0]); |
449 } | 451 } |
450 sk_tools::ImageResultsSummary jsonSummary; | 452 sk_tools::ImageResultsSummary jsonSummary; |
451 sk_tools::ImageResultsSummary* jsonSummaryPtr = NULL; | 453 sk_tools::ImageResultsSummary* jsonSummaryPtr = NULL; |
452 if (FLAGS_writeJsonSummaryPath.count() == 1) { | 454 if (FLAGS_writeJsonSummaryPath.count() == 1) { |
453 jsonSummaryPtr = &jsonSummary; | 455 jsonSummaryPtr = &jsonSummary; |
| 456 if (FLAGS_readJsonSummaryPath.count() == 1) { |
| 457 SkASSERT(jsonSummary.readExpectationsFile(FLAGS_readJsonSummaryPath[
0])); |
| 458 } |
454 } | 459 } |
455 | 460 |
456 int failures = 0; | 461 int failures = 0; |
457 for (int i = 0; i < FLAGS_readPath.count(); i ++) { | 462 for (int i = 0; i < FLAGS_readPath.count(); i ++) { |
458 failures += process_input(FLAGS_readPath[i], &outputDir, *renderer.get()
, jsonSummaryPtr); | 463 failures += process_input(FLAGS_readPath[i], &outputDir, *renderer.get()
, jsonSummaryPtr); |
459 } | 464 } |
460 if (failures != 0) { | 465 if (failures != 0) { |
461 SkDebugf("Failed to render %i pictures.\n", failures); | 466 SkDebugf("Failed to render %i pictures.\n", failures); |
462 return 1; | 467 return 1; |
463 } | 468 } |
(...skipping 12 matching lines...) Expand all Loading... |
476 jsonSummary.writeToFile(FLAGS_writeJsonSummaryPath[0]); | 481 jsonSummary.writeToFile(FLAGS_writeJsonSummaryPath[0]); |
477 } | 482 } |
478 return 0; | 483 return 0; |
479 } | 484 } |
480 | 485 |
481 #if !defined SK_BUILD_FOR_IOS | 486 #if !defined SK_BUILD_FOR_IOS |
482 int main(int argc, char * const argv[]) { | 487 int main(int argc, char * const argv[]) { |
483 return tool_main(argc, (char**) argv); | 488 return tool_main(argc, (char**) argv); |
484 } | 489 } |
485 #endif | 490 #endif |
OLD | NEW |