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

Unified Diff: src/images/SkImageDecoder_libpng.cpp

Issue 25275004: store SkAlphaType inside SkBitmap, on road to support unpremul (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 2 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
Index: src/images/SkImageDecoder_libpng.cpp
diff --git a/src/images/SkImageDecoder_libpng.cpp b/src/images/SkImageDecoder_libpng.cpp
index 5fc9350b519e23d691bb368aac9cef8d3a0d726b..e8150464c21787c6c606034beafeb8e26e50e021 100644
--- a/src/images/SkImageDecoder_libpng.cpp
+++ b/src/images/SkImageDecoder_libpng.cpp
@@ -466,7 +466,16 @@ bool SkPNGImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* decodedBitmap,
if (SkBitmap::kA8_Config == decodedBitmap->config()) {
reallyHasAlpha = true;
}
- decodedBitmap->setIsOpaque(!reallyHasAlpha);
+
+ SkAlphaType alphaType = kOpaque_SkAlphaType;
+ if (reallyHasAlpha) {
+ if (this->getRequireUnpremultipliedColors()) {
+ alphaType = kUnpremul_SkAlphaType;
+ } else {
+ alphaType = kPremul_SkAlphaType;
+ }
+ }
+ decodedBitmap->setAlphaType(alphaType);
return true;
}
@@ -939,7 +948,7 @@ bool SkPNGImageDecoder::onDecodeSubset(SkBitmap* bm, const SkIRect& region) {
if (SkBitmap::kA8_Config == decodedBitmap.config()) {
reallyHasAlpha = true;
}
- decodedBitmap.setIsOpaque(!reallyHasAlpha);
+ decodedBitmap.setAlphaType(reallyHasAlpha ? kPremul_SkAlphaType : kOpaque_SkAlphaType);
scroggo 2013/10/18 19:32:40 This should also check for getRequireUnpremultipli
if (swapOnly) {
bm->swap(decodedBitmap);

Powered by Google App Engine
This is Rietveld 408576698