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

Unified Diff: src/images/SkImageRef.cpp

Issue 112603003: Reverting r12665 & r12666 (Remove duplicate impl for SkImageInfo flattening) due to Chromium/Blink … (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years 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/image/SkSurface_Raster.cpp ('k') | src/images/SkImageRef_GlobalPool.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkImageRef.cpp
===================================================================
--- src/images/SkImageRef.cpp (revision 12666)
+++ src/images/SkImageRef.cpp (working copy)
@@ -15,14 +15,16 @@
//#define DUMP_IMAGEREF_LIFECYCLE
+
///////////////////////////////////////////////////////////////////////////////
-SkImageRef::SkImageRef(const SkImageInfo& info, SkStreamRewindable* stream,
+SkImageRef::SkImageRef(SkStreamRewindable* stream, SkBitmap::Config config,
int sampleSize, SkBaseMutex* mutex)
- : INHERITED(info, mutex), fErrorInDecoding(false) {
+ : SkPixelRef(mutex), fErrorInDecoding(false) {
SkASSERT(stream);
stream->ref();
fStream = stream;
+ fConfig = config;
fSampleSize = sampleSize;
fDoDither = true;
fPrev = fNext = NULL;
@@ -38,7 +40,7 @@
#ifdef DUMP_IMAGEREF_LIFECYCLE
SkDebugf("delete ImageRef %p [%d] data=%d\n",
- this, this->info().fColorType, (int)fStream->getLength());
+ this, fConfig, (int)fStream->getLength());
#endif
fStream->unref();
@@ -90,6 +92,14 @@
return false;
}
+ /* As soon as we really know our config, we record it, so that on
+ subsequent calls to the codec, we are sure we will always get the same
+ result.
+ */
+ if (SkBitmap::kNo_Config != fBitmap.config()) {
+ fConfig = fBitmap.config();
+ }
+
if (NULL != fBitmap.getPixels() ||
(SkBitmap::kNo_Config != fBitmap.config() &&
SkImageDecoder::kDecodeBounds_Mode == mode)) {
@@ -115,7 +125,7 @@
codec->setSampleSize(fSampleSize);
codec->setDitherImage(fDoDither);
- if (this->onDecode(codec, fStream, &fBitmap, fBitmap.config(), mode)) {
+ if (this->onDecode(codec, fStream, &fBitmap, fConfig, mode)) {
return true;
}
}
@@ -133,18 +143,15 @@
return false;
}
-bool SkImageRef::onNewLockPixels(LockRec* rec) {
+void* SkImageRef::onLockPixels(SkColorTable** ct) {
if (NULL == fBitmap.getPixels()) {
(void)this->prepareBitmap(SkImageDecoder::kDecodePixels_Mode);
}
- if (NULL == fBitmap.getPixels()) {
- return false;
+ if (ct) {
+ *ct = fBitmap.getColorTable();
}
- rec->fPixels = fBitmap.getPixels();
- rec->fColorTable = NULL;
- rec->fRowBytes = fBitmap.rowBytes();
- return true;
+ return fBitmap.getPixels();
}
size_t SkImageRef::ramUsed() const {
@@ -163,6 +170,7 @@
SkImageRef::SkImageRef(SkFlattenableReadBuffer& buffer, SkBaseMutex* mutex)
: INHERITED(buffer, mutex), fErrorInDecoding(false) {
+ fConfig = (SkBitmap::Config)buffer.readUInt();
fSampleSize = buffer.readInt();
fDoDither = buffer.readBool();
@@ -177,6 +185,7 @@
void SkImageRef::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
+ buffer.writeUInt(fConfig);
buffer.writeInt(fSampleSize);
buffer.writeBool(fDoDither);
// FIXME: Consider moving this logic should go into writeStream itself.
« no previous file with comments | « src/image/SkSurface_Raster.cpp ('k') | src/images/SkImageRef_GlobalPool.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698