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