aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkPixelRef.cpp
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-11 20:55:41 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-12-11 20:55:41 +0000
commitff9c6c92e5f962b34f7421e67ac112f81a018bd3 (patch)
treedcdc55d3965c58fc74cb8477c841228fd0e9a835 /src/core/SkPixelRef.cpp
parent7dd5d6e5d72a9e59fe3c2c7cb9e33bdefb8ba072 (diff)
Reason for revert: breaks chrome-mac-tests TBR= NOTREECHECKS=true NOTRY=true Author: reed@google.com Review URL: https://codereview.chromium.org/113193003 git-svn-id: http://skia.googlecode.com/svn/trunk@12629 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkPixelRef.cpp')
-rw-r--r--src/core/SkPixelRef.cpp84
1 files changed, 30 insertions, 54 deletions
diff --git a/src/core/SkPixelRef.cpp b/src/core/SkPixelRef.cpp
index 60b5cfb26c..b5daf0b57a 100644
--- a/src/core/SkPixelRef.cpp
+++ b/src/core/SkPixelRef.cpp
@@ -82,32 +82,44 @@ void SkPixelRef::setMutex(SkBaseMutex* mutex) {
// just need a > 0 value, so pick a funny one to aid in debugging
#define SKPIXELREF_PRELOCKED_LOCKCOUNT 123456789
-SkPixelRef::SkPixelRef(const SkImageInfo& info) {
+SkPixelRef::SkPixelRef(const SkImageInfo&, SkBaseMutex* mutex) {
+ this->setMutex(mutex);
+ fPixels = NULL;
+ fColorTable = NULL; // we do not track ownership of this
+ fLockCount = 0;
+ this->needsNewGenID();
+ fIsImmutable = false;
+ fPreLocked = false;
+}
+
+SkPixelRef::SkPixelRef(const SkImageInfo&) {
this->setMutex(NULL);
- fInfo = info;
- fRec.zero();
+ fPixels = NULL;
+ fColorTable = NULL; // we do not track ownership of this
fLockCount = 0;
this->needsNewGenID();
fIsImmutable = false;
fPreLocked = false;
}
-SkPixelRef::SkPixelRef(const SkImageInfo& info, SkBaseMutex* mutex) {
+#ifdef SK_SUPPORT_LEGACY_PIXELREF_CONSTRUCTOR
+// THIS GUY IS DEPRECATED -- don't use me!
+SkPixelRef::SkPixelRef(SkBaseMutex* mutex) {
this->setMutex(mutex);
- fInfo = info;
- fRec.zero();
+ fPixels = NULL;
+ fColorTable = NULL; // we do not track ownership of this
fLockCount = 0;
this->needsNewGenID();
fIsImmutable = false;
fPreLocked = false;
}
+#endif
SkPixelRef::SkPixelRef(SkFlattenableReadBuffer& buffer, SkBaseMutex* mutex)
: INHERITED(buffer) {
this->setMutex(mutex);
-
- fInfo.unflatten(buffer);
- fRec.zero();
+ fPixels = NULL;
+ fColorTable = NULL; // we do not track ownership of this
fLockCount = 0;
fIsImmutable = buffer.readBool();
fGenerationID = buffer.readUInt();
@@ -131,13 +143,12 @@ void SkPixelRef::cloneGenID(const SkPixelRef& that) {
that.fUniqueGenerationID = false;
}
-void SkPixelRef::setPreLocked(void* pixels, size_t rowBytes, SkColorTable* ctable) {
+void SkPixelRef::setPreLocked(void* pixels, SkColorTable* ctable) {
#ifndef SK_IGNORE_PIXELREF_SETPRELOCKED
// only call me in your constructor, otherwise fLockCount tracking can get
// out of sync.
- fRec.fPixels = pixels;
- fRec.fColorTable = ctable;
- fRec.fRowBytes = rowBytes;
+ fPixels = pixels;
+ fColorTable = ctable;
fLockCount = SKPIXELREF_PRELOCKED_LOCKCOUNT;
fPreLocked = true;
#endif
@@ -145,8 +156,6 @@ void SkPixelRef::setPreLocked(void* pixels, size_t rowBytes, SkColorTable* ctabl
void SkPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
-
- fInfo.flatten(buffer);
buffer.writeBool(fIsImmutable);
// We write the gen ID into the picture for within-process recording. This
// is safe since the same genID will never refer to two different sets of
@@ -161,27 +170,16 @@ void SkPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const {
}
}
-bool SkPixelRef::lockPixels(LockRec* rec) {
+void SkPixelRef::lockPixels() {
SkASSERT(!fPreLocked || SKPIXELREF_PRELOCKED_LOCKCOUNT == fLockCount);
-
+
if (!fPreLocked) {
SkAutoMutexAcquire ac(*fMutex);
-
+
if (1 == ++fLockCount) {
- LockRec rec;
- if (!this->onNewLockPixels(&rec)) {
- return false;
- }
- fRec = rec;
+ fPixels = this->onLockPixels(&fColorTable);
}
}
- *rec = fRec;
- return true;
-}
-
-bool SkPixelRef::lockPixels() {
- LockRec rec;
- return this->lockPixels(&rec);
}
void SkPixelRef::unlockPixels() {
@@ -193,7 +191,8 @@ void SkPixelRef::unlockPixels() {
SkASSERT(fLockCount > 0);
if (0 == --fLockCount) {
this->onUnlockPixels();
- fRec.zero();
+ fPixels = NULL;
+ fColorTable = NULL;
}
}
}
@@ -274,29 +273,6 @@ size_t SkPixelRef::getAllocatedSizeInBytes() const {
///////////////////////////////////////////////////////////////////////////////
-#ifdef SK_SUPPORT_LEGACY_ONLOCKPIXELS
-
-void* SkPixelRef::onLockPixels(SkColorTable** ctable) {
- return NULL;
-}
-
-bool SkPixelRef::onNewLockPixels(LockRec* rec) {
- SkColorTable* ctable;
- void* pixels = this->onLockPixels(&ctable);
- if (!pixels) {
- return false;
- }
-
- rec->fPixels = pixels;
- rec->fColorTable = ctable;
- rec->fRowBytes = 0; // callers don't currently need this (thank goodness)
- return true;
-}
-
-#endif
-
-///////////////////////////////////////////////////////////////////////////////
-
#ifdef SK_BUILD_FOR_ANDROID
void SkPixelRef::globalRef(void* data) {
this->ref();