Chromium Code Reviews| 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 | 49 // Defined in PictureRenderingFlags.cpp |
| 53 extern bool lazy_decode_bitmap(const void* buffer, size_t size, SkBitmap* bitmap ); | 50 extern bool lazy_decode_bitmap(const void* buffer, size_t size, SkBitmap* bitmap ); |
|
scroggo
2013/07/15 18:02:41
No longer needed.
| |
| 54 | 51 |
| 55 //////////////////////////////////////////////////////////////////////////////// //////////////////// | 52 //////////////////////////////////////////////////////////////////////////////// //////////////////// |
| 56 | 53 |
| 57 /** | 54 /** |
| 58 * Table for translating from format of data to a suffix. | 55 * Table for translating from format of data to a suffix. |
| 59 */ | 56 */ |
| 60 struct Format { | 57 struct Format { |
| 61 SkImageDecoder::Format fFormat; | 58 SkImageDecoder::Format fFormat; |
| 62 const char* fSuffix; | 59 const char* fSuffix; |
| 63 }; | 60 }; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 | 141 |
| 145 SkFILEStream inputStream; | 142 SkFILEStream inputStream; |
| 146 inputStream.setPath(inputPath.c_str()); | 143 inputStream.setPath(inputPath.c_str()); |
| 147 if (!inputStream.isValid()) { | 144 if (!inputStream.isValid()) { |
| 148 SkDebugf("Could not open file %s\n", inputPath.c_str()); | 145 SkDebugf("Could not open file %s\n", inputPath.c_str()); |
| 149 return false; | 146 return false; |
| 150 } | 147 } |
| 151 | 148 |
| 152 SkPicture::InstallPixelRefProc proc; | 149 SkPicture::InstallPixelRefProc proc; |
| 153 if (FLAGS_deferImageDecoding) { | 150 if (FLAGS_deferImageDecoding) { |
| 154 proc = &lazy_decode_bitmap; | 151 proc = &LazyDecodeBitmap; |
| 155 } else if (FLAGS_writeEncodedImages) { | 152 } else if (FLAGS_writeEncodedImages) { |
| 156 SkASSERT(!FLAGS_writePath.isEmpty()); | 153 SkASSERT(!FLAGS_writePath.isEmpty()); |
| 157 reset_image_file_base_name(inputFilename); | 154 reset_image_file_base_name(inputFilename); |
| 158 proc = &write_image_to_file; | 155 proc = &write_image_to_file; |
| 159 } else { | 156 } else { |
| 160 proc = &SkImageDecoder::DecodeMemory; | 157 proc = &SkImageDecoder::DecodeMemory; |
| 161 } | 158 } |
| 162 | 159 |
| 163 SkDebugf("deserializing... %s\n", inputPath.c_str()); | 160 SkDebugf("deserializing... %s\n", inputPath.c_str()); |
| 164 | 161 |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 443 #endif | 440 #endif |
| 444 #endif | 441 #endif |
| 445 return 0; | 442 return 0; |
| 446 } | 443 } |
| 447 | 444 |
| 448 #if !defined SK_BUILD_FOR_IOS | 445 #if !defined SK_BUILD_FOR_IOS |
| 449 int main(int argc, char * const argv[]) { | 446 int main(int argc, char * const argv[]) { |
| 450 return tool_main(argc, (char**) argv); | 447 return tool_main(argc, (char**) argv); |
| 451 } | 448 } |
| 452 #endif | 449 #endif |
| OLD | NEW |