diff options
author | scroggo <scroggo@chromium.org> | 2016-05-20 13:56:13 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-20 13:56:13 -0700 |
commit | ba5848953e00685f9a57343aef94372c5803130a (patch) | |
tree | d649d222b437821786d485abd515a81963c1b265 /dm | |
parent | 17b4a109219d063dc10a988b1ed46aaefe278477 (diff) |
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
Diffstat (limited to 'dm')
-rw-r--r-- | dm/DMSrcSink.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp index 028dff886b..33848975e9 100644 --- a/dm/DMSrcSink.cpp +++ b/dm/DMSrcSink.cpp @@ -314,7 +314,7 @@ static void premultiply_if_necessary(SkBitmap& bitmap) { } 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 @@ static bool get_decode_info(SkImageInfo* decodeInfo, SkColorType canvasColorType break; } + *decodeInfo = decodeInfo->makeAlphaType(dstAlphaType); return true; } @@ -373,8 +374,9 @@ Error CodecSrc::draw(SkCanvas* canvas) const { 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 @@ Error AndroidCodecSrc::draw(SkCanvas* canvas) const { 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 @@ Error ImageGenSrc::draw(SkCanvas* canvas) const { // 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); |