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:
commit-bot@chromium.org 2013-12-12 18:08:08 +00:00
parent 7eee8d60b9
commit 281713e4d4
6 changed files with 26 additions and 29 deletions

View File

@ -244,15 +244,10 @@ protected:
acquire a mutex for thread safety, so this method need not do that.
*/
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
* that.
*
* If the previous call to onLockPixels failed (i.e. returned NULL), then
* the onUnlockPixels will NOT be called.
*/
/** 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
that.
*/
virtual void onUnlockPixels() = 0;
/** Default impl returns true */

View File

@ -182,10 +182,6 @@ void SkPixelRef::lockPixels() {
if (1 == ++fLockCount) {
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);
if (0 == --fLockCount) {
// don't call onUnlockPixels unless onLockPixels succeeded
if (fPixels) {
this->onUnlockPixels();
fPixels = NULL;
fColorTable = NULL;
} else {
SkASSERT(NULL == fColorTable);
}
this->onUnlockPixels();
fPixels = NULL;
fColorTable = NULL;
}
}
}

View File

@ -209,6 +209,7 @@ private:
SkDiscardableMemory* fDM;
size_t fRB;
bool fFirstTime;
bool fIsLocked;
typedef SkPixelRef INHERITED;
};
@ -224,6 +225,7 @@ SkOneShotDiscardablePixelRef::SkOneShotDiscardablePixelRef(const SkImageInfo& in
SkASSERT(dm->data());
fFirstTime = true;
fIsLocked = false;
}
SkOneShotDiscardablePixelRef::~SkOneShotDiscardablePixelRef() {
@ -233,16 +235,21 @@ SkOneShotDiscardablePixelRef::~SkOneShotDiscardablePixelRef() {
void* SkOneShotDiscardablePixelRef::onLockPixels(SkColorTable** ctable) {
if (fFirstTime) {
// we're already locked
SkASSERT(fDM->data());
fFirstTime = false;
return fDM->data();
}
return fDM->lock() ? fDM->data() : NULL;
SkASSERT(!fIsLocked);
fIsLocked = fDM->lock();
return fIsLocked ? fDM->data() : NULL;
}
void SkOneShotDiscardablePixelRef::onUnlockPixels() {
SkASSERT(!fFirstTime);
fDM->unlock();
if (fIsLocked) {
fIsLocked = false;
fDM->unlock();
}
}
size_t SkOneShotDiscardablePixelRef::getAllocatedSizeInBytes() const {

View File

@ -1,10 +1,10 @@
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkImageRef_ashmem.h"
#include "SkImageDecoder.h"
#include "SkFlattenableBuffers.h"

View File

@ -90,7 +90,9 @@ void* SkCachingPixelRef::onLockPixels(SkColorTable** colorTable) {
}
void SkCachingPixelRef::onUnlockPixels() {
SkASSERT(fScaledCacheId != NULL);
SkScaledImageCache::Unlock( static_cast<SkScaledImageCache::ID*>(fScaledCacheId));
fScaledCacheId = NULL;
if (fScaledCacheId != NULL) {
SkScaledImageCache::Unlock(
static_cast<SkScaledImageCache::ID*>(fScaledCacheId));
fScaledCacheId = NULL;
}
}

View File

@ -58,7 +58,9 @@ void* SkDiscardablePixelRef::onLockPixels(SkColorTable**) {
return pixels;
}
void SkDiscardablePixelRef::onUnlockPixels() {
fDiscardableMemory->unlock();
if (fDiscardableMemory != NULL) {
fDiscardableMemory->unlock();
}
}
bool SkInstallDiscardablePixelRef(SkImageGenerator* generator,