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? |
| 202 // Further discussion on this topic is at skbug.com/3683 |
| 203 case kIndex_8_SkColorType: |
| 204 push_src("image", "codec kIndex8", new CodecSrc(path, CodecSrc::kNorma
l_Mode, |
| 205 CodecSrc::kIndex8_Always_DstColorType)); |
| 206 push_src("image", "scanline kIndex8", new CodecSrc(path, CodecSrc::kSc
anline_Mode, |
| 207 CodecSrc::kIndex8_Always_DstColorType)); |
| 208 break; |
| 209 default: |
| 210 // Do nothing |
| 211 break; |
| 212 } |
| 213 |
| 214 // Decode all images to the canvas color type |
| 215 push_src("image", "codec", new CodecSrc(path, CodecSrc::kNormal_Mode, |
| 216 CodecSrc::kGetFromCanvas_DstColorType)); |
| 217 push_src("image", "scanline", new CodecSrc(path, CodecSrc::kScanline_Mode, |
| 218 CodecSrc::kGetFromCanvas_DstColorType)); |
| 219 } |
| 220 |
181 static bool codec_supported(const char* ext) { | 221 static bool codec_supported(const char* ext) { |
182 // FIXME: Once other versions of SkCodec are available, we can add them to t
his | 222 // 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
). | 223 // list (and eventually we can remove this check once they are all supported
). |
184 static const char* const exts[] = { | 224 static const char* const exts[] = { |
185 "bmp", "gif", "png", "ico", "wbmp", | 225 "bmp", "gif", "png", "ico", "wbmp", |
186 "BMP", "GIF", "PNG", "ICO", "WBMP" | 226 "BMP", "GIF", "PNG", "ICO", "WBMP" |
187 }; | 227 }; |
188 | 228 |
189 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { | 229 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { |
190 if (0 == strcmp(exts[i], ext)) { | 230 if (0 == strcmp(exts[i], ext)) { |
(...skipping 25 matching lines...) Expand all Loading... |
216 for (int i = 0; i < FLAGS_images.count(); i++) { | 256 for (int i = 0; i < FLAGS_images.count(); i++) { |
217 const char* flag = FLAGS_images[i]; | 257 const char* flag = FLAGS_images[i]; |
218 if (sk_isdir(flag)) { | 258 if (sk_isdir(flag)) { |
219 for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) { | 259 for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) { |
220 SkOSFile::Iter it(flag, exts[j]); | 260 SkOSFile::Iter it(flag, exts[j]); |
221 for (SkString file; it.next(&file); ) { | 261 for (SkString file; it.next(&file); ) { |
222 SkString path = SkOSPath::Join(flag, file.c_str()); | 262 SkString path = SkOSPath::Join(flag, file.c_str()); |
223 push_src("image", "decode", new ImageSrc(path)); // Decode e
ntire image | 263 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 | 264 push_src("image", "subset", new ImageSrc(path, 2)); // Decod
e into 2x2 subsets |
225 if (codec_supported(exts[j])) { | 265 if (codec_supported(exts[j])) { |
226 push_src("image", "codec", new CodecSrc(path, CodecSrc::
kNormal_Mode)); | 266 push_codec_srcs(path); |
227 push_src("image", "scanline", new CodecSrc(path, CodecSr
c::kScanline_Mode)); | |
228 } | 267 } |
229 } | 268 } |
230 } | 269 } |
231 } else if (sk_exists(flag)) { | 270 } else if (sk_exists(flag)) { |
232 // assume that FLAGS_images[i] is a valid image if it is a file. | 271 // 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. | 272 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 | 273 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
)); | 274 push_codec_srcs(flag); |
236 push_src("image", "scanline", new CodecSrc(flag, CodecSrc::kScanline
_Mode)); | |
237 } | 275 } |
238 } | 276 } |
239 } | 277 } |
240 | 278 |
241 static GrGLStandard get_gpu_api() { | 279 static GrGLStandard get_gpu_api() { |
242 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } | 280 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } |
243 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } | 281 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } |
244 return kNone_GrGLStandard; | 282 return kNone_GrGLStandard; |
245 } | 283 } |
246 | 284 |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 } | 743 } |
706 return 0; | 744 return 0; |
707 } | 745 } |
708 | 746 |
709 #if !defined(SK_BUILD_FOR_IOS) | 747 #if !defined(SK_BUILD_FOR_IOS) |
710 int main(int argc, char** argv) { | 748 int main(int argc, char** argv) { |
711 SkCommandLineFlags::Parse(argc, argv); | 749 SkCommandLineFlags::Parse(argc, argv); |
712 return dm_main(); | 750 return dm_main(); |
713 } | 751 } |
714 #endif | 752 #endif |
OLD | NEW |