Chromium Code Reviews| 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 const char* get_output_dir(const char* mode, const SkString& scale) { | |
| 209 SkString* str = new SkString(mode); | |
|
scroggo
2015/08/31 19:35:24
This string is leaked.
msarett
2015/08/31 21:05:28
Acknowledged.
| |
| 210 str->append(scale); | |
| 211 return str->c_str(); | |
|
scroggo
2015/08/31 19:35:24
This only works because you leaked str. c_str() re
msarett
2015/08/31 21:05:28
Acknowledged.
| |
| 212 } | |
| 213 | |
| 208 static void push_codec_srcs(Path path) { | 214 static void push_codec_srcs(Path path) { |
| 209 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); | 215 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); |
| 210 if (!encoded) { | 216 if (!encoded) { |
| 211 SkDebugf("Couldn't read %s.", path.c_str()); | 217 SkDebugf("Couldn't read %s.", path.c_str()); |
| 212 return; | 218 return; |
| 213 } | 219 } |
| 214 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); | 220 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); |
| 215 if (nullptr == codec.get()) { | 221 if (nullptr == codec.get()) { |
| 216 SkDebugf("Couldn't create codec for %s.", path.c_str()); | 222 SkDebugf("Couldn't create codec for %s.", path.c_str()); |
| 217 return; | 223 return; |
| 218 } | 224 } |
| 219 | 225 |
| 220 // Choose scales for scaling tests. | 226 // 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 | 227 // TODO (msarett): Implement scaling tests for SkImageDecoder in order to co mpare with these |
| 223 // tests. SkImageDecoder supports downscales by integer fac tors. | 228 // 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 | 229 // 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 | 230 // 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 | 231 // 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 | 232 // 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, | 233 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 }; | 234 0.625f, 0.750f, 0.8f, 0.875f, 1.0f }; |
| 230 | 235 |
| 231 for (float scale : scales) { | 236 for (float scale : scales) { |
| 232 if (scale != 1.0f && (path.endsWith(".webp") || path.endsWith(".WEBP"))) { | 237 if (scale != 1.0f && (path.endsWith(".webp") || path.endsWith(".WEBP"))) { |
| 233 // FIXME: skbug.com/4038 Scaling webp seems to leave some pixels uni nitialized/ | 238 // FIXME: skbug.com/4038 Scaling webp seems to leave some pixels uni nitialized/ |
| 234 // compute their colors based on uninitialized values. | 239 // compute their colors based on uninitialized values. |
| 235 continue; | 240 continue; |
| 236 } | 241 } |
| 242 | |
| 243 // We will categorize test outputs by scale, mode, and color type. Star t by converting | |
| 244 // the scale to a string. | |
| 245 SkString scaleStr; | |
| 246 if (1.0f != scale) { | |
| 247 scaleStr.appendf("_%.3f", scale); | |
| 248 } | |
| 249 | |
| 237 // Build additional test cases for images that decode natively to non-ca nvas types | 250 // Build additional test cases for images that decode natively to non-ca nvas types |
| 238 switch(codec->getInfo().colorType()) { | 251 switch(codec->getInfo().colorType()) { |
| 239 case kGray_8_SkColorType: | 252 case kGray_8_SkColorType: |
| 240 push_src("image", "codec_kGray8", new CodecSrc(path, CodecSrc::k Normal_Mode, | 253 push_src("image", get_output_dir("scaled_codec_kGray8", scaleStr ), |
|
scroggo
2015/08/31 19:35:24
Why not pas scale directly to get_output_dir? It c
msarett
2015/08/31 21:05:28
Acknowledged.
| |
| 254 new CodecSrc(path, CodecSrc::kScaledCodec_Mode, | |
| 241 CodecSrc::kGrayscale_Always_DstColorType, scale)); | 255 CodecSrc::kGrayscale_Always_DstColorType, scale)); |
| 242 push_src("image", "scanline_kGray8", new CodecSrc(path, CodecSrc ::kScanline_Mode, | 256 push_src("image", get_output_dir("codec_kGray8", scaleStr), |
|
scroggo
2015/08/31 19:35:24
This is getting messy. I think we can clean this u
msarett
2015/08/31 21:05:28
Yes this is far better!
| |
| 257 new CodecSrc(path, CodecSrc::kCodec_Mode, | |
| 243 CodecSrc::kGrayscale_Always_DstColorType, scale)); | 258 CodecSrc::kGrayscale_Always_DstColorType, scale)); |
| 244 push_src("image", "scanline_subset_kGray8", new CodecSrc(path, | 259 push_src("image", get_output_dir("scanline_kGray8", scaleStr), |
| 245 CodecSrc::kScanline_Subset_Mode, CodecSrc::kGrayscale_Al ways_DstColorType, | 260 new CodecSrc(path, CodecSrc::kScanline_Mode, |
| 246 scale)); | 261 CodecSrc::kGrayscale_Always_DstColorType, scale)); |
| 247 push_src("image", "stripe_kGray8", new CodecSrc(path, CodecSrc:: kStripe_Mode, | 262 push_src("image", get_output_dir("scanline_subset_kGray8", scale Str), |
| 263 new CodecSrc(path, CodecSrc::kScanline_Subset_Mode, | |
| 264 CodecSrc::kGrayscale_Always_DstColorType, scale)); | |
| 265 push_src("image", get_output_dir("stripe_kGray8", scaleStr), | |
| 266 new CodecSrc(path, CodecSrc::kStripe_Mode, | |
| 248 CodecSrc::kGrayscale_Always_DstColorType, scale)); | 267 CodecSrc::kGrayscale_Always_DstColorType, scale)); |
| 249 // Intentional fall through | 268 // Intentional fall through |
| 250 // FIXME: Is this a long term solution for testing wbmps decodes to kIndex8? | 269 // FIXME: Is this a long term solution for testing wbmps decodes to kIndex8? |
| 251 // Further discussion on this topic is at skbug.com/3683 | 270 // Further discussion on this topic is at skbug.com/3683 |
| 252 case kIndex_8_SkColorType: | 271 case kIndex_8_SkColorType: |
| 253 push_src("image", "codec_kIndex8", new CodecSrc(path, CodecSrc:: kNormal_Mode, | 272 push_src("image", get_output_dir("scaled_codec_kIndex8", scaleSt r), |
| 273 new CodecSrc(path, CodecSrc::kScaledCodec_Mode, | |
| 254 CodecSrc::kIndex8_Always_DstColorType, scale)); | 274 CodecSrc::kIndex8_Always_DstColorType, scale)); |
| 255 push_src("image", "scanline_kIndex8", new CodecSrc(path, CodecSr c::kScanline_Mode, | 275 push_src("image", get_output_dir("codec_kIndex8", scaleStr), |
| 276 new CodecSrc(path, CodecSrc::kCodec_Mode, | |
| 256 CodecSrc::kIndex8_Always_DstColorType, scale)); | 277 CodecSrc::kIndex8_Always_DstColorType, scale)); |
| 257 push_src("image", "scanline_subset_kIndex8", new CodecSrc(path, | 278 push_src("image", get_output_dir("scanline_kIndex8", scaleStr), |
| 258 CodecSrc::kScanline_Subset_Mode, CodecSrc::kIndex8_Alway s_DstColorType, | 279 new CodecSrc(path, CodecSrc::kScanline_Mode, |
| 259 scale)); | 280 CodecSrc::kIndex8_Always_DstColorType, scale)); |
| 260 push_src("image", "stripe_kIndex8", new CodecSrc(path, CodecSrc: :kStripe_Mode, | 281 push_src("image", get_output_dir("scanline_subset_kIndex8", scal eStr), |
| 282 new CodecSrc(path, CodecSrc::kScanline_Subset_Mode, | |
| 283 CodecSrc::kIndex8_Always_DstColorType, scale)); | |
| 284 push_src("image", get_output_dir("stripe_kIndex8", scaleStr), | |
| 285 new CodecSrc(path, CodecSrc::kStripe_Mode, | |
| 261 CodecSrc::kIndex8_Always_DstColorType, scale)); | 286 CodecSrc::kIndex8_Always_DstColorType, scale)); |
| 262 break; | 287 break; |
| 263 default: | 288 default: |
| 264 // Do nothing | 289 // Do nothing |
| 265 break; | 290 break; |
| 266 } | 291 } |
| 267 | 292 |
| 268 // Decode all images to the canvas color type | 293 // Decode all images to the canvas color type |
| 269 push_src("image", "codec", new CodecSrc(path, CodecSrc::kNormal_Mode, | 294 push_src("image", get_output_dir("scaled_codec", scaleStr), |
| 295 new CodecSrc(path, CodecSrc::kScaledCodec_Mode, | |
| 270 CodecSrc::kGetFromCanvas_DstColorType, scale)); | 296 CodecSrc::kGetFromCanvas_DstColorType, scale)); |
| 271 push_src("image", "scanline", new CodecSrc(path, CodecSrc::kScanline_Mod e, | 297 push_src("image", get_output_dir("codec", scaleStr), |
| 298 new CodecSrc(path, CodecSrc::kCodec_Mode, | |
| 272 CodecSrc::kGetFromCanvas_DstColorType, scale)); | 299 CodecSrc::kGetFromCanvas_DstColorType, scale)); |
| 273 push_src("image", "scanline_subset", new CodecSrc(path, CodecSrc::kScanl ine_Subset_Mode, | 300 push_src("image", get_output_dir("scanline", scaleStr), |
| 301 new CodecSrc(path, CodecSrc::kScanline_Mode, | |
| 274 CodecSrc::kGetFromCanvas_DstColorType, scale)); | 302 CodecSrc::kGetFromCanvas_DstColorType, scale)); |
| 275 push_src("image", "stripe", new CodecSrc(path, CodecSrc::kStripe_Mode, | 303 push_src("image", get_output_dir("scanline_subset", scaleStr), |
| 304 new CodecSrc(path, CodecSrc::kScanline_Subset_Mode, | |
| 305 CodecSrc::kGetFromCanvas_DstColorType, scale)); | |
| 306 push_src("image", get_output_dir("stripe", scaleStr), | |
| 307 new CodecSrc(path, CodecSrc::kStripe_Mode, | |
| 276 CodecSrc::kGetFromCanvas_DstColorType, scale)); | 308 CodecSrc::kGetFromCanvas_DstColorType, scale)); |
| 277 // Note: The only codec which supports subsets natively is SkWebpCodec, which will never | 309 // 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 | 310 // report kIndex_8 or kGray_8, so there is no need to test kSubset_mode with those color |
| 279 // types specifically requested. | 311 // types specifically requested. |
| 280 push_src("image", "codec_subset", new CodecSrc(path, CodecSrc::kSubset_M ode, | 312 push_src("image", get_output_dir("codec_subset", scaleStr), |
| 313 new CodecSrc(path, CodecSrc::kSubset_Mode, | |
| 281 CodecSrc::kGetFromCanvas_DstColorType, scale)); | 314 CodecSrc::kGetFromCanvas_DstColorType, scale)); |
| 282 } | 315 } |
| 283 } | 316 } |
| 284 | 317 |
| 285 static bool codec_supported(const char* ext) { | 318 static bool codec_supported(const char* ext) { |
| 286 // FIXME: Once other versions of SkCodec are available, we can add them to t his | 319 // 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 ). | 320 // list (and eventually we can remove this check once they are all supported ). |
| 288 static const char* const exts[] = { | 321 static const char* const exts[] = { |
| 289 "bmp", "gif", "jpg", "jpeg", "png", "ico", "wbmp", "webp", | 322 "bmp", "gif", "jpg", "jpeg", "png", "ico", "wbmp", "webp", |
| 290 "BMP", "GIF", "JPG", "JPEG", "PNG", "ICO", "WBMP", "WEBP", | 323 "BMP", "GIF", "JPG", "JPEG", "PNG", "ICO", "WBMP", "WEBP", |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 913 } | 946 } |
| 914 return 0; | 947 return 0; |
| 915 } | 948 } |
| 916 | 949 |
| 917 #if !defined(SK_BUILD_FOR_IOS) | 950 #if !defined(SK_BUILD_FOR_IOS) |
| 918 int main(int argc, char** argv) { | 951 int main(int argc, char** argv) { |
| 919 SkCommandLineFlags::Parse(argc, argv); | 952 SkCommandLineFlags::Parse(argc, argv); |
| 920 return dm_main(); | 953 return dm_main(); |
| 921 } | 954 } |
| 922 #endif | 955 #endif |
| OLD | NEW |