Reason for revert: Failing assert on Android R=scroggo@google.com, halcanary@google.com, reed@google.com, rmistry@google.com TBR=halcanary@google.com, reed@google.com, scroggo@google.com NOTREECHECKS=true NOTRY=true Author: robertphillips@google.com Review URL: https://codereview.chromium.org/93673005 git-svn-id: http://skia.googlecode.com/svn/trunk@12646 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
7eee8d60b9
commit
281713e4d4
@ -244,15 +244,10 @@ protected:
|
|||||||
acquire a mutex for thread safety, so this method need not do that.
|
acquire a mutex for thread safety, so this method need not do that.
|
||||||
*/
|
*/
|
||||||
virtual void* onLockPixels(SkColorTable**) = 0;
|
virtual void* onLockPixels(SkColorTable**) = 0;
|
||||||
|
/** Called when the lock count goes from 1 to 0. The caller will have
|
||||||
/**
|
already acquire a mutex for thread safety, so this method need not do
|
||||||
* Called when the lock count goes from 1 to 0. The caller will have
|
that.
|
||||||
* already acquire a mutex for thread safety, so this method need not do
|
*/
|
||||||
* that.
|
|
||||||
*
|
|
||||||
* If the previous call to onLockPixels failed (i.e. returned NULL), then
|
|
||||||
* the onUnlockPixels will NOT be called.
|
|
||||||
*/
|
|
||||||
virtual void onUnlockPixels() = 0;
|
virtual void onUnlockPixels() = 0;
|
||||||
|
|
||||||
/** Default impl returns true */
|
/** Default impl returns true */
|
||||||
|
@ -182,10 +182,6 @@ void SkPixelRef::lockPixels() {
|
|||||||
|
|
||||||
if (1 == ++fLockCount) {
|
if (1 == ++fLockCount) {
|
||||||
fPixels = this->onLockPixels(&fColorTable);
|
fPixels = this->onLockPixels(&fColorTable);
|
||||||
// If onLockPixels failed, it will return NULL
|
|
||||||
if (NULL == fPixels) {
|
|
||||||
fColorTable = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -198,14 +194,9 @@ void SkPixelRef::unlockPixels() {
|
|||||||
|
|
||||||
SkASSERT(fLockCount > 0);
|
SkASSERT(fLockCount > 0);
|
||||||
if (0 == --fLockCount) {
|
if (0 == --fLockCount) {
|
||||||
// don't call onUnlockPixels unless onLockPixels succeeded
|
this->onUnlockPixels();
|
||||||
if (fPixels) {
|
fPixels = NULL;
|
||||||
this->onUnlockPixels();
|
fColorTable = NULL;
|
||||||
fPixels = NULL;
|
|
||||||
fColorTable = NULL;
|
|
||||||
} else {
|
|
||||||
SkASSERT(NULL == fColorTable);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -209,6 +209,7 @@ private:
|
|||||||
SkDiscardableMemory* fDM;
|
SkDiscardableMemory* fDM;
|
||||||
size_t fRB;
|
size_t fRB;
|
||||||
bool fFirstTime;
|
bool fFirstTime;
|
||||||
|
bool fIsLocked;
|
||||||
|
|
||||||
typedef SkPixelRef INHERITED;
|
typedef SkPixelRef INHERITED;
|
||||||
};
|
};
|
||||||
@ -224,6 +225,7 @@ SkOneShotDiscardablePixelRef::SkOneShotDiscardablePixelRef(const SkImageInfo& in
|
|||||||
|
|
||||||
SkASSERT(dm->data());
|
SkASSERT(dm->data());
|
||||||
fFirstTime = true;
|
fFirstTime = true;
|
||||||
|
fIsLocked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkOneShotDiscardablePixelRef::~SkOneShotDiscardablePixelRef() {
|
SkOneShotDiscardablePixelRef::~SkOneShotDiscardablePixelRef() {
|
||||||
@ -233,16 +235,21 @@ SkOneShotDiscardablePixelRef::~SkOneShotDiscardablePixelRef() {
|
|||||||
void* SkOneShotDiscardablePixelRef::onLockPixels(SkColorTable** ctable) {
|
void* SkOneShotDiscardablePixelRef::onLockPixels(SkColorTable** ctable) {
|
||||||
if (fFirstTime) {
|
if (fFirstTime) {
|
||||||
// we're already locked
|
// we're already locked
|
||||||
SkASSERT(fDM->data());
|
|
||||||
fFirstTime = false;
|
fFirstTime = false;
|
||||||
return fDM->data();
|
return fDM->data();
|
||||||
}
|
}
|
||||||
return fDM->lock() ? fDM->data() : NULL;
|
|
||||||
|
SkASSERT(!fIsLocked);
|
||||||
|
fIsLocked = fDM->lock();
|
||||||
|
return fIsLocked ? fDM->data() : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkOneShotDiscardablePixelRef::onUnlockPixels() {
|
void SkOneShotDiscardablePixelRef::onUnlockPixels() {
|
||||||
SkASSERT(!fFirstTime);
|
SkASSERT(!fFirstTime);
|
||||||
fDM->unlock();
|
if (fIsLocked) {
|
||||||
|
fIsLocked = false;
|
||||||
|
fDM->unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SkOneShotDiscardablePixelRef::getAllocatedSizeInBytes() const {
|
size_t SkOneShotDiscardablePixelRef::getAllocatedSizeInBytes() const {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2011 Google Inc.
|
* Copyright 2011 Google Inc.
|
||||||
*
|
*
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "SkImageRef_ashmem.h"
|
#include "SkImageRef_ashmem.h"
|
||||||
#include "SkImageDecoder.h"
|
#include "SkImageDecoder.h"
|
||||||
#include "SkFlattenableBuffers.h"
|
#include "SkFlattenableBuffers.h"
|
||||||
|
@ -90,7 +90,9 @@ void* SkCachingPixelRef::onLockPixels(SkColorTable** colorTable) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SkCachingPixelRef::onUnlockPixels() {
|
void SkCachingPixelRef::onUnlockPixels() {
|
||||||
SkASSERT(fScaledCacheId != NULL);
|
if (fScaledCacheId != NULL) {
|
||||||
SkScaledImageCache::Unlock( static_cast<SkScaledImageCache::ID*>(fScaledCacheId));
|
SkScaledImageCache::Unlock(
|
||||||
fScaledCacheId = NULL;
|
static_cast<SkScaledImageCache::ID*>(fScaledCacheId));
|
||||||
|
fScaledCacheId = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,9 @@ void* SkDiscardablePixelRef::onLockPixels(SkColorTable**) {
|
|||||||
return pixels;
|
return pixels;
|
||||||
}
|
}
|
||||||
void SkDiscardablePixelRef::onUnlockPixels() {
|
void SkDiscardablePixelRef::onUnlockPixels() {
|
||||||
fDiscardableMemory->unlock();
|
if (fDiscardableMemory != NULL) {
|
||||||
|
fDiscardableMemory->unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkInstallDiscardablePixelRef(SkImageGenerator* generator,
|
bool SkInstallDiscardablePixelRef(SkImageGenerator* generator,
|
||||||
|
Loading…
Reference in New Issue
Block a user