Finish supporting decoding opaque to non-opaque

When decoding to 565 or Gray, allow the client to incorrectly ask for premul.

When checking whether it's possible to decode to 565, return whether the
source is opaque.

In DM, allow decoding to 565 or Gray, even if the client also asked for premul.

This fixes a bug introduced in crrev.com/1999593003 when we stopped ever
requesting Opaque, resulting in us not testing 565 or Gray.

BUG=skia:4616
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=1996993003

Review-Url: https://codereview.chromium.org/1996993003
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 028dff8..3384897 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -314,7 +314,7 @@
 }
 
 static bool get_decode_info(SkImageInfo* decodeInfo, SkColorType canvasColorType,
-                            CodecSrc::DstColorType dstColorType) {
+                            CodecSrc::DstColorType dstColorType, SkAlphaType dstAlphaType) {
     switch (dstColorType) {
         case CodecSrc::kIndex8_Always_DstColorType:
             if (kRGB_565_SkColorType == canvasColorType) {
@@ -348,6 +348,7 @@
             break;
     }
 
+    *decodeInfo = decodeInfo->makeAlphaType(dstAlphaType);
     return true;
 }
 
@@ -373,8 +374,9 @@
         return SkStringPrintf("Couldn't create codec for %s.", fPath.c_str());
     }
 
-    SkImageInfo decodeInfo = codec->getInfo().makeAlphaType(fDstAlphaType);
-    if (!get_decode_info(&decodeInfo, canvas->imageInfo().colorType(), fDstColorType)) {
+    SkImageInfo decodeInfo = codec->getInfo();
+    if (!get_decode_info(&decodeInfo, canvas->imageInfo().colorType(), fDstColorType,
+                         fDstAlphaType)) {
         return Error::Nonfatal("Testing non-565 to 565 is uninteresting.");
     }
 
@@ -656,8 +658,9 @@
         return SkStringPrintf("Couldn't create android codec for %s.", fPath.c_str());
     }
 
-    SkImageInfo decodeInfo = codec->getInfo().makeAlphaType(fDstAlphaType);
-    if (!get_decode_info(&decodeInfo, canvas->imageInfo().colorType(), fDstColorType)) {
+    SkImageInfo decodeInfo = codec->getInfo();
+    if (!get_decode_info(&decodeInfo, canvas->imageInfo().colorType(), fDstColorType,
+                         fDstAlphaType)) {
         return Error::Nonfatal("Testing non-565 to 565 is uninteresting.");
     }
 
@@ -793,11 +796,6 @@
     // Test various color and alpha types on CPU
     SkImageInfo decodeInfo = gen->getInfo().makeAlphaType(fDstAlphaType);
 
-    if (kGray_8_SkColorType == decodeInfo.colorType() &&
-            kOpaque_SkAlphaType != decodeInfo.alphaType()) {
-        return Error::Nonfatal("Avoid requesting non-opaque kGray8 decodes.");
-    }
-
     int bpp = SkColorTypeBytesPerPixel(decodeInfo.colorType());
     size_t rowBytes = decodeInfo.width() * bpp;
     SkAutoMalloc pixels(decodeInfo.height() * rowBytes);