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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
198 if (!encoded) { | 198 if (!encoded) { |
199 SkDebugf("Couldn't read %s.", path.c_str()); | 199 SkDebugf("Couldn't read %s.", path.c_str()); |
200 return; | 200 return; |
201 } | 201 } |
202 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); | 202 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); |
203 if (NULL == codec.get()) { | 203 if (NULL == codec.get()) { |
204 SkDebugf("Couldn't create codec for %s.", path.c_str()); | 204 SkDebugf("Couldn't create codec for %s.", path.c_str()); |
205 return; | 205 return; |
206 } | 206 } |
207 | 207 |
208 // Build additional test cases for images that decode natively to non-canvas types | 208 // Choose scales for scaling tests. |
209 switch(codec->getInfo().colorType()) { | 209 // TODO (msarett): Add more scaling tests as we implement more flexible scal ing. |
210 case kGray_8_SkColorType: | 210 // TODO (msarett): Implement scaling tests for SkImageDecoder in order to co mpare with these |
211 push_src("image", "codec_kGray8", new CodecSrc(path, CodecSrc::kNorm al_Mode, | 211 // tests. SkImageDecoder supports downscales by integer fac tors. |
212 CodecSrc::kGrayscale_Always_DstColorType)); | 212 const float scales[] = { 0.125f, 0.25f, 0.5f, 1.0f }; |
213 push_src("image", "scanline_kGray8", new CodecSrc(path, CodecSrc::kS canline_Mode, | 213 |
214 CodecSrc::kGrayscale_Always_DstColorType)); | 214 for (float scale : scales) { |
215 push_src("image", "scanline_subset_kGray8", new CodecSrc(path, | 215 // Build additional test cases for images that decode natively to non-ca nvas types |
216 CodecSrc::kScanline_Subset_Mode, CodecSrc::kGrayscale_Always _DstColorType)); | 216 switch(codec->getInfo().colorType()) { |
217 // Intentional fall through | 217 case kGray_8_SkColorType: |
218 // FIXME: Is this a long term solution for testing wbmps decodes to kIndex8? | 218 push_src("image", "codec_kGray8", new CodecSrc(path, CodecSrc::k Normal_Mode, |
219 // Further discussion on this topic is at skbug.com/3683 | 219 CodecSrc::kGrayscale_Always_DstColorType, scale)); |
220 case kIndex_8_SkColorType: | 220 push_src("image", "scanline_kGray8", new CodecSrc(path, CodecSrc ::kScanline_Mode, |
221 push_src("image", "codec_kIndex8", new CodecSrc(path, CodecSrc::kNor mal_Mode, | 221 CodecSrc::kGrayscale_Always_DstColorType, scale)); |
222 CodecSrc::kIndex8_Always_DstColorType)); | 222 push_src("image", "scanline_subset_kGray8", new CodecSrc(path, |
223 push_src("image", "scanline_kIndex8", new CodecSrc(path, CodecSrc::k Scanline_Mode, | 223 CodecSrc::kScanline_Subset_Mode, CodecSrc::kGrayscale_Al ways_DstColorType, |
224 CodecSrc::kIndex8_Always_DstColorType)); | 224 scale)); |
225 push_src("image", "scanline_subset_kIndex8", new CodecSrc(path, | 225 push_src("image", "scale_kGray8", new CodecSrc(path, CodecSrc::k Stripe_Mode, |
scroggo
2015/06/11 20:12:48
stripe_kGray8?
msarett
2015/06/11 21:20:27
Yup!
| |
226 CodecSrc::kScanline_Subset_Mode, CodecSrc::kIndex8_Always_Ds tColorType)); | 226 CodecSrc::kGrayscale_Always_DstColorType, scale)); |
227 break; | 227 // Intentional fall through |
228 default: | 228 // FIXME: Is this a long term solution for testing wbmps decodes to kIndex8? |
229 // Do nothing | 229 // Further discussion on this topic is at skbug.com/3683 |
230 break; | 230 case kIndex_8_SkColorType: |
231 push_src("image", "codec_kIndex8", new CodecSrc(path, CodecSrc:: kNormal_Mode, | |
232 CodecSrc::kIndex8_Always_DstColorType, scale)); | |
233 push_src("image", "scanline_kIndex8", new CodecSrc(path, CodecSr c::kScanline_Mode, | |
234 CodecSrc::kIndex8_Always_DstColorType, scale)); | |
235 push_src("image", "scanline_subset_kIndex8", new CodecSrc(path, | |
236 CodecSrc::kScanline_Subset_Mode, CodecSrc::kIndex8_Alway s_DstColorType, | |
237 scale)); | |
238 push_src("image", "stripe_kIndex8", new CodecSrc(path, CodecSrc: :kStripe_Mode, | |
239 CodecSrc::kIndex8_Always_DstColorType, scale)); | |
240 break; | |
241 default: | |
242 // Do nothing | |
243 break; | |
244 } | |
245 | |
246 // Decode all images to the canvas color type | |
247 push_src("image", "codec", new CodecSrc(path, CodecSrc::kNormal_Mode, | |
248 CodecSrc::kGetFromCanvas_DstColorType, scale)); | |
249 push_src("image", "scanline", new CodecSrc(path, CodecSrc::kScanline_Mod e, | |
250 CodecSrc::kGetFromCanvas_DstColorType, scale)); | |
251 push_src("image", "scanline_subset", new CodecSrc(path, CodecSrc::kScanl ine_Subset_Mode, | |
252 CodecSrc::kGetFromCanvas_DstColorType, scale)); | |
253 push_src("image", "stripe", new CodecSrc(path, CodecSrc::kStripe_Mode, | |
254 CodecSrc::kGetFromCanvas_DstColorType, scale)); | |
231 } | 255 } |
232 | |
233 // Decode all images to the canvas color type | |
234 push_src("image", "codec", new CodecSrc(path, CodecSrc::kNormal_Mode, | |
235 CodecSrc::kGetFromCanvas_DstColorType)); | |
236 push_src("image", "scanline", new CodecSrc(path, CodecSrc::kScanline_Mode, | |
237 CodecSrc::kGetFromCanvas_DstColorType)); | |
238 push_src("image", "scanline_subset", new CodecSrc(path, CodecSrc::kScanline_ Subset_Mode, | |
239 CodecSrc::kGetFromCanvas_DstColorType)); | |
240 } | 256 } |
241 | 257 |
242 static bool codec_supported(const char* ext) { | 258 static bool codec_supported(const char* ext) { |
243 // FIXME: Once other versions of SkCodec are available, we can add them to t his | 259 // FIXME: Once other versions of SkCodec are available, we can add them to t his |
244 // list (and eventually we can remove this check once they are all supported ). | 260 // list (and eventually we can remove this check once they are all supported ). |
245 static const char* const exts[] = { | 261 static const char* const exts[] = { |
246 "bmp", "gif", "jpg", "jpeg", "png", "ico", "wbmp", | 262 "bmp", "gif", "jpg", "jpeg", "png", "ico", "wbmp", |
247 "BMP", "GIF", "JPG", "JPEG", "PNG", "ICO", "WBMP" | 263 "BMP", "GIF", "JPG", "JPEG", "PNG", "ICO", "WBMP" |
248 }; | 264 }; |
249 | 265 |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
790 } | 806 } |
791 return 0; | 807 return 0; |
792 } | 808 } |
793 | 809 |
794 #if !defined(SK_BUILD_FOR_IOS) | 810 #if !defined(SK_BUILD_FOR_IOS) |
795 int main(int argc, char** argv) { | 811 int main(int argc, char** argv) { |
796 SkCommandLineFlags::Parse(argc, argv); | 812 SkCommandLineFlags::Parse(argc, argv); |
797 return dm_main(); | 813 return dm_main(); |
798 } | 814 } |
799 #endif | 815 #endif |
OLD | NEW |