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

Unified Diff: src/images/SkImageDecoder_libjpeg.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, 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
Index: src/images/SkImageDecoder_libjpeg.cpp
diff --git a/src/images/SkImageDecoder_libjpeg.cpp b/src/images/SkImageDecoder_libjpeg.cpp
index 37be2a7091f240cc9aa28b183aa5071554ce64a5..8be7f3b6ab179ea19f5f18bd59a47595d85c76b1 100644
--- a/src/images/SkImageDecoder_libjpeg.cpp
+++ b/src/images/SkImageDecoder_libjpeg.cpp
@@ -490,9 +490,9 @@ bool SkJPEGImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) {
#endif
if (1 == sampleSize && SkImageDecoder::kDecodeBounds_Mode == mode) {
- bm->setConfig(config, cinfo.image_width, cinfo.image_height);
- bm->setIsOpaque(config != SkBitmap::kA8_Config);
- return true;
+ return bm->setConfig(config, cinfo.image_width, cinfo.image_height, 0,
+ SkBitmap::kA8_Config == config ?
+ kPremul_SkAlphaType : kOpaque_SkAlphaType);
}
/* image_width and image_height are the original dimensions, available
@@ -512,9 +512,9 @@ bool SkJPEGImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) {
if (SkImageDecoder::kDecodeBounds_Mode == mode && valid_output_dimensions(cinfo)) {
SkScaledBitmapSampler smpl(cinfo.output_width, cinfo.output_height,
recompute_sampleSize(sampleSize, cinfo));
- bm->setConfig(config, smpl.scaledWidth(), smpl.scaledHeight());
- bm->setIsOpaque(config != SkBitmap::kA8_Config);
- return true;
+ return bm->setConfig(config, smpl.scaledWidth(), smpl.scaledHeight(),
+ 0, SkBitmap::kA8_Config == config ?
+ kPremul_SkAlphaType : kOpaque_SkAlphaType);
} else {
return return_false(cinfo, *bm, "start_decompress");
}
@@ -527,8 +527,8 @@ bool SkJPEGImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) {
}
SkScaledBitmapSampler sampler(cinfo.output_width, cinfo.output_height, sampleSize);
- bm->setConfig(config, sampler.scaledWidth(), sampler.scaledHeight());
- bm->setIsOpaque(config != SkBitmap::kA8_Config);
+ bm->setConfig(config, sampler.scaledWidth(), sampler.scaledHeight(), 0,
+ SkBitmap::kA8_Config != config ? kOpaque_SkAlphaType : kPremul_SkAlphaType);
if (SkImageDecoder::kDecodeBounds_Mode == mode) {
return true;
}
@@ -742,8 +742,8 @@ bool SkJPEGImageDecoder::onDecodeSubset(SkBitmap* bm, const SkIRect& region) {
SkScaledBitmapSampler sampler(width, height, skiaSampleSize);
SkBitmap bitmap;
- bitmap.setConfig(config, sampler.scaledWidth(), sampler.scaledHeight());
- bitmap.setIsOpaque(true);
+ bitmap.setConfig(config, sampler.scaledWidth(), sampler.scaledHeight(), 0,
+ kOpaque_SkAlphaType);
// Check ahead of time if the swap(dest, src) is possible or not.
// If yes, then we will stick to AllocPixelRef since it's cheaper with the

Powered by Google App Engine
This is Rietveld 408576698