Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Unified Diff: src/codec/SkCodec_libico.cpp

Issue 1321913003: Fix bug in ico decodes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkCodec_libico.cpp
diff --git a/src/codec/SkCodec_libico.cpp b/src/codec/SkCodec_libico.cpp
index 6f343369c4cc0cb389d641728e962235ff4538e6..ec92937f5431b3352361ba148da8548307458bf6 100644
--- a/src/codec/SkCodec_libico.cpp
+++ b/src/codec/SkCodec_libico.cpp
@@ -255,10 +255,24 @@ SkCodec::Result SkIcoCodec::onGetPixels(const SkImageInfo& dstInfo,
if (dstInfo.dimensions() == embeddedCodec->getInfo().dimensions()) {
// Perform the decode
- // FIXME: (msarett): ICO is considered non-opaque, even if the embedded BMP
+ // FIXME (msarett): ICO is considered non-opaque, even if the embedded BMP
// incorrectly claims it has no alpha.
- SkImageInfo info = dstInfo.makeAlphaType(embeddedCodec->getInfo().alphaType());
- result = embeddedCodec->getPixels(info, dst, dstRowBytes, &opts, ct, ptr);
+ SkAlphaType embeddedAlpha = embeddedCodec->getInfo().alphaType();
+ switch (embeddedAlpha) {
+ case kPremul_SkAlphaType:
+ case kUnpremul_SkAlphaType:
+ // Use the requested alpha type if the embedded codec supports alpha.
+ embeddedAlpha = dstInfo.alphaType();
scroggo 2015/09/02 21:50:54 I suppose this is safe because dstInfo.alphaType()
msarett 2015/09/02 21:56:36 Yes - we always guess that ICOs have alpha (and th
+ break;
+ case kOpaque_SkAlphaType:
+ // If the embedded codec claims it is opaque, decode as if it is opaque.
+ break;
+ default:
+ SkASSERT(false);
+ break;
+ }
+ SkImageInfo info = dstInfo.makeAlphaType(embeddedAlpha);
+ result = embeddedCodec->getPixels(dstInfo, dst, dstRowBytes, &opts, ct, ptr);
// On a fatal error, keep trying to find an image to decode
if (kInvalidConversion == result || kInvalidInput == result ||
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698