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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 break; | 336 break; |
337 case CodecSrc::kStripe_Mode: | 337 case CodecSrc::kStripe_Mode: |
338 folder.append("stripe"); | 338 folder.append("stripe"); |
339 break; | 339 break; |
340 case CodecSrc::kCroppedScanline_Mode: | 340 case CodecSrc::kCroppedScanline_Mode: |
341 folder.append("crop"); | 341 folder.append("crop"); |
342 break; | 342 break; |
343 case CodecSrc::kSubset_Mode: | 343 case CodecSrc::kSubset_Mode: |
344 folder.append("codec_subset"); | 344 folder.append("codec_subset"); |
345 break; | 345 break; |
346 case CodecSrc::kGen_Mode: | |
347 folder.append("gen"); | |
348 break; | |
349 } | 346 } |
350 | 347 |
351 switch (dstColorType) { | 348 switch (dstColorType) { |
352 case CodecSrc::kGrayscale_Always_DstColorType: | 349 case CodecSrc::kGrayscale_Always_DstColorType: |
353 folder.append("_kGray8"); | 350 folder.append("_kGray8"); |
354 break; | 351 break; |
355 case CodecSrc::kIndex8_Always_DstColorType: | 352 case CodecSrc::kIndex8_Always_DstColorType: |
356 folder.append("_kIndex8"); | 353 folder.append("_kIndex8"); |
357 break; | 354 break; |
358 default: | 355 default: |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 } | 416 } |
420 | 417 |
421 if (1 != sampleSize) { | 418 if (1 != sampleSize) { |
422 folder.appendf("_%.3f", 1.0f / (float) sampleSize); | 419 folder.appendf("_%.3f", 1.0f / (float) sampleSize); |
423 } | 420 } |
424 | 421 |
425 AndroidCodecSrc* src = new AndroidCodecSrc(path, mode, dstColorType, dstAlph
aType, sampleSize); | 422 AndroidCodecSrc* src = new AndroidCodecSrc(path, mode, dstColorType, dstAlph
aType, sampleSize); |
426 push_src("image", folder, src); | 423 push_src("image", folder, src); |
427 } | 424 } |
428 | 425 |
| 426 static void push_image_gen_src(Path path, ImageGenSrc::Mode mode, SkAlphaType al
phaType, bool isGpu) |
| 427 { |
| 428 SkString folder; |
| 429 switch (mode) { |
| 430 case ImageGenSrc::kCodec_Mode: |
| 431 folder.append("gen_codec"); |
| 432 break; |
| 433 case ImageGenSrc::kPlatform_Mode: |
| 434 folder.append("gen_platform"); |
| 435 break; |
| 436 } |
| 437 |
| 438 if (isGpu) { |
| 439 folder.append("_gpu"); |
| 440 } else { |
| 441 switch (alphaType) { |
| 442 case kOpaque_SkAlphaType: |
| 443 folder.append("_opaque"); |
| 444 break; |
| 445 case kPremul_SkAlphaType: |
| 446 folder.append("_premul"); |
| 447 break; |
| 448 case kUnpremul_SkAlphaType: |
| 449 folder.append("_unpremul"); |
| 450 break; |
| 451 default: |
| 452 break; |
| 453 } |
| 454 } |
| 455 |
| 456 ImageGenSrc* src = new ImageGenSrc(path, mode, alphaType, isGpu); |
| 457 push_src("image", folder, src); |
| 458 } |
| 459 |
429 static void push_codec_srcs(Path path) { | 460 static void push_codec_srcs(Path path) { |
430 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); | 461 SkAutoTUnref<SkData> encoded(SkData::NewFromFileName(path.c_str())); |
431 if (!encoded) { | 462 if (!encoded) { |
432 info("Couldn't read %s.", path.c_str()); | 463 info("Couldn't read %s.", path.c_str()); |
433 return; | 464 return; |
434 } | 465 } |
435 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); | 466 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded)); |
436 if (nullptr == codec.get()) { | 467 if (nullptr == codec.get()) { |
437 info("Couldn't create codec for %s.", path.c_str()); | 468 info("Couldn't create codec for %s.", path.c_str()); |
438 return; | 469 return; |
439 } | 470 } |
440 | 471 |
441 // Native Scales | 472 // Native Scales |
442 // SkJpegCodec natively supports scaling to: 0.125, 0.25, 0.375, 0.5, 0.625,
0.75, 0.875 | 473 // SkJpegCodec natively supports scaling to: 0.125, 0.25, 0.375, 0.5, 0.625,
0.75, 0.875 |
443 const float nativeScales[] = { 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.750f,
0.875f, 1.0f }; | 474 const float nativeScales[] = { 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.750f,
0.875f, 1.0f }; |
444 | 475 |
445 SkTArray<CodecSrc::Mode> nativeModes; | 476 SkTArray<CodecSrc::Mode> nativeModes; |
446 nativeModes.push_back(CodecSrc::kCodec_Mode); | 477 nativeModes.push_back(CodecSrc::kCodec_Mode); |
447 nativeModes.push_back(CodecSrc::kCodecZeroInit_Mode); | 478 nativeModes.push_back(CodecSrc::kCodecZeroInit_Mode); |
448 nativeModes.push_back(CodecSrc::kGen_Mode); | |
449 switch (codec->getEncodedFormat()) { | 479 switch (codec->getEncodedFormat()) { |
450 case SkEncodedFormat::kJPEG_SkEncodedFormat: | 480 case SkEncodedFormat::kJPEG_SkEncodedFormat: |
451 nativeModes.push_back(CodecSrc::kScanline_Mode); | 481 nativeModes.push_back(CodecSrc::kScanline_Mode); |
452 nativeModes.push_back(CodecSrc::kStripe_Mode); | 482 nativeModes.push_back(CodecSrc::kStripe_Mode); |
453 nativeModes.push_back(CodecSrc::kCroppedScanline_Mode); | 483 nativeModes.push_back(CodecSrc::kCroppedScanline_Mode); |
454 break; | 484 break; |
455 case SkEncodedFormat::kWEBP_SkEncodedFormat: | 485 case SkEncodedFormat::kWEBP_SkEncodedFormat: |
456 nativeModes.push_back(CodecSrc::kSubset_Mode); | 486 nativeModes.push_back(CodecSrc::kSubset_Mode); |
457 break; | 487 break; |
458 case SkEncodedFormat::kRAW_SkEncodedFormat: | 488 case SkEncodedFormat::kRAW_SkEncodedFormat: |
(...skipping 21 matching lines...) Expand all Loading... |
480 } | 510 } |
481 | 511 |
482 SkTArray<SkAlphaType> alphaModes; | 512 SkTArray<SkAlphaType> alphaModes; |
483 alphaModes.push_back(kPremul_SkAlphaType); | 513 alphaModes.push_back(kPremul_SkAlphaType); |
484 alphaModes.push_back(kUnpremul_SkAlphaType); | 514 alphaModes.push_back(kUnpremul_SkAlphaType); |
485 if (codec->getInfo().alphaType() == kOpaque_SkAlphaType) { | 515 if (codec->getInfo().alphaType() == kOpaque_SkAlphaType) { |
486 alphaModes.push_back(kOpaque_SkAlphaType); | 516 alphaModes.push_back(kOpaque_SkAlphaType); |
487 } | 517 } |
488 | 518 |
489 for (CodecSrc::Mode mode : nativeModes) { | 519 for (CodecSrc::Mode mode : nativeModes) { |
490 // SkCodecImageGenerator only runs for the default colorType | |
491 // recommended by SkCodec. There is no need to generate multiple | |
492 // tests for different colorTypes. | |
493 // TODO (msarett): Add scaling support to SkCodecImageGenerator. | |
494 if (CodecSrc::kGen_Mode == mode) { | |
495 // FIXME: The gpu backend does not draw kGray sources correctly. (sk
bug.com/4822) | |
496 if (kGray_8_SkColorType != codec->getInfo().colorType()) { | |
497 push_codec_src(path, mode, CodecSrc::kGetFromCanvas_DstColorType
, | |
498 codec->getInfo().alphaType(), 1.0f); | |
499 } | |
500 continue; | |
501 } | |
502 | |
503 for (float scale : nativeScales) { | 520 for (float scale : nativeScales) { |
504 for (CodecSrc::DstColorType colorType : colorTypes) { | 521 for (CodecSrc::DstColorType colorType : colorTypes) { |
505 for (SkAlphaType alphaType : alphaModes) { | 522 for (SkAlphaType alphaType : alphaModes) { |
506 // Only test kCroppedScanline_Mode when the alpha type is op
aque. The test is | 523 // Only test kCroppedScanline_Mode when the alpha type is op
aque. The test is |
507 // slow and won't be interestingly different with different
alpha types. | 524 // slow and won't be interestingly different with different
alpha types. |
508 if (CodecSrc::kCroppedScanline_Mode == mode && | 525 if (CodecSrc::kCroppedScanline_Mode == mode && |
509 kOpaque_SkAlphaType != alphaType) { | 526 kOpaque_SkAlphaType != alphaType) { |
510 continue; | 527 continue; |
511 } | 528 } |
512 | 529 |
(...skipping 29 matching lines...) Expand all Loading... |
542 for (SkAlphaType alphaType : alphaModes) { | 559 for (SkAlphaType alphaType : alphaModes) { |
543 push_android_codec_src(path, AndroidCodecSrc::kFullImage_Mode, c
olorType, | 560 push_android_codec_src(path, AndroidCodecSrc::kFullImage_Mode, c
olorType, |
544 alphaType, sampleSize); | 561 alphaType, sampleSize); |
545 if (subset) { | 562 if (subset) { |
546 push_android_codec_src(path, AndroidCodecSrc::kDivisor_Mode,
colorType, | 563 push_android_codec_src(path, AndroidCodecSrc::kDivisor_Mode,
colorType, |
547 alphaType, sampleSize); | 564 alphaType, sampleSize); |
548 } | 565 } |
549 } | 566 } |
550 } | 567 } |
551 } | 568 } |
| 569 |
| 570 static const char* const rawExts[] = { |
| 571 "arw", "cr2", "dng", "nef", "nrw", "orf", "raf", "rw2", "pef", "srw", |
| 572 "ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "RAF", "RW2", "PEF", "SRW", |
| 573 }; |
| 574 |
| 575 // There is not currently a reason to test RAW images on image generator. |
| 576 // If we want to enable these tests, we will need to fix skbug.com/5079. |
| 577 for (const char* ext : rawExts) { |
| 578 if (path.endsWith(ext)) { |
| 579 return; |
| 580 } |
| 581 } |
| 582 |
| 583 // Push image generator GPU test. |
| 584 // FIXME: The gpu backend does not draw kGray sources correctly. (skbug.com/
4822) |
| 585 if (kGray_8_SkColorType != codec->getInfo().colorType()) { |
| 586 push_image_gen_src(path, ImageGenSrc::kCodec_Mode, codec->getInfo().alph
aType(), true); |
| 587 } |
| 588 |
| 589 // Push image generator CPU tests. |
| 590 for (SkAlphaType alphaType : alphaModes) { |
| 591 push_image_gen_src(path, ImageGenSrc::kCodec_Mode, alphaType, false); |
| 592 |
| 593 #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) |
| 594 if (kWEBP_SkEncodedFormat != codec->getEncodedFormat() && |
| 595 kWBMP_SkEncodedFormat != codec->getEncodedFormat() && |
| 596 kUnpremul_SkAlphaType != alphaType) |
| 597 { |
| 598 push_image_gen_src(path, ImageGenSrc::kPlatform_Mode, alphaType, fal
se); |
| 599 } |
| 600 #endif |
| 601 } |
552 } | 602 } |
553 | 603 |
554 static bool brd_color_type_supported(SkBitmapRegionDecoder::Strategy strategy, | 604 static bool brd_color_type_supported(SkBitmapRegionDecoder::Strategy strategy, |
555 CodecSrc::DstColorType dstColorType) { | 605 CodecSrc::DstColorType dstColorType) { |
556 switch (strategy) { | 606 switch (strategy) { |
557 case SkBitmapRegionDecoder::kCanvas_Strategy: | 607 case SkBitmapRegionDecoder::kCanvas_Strategy: |
558 if (CodecSrc::kGetFromCanvas_DstColorType == dstColorType) { | 608 if (CodecSrc::kGetFromCanvas_DstColorType == dstColorType) { |
559 return true; | 609 return true; |
560 } | 610 } |
561 return false; | 611 return false; |
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1429 Reporter* reporter, | 1479 Reporter* reporter, |
1430 GrContextFactory* fac
tory); | 1480 GrContextFactory* fac
tory); |
1431 } // namespace skiatest | 1481 } // namespace skiatest |
1432 | 1482 |
1433 #if !defined(SK_BUILD_FOR_IOS) | 1483 #if !defined(SK_BUILD_FOR_IOS) |
1434 int main(int argc, char** argv) { | 1484 int main(int argc, char** argv) { |
1435 SkCommandLineFlags::Parse(argc, argv); | 1485 SkCommandLineFlags::Parse(argc, argv); |
1436 return dm_main(); | 1486 return dm_main(); |
1437 } | 1487 } |
1438 #endif | 1488 #endif |
OLD | NEW |