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 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); | |
183 if (!encoded) { | |
184 SkDebugf("Couldn't read %s.", path.c_str()); | |
185 return; | |
186 } | |
187 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); | |
188 if (NULL == codec.get()) { | |
189 SkDebugf("Couldn't create codec for %s.", path.c_str()); | |
190 return; | |
191 } | |
192 | |
193 // Build additional test cases for images that decode natively to non-canvas types | |
194 switch(codec->getInfo().colorType()) { | |
195 case kGray_8_SkColorType: | |
196 push_src("image", "codec kGray8", new CodecSrc(path, CodecSrc::kNorm al_Mode, | |
197 CodecSrc::kGrayscale_Always_DstColorType)); | |
198 push_src("image", "scanline kGray8", new CodecSrc(path, CodecSrc::kS canline_Mode, | |
199 CodecSrc::kGrayscale_Always_DstColorType)); | |
200 // Intentional fall through | |
201 // FIXME: Is this a long term solution for testing wbmps decodes to kIndex8? | |
scroggo
2015/04/09 14:53:48
nit: please reference skbug.com/3683
msarett
2015/04/09 16:26:32
Done.
| |
202 case kIndex_8_SkColorType: | |
203 push_src("image", "codec kIndex8", new CodecSrc(path, CodecSrc::kNorma l_Mode, | |
204 CodecSrc::kIndex8_Always_DstColorType)); | |
205 push_src("image", "scanline kIndex8", new CodecSrc(path, CodecSrc::kSc anline_Mode, | |
206 CodecSrc::kIndex8_Always_DstColorType)); | |
207 break; | |
208 default: | |
209 // Do nothing | |
210 break; | |
211 } | |
212 | |
213 // Decode all images to the canvas color type | |
214 push_src("image", "codec", new CodecSrc(path, CodecSrc::kNormal_Mode, | |
215 CodecSrc::kGetFromCanvas_DstColorType)); | |
216 push_src("image", "scanline", new CodecSrc(path, CodecSrc::kScanline_Mode, | |
217 CodecSrc::kGetFromCanvas_DstColorType)); | |
218 } | |
219 | |
181 static bool codec_supported(const char* ext) { | 220 static bool codec_supported(const char* ext) { |
182 // FIXME: Once other versions of SkCodec are available, we can add them to t his | 221 // 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 ). | 222 // list (and eventually we can remove this check once they are all supported ). |
184 static const char* const exts[] = { | 223 static const char* const exts[] = { |
185 "bmp", "gif", "png", "ico", "wbmp", | 224 "bmp", "gif", "png", "ico", "wbmp", |
186 "BMP", "GIF", "PNG", "ICO", "WBMP" | 225 "BMP", "GIF", "PNG", "ICO", "WBMP" |
187 }; | 226 }; |
188 | 227 |
189 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { | 228 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { |
190 if (0 == strcmp(exts[i], ext)) { | 229 if (0 == strcmp(exts[i], ext)) { |
(...skipping 25 matching lines...) Expand all Loading... | |
216 for (int i = 0; i < FLAGS_images.count(); i++) { | 255 for (int i = 0; i < FLAGS_images.count(); i++) { |
217 const char* flag = FLAGS_images[i]; | 256 const char* flag = FLAGS_images[i]; |
218 if (sk_isdir(flag)) { | 257 if (sk_isdir(flag)) { |
219 for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) { | 258 for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) { |
220 SkOSFile::Iter it(flag, exts[j]); | 259 SkOSFile::Iter it(flag, exts[j]); |
221 for (SkString file; it.next(&file); ) { | 260 for (SkString file; it.next(&file); ) { |
222 SkString path = SkOSPath::Join(flag, file.c_str()); | 261 SkString path = SkOSPath::Join(flag, file.c_str()); |
223 push_src("image", "decode", new ImageSrc(path)); // Decode e ntire image | 262 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 | 263 push_src("image", "subset", new ImageSrc(path, 2)); // Decod e into 2x2 subsets |
225 if (codec_supported(exts[j])) { | 264 if (codec_supported(exts[j])) { |
226 push_src("image", "codec", new CodecSrc(path, CodecSrc:: kNormal_Mode)); | 265 push_codec_srcs(path); |
227 push_src("image", "scanline", new CodecSrc(path, CodecSr c::kScanline_Mode)); | |
228 } | 266 } |
229 } | 267 } |
230 } | 268 } |
231 } else if (sk_exists(flag)) { | 269 } else if (sk_exists(flag)) { |
232 // assume that FLAGS_images[i] is a valid image if it is a file. | 270 // 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. | 271 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 | 272 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 )); | 273 push_codec_srcs(flag); |
236 push_src("image", "scanline", new CodecSrc(flag, CodecSrc::kScanline _Mode)); | |
237 } | 274 } |
238 } | 275 } |
239 } | 276 } |
240 | 277 |
241 static GrGLStandard get_gpu_api() { | 278 static GrGLStandard get_gpu_api() { |
242 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } | 279 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } |
243 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } | 280 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } |
244 return kNone_GrGLStandard; | 281 return kNone_GrGLStandard; |
245 } | 282 } |
246 | 283 |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
705 } | 742 } |
706 return 0; | 743 return 0; |
707 } | 744 } |
708 | 745 |
709 #if !defined(SK_BUILD_FOR_IOS) | 746 #if !defined(SK_BUILD_FOR_IOS) |
710 int main(int argc, char** argv) { | 747 int main(int argc, char** argv) { |
711 SkCommandLineFlags::Parse(argc, argv); | 748 SkCommandLineFlags::Parse(argc, argv); |
712 return dm_main(); | 749 return dm_main(); |
713 } | 750 } |
714 #endif | 751 #endif |
OLD | NEW |