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

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, 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_libjpeg.cpp
diff --git a/src/images/SkImageDecoder_libjpeg.cpp b/src/images/SkImageDecoder_libjpeg.cpp
index 52c7483d7cc05def1d59ff9f573c65552e7907c4..67b17823e262bba903fbd55a4e437efbce5dfd8d 100644
--- a/src/images/SkImageDecoder_libjpeg.cpp
+++ b/src/images/SkImageDecoder_libjpeg.cpp
@@ -543,9 +543,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
@@ -565,9 +565,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");
}
@@ -580,8 +580,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;
}
@@ -801,8 +801,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