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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 // compute their colors based on uninitialized values. | 320 // compute their colors based on uninitialized values. |
321 continue; | 321 continue; |
322 } | 322 } |
323 | 323 |
324 for (uint32_t i = 0; i < numColorTypes; i++) { | 324 for (uint32_t i = 0; i < numColorTypes; i++) { |
325 push_codec_src(path, CodecSrc::kScaledCodec_Mode, colorTypes[i], sca
le); | 325 push_codec_src(path, CodecSrc::kScaledCodec_Mode, colorTypes[i], sca
le); |
326 } | 326 } |
327 } | 327 } |
328 } | 328 } |
329 | 329 |
330 static bool brd_color_type_supported(SkBitmapRegionDecoderInterface::Strategy st
rategy, | 330 static bool codec_supported(const char* ext) { |
331 CodecSrc::DstColorType dstColorType) { | 331 // FIXME: Once other versions of SkCodec are available, we can add them to t
his |
332 switch (strategy) { | 332 // list (and eventually we can remove this check once they are all supported
). |
333 case SkBitmapRegionDecoderInterface::kCanvas_Strategy: | |
334 if (CodecSrc::kGetFromCanvas_DstColorType == dstColorType) { | |
335 return true; | |
336 } | |
337 return false; | |
338 case SkBitmapRegionDecoderInterface::kOriginal_Strategy: | |
339 switch (dstColorType) { | |
340 case CodecSrc::kGetFromCanvas_DstColorType: | |
341 case CodecSrc::kIndex8_Always_DstColorType: | |
342 case CodecSrc::kGrayscale_Always_DstColorType: | |
343 return true; | |
344 default: | |
345 return false; | |
346 } | |
347 default: | |
348 SkASSERT(false); | |
349 return false; | |
350 } | |
351 } | |
352 | |
353 static void push_brd_src(Path path, SkBitmapRegionDecoderInterface::Strategy str
ategy, | |
354 CodecSrc::DstColorType dstColorType, BRDSrc::Mode mode, uint32_t sampleS
ize) { | |
355 SkString folder; | |
356 switch (strategy) { | |
357 case SkBitmapRegionDecoderInterface::kCanvas_Strategy: | |
358 folder.append("brd_canvas"); | |
359 break; | |
360 case SkBitmapRegionDecoderInterface::kOriginal_Strategy: | |
361 folder.append("brd_sample"); | |
362 break; | |
363 default: | |
364 SkASSERT(false); | |
365 return; | |
366 } | |
367 | |
368 switch (mode) { | |
369 case BRDSrc::kFullImage_Mode: | |
370 break; | |
371 case BRDSrc::kDivisor_Mode: | |
372 folder.append("_divisor"); | |
373 break; | |
374 default: | |
375 SkASSERT(false); | |
376 return; | |
377 } | |
378 | |
379 switch (dstColorType) { | |
380 case CodecSrc::kGetFromCanvas_DstColorType: | |
381 break; | |
382 case CodecSrc::kIndex8_Always_DstColorType: | |
383 folder.append("_kIndex"); | |
384 break; | |
385 case CodecSrc::kGrayscale_Always_DstColorType: | |
386 folder.append("_kGray"); | |
387 break; | |
388 default: | |
389 SkASSERT(false); | |
390 return; | |
391 } | |
392 | |
393 if (1 != sampleSize) { | |
394 folder.appendf("_%.3f", BRDSrc::GetScale(sampleSize)); | |
395 } | |
396 | |
397 BRDSrc* src = new BRDSrc(path, strategy, mode, dstColorType, sampleSize); | |
398 push_src("image", folder, src); | |
399 } | |
400 | |
401 static void push_brd_srcs(Path path) { | |
402 | |
403 const SkBitmapRegionDecoderInterface::Strategy strategies[] = { | |
404 SkBitmapRegionDecoderInterface::kCanvas_Strategy, | |
405 SkBitmapRegionDecoderInterface::kOriginal_Strategy | |
406 }; | |
407 | |
408 // We will only test to one backend (8888), but we will test all of the | |
409 // color types that we need to decode to on this backend. | |
410 const CodecSrc::DstColorType dstColorTypes[] = { | |
411 CodecSrc::kGetFromCanvas_DstColorType, | |
412 CodecSrc::kIndex8_Always_DstColorType, | |
413 CodecSrc::kGrayscale_Always_DstColorType, | |
414 }; | |
415 | |
416 const BRDSrc::Mode modes[] = { | |
417 BRDSrc::kFullImage_Mode, | |
418 BRDSrc::kDivisor_Mode | |
419 }; | |
420 | |
421 const uint32_t sampleSizes[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; | |
422 | |
423 for (SkBitmapRegionDecoderInterface::Strategy strategy : strategies) { | |
424 for (CodecSrc::DstColorType dstColorType : dstColorTypes) { | |
425 if (brd_color_type_supported(strategy, dstColorType)) { | |
426 for (BRDSrc::Mode mode : modes) { | |
427 for (uint32_t sampleSize : sampleSizes) { | |
428 push_brd_src(path, strategy, dstColorType, mode, sampleS
ize); | |
429 } | |
430 } | |
431 } | |
432 } | |
433 } | |
434 } | |
435 | |
436 static bool brd_supported(const char* ext) { | |
437 static const char* const exts[] = { | 333 static const char* const exts[] = { |
438 "jpg", "jpeg", "png", "webp", | 334 "bmp", "gif", "jpg", "jpeg", "png", "ico", "wbmp", "webp", |
439 "JPG", "JPEG", "PNG", "WEBP", | 335 "BMP", "GIF", "JPG", "JPEG", "PNG", "ICO", "WBMP", "WEBP", |
440 }; | 336 }; |
441 | 337 |
442 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { | 338 for (uint32_t i = 0; i < SK_ARRAY_COUNT(exts); i++) { |
443 if (0 == strcmp(exts[i], ext)) { | 339 if (0 == strcmp(exts[i], ext)) { |
444 return true; | 340 return true; |
445 } | 341 } |
446 } | 342 } |
447 return false; | 343 return false; |
448 } | 344 } |
449 | 345 |
(...skipping 18 matching lines...) Expand all Loading... |
468 }; | 364 }; |
469 for (int i = 0; i < FLAGS_images.count(); i++) { | 365 for (int i = 0; i < FLAGS_images.count(); i++) { |
470 const char* flag = FLAGS_images[i]; | 366 const char* flag = FLAGS_images[i]; |
471 if (sk_isdir(flag)) { | 367 if (sk_isdir(flag)) { |
472 for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) { | 368 for (size_t j = 0; j < SK_ARRAY_COUNT(exts); j++) { |
473 SkOSFile::Iter it(flag, exts[j]); | 369 SkOSFile::Iter it(flag, exts[j]); |
474 for (SkString file; it.next(&file); ) { | 370 for (SkString file; it.next(&file); ) { |
475 SkString path = SkOSPath::Join(flag, file.c_str()); | 371 SkString path = SkOSPath::Join(flag, file.c_str()); |
476 push_src("image", "decode", new ImageSrc(path)); // Decode e
ntire image | 372 push_src("image", "decode", new ImageSrc(path)); // Decode e
ntire image |
477 push_src("image", "subset", new ImageSrc(path, 2)); // Decod
e into 2x2 subsets | 373 push_src("image", "subset", new ImageSrc(path, 2)); // Decod
e into 2x2 subsets |
478 push_codec_srcs(path); | 374 if (codec_supported(exts[j])) { |
479 if (brd_supported(exts[j])) { | 375 push_codec_srcs(path); |
480 push_brd_srcs(path); | |
481 } | 376 } |
482 } | 377 } |
483 } | 378 } |
484 } else if (sk_exists(flag)) { | 379 } else if (sk_exists(flag)) { |
485 // assume that FLAGS_images[i] is a valid image if it is a file. | 380 // assume that FLAGS_images[i] is a valid image if it is a file. |
486 push_src("image", "decode", new ImageSrc(flag)); // Decode entire im
age. | 381 push_src("image", "decode", new ImageSrc(flag)); // Decode entire im
age. |
487 push_src("image", "subset", new ImageSrc(flag, 2)); // Decode into 2
x 2 subsets | 382 push_src("image", "subset", new ImageSrc(flag, 2)); // Decode into 2
x 2 subsets |
488 push_codec_srcs(flag); | 383 push_codec_srcs(flag); |
489 push_brd_srcs(flag); | |
490 } | 384 } |
491 } | 385 } |
492 } | 386 } |
493 | 387 |
494 static GrGLStandard get_gpu_api() { | 388 static GrGLStandard get_gpu_api() { |
495 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } | 389 if (FLAGS_gpuAPI.contains("gl")) { return kGL_GrGLStandard; } |
496 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } | 390 if (FLAGS_gpuAPI.contains("gles")) { return kGLES_GrGLStandard; } |
497 return kNone_GrGLStandard; | 391 return kNone_GrGLStandard; |
498 } | 392 } |
499 | 393 |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 } | 959 } |
1066 return 0; | 960 return 0; |
1067 } | 961 } |
1068 | 962 |
1069 #if !defined(SK_BUILD_FOR_IOS) | 963 #if !defined(SK_BUILD_FOR_IOS) |
1070 int main(int argc, char** argv) { | 964 int main(int argc, char** argv) { |
1071 SkCommandLineFlags::Parse(argc, argv); | 965 SkCommandLineFlags::Parse(argc, argv); |
1072 return dm_main(); | 966 return dm_main(); |
1073 } | 967 } |
1074 #endif | 968 #endif |
OLD | NEW |