Support more swizzles to 565 in SkCodec
Add more swizzling functions for swizzling to 565. Much of this
code was revived from crrev.com/1055743003 (for BMP). Also added
swizzling functions for WBMP.
Consolidate the static function conversion_possible.
In SkCodec::getPixels, check that the alphatype corresponds to the
colorType. This prevents requesting 565 + non-opaque.
In SkIcoCodec, report that the image is unpremul (instead of
whatever the largest embedded codec thinks), but modify the
requested info to have the alpha type expected/required by the
embedded codec.
Add tests for decoding to 565.
BUG=skia:3257
BUG=skia:3683
Review URL: https://codereview.chromium.org/1277213002
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp
index 3e5ebe1..62eec27 100644
--- a/src/codec/SkCodec.cpp
+++ b/src/codec/SkCodec.cpp
@@ -123,6 +123,15 @@
ctable = NULL;
}
+ {
+ SkAlphaType canonical;
+ if (!SkColorTypeValidateAlphaType(info.colorType(), info.alphaType(), &canonical)
+ || canonical != info.alphaType())
+ {
+ return kInvalidConversion;
+ }
+ }
+
// Default options.
Options optsStorage;
if (NULL == options) {