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