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 (in_shard() && | 198 if (in_shard() && |
199 FLAGS_src.contains(tag) && | 199 FLAGS_src.contains(tag) && |
200 !SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) { | 200 !SkCommandLineFlags::ShouldSkip(FLAGS_match, src->name().c_str())) { |
201 TaggedSrc& s = gSrcs.push_back(); | 201 TaggedSrc& s = gSrcs.push_back(); |
202 s.reset(src.detach()); | 202 s.reset(src.detach()); |
203 s.tag = tag; | 203 s.tag = tag; |
204 s.options = options; | 204 s.options = options; |
205 } | 205 } |
206 } | 206 } |
207 | 207 |
208 static void push_codec_src(Path path, CodecSrc::Mode mode, CodecSrc::DstColorTyp e dstColorType, | |
209 float scale) { | |
210 SkAutoTDelete<SkString> folder(new SkString()); | |
211 switch (mode) { | |
212 case CodecSrc::kCodec_Mode: | |
213 folder->append("codec"); | |
214 break; | |
215 case CodecSrc::kScaledCodec_Mode: | |
216 folder->append("scaled_codec"); | |
217 break; | |
218 case CodecSrc::kScanline_Mode: | |
219 folder->append("scanline"); | |
220 break; | |
221 case CodecSrc::kScanline_Subset_Mode: | |
222 folder->append("scanline_subset"); | |
223 break; | |
224 case CodecSrc::kStripe_Mode: | |
225 folder->append("stripe"); | |
226 break; | |
227 case CodecSrc::kSubset_Mode: | |
228 folder->append("subset"); | |
229 break; | |
230 } | |
231 | |
232 switch (dstColorType) { | |
233 case CodecSrc::kGrayscale_Always_DstColorType: | |
234 folder->append("_kGray8"); | |
235 break; | |
236 case CodecSrc::kIndex8_Always_DstColorType: | |
237 folder->append("_kIndex8"); | |
238 break; | |
239 default: | |
240 break; | |
241 } | |
242 | |
243 if (1.0f != scale) { | |
244 folder->appendf("_%.3f", scale); | |
245 } | |
246 | |
247 const char* folderStr = folder->c_str(); | |
scroggo
2015/09/01 13:11:44
Could you add a comment here that explains why thi
| |
248 CodecSrc* src = new CodecSrc(path, mode, dstColorType, scale, folder.detach( )); | |
249 push_src("image", folderStr, src); | |
mtklein
2015/09/01 14:07:02
Yes, folderStr will be deleted when this function
scroggo
2015/09/01 14:10:04
?
folderStr points into folder, which is owned by
mtklein
2015/09/01 14:18:11
Oh! I missed the detach. This is fine.
| |
250 } | |
251 | |
208 static void push_codec_srcs(Path path) { | 252 static void push_codec_srcs(Path path) { |
209 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); | 253 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); |
210 if (!encoded) { | 254 if (!encoded) { |
211 SkDebugf("Couldn't read %s.", path.c_str()); | 255 SkDebugf("Couldn't read %s.", path.c_str()); |
212 return; | 256 return; |
213 } | 257 } |
214 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); | 258 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); |
215 if (nullptr == codec.get()) { | 259 if (nullptr == codec.get()) { |
216 SkDebugf("Couldn't create codec for %s.", path.c_str()); | 260 SkDebugf("Couldn't create codec for %s.", path.c_str()); |
217 return; | 261 return; |
218 } | 262 } |
219 | 263 |
220 // Choose scales for scaling tests. | 264 // Choose scales for scaling tests. |
221 // TODO (msarett): Add more scaling tests as we implement more flexible scal ing. | |
222 // TODO (msarett): Implement scaling tests for SkImageDecoder in order to co mpare with these | 265 // TODO (msarett): Implement scaling tests for SkImageDecoder in order to co mpare with these |
223 // tests. SkImageDecoder supports downscales by integer fac tors. | 266 // tests. SkImageDecoder supports downscales by integer fac tors. |
224 // SkJpegCodec natively supports scaling to: 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875 | 267 // SkJpegCodec natively supports scaling to: 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875 |
225 // 0.1, 0.16, 0.2 etc allow us to test SkScaledCodec with sampleSize 10, 6, 5, etc | 268 // 0.1, 0.16, 0.2 etc allow us to test SkScaledCodec with sampleSize 10, 6, 5, etc |
226 // 0.4, 0.7 etc allow to test what happens when the client requests a scale that | 269 // 0.4, 0.7 etc allow to test what happens when the client requests a scale that |
227 // does not exactly match a sampleSize or native scaling capability | 270 // does not exactly match a sampleSize or native scaling capability |
228 const float scales[] = { 0.1f, 0.125f, 0.166f, 0.2f, 0.25f, 0.333f, 0.375f, 0.4f, 0.5f, 0.6f, | 271 const float scales[] = { 0.1f, 0.125f, 0.166f, 0.2f, 0.25f, 0.333f, 0.375f, 0.4f, 0.5f, 0.6f, |
229 0.625f, 0.750f, 0.8f, 0.875f, 1.0f }; | 272 0.625f, 0.750f, 0.8f, 0.875f, 1.0f }; |
230 | 273 |
274 const CodecSrc::Mode modes[] = { CodecSrc::kCodec_Mode, CodecSrc::kScaledCod ec_Mode, | |
275 CodecSrc::kScanline_Mode, CodecSrc::kScanline_Subset_Mode, CodecSrc: :kStripe_Mode, | |
276 CodecSrc::kSubset_Mode }; | |
msarett
2015/08/31 21:05:29
Behavior change: We will now "try" to test subset
| |
277 | |
278 const CodecSrc::DstColorType colorTypes[] = { CodecSrc::kGetFromCanvas_DstCo lorType, | |
279 CodecSrc::kGrayscale_Always_DstColorType, CodecSrc::kIndex8_Always_D stColorType }; | |
280 | |
231 for (float scale : scales) { | 281 for (float scale : scales) { |
232 if (scale != 1.0f && (path.endsWith(".webp") || path.endsWith(".WEBP"))) { | 282 if (scale != 1.0f && (path.endsWith(".webp") || path.endsWith(".WEBP"))) { |
233 // FIXME: skbug.com/4038 Scaling webp seems to leave some pixels uni nitialized/ | 283 // FIXME: skbug.com/4038 Scaling webp seems to leave some pixels uni nitialized/ |
234 // compute their colors based on uninitialized values. | 284 // compute their colors based on uninitialized values. |
235 continue; | 285 continue; |
236 } | 286 } |
237 // Build additional test cases for images that decode natively to non-ca nvas types | 287 |
238 switch(codec->getInfo().colorType()) { | 288 for (CodecSrc::Mode mode : modes) { |
239 case kGray_8_SkColorType: | 289 for (CodecSrc::DstColorType colorType : colorTypes) { |
240 push_src("image", "codec_kGray8", new CodecSrc(path, CodecSrc::k Normal_Mode, | 290 push_codec_src(path, mode, colorType, scale); |
241 CodecSrc::kGrayscale_Always_DstColorType, scale)); | 291 } |
242 push_src("image", "scanline_kGray8", new CodecSrc(path, CodecSrc ::kScanline_Mode, | |
243 CodecSrc::kGrayscale_Always_DstColorType, scale)); | |
244 push_src("image", "scanline_subset_kGray8", new CodecSrc(path, | |
245 CodecSrc::kScanline_Subset_Mode, CodecSrc::kGrayscale_Al ways_DstColorType, | |
246 scale)); | |
247 push_src("image", "stripe_kGray8", new CodecSrc(path, CodecSrc:: kStripe_Mode, | |
248 CodecSrc::kGrayscale_Always_DstColorType, scale)); | |
249 // Intentional fall through | |
250 // FIXME: Is this a long term solution for testing wbmps decodes to kIndex8? | |
251 // Further discussion on this topic is at skbug.com/3683 | |
252 case kIndex_8_SkColorType: | |
253 push_src("image", "codec_kIndex8", new CodecSrc(path, CodecSrc:: kNormal_Mode, | |
254 CodecSrc::kIndex8_Always_DstColorType, scale)); | |
255 push_src("image", "scanline_kIndex8", new CodecSrc(path, CodecSr c::kScanline_Mode, | |
256 CodecSrc::kIndex8_Always_DstColorType, scale)); | |
257 push_src("image", "scanline_subset_kIndex8", new CodecSrc(path, | |
258 CodecSrc::kScanline_Subset_Mode, CodecSrc::kIndex8_Alway s_DstColorType, | |
259 scale)); | |
260 push_src("image", "stripe_kIndex8", new CodecSrc(path, CodecSrc: :kStripe_Mode, | |
261 CodecSrc::kIndex8_Always_DstColorType, scale)); | |
262 break; | |
263 default: | |
264 // Do nothing | |
265 break; | |
266 } | 292 } |
267 | |
268 // Decode all images to the canvas color type | |
269 push_src("image", "codec", new CodecSrc(path, CodecSrc::kNormal_Mode, | |
270 CodecSrc::kGetFromCanvas_DstColorType, scale)); | |
271 push_src("image", "scanline", new CodecSrc(path, CodecSrc::kScanline_Mod e, | |
272 CodecSrc::kGetFromCanvas_DstColorType, scale)); | |
273 push_src("image", "scanline_subset", new CodecSrc(path, CodecSrc::kScanl ine_Subset_Mode, | |
274 CodecSrc::kGetFromCanvas_DstColorType, scale)); | |
275 push_src("image", "stripe", new CodecSrc(path, CodecSrc::kStripe_Mode, | |
276 CodecSrc::kGetFromCanvas_DstColorType, scale)); | |
277 // Note: The only codec which supports subsets natively is SkWebpCodec, which will never | |
278 // report kIndex_8 or kGray_8, so there is no need to test kSubset_mode with those color | |
279 // types specifically requested. | |
280 push_src("image", "codec_subset", new CodecSrc(path, CodecSrc::kSubset_M ode, | |
281 CodecSrc::kGetFromCanvas_DstColorType, scale)); | |
282 } | 293 } |
283 } | 294 } |
284 | 295 |
285 static bool codec_supported(const char* ext) { | 296 static bool codec_supported(const char* ext) { |
286 // FIXME: Once other versions of SkCodec are available, we can add them to t his | 297 // FIXME: Once other versions of SkCodec are available, we can add them to t his |
287 // list (and eventually we can remove this check once they are all supported ). | 298 // list (and eventually we can remove this check once they are all supported ). |
288 static const char* const exts[] = { | 299 static const char* const exts[] = { |
289 "bmp", "gif", "jpg", "jpeg", "png", "ico", "wbmp", "webp", | 300 "bmp", "gif", "jpg", "jpeg", "png", "ico", "wbmp", "webp", |
290 "BMP", "GIF", "JPG", "JPEG", "PNG", "ICO", "WBMP", "WEBP", | 301 "BMP", "GIF", "JPG", "JPEG", "PNG", "ICO", "WBMP", "WEBP", |
291 }; | 302 }; |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
913 } | 924 } |
914 return 0; | 925 return 0; |
915 } | 926 } |
916 | 927 |
917 #if !defined(SK_BUILD_FOR_IOS) | 928 #if !defined(SK_BUILD_FOR_IOS) |
918 int main(int argc, char** argv) { | 929 int main(int argc, char** argv) { |
919 SkCommandLineFlags::Parse(argc, argv); | 930 SkCommandLineFlags::Parse(argc, argv); |
920 return dm_main(); | 931 return dm_main(); |
921 } | 932 } |
922 #endif | 933 #endif |
OLD | NEW |