diff options
author | scroggo <scroggo@chromium.org> | 2015-08-14 08:32:46 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-14 08:32:46 -0700 |
commit | cc2feb161f756c4035a407296567654d86bc7be7 (patch) | |
tree | fc18ba44cbd7bfc55ac169fe2610c45c4194fe03 /src/codec/SkBmpStandardCodec.cpp | |
parent | 8f4ba76742c329bc4d5e1b8ca376d27922bd00b1 (diff) |
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
Diffstat (limited to 'src/codec/SkBmpStandardCodec.cpp')
-rw-r--r-- | src/codec/SkBmpStandardCodec.cpp | 34 |
1 files changed, 5 insertions, 29 deletions
diff --git a/src/codec/SkBmpStandardCodec.cpp b/src/codec/SkBmpStandardCodec.cpp index 1dfd04ee21..27cea4ead0 100644 --- a/src/codec/SkBmpStandardCodec.cpp +++ b/src/codec/SkBmpStandardCodec.cpp @@ -12,35 +12,6 @@ #include "SkStream.h" /* - * Checks if the conversion between the input image and the requested output - * image has been implemented - */ -static bool conversion_possible(const SkImageInfo& dst, - const SkImageInfo& src) { - // Ensure that the profile type is unchanged - if (dst.profileType() != src.profileType()) { - return false; - } - - // Ensure the alpha type is valid - if (!valid_alpha(dst.alphaType(), src.alphaType())) { - return false; - } - - // Check for supported color types - switch (dst.colorType()) { - // Allow output to kN32 from any type of input - case kN32_SkColorType: - return true; - // Allow output to kIndex_8 from compatible inputs - case kIndex_8_SkColorType: - return kIndex_8_SkColorType == src.colorType(); - default: - return false; - } -} - -/* * Creates an instance of the decoder * Called only by NewFromStream */ @@ -323,6 +294,11 @@ SkCodec::Result SkBmpStandardCodec::decode(const SkImageInfo& dstInfo, // Finally, apply the AND mask for bmp-in-ico images if (fInIco) { + // BMP in ICO have transparency, so this cannot be 565, and this mask + // prevents us from using kIndex8. The below code depends on the output + // being an SkPMColor. + SkASSERT(dstInfo.colorType() == kN32_SkColorType); + // The AND mask is always 1 bit per pixel const size_t rowBytes = SkAlign4(compute_row_bytes(width, 1)); |