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

Unified Diff: src/images/SkImageRef.cpp

Issue 167763003: Fix issue in image decoders where the bitmap config was not properly set. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: comments Created 6 years, 10 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 | « src/images/SkImageDecoder_libpng.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkImageRef.cpp
diff --git a/src/images/SkImageRef.cpp b/src/images/SkImageRef.cpp
index ea129642db15617ccf4f2a1f23b96c2a2979d9de..f3cc9e55901395f9b9fafe5a2f1323de4775e532 100644
--- a/src/images/SkImageRef.cpp
+++ b/src/images/SkImageRef.cpp
@@ -30,6 +30,10 @@ SkImageRef::SkImageRef(const SkImageInfo& info, SkStreamRewindable* stream,
fPrev = fNext = NULL;
fFactory = NULL;
+ // This sets the colortype/alphatype to exactly match our info, so that this
+ // can get communicated down to the codec.
+ fBitmap.setConfig(info);
+
#ifdef DUMP_IMAGEREF_LIFECYCLE
SkDebugf("add ImageRef %p [%d] data=%d\n",
this, this->info().fColorType, (int)stream->getLength());
@@ -118,6 +122,12 @@ bool SkImageRef::prepareBitmap(SkImageDecoder::Mode mode) {
codec->setSampleSize(fSampleSize);
codec->setDitherImage(fDoDither);
if (this->onDecode(codec, fStream, &fBitmap, fBitmap.config(), mode)) {
+ if (kOpaque_SkAlphaType == fBitmap.alphaType()) {
+ this->changeAlphaType(kOpaque_SkAlphaType);
+ }
+ SkASSERT(this->info().fColorType == fBitmap.colorType());
+ SkASSERT(this->info().fWidth == fBitmap.width());
+ SkASSERT(this->info().fHeight == fBitmap.height());
return true;
}
}
@@ -178,6 +188,10 @@ SkImageRef::SkImageRef(SkReadBuffer& buffer, SkBaseMutex* mutex)
fPrev = fNext = NULL;
fFactory = NULL;
+
+ // This sets the colortype/alphatype to exactly match our info, so that this
+ // can get communicated down to the codec.
+ fBitmap.setConfig(this->info());
}
void SkImageRef::flatten(SkWriteBuffer& buffer) const {
« no previous file with comments | « src/images/SkImageDecoder_libpng.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698