| 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 "CopyTilesRenderer.h" | 9 #include "CopyTilesRenderer.h" |
| 9 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
| 10 #include "SkDevice.h" | 11 #include "SkDevice.h" |
| 11 #include "SkCommandLineFlags.h" | 12 #include "SkCommandLineFlags.h" |
| 12 #include "SkForceLinking.h" | |
| 13 #include "SkGraphics.h" | 13 #include "SkGraphics.h" |
| 14 #include "SkImageDecoder.h" | 14 #include "SkImageDecoder.h" |
| 15 #include "SkImageEncoder.h" | 15 #include "SkImageEncoder.h" |
| 16 #include "SkMath.h" | 16 #include "SkMath.h" |
| 17 #include "SkOSFile.h" | 17 #include "SkOSFile.h" |
| 18 #include "SkPicture.h" | 18 #include "SkPicture.h" |
| 19 #include "SkStream.h" | 19 #include "SkStream.h" |
| 20 #include "SkString.h" | 20 #include "SkString.h" |
| 21 #include "PictureRenderer.h" | 21 #include "PictureRenderer.h" |
| 22 #include "PictureRenderingFlags.h" | 22 #include "PictureRenderingFlags.h" |
| 23 #include "picture_utils.h" | 23 #include "picture_utils.h" |
| 24 | 24 |
| 25 // Required to ensure that image decoders get linked correctly. | |
| 26 __SK_FORCE_IMAGE_DECODER_LINKING; | |
| 27 | |
| 28 // Flags used by this file, alphabetically: | 25 // Flags used by this file, alphabetically: |
| 29 DEFINE_int32(clone, 0, "Clone the picture n times before rendering."); | 26 DEFINE_int32(clone, 0, "Clone the picture n times before rendering."); |
| 30 DECLARE_bool(deferImageDecoding); | 27 DECLARE_bool(deferImageDecoding); |
| 31 DEFINE_int32(maxComponentDiff, 256, "Maximum diff on a component, 0 - 256. Compo
nents that differ " | 28 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. " | 29 "by more than this amount are considered errors, though all diffs a
re reported. " |
| 33 "Requires --validate."); | 30 "Requires --validate."); |
| 34 DECLARE_string(readPath); | 31 DECLARE_string(readPath); |
| 35 DEFINE_bool(writeEncodedImages, false, "Any time the skp contains an encoded ima
ge, write it to a " | 32 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 " | 33 "file rather than decoding it. Requires writePath to be set. Skips d
rawing the full " |
| 37 "skp to a file. Not compatible with deferImageDecoding."); | 34 "skp to a file. Not compatible with deferImageDecoding."); |
| 38 DEFINE_string2(writePath, w, "", "Directory to write the rendered images."); | 35 DEFINE_string2(writePath, w, "", "Directory to write the rendered images."); |
| 39 DEFINE_bool(writeWholeImage, false, "In tile mode, write the entire rendered ima
ge to a " | 36 DEFINE_bool(writeWholeImage, false, "In tile mode, write the entire rendered ima
ge to a " |
| 40 "file, instead of an image for each tile."); | 37 "file, instead of an image for each tile."); |
| 41 DEFINE_bool(validate, false, "Verify that the rendered image contains the same p
ixels as " | 38 DEFINE_bool(validate, false, "Verify that the rendered image contains the same p
ixels as " |
| 42 "the picture rendered in simple mode. When used in conjunction with
--bbh, results " | 39 "the picture rendered in simple mode. When used in conjunction with
--bbh, results " |
| 43 "are validated against the picture rendered in the same mode, but wi
thout the bbh."); | 40 "are validated against the picture rendered in the same mode, but wi
thout the bbh."); |
| 44 | 41 |
| 45 static void make_output_filepath(SkString* path, const SkString& dir, | 42 static void make_output_filepath(SkString* path, const SkString& dir, |
| 46 const SkString& name) { | 43 const SkString& name) { |
| 47 sk_tools::make_filepath(path, dir, name); | 44 sk_tools::make_filepath(path, dir, name); |
| 48 // Remove ".skp" | 45 // Remove ".skp" |
| 49 path->remove(path->size() - 4, 4); | 46 path->remove(path->size() - 4, 4); |
| 50 } | 47 } |
| 51 | 48 |
| 52 // Defined in PictureRenderingFlags.cpp | |
| 53 extern bool lazy_decode_bitmap(const void* buffer, size_t size, SkBitmap* bitmap
); | |
| 54 | |
| 55 ////////////////////////////////////////////////////////////////////////////////
//////////////////// | 49 ////////////////////////////////////////////////////////////////////////////////
//////////////////// |
| 56 | 50 |
| 57 /** | 51 /** |
| 58 * Table for translating from format of data to a suffix. | 52 * Table for translating from format of data to a suffix. |
| 59 */ | 53 */ |
| 60 struct Format { | 54 struct Format { |
| 61 SkImageDecoder::Format fFormat; | 55 SkImageDecoder::Format fFormat; |
| 62 const char* fSuffix; | 56 const char* fSuffix; |
| 63 }; | 57 }; |
| 64 static const Format gFormats[] = { | 58 static const Format gFormats[] = { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 138 |
| 145 SkFILEStream inputStream; | 139 SkFILEStream inputStream; |
| 146 inputStream.setPath(inputPath.c_str()); | 140 inputStream.setPath(inputPath.c_str()); |
| 147 if (!inputStream.isValid()) { | 141 if (!inputStream.isValid()) { |
| 148 SkDebugf("Could not open file %s\n", inputPath.c_str()); | 142 SkDebugf("Could not open file %s\n", inputPath.c_str()); |
| 149 return false; | 143 return false; |
| 150 } | 144 } |
| 151 | 145 |
| 152 SkPicture::InstallPixelRefProc proc; | 146 SkPicture::InstallPixelRefProc proc; |
| 153 if (FLAGS_deferImageDecoding) { | 147 if (FLAGS_deferImageDecoding) { |
| 154 proc = &lazy_decode_bitmap; | 148 proc = &sk_tools::LazyDecodeBitmap; |
| 155 } else if (FLAGS_writeEncodedImages) { | 149 } else if (FLAGS_writeEncodedImages) { |
| 156 SkASSERT(!FLAGS_writePath.isEmpty()); | 150 SkASSERT(!FLAGS_writePath.isEmpty()); |
| 157 reset_image_file_base_name(inputFilename); | 151 reset_image_file_base_name(inputFilename); |
| 158 proc = &write_image_to_file; | 152 proc = &write_image_to_file; |
| 159 } else { | 153 } else { |
| 160 proc = &SkImageDecoder::DecodeMemory; | 154 proc = &SkImageDecoder::DecodeMemory; |
| 161 } | 155 } |
| 162 | 156 |
| 163 SkDebugf("deserializing... %s\n", inputPath.c_str()); | 157 SkDebugf("deserializing... %s\n", inputPath.c_str()); |
| 164 | 158 |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 #endif | 437 #endif |
| 444 #endif | 438 #endif |
| 445 return 0; | 439 return 0; |
| 446 } | 440 } |
| 447 | 441 |
| 448 #if !defined SK_BUILD_FOR_IOS | 442 #if !defined SK_BUILD_FOR_IOS |
| 449 int main(int argc, char * const argv[]) { | 443 int main(int argc, char * const argv[]) { |
| 450 return tool_main(argc, (char**) argv); | 444 return tool_main(argc, (char**) argv); |
| 451 } | 445 } |
| 452 #endif | 446 #endif |
| OLD | NEW |