Only decode opaque to premul in DM image

Previously, we would test decoding an opaque SkCodec to all three:
kUnpremul,
kPremul,
kOpaque

The image should look the same in all three cases. We already test for
that in CodecTest [1], where we require that the result matches exactly.
CodecTest runs on a smaller set of images, but it covers a variety of
opaque images. No need to test on all opaque images.

Running locally on my Mac laptop, the following command:

    dm --src image --images resources/

dropped from:
5932 srcs
11.2s

to:

3544 srcs
6.69s

for a 40% speedup.

BUG=skia:5307

[1] https://skia.googlesource.com/skia/+/master/tests/CodecTest.cpp#119
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1999593003

Review-Url: https://codereview.chromium.org/1999593003
This commit is contained in:
scroggo 2016-05-20 11:08:27 -07:00 committed by Commit bot
parent e76ca8b9c2
commit f2c96a2a6f

View File

@ -373,9 +373,6 @@ static void push_codec_src(Path path, CodecSrc::Mode mode, CodecSrc::DstColorTyp
}
switch (dstAlphaType) {
case kOpaque_SkAlphaType:
folder.append("_opaque");
break;
case kPremul_SkAlphaType:
folder.append("_premul");
break;
@ -414,9 +411,6 @@ static void push_android_codec_src(Path path, CodecSrc::DstColorType dstColorTyp
}
switch (dstAlphaType) {
case kOpaque_SkAlphaType:
folder.append("_opaque");
break;
case kPremul_SkAlphaType:
folder.append("_premul");
break;
@ -524,18 +518,17 @@ static void push_codec_srcs(Path path) {
SkTArray<SkAlphaType> alphaModes;
alphaModes.push_back(kPremul_SkAlphaType);
alphaModes.push_back(kUnpremul_SkAlphaType);
if (codec->getInfo().alphaType() == kOpaque_SkAlphaType) {
alphaModes.push_back(kOpaque_SkAlphaType);
if (codec->getInfo().alphaType() != kOpaque_SkAlphaType) {
alphaModes.push_back(kUnpremul_SkAlphaType);
}
for (CodecSrc::Mode mode : nativeModes) {
for (CodecSrc::DstColorType colorType : colorTypes) {
for (SkAlphaType alphaType : alphaModes) {
// Only test kCroppedScanline_Mode when the alpha type is opaque. The test is
// Only test kCroppedScanline_Mode when the alpha type is premul. The test is
// slow and won't be interestingly different with different alpha types.
if (CodecSrc::kCroppedScanline_Mode == mode &&
kOpaque_SkAlphaType != alphaType) {
kPremul_SkAlphaType != alphaType) {
continue;
}