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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 } | 285 } |
286 | 286 |
287 for (CodecSrc::Mode mode : modes) { | 287 for (CodecSrc::Mode mode : modes) { |
288 for (CodecSrc::DstColorType colorType : colorTypes) { | 288 for (CodecSrc::DstColorType colorType : colorTypes) { |
289 push_codec_src(path, mode, colorType, scale); | 289 push_codec_src(path, mode, colorType, scale); |
290 } | 290 } |
291 } | 291 } |
292 } | 292 } |
293 } | 293 } |
294 | 294 |
295 static bool codec_supported(const char* ext) { | 295 static bool brd_color_type_supported(SkBitmapRegionDecoder::Strategy strategy, |
296 // FIXME: Once other versions of SkCodec are available, we can add them to t
his | 296 CodecSrc::DstColorType dstColorType) { |
297 // list (and eventually we can remove this check once they are all supported
). | 297 switch (strategy) { |
| 298 case SkBitmapRegionDecoder::kCanvas_Strategy: |
| 299 if (CodecSrc::kGetFromCanvas_DstColorType == dstColorType) { |
| 300 return true; |
| 301 } |
| 302 return false; |
| 303 case SkBitmapRegionDecoder::kOriginal_Strategy: |
| 304 switch (dstColorType) { |
| 305 case CodecSrc::kGetFromCanvas_DstColorType: |
| 306 case CodecSrc::kIndex8_Always_DstColorType: |
| 307 case CodecSrc::kAlpha_Always_DstColorType: |
| 308 return true; |
| 309 default: |
| 310 return false; |
| 311 } |
| 312 default: |
| 313 SkASSERT(false); |
| 314 return false; |
| 315 } |
| 316 } |
| 317 |
| 318 static void push_brd_src(Path path, SkBitmapRegionDecoder::Strategy strategy, |
| 319 CodecSrc::DstColorType dstColorType, BRDSrc::Mode mode, uint32_t sampleS
ize) { |
| 320 SkString folder; |
| 321 switch (strategy) { |
| 322 case SkBitmapRegionDecoder::kCanvas_Strategy: |
| 323 folder.append("brd_canvas"); |
| 324 break; |
| 325 case SkBitmapRegionDecoder::kOriginal_Strategy: |
| 326 folder.append("brd_sample"); |
| 327 break; |
| 328 default: |
| 329 SkASSERT(false); |
| 330 return; |
| 331 } |
| 332 |
| 333 switch (mode) { |
| 334 case BRDSrc::kFullImage_Mode: |
| 335 break; |
| 336 case BRDSrc::kDivisor_Mode: |
| 337 folder.append("_divisor"); |
| 338 break; |
| 339 default: |
| 340 SkASSERT(false); |
| 341 return; |
| 342 } |
| 343 |
| 344 switch (dstColorType) { |
| 345 case CodecSrc::kGetFromCanvas_DstColorType: |
| 346 break; |
| 347 case CodecSrc::kIndex8_Always_DstColorType: |
| 348 folder.append("_kIndex"); |
| 349 break; |
| 350 case CodecSrc::kAlpha_Always_DstColorType: |
| 351 folder.append("_kAlpha"); |
| 352 break; |
| 353 default: |
| 354 SkASSERT(false); |
| 355 return; |
| 356 } |
| 357 |
| 358 if (1 != sampleSize) { |
| 359 folder.appendf("_%.3f", BRDSrc::GetScale(sampleSize)); |
| 360 } |
| 361 |
| 362 BRDSrc* src = new BRDSrc(path, strategy, mode, dstColorType, sampleSize); |
| 363 push_src("image", folder, src); |
| 364 } |
| 365 |
| 366 static void push_brd_srcs(Path path) { |
| 367 |
| 368 const SkBitmapRegionDecoder::Strategy strategies[] = { |
| 369 SkBitmapRegionDecoder::kCanvas_Strategy, |
| 370 SkBitmapRegionDecoder::kOriginal_Strategy |
| 371 }; |
| 372 |
| 373 // We will only test to one backend (8888), but we will test all of the |
| 374 // color types that we need to decode to on this backend. |
| 375 const CodecSrc::DstColorType dstColorTypes[] = { |
| 376 CodecSrc::kGetFromCanvas_DstColorType, |
| 377 CodecSrc::kIndex8_Always_DstColorType, |
| 378 CodecSrc::kAlpha_Always_DstColorType, |
| 379 }; |
| 380 |
| 381 const BRDSrc::Mode modes[] = { |
| 382 BRDSrc::kFullImage_Mode, |
| 383 BRDSrc::kDivisor_Mode |
| 384 }; |
| 385 |
| 386 const uint32_t sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; |
| 387 |
| 388 for (SkBitmapRegionDecoder::Strategy strategy : strategies) { |
| 389 for (CodecSrc::DstColorType dstColorType : dstColorTypes) { |
| 390 if (brd_color_type_supported(strategy, dstColorType)) { |
| 391 for (BRDSrc::Mode mode : modes) { |
| 392 for (uint32_t sampleSize : sampleSizes) { |
| 393 push_brd_src(path, strategy, dstColorType, mode, sampleS
ize); |
| 394 } |
| 395 } |
| 396 } |
| 397 } |
| 398 } |
| 399 } |
| 400 |
| 401 static bool brd_supported(const char* ext) { |
298 static const char* const exts[] = { | 402 static const char* const exts[] = { |
299 "bmp", "gif", "jpg", "jpeg", "png", "ico", "wbmp", "webp", | 403 "jpg", "jpeg", "png", "webp", |
300 "BMP", "GIF", "JPG", "JPEG", "PNG", "ICO", "WBMP", "WEBP", | 404 "JPG", "JPEG", "PNG", "WEBP", |
301 }; | 405 }; |
302 | 406 |
303 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { | 407 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { |
304 if (0 == strcmp(exts[i], ext)) { | 408 if (0 == strcmp(exts[i], ext)) { |
305 return true; | 409 return true; |
306 } | 410 } |
307 } | 411 } |
308 return false; | 412 return false; |
309 } | 413 } |
310 | 414 |
(...skipping 18 matching lines...) Expand all Loading... |
329 }; | 433 }; |
330 for (int i = 0; i < FLAGS_images.count(); i++) { | 434 for (int i = 0; i < FLAGS_images.count(); i++) { |
331 const char* flag = FLAGS_images[i]; | 435 const char* flag = FLAGS_images[i]; |
332 if (sk_isdir(flag)) { | 436 if (sk_isdir(flag)) { |
333 for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) { | 437 for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) { |
334 SkOSFile::Iter it(flag, exts[j]); | 438 SkOSFile::Iter it(flag, exts[j]); |
335 for (SkString file; it.next(&file); ) { | 439 for (SkString file; it.next(&file); ) { |
336 SkString path = SkOSPath::Join(flag, file.c_str()); | 440 SkString path = SkOSPath::Join(flag, file.c_str()); |
337 push_src("image", "decode", new ImageSrc(path)); // Decode e
ntire image | 441 push_src("image", "decode", new ImageSrc(path)); // Decode e
ntire image |
338 push_src("image", "subset", new ImageSrc(path, 2)); // Decod
e into 2x2 subsets | 442 push_src("image", "subset", new ImageSrc(path, 2)); // Decod
e into 2x2 subsets |
339 if (codec_supported(exts[j])) { | 443 push_codec_srcs(path); |
340 push_codec_srcs(path); | 444 if (brd_supported(exts[j])) { |
| 445 push_brd_srcs(path); |
341 } | 446 } |
342 } | 447 } |
343 } | 448 } |
344 } else if (sk_exists(flag)) { | 449 } else if (sk_exists(flag)) { |
345 // assume that FLAGS_images[i] is a valid image if it is a file. | 450 // assume that FLAGS_images[i] is a valid image if it is a file. |
346 push_src("image", "decode", new ImageSrc(flag)); // Decode entire im
age. | 451 push_src("image", "decode", new ImageSrc(flag)); // Decode entire im
age. |
347 push_src("image", "subset", new ImageSrc(flag, 2)); // Decode into 2
x 2 subsets | 452 push_src("image", "subset", new ImageSrc(flag, 2)); // Decode into 2
x 2 subsets |
348 push_codec_srcs(flag); | 453 push_codec_srcs(flag); |
| 454 push_brd_srcs(flag); |
349 } | 455 } |
350 } | 456 } |
351 } | 457 } |
352 | 458 |
353 static GrGLStandard get_gpu_api() { | 459 static GrGLStandard get_gpu_api() { |
354 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } | 460 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } |
355 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } | 461 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } |
356 return kNone_GrGLStandard; | 462 return kNone_GrGLStandard; |
357 } | 463 } |
358 | 464 |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
924 } | 1030 } |
925 return 0; | 1031 return 0; |
926 } | 1032 } |
927 | 1033 |
928 #if !defined(SK_BUILD_FOR_IOS) | 1034 #if !defined(SK_BUILD_FOR_IOS) |
929 int main(int argc, char** argv) { | 1035 int main(int argc, char** argv) { |
930 SkCommandLineFlags::Parse(argc, argv); | 1036 SkCommandLineFlags::Parse(argc, argv); |
931 return dm_main(); | 1037 return dm_main(); |
932 } | 1038 } |
933 #endif | 1039 #endif |
OLD | NEW |