Make kInvalidConversion a fatal failure in DMSrcSink
authormsarett <msarett@google.com>
Tue, 16 Feb 2016 21:24:54 +0000 (13:24 -0800)
committerCommit bot <commit-bot@chromium.org>
Tue, 16 Feb 2016 21:24:54 +0000 (13:24 -0800)
We just need to abort early on tests that we know
are invalid conversions.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1704433003

Review URL: https://codereview.chromium.org/1704433003

dm/DM.cpp
dm/DMSrcSink.cpp

index c87f578babf22df5bf86aec95ace2b86d27ca205..c8b65842d042f660abbf5614407b99fa46e0399d 100644 (file)
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -354,14 +354,14 @@ static void push_codec_srcs(Path path) {
     uint32_t numColorTypes;
     switch (codec->getInfo().colorType()) {
         case kGray_8_SkColorType:
-            // FIXME: Is this a long term solution for testing wbmps decodes to kIndex8?
-            // Further discussion on this topic is at https://bug.skia.org/3683 .
-            // This causes us to try to convert grayscale jpegs to kIndex8.  We currently
-            // fail non-fatally in this case.
             colorTypes[0] = CodecSrc::kGetFromCanvas_DstColorType;
             colorTypes[1] = CodecSrc::kGrayscale_Always_DstColorType;
-            colorTypes[2] = CodecSrc::kIndex8_Always_DstColorType;
-            numColorTypes = 3;
+            if (kWBMP_SkEncodedFormat == codec->getEncodedFormat()) {
+                colorTypes[2] = CodecSrc::kIndex8_Always_DstColorType;
+                numColorTypes = 3;
+            } else {
+                numColorTypes = 2;
+            }
             break;
         case kIndex_8_SkColorType:
             colorTypes[0] = CodecSrc::kGetFromCanvas_DstColorType;
index 0e2d307264eebe78a97db215efc1ef88c3b52e2e..e5d18cdaafd86af6d66ff5f3b4660619b64cc933 100644 (file)
@@ -321,12 +321,17 @@ bool get_decode_info(SkImageInfo* decodeInfo, SkColorType canvasColorType,
             *decodeInfo = decodeInfo->makeColorType(kIndex_8_SkColorType);
             break;
         case CodecSrc::kGrayscale_Always_DstColorType:
-            if (kRGB_565_SkColorType == canvasColorType) {
+            if (kRGB_565_SkColorType == canvasColorType ||
+                    kOpaque_SkAlphaType != decodeInfo->alphaType()) {
                 return false;
             }
             *decodeInfo = decodeInfo->makeColorType(kGray_8_SkColorType);
             break;
         default:
+            if (kRGB_565_SkColorType == canvasColorType &&
+                    kOpaque_SkAlphaType != decodeInfo->alphaType()) {
+                return false;
+            }
             *decodeInfo = decodeInfo->makeColorType(canvasColorType);
             break;
     }
@@ -428,8 +433,6 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
                     // available.
                 case SkCodec::kIncompleteInput:
                     break;
-                case SkCodec::kInvalidConversion:
-                    return Error::Nonfatal("Incompatible colortype conversion");
                 default:
                     // Everything else is considered a failure.
                     return SkStringPrintf("Couldn't getPixels %s.", fPath.c_str());
@@ -700,8 +703,6 @@ Error AndroidCodecSrc::draw(SkCanvas* canvas) const {
                 case SkCodec::kSuccess:
                 case SkCodec::kIncompleteInput:
                     break;
-                case SkCodec::kInvalidConversion:
-                    return Error::Nonfatal("Cannot convert to requested color type.");
                 default:
                     return SkStringPrintf("Couldn't getPixels %s.", fPath.c_str());
             }