OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "CrashHandler.h" | 8 #include "CrashHandler.h" |
9 #include "DMJsonWriter.h" | 9 #include "DMJsonWriter.h" |
10 #include "DMSrcSink.h" | 10 #include "DMSrcSink.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 SkAutoTDelete<Src> src(s); | 171 SkAutoTDelete<Src> src(s); |
172 if (FLAGS_src.contains(tag) && | 172 if (FLAGS_src.contains(tag) && |
173 !SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) { | 173 !SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) { |
174 Tagged<Src>& s = gSrcs.push_back(); | 174 Tagged<Src>& s = gSrcs.push_back(); |
175 s.reset(src.detach()); | 175 s.reset(src.detach()); |
176 s.tag = tag; | 176 s.tag = tag; |
177 s.options = options; | 177 s.options = options; |
178 } | 178 } |
179 } | 179 } |
180 | 180 |
181 static void push_codec_srcs(Path path) { | |
182 // These are the extensions for images that might be natively kIndex8. For these images, | |
183 // we should test decoding to kIndex8 and also to the canvas color type. | |
184 // All gifs are natively kIndex8 compatible. Only some bmps and rarely icos (when they | |
185 // contain a kIndex8 bmp) can be decoded to kIndex8. In the case that we tr y to decode | |
186 // incompatible images to kIndex8, we will fail gracefully in CodecSrc::draw (). | |
187 static const char* const indexExts[] = { | |
188 "bmp", "gif", "ico", | |
189 "BMP", "GIF", "ICO", | |
190 }; | |
191 | |
192 // The same applies to natively kGray images. | |
193 static const char* const grayExts[] = { | |
194 "wbmp", "WBMP", | |
195 }; | |
196 | |
197 // Push sources that we want to try to decode to kIndex8 | |
198 for (uint32_t i = 0; i < SK_ARRAY_COUNT(indexExts); i++) { | |
199 if (path.endsWith(indexExts[i])) { | |
scroggo
2015/04/07 21:15:34
Here's how I imagined this working:
SkAutoTDelete
msarett
2015/04/08 13:59:10
What you've described is how I originally thought
scroggo
2015/04/08 17:21:26
That seems okay, although it seems like you call c
msarett
2015/04/08 19:35:39
That was my disappointment with this approach. We
| |
200 push_src("image", "codec kIndex8", new CodecSrc( | |
201 path, CodecSrc::kNormal_Mode, CodecSrc::kIndex8_Always_DstCo lorType)); | |
202 break; | |
203 } | |
204 } | |
205 | |
206 // Push sources that we want to try to decode to kGray8 | |
207 for (uint32_t i = 0; i < SK_ARRAY_COUNT(grayExts); i++) { | |
208 if (path.endsWith(grayExts[i])) { | |
209 push_src("image", "codec kGray8", new CodecSrc( | |
210 path, CodecSrc::kNormal_Mode, CodecSrc::kGrayscale_Always_Ds tColorType)); | |
211 break; | |
212 } | |
213 } | |
214 | |
215 // Decode all sources to the canvas color type | |
216 push_src("image", "codec", new CodecSrc( | |
217 path, CodecSrc::kNormal_Mode, CodecSrc::kGetFromCanvas_DstColorType) ); | |
218 push_src("image", "scanline", new CodecSrc( | |
219 path, CodecSrc::kScanline_Mode, CodecSrc::kGetFromCanvas_DstColorTyp e)); | |
220 } | |
221 | |
181 static bool codec_supported(const char* ext) { | 222 static bool codec_supported(const char* ext) { |
182 // FIXME: Once other versions of SkCodec are available, we can add them to t his | 223 // FIXME: Once other versions of SkCodec are available, we can add them to t his |
183 // list (and eventually we can remove this check once they are all supported ). | 224 // list (and eventually we can remove this check once they are all supported ). |
184 static const char* const exts[] = { | 225 static const char* const exts[] = { |
185 "bmp", "gif", "png", "ico", "wbmp", | 226 "bmp", "gif", "png", "ico", "wbmp", |
186 "BMP", "GIF", "PNG", "ICO", "WBMP" | 227 "BMP", "GIF", "PNG", "ICO", "WBMP" |
187 }; | 228 }; |
188 | 229 |
189 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { | 230 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { |
190 if (0 == strcmp(exts[i], ext)) { | 231 if (0 == strcmp(exts[i], ext)) { |
(...skipping 25 matching lines...) Expand all Loading... | |
216 for (int i = 0; i < FLAGS_images.count(); i++) { | 257 for (int i = 0; i < FLAGS_images.count(); i++) { |
217 const char* flag = FLAGS_images[i]; | 258 const char* flag = FLAGS_images[i]; |
218 if (sk_isdir(flag)) { | 259 if (sk_isdir(flag)) { |
219 for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) { | 260 for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) { |
220 SkOSFile::Iter it(flag, exts[j]); | 261 SkOSFile::Iter it(flag, exts[j]); |
221 for (SkString file; it.next(&file); ) { | 262 for (SkString file; it.next(&file); ) { |
222 SkString path = SkOSPath::Join(flag, file.c_str()); | 263 SkString path = SkOSPath::Join(flag, file.c_str()); |
223 push_src("image", "decode", new ImageSrc(path)); // Decode e ntire image | 264 push_src("image", "decode", new ImageSrc(path)); // Decode e ntire image |
224 push_src("image", "subset", new ImageSrc(path, 2)); // Decod e into 2x2 subsets | 265 push_src("image", "subset", new ImageSrc(path, 2)); // Decod e into 2x2 subsets |
225 if (codec_supported(exts[j])) { | 266 if (codec_supported(exts[j])) { |
226 push_src("image", "codec", new CodecSrc(path, CodecSrc:: kNormal_Mode)); | 267 push_codec_srcs(path); |
227 push_src("image", "scanline", new CodecSrc(path, CodecSr c::kScanline_Mode)); | |
228 } | 268 } |
229 } | 269 } |
230 } | 270 } |
231 } else if (sk_exists(flag)) { | 271 } else if (sk_exists(flag)) { |
232 // assume that FLAGS_images[i] is a valid image if it is a file. | 272 // assume that FLAGS_images[i] is a valid image if it is a file. |
233 push_src("image", "decode", new ImageSrc(flag)); // Decode entire im age. | 273 push_src("image", "decode", new ImageSrc(flag)); // Decode entire im age. |
234 push_src("image", "subset", new ImageSrc(flag, 2)); // Decode into 2 x 2 subsets | 274 push_src("image", "subset", new ImageSrc(flag, 2)); // Decode into 2 x 2 subsets |
235 push_src("image", "codec", new CodecSrc(flag, CodecSrc::kNormal_Mode )); | 275 push_codec_srcs(flag); |
236 push_src("image", "scanline", new CodecSrc(flag, CodecSrc::kScanline _Mode)); | |
237 } | 276 } |
238 } | 277 } |
239 } | 278 } |
240 | 279 |
241 static GrGLStandard get_gpu_api() { | 280 static GrGLStandard get_gpu_api() { |
242 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } | 281 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } |
243 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } | 282 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } |
244 return kNone_GrGLStandard; | 283 return kNone_GrGLStandard; |
245 } | 284 } |
246 | 285 |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
699 } | 738 } |
700 return 0; | 739 return 0; |
701 } | 740 } |
702 | 741 |
703 #if !defined(SK_BUILD_FOR_IOS) | 742 #if !defined(SK_BUILD_FOR_IOS) |
704 int main(int argc, char** argv) { | 743 int main(int argc, char** argv) { |
705 SkCommandLineFlags::Parse(argc, argv); | 744 SkCommandLineFlags::Parse(argc, argv); |
706 return dm_main(); | 745 return dm_main(); |
707 } | 746 } |
708 #endif | 747 #endif |
OLD | NEW |