aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/images
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-06 18:41:33 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-06 18:41:33 +0000
commit3e89524e747b513986abfeeea00b6fac79593f26 (patch)
tree2ccdbfb082b488e8a60749a07d778d9f82fac33c /src/images
parent332999eabf8738d3b34e91b4a2e92daf5c7d7573 (diff)
PixelRef now returns (nearly) everything that is currently in SkBitmap. The goal is to refactor bitmap later to remove redundancy, and more interestingly, remove the chance for a disconnect between the actual (pixelref) rowbytes and config, and the one claimed by the bitmap.
R=mtklein@google.com, scroggo@google.com Review URL: https://codereview.chromium.org/68973005 git-svn-id: http://skia.googlecode.com/svn/trunk@12537 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/images')
-rw-r--r--src/images/SkImageRef.cpp31
-rw-r--r--src/images/SkImageRef_GlobalPool.cpp6
2 files changed, 14 insertions, 23 deletions
diff --git a/src/images/SkImageRef.cpp b/src/images/SkImageRef.cpp
index 1a8284bdd4..99782c45c0 100644
--- a/src/images/SkImageRef.cpp
+++ b/src/images/SkImageRef.cpp
@@ -15,16 +15,14 @@
//#define DUMP_IMAGEREF_LIFECYCLE
-
///////////////////////////////////////////////////////////////////////////////
-SkImageRef::SkImageRef(SkStreamRewindable* stream, SkBitmap::Config config,
+SkImageRef::SkImageRef(const SkImageInfo& info, SkStreamRewindable* stream,
int sampleSize, SkBaseMutex* mutex)
- : SkPixelRef(mutex), fErrorInDecoding(false) {
+ : INHERITED(info, mutex), fErrorInDecoding(false) {
SkASSERT(stream);
stream->ref();
fStream = stream;
- fConfig = config;
fSampleSize = sampleSize;
fDoDither = true;
fPrev = fNext = NULL;
@@ -40,7 +38,7 @@ SkImageRef::~SkImageRef() {
#ifdef DUMP_IMAGEREF_LIFECYCLE
SkDebugf("delete ImageRef %p [%d] data=%d\n",
- this, fConfig, (int)fStream->getLength());
+ this, this->info().fColorType, (int)fStream->getLength());
#endif
fStream->unref();
@@ -92,14 +90,6 @@ bool SkImageRef::prepareBitmap(SkImageDecoder::Mode mode) {
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)) {
@@ -125,7 +115,7 @@ bool SkImageRef::prepareBitmap(SkImageDecoder::Mode mode) {
codec->setSampleSize(fSampleSize);
codec->setDitherImage(fDoDither);
- if (this->onDecode(codec, fStream, &fBitmap, fConfig, mode)) {
+ if (this->onDecode(codec, fStream, &fBitmap, fBitmap.config(), mode)) {
return true;
}
}
@@ -143,15 +133,18 @@ bool SkImageRef::prepareBitmap(SkImageDecoder::Mode mode) {
return false;
}
-void* SkImageRef::onLockPixels(SkColorTable** ct) {
+bool SkImageRef::onNewLockPixels(LockRec* rec) {
if (NULL == fBitmap.getPixels()) {
(void)this->prepareBitmap(SkImageDecoder::kDecodePixels_Mode);
}
- if (ct) {
- *ct = fBitmap.getColorTable();
+ if (NULL == fBitmap.getPixels()) {
+ return false;
}
- return fBitmap.getPixels();
+ rec->fPixels = fBitmap.getPixels();
+ rec->fColorTable = NULL;
+ rec->fRowBytes = fBitmap.rowBytes();
+ return true;
}
size_t SkImageRef::ramUsed() const {
@@ -170,7 +163,6 @@ size_t SkImageRef::ramUsed() const {
SkImageRef::SkImageRef(SkFlattenableReadBuffer& buffer, SkBaseMutex* mutex)
: INHERITED(buffer, mutex), fErrorInDecoding(false) {
- fConfig = (SkBitmap::Config)buffer.readUInt();
fSampleSize = buffer.readInt();
fDoDither = buffer.readBool();
@@ -185,7 +177,6 @@ SkImageRef::SkImageRef(SkFlattenableReadBuffer& buffer, SkBaseMutex* mutex)
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.
diff --git a/src/images/SkImageRef_GlobalPool.cpp b/src/images/SkImageRef_GlobalPool.cpp
index 352dd42d9f..f91cebabbf 100644
--- a/src/images/SkImageRef_GlobalPool.cpp
+++ b/src/images/SkImageRef_GlobalPool.cpp
@@ -24,10 +24,10 @@ static SkImageRefPool* GetGlobalPool() {
return gPool;
}
-SkImageRef_GlobalPool::SkImageRef_GlobalPool(SkStreamRewindable* stream,
- SkBitmap::Config config,
+SkImageRef_GlobalPool::SkImageRef_GlobalPool(const SkImageInfo& info,
+ SkStreamRewindable* stream,
int sampleSize)
- : SkImageRef(stream, config, sampleSize, &gGlobalPoolMutex) {
+ : SkImageRef(info, stream, sampleSize, &gGlobalPoolMutex) {
SkASSERT(&gGlobalPoolMutex == this->mutex());
SkAutoMutexAcquire ac(gGlobalPoolMutex);
GetGlobalPool()->addToHead(this);