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

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..e54387af34cf960f143a9963d857fd100e7bba73 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,15 @@ bool SkPNGImageDecoder::onDecodeSubset(SkBitmap* bm, const SkIRect& region) {
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);
if (swapOnly) {
bm->swap(decodedBitmap);

Powered by Google App Engine
This is Rietveld 408576698