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
diff --git a/dm/DM.cpp b/dm/DM.cpp
index bb53638..d35787e 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -373,9 +373,6 @@
}
switch (dstAlphaType) {
- case kOpaque_SkAlphaType:
- folder.append("_opaque");
- break;
case kPremul_SkAlphaType:
folder.append("_premul");
break;
@@ -414,9 +411,6 @@
}
switch (dstAlphaType) {
- case kOpaque_SkAlphaType:
- folder.append("_opaque");
- break;
case kPremul_SkAlphaType:
folder.append("_premul");
break;
@@ -524,18 +518,17 @@
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;
}