aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-09-09 14:44:15 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-09-09 14:44:15 +0000
commit9fbcad0f00d7098574cf3394a812c9d845c9cc5b (patch)
tree7cc1373d7288d7ba373caf108745e9aa311fc838
parent3590a248bb110a5346b6e2cbdda5cc3345cbe01b (diff)
Removed old resource locking system
-rw-r--r--include/gpu/GrContext.h37
-rw-r--r--src/gpu/GrContext.cpp63
-rw-r--r--src/gpu/GrGpu.cpp6
-rw-r--r--src/gpu/GrRenderTarget.cpp5
-rw-r--r--src/gpu/GrResourceCache.cpp115
-rw-r--r--src/gpu/GrResourceCache.h38
-rw-r--r--src/gpu/GrStencilBuffer.cpp4
-rw-r--r--src/gpu/GrStencilBuffer.h5
-rw-r--r--src/gpu/SkGr.cpp17
-rw-r--r--src/gpu/SkGrPixelRef.cpp2
-rw-r--r--src/gpu/effects/GrTextureStripAtlas.cpp5
-rw-r--r--src/gpu/gl/GrGpuGL.cpp2
12 files changed, 84 insertions, 215 deletions
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index 76cba9aff0..53c6cb73af 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -110,10 +110,10 @@ public:
* @param rowBytes The number of bytes between rows of the texture. Zero
* implies tightly packed rows.
*/
- GrTexture* createAndLockTexture(const GrTextureParams* params,
- const GrTextureDesc& desc,
- const GrCacheData& cacheData,
- void* srcData, size_t rowBytes);
+ GrTexture* createTexture(const GrTextureParams* params,
+ const GrTextureDesc& desc,
+ const GrCacheData& cacheData,
+ void* srcData, size_t rowBytes);
/**
* Look for a texture that matches 'key' in the cache. If not found,
@@ -122,9 +122,8 @@ public:
GrTexture* findTexture(const GrCacheKey& key);
/**
- * Search for an entry based on key and dimensions. If found, "lock" it and
+ * Search for an entry based on key and dimensions. If found,
* return it. The return value will be NULL if not found.
- * Must be balanced with an unlockTexture() call.
*
* @param desc Description of the texture properties.
* @param cacheData Cache-specific properties (e.g., texture gen ID)
@@ -133,9 +132,9 @@ public:
* for different wrap modes on GPUs with limited NPOT
* texture support). NULL implies clamp wrap modes.
*/
- GrTexture* findAndLockTexture(const GrTextureDesc& desc,
- const GrCacheData& cacheData,
- const GrTextureParams* params);
+ GrTexture* findTexture(const GrTextureDesc& desc,
+ const GrCacheData& cacheData,
+ const GrTextureParams* params);
/**
* Determines whether a texture is in the cache. If the texture is found it
* will not be locked or returned. This call does not affect the priority of
@@ -181,20 +180,17 @@ public:
ScratchTexMatch match);
/**
- * Make a texture un-purgeable in the cache
- */
- void lockTexture(GrTexture* texture);
-
- /**
* When done with an entry, call unlockTexture(entry) on it, which returns
* it to the cache, where it may be purged.
*/
- void unlockTexture(GrTexture* texture);
+ void unlockScratchTexture(GrTexture* texture);
/**
* This method should be called whenever a GrTexture is unreffed or
* switched from exclusive to non-exclusive. This
* gives the resource cache a chance to discard unneeded textures.
+ * Note: this entry point will be removed once totally ref-driven
+ * cache maintenance is implemented
*/
void purgeCache();
@@ -767,14 +763,11 @@ public:
/**
* Stencil buffers add themselves to the cache using
- * addAndLockStencilBuffer. When a SB's RT-attachment count
- * reaches zero the SB unlocks itself using unlockStencilBuffer and is
- * eligible for purging. findAndLockStencilBuffer is called to check the
+ * addStencilBuffer. findStencilBuffer is called to check the
* cache for a SB that matches an RT's criteria.
*/
- void addAndLockStencilBuffer(GrStencilBuffer* sb);
- void unlockStencilBuffer(GrStencilBuffer* sb);
- GrStencilBuffer* findAndLockStencilBuffer(int width, int height, int sampleCnt);
+ void addStencilBuffer(GrStencilBuffer* sb);
+ GrStencilBuffer* findStencilBuffer(int width, int height, int sampleCnt);
GrPathRenderer* getPathRenderer(const SkPath& path,
GrPathFill fill,
@@ -875,7 +868,7 @@ public:
void reset() {
if (NULL != fContext && NULL != fTexture) {
- fContext->unlockTexture(fTexture);
+ fContext->unlockScratchTexture(fTexture);
fTexture = NULL;
}
}
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 9b01eb27e2..4599990f5b 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -212,11 +212,11 @@ GrTexture* GrContext::findTexture(const GrCacheKey& key) {
return static_cast<GrTexture*>(fTextureCache->find(key.key()));
}
-GrTexture* GrContext::findAndLockTexture(const GrTextureDesc& desc,
- const GrCacheData& cacheData,
- const GrTextureParams* params) {
+GrTexture* GrContext::findTexture(const GrTextureDesc& desc,
+ const GrCacheData& cacheData,
+ const GrTextureParams* params) {
GrResourceKey resourceKey = GrTexture::ComputeKey(fGpu, params, desc, cacheData, false);
- GrResource* resource = fTextureCache->findAndLock(resourceKey);
+ GrResource* resource = fTextureCache->find(resourceKey);
return static_cast<GrTexture*>(resource);
}
@@ -227,41 +227,24 @@ bool GrContext::isTextureInCache(const GrTextureDesc& desc,
return fTextureCache->hasKey(resourceKey);
}
-void GrContext::addAndLockStencilBuffer(GrStencilBuffer* sb) {
+void GrContext::addStencilBuffer(GrStencilBuffer* sb) {
ASSERT_OWNED_RESOURCE(sb);
GrResourceKey resourceKey = GrStencilBuffer::ComputeKey(sb->width(),
sb->height(),
sb->numSamples());
- fTextureCache->createAndLock(resourceKey, sb);
+ fTextureCache->create(resourceKey, sb);
}
-GrStencilBuffer* GrContext::findAndLockStencilBuffer(int width, int height,
+GrStencilBuffer* GrContext::findStencilBuffer(int width, int height,
int sampleCnt) {
GrResourceKey resourceKey = GrStencilBuffer::ComputeKey(width,
height,
sampleCnt);
- GrResource* resource = fTextureCache->findAndLock(resourceKey);
+ GrResource* resource = fTextureCache->find(resourceKey);
return static_cast<GrStencilBuffer*>(resource);
}
-void GrContext::unlockStencilBuffer(GrStencilBuffer* sb) {
-
- if (NULL == sb->getCacheEntry()) {
- // This can happen when the GrResourceCache is being deleted. If
- // a stencil buffer was evicted before its reffing render targets,
- // the render targets will attempt to unlock the stencil buffer
- // when they are deleted.
- return;
- }
-
- // If the texture cache still exists we know the GrGpu & GrContext still
- // exist so we can verify ownership.
- ASSERT_OWNED_RESOURCE(sb);
-
- fTextureCache->unlock(sb->getCacheEntry());
-}
-
static void stretchImage(void* dst,
int dstW,
int dstH,
@@ -296,10 +279,12 @@ GrTexture* GrContext::createResizedTexture(const GrTextureDesc& desc,
void* srcData,
size_t rowBytes,
bool needsFiltering) {
- GrTexture* clampedTexture = this->findAndLockTexture(desc, cacheData, NULL);
+ SkAutoTUnref<GrTexture> clampedTexture(this->findTexture(desc, cacheData, NULL));
if (NULL == clampedTexture) {
- clampedTexture = this->createAndLockTexture(NULL, desc, cacheData, srcData, rowBytes);
+ clampedTexture.reset(
+ this->createTexture(NULL, desc, cacheData, srcData, rowBytes));
+
GrAssert(NULL != clampedTexture);
if (NULL == clampedTexture) {
return NULL;
@@ -365,12 +350,11 @@ GrTexture* GrContext::createResizedTexture(const GrTextureDesc& desc,
stretchedRowBytes);
GrAssert(NULL != texture);
}
- this->unlockTexture(clampedTexture);
return texture;
}
-GrTexture* GrContext::createAndLockTexture(
+GrTexture* GrContext::createTexture(
const GrTextureParams* params,
const GrTextureDesc& desc,
const GrCacheData& cacheData,
@@ -394,7 +378,7 @@ GrTexture* GrContext::createAndLockTexture(
}
if (NULL != texture) {
- fTextureCache->createAndLock(resourceKey, texture);
+ fTextureCache->create(resourceKey, texture);
}
return texture;
@@ -423,7 +407,7 @@ GrTexture* GrContext::lockScratchTexture(const GrTextureDesc& inDesc,
do {
GrResourceKey key = GrTexture::ComputeKey(fGpu, NULL, desc, cacheData, true);
- resource = fTextureCache->findAndLock(key);
+ resource = fTextureCache->find(key);
// if we miss, relax the fit of the flags...
// then try doubling width... then height.
if (NULL != resource || kExact_ScratchTexMatch == match) {
@@ -459,7 +443,7 @@ GrTexture* GrContext::lockScratchTexture(const GrTextureDesc& inDesc,
texture->desc(),
cacheData,
true);
- fTextureCache->createAndLock(key, texture);
+ fTextureCache->create(key, texture);
resource = texture;
}
}
@@ -492,23 +476,11 @@ void GrContext::addExistingTextureToCache(GrTexture* texture) {
// still be in the exclusive pile
fTextureCache->makeNonExclusive(texture->getCacheEntry());
- // and it should still be locked
- fTextureCache->unlock(texture->getCacheEntry());
this->purgeCache();
}
-void GrContext::lockTexture(GrTexture* texture) {
-
- if (NULL == texture->getCacheEntry()) {
- // not in the cache
- GrAssert(0);
- return;
- }
-
- fTextureCache->lock(texture->getCacheEntry());
-}
-void GrContext::unlockTexture(GrTexture* texture) {
+void GrContext::unlockScratchTexture(GrTexture* texture) {
ASSERT_OWNED_RESOURCE(texture);
GrAssert(NULL != texture->getCacheEntry());
@@ -519,7 +491,6 @@ void GrContext::unlockTexture(GrTexture* texture) {
fTextureCache->makeNonExclusive(texture->getCacheEntry());
}
- fTextureCache->unlock(texture->getCacheEntry());
this->purgeCache();
}
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index fae9d992f1..514d176afc 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -144,9 +144,9 @@ GrTexture* GrGpu::createTexture(const GrTextureDesc& desc,
bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt) {
GrAssert(NULL == rt->getStencilBuffer());
GrStencilBuffer* sb =
- this->getContext()->findAndLockStencilBuffer(rt->width(),
- rt->height(),
- rt->numSamples());
+ this->getContext()->findStencilBuffer(rt->width(),
+ rt->height(),
+ rt->numSamples());
if (NULL != sb) {
rt->setStencilBuffer(sb);
bool attached = this->attachStencilBufferToRenderTarget(sb, rt);
diff --git a/src/gpu/GrRenderTarget.cpp b/src/gpu/GrRenderTarget.cpp
index f8f9e3c796..0d36fd0319 100644
--- a/src/gpu/GrRenderTarget.cpp
+++ b/src/gpu/GrRenderTarget.cpp
@@ -96,11 +96,12 @@ void GrRenderTarget::overrideResolveRect(const GrIRect rect) {
void GrRenderTarget::setStencilBuffer(GrStencilBuffer* stencilBuffer) {
if (NULL != fStencilBuffer) {
+ fStencilBuffer->unref();
+
GrContext* context = this->getContext();
if (NULL != context) {
- context->unlockStencilBuffer(fStencilBuffer);
+ context->purgeCache();
}
- fStencilBuffer->unref();
if (NULL != context) {
context->purgeCache();
diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp
index b567ecb07d..89fce55f70 100644
--- a/src/gpu/GrResourceCache.cpp
+++ b/src/gpu/GrResourceCache.cpp
@@ -13,8 +13,6 @@
GrResourceEntry::GrResourceEntry(const GrResourceKey& key, GrResource* resource)
: fKey(key), fResource(resource) {
- fLockCount = 0;
-
// we assume ownership of the resource, and will unref it when we die
GrAssert(resource);
resource->ref();
@@ -27,7 +25,6 @@ GrResourceEntry::~GrResourceEntry() {
#if GR_DEBUG
void GrResourceEntry::validate() const {
- GrAssert(fLockCount >= 0);
GrAssert(fResource);
GrAssert(fResource->getCacheEntry() == this);
fResource->validate();
@@ -71,14 +68,12 @@ GrResourceCache::GrResourceCache(int maxCount, size_t maxBytes) :
fMaxBytes(maxBytes) {
#if GR_CACHE_STATS
fHighWaterEntryCount = 0;
- fHighWaterUnlockedEntryCount = 0;
fHighWaterEntryBytes = 0;
fHighWaterClientDetachedCount = 0;
fHighWaterClientDetachedBytes = 0;
#endif
fEntryCount = 0;
- fUnlockedEntryCount = 0;
fEntryBytes = 0;
fClientDetachedCount = 0;
fClientDetachedBytes = 0;
@@ -129,10 +124,6 @@ void GrResourceCache::internalDetach(GrResourceEntry* entry,
bool clientDetach) {
fList.remove(entry);
- if (!entry->isLocked()) {
- --fUnlockedEntryCount;
- }
-
// update our stats
if (clientDetach) {
fClientDetachedCount += 1;
@@ -157,15 +148,6 @@ void GrResourceCache::attachToHead(GrResourceEntry* entry,
bool clientReattach) {
fList.addToHead(entry);
- if (!entry->isLocked()) {
- ++fUnlockedEntryCount;
-#if GR_CACHE_STATS
- if (fHighWaterUnlockedEntryCount < fUnlockedEntryCount) {
- fHighWaterUnlockedEntryCount = fUnlockedEntryCount;
- }
-#endif
- }
-
// update our stats
if (clientReattach) {
fClientDetachedCount -= 1;
@@ -193,22 +175,9 @@ GrResource* GrResourceCache::find(const GrResourceKey& key) {
return NULL;
}
- return entry->fResource;
-}
-
-GrResource* GrResourceCache::findAndLock(const GrResourceKey& key) {
- GrAutoResourceCacheValidate atcv(this);
-
- GrResourceEntry* entry = fCache.find(key);
- if (NULL == entry) {
- return NULL;
- }
-
this->internalDetach(entry, false);
this->attachToHead(entry, false);
- this->lock(entry);
-
return entry->fResource;
}
@@ -237,14 +206,6 @@ void GrResourceCache::create(const GrResourceKey& key, GrResource* resource) {
#endif
}
-void GrResourceCache::createAndLock(const GrResourceKey& key,
- GrResource* resource) {
- this->create(key, resource);
-
- GrAssert(NULL != resource->getCacheEntry());
- this->lock(resource->getCacheEntry());
-}
-
void GrResourceCache::makeExclusive(GrResourceEntry* entry) {
GrAutoResourceCacheValidate atcv(this);
@@ -284,39 +245,6 @@ void GrResourceCache::makeNonExclusive(GrResourceEntry* entry) {
}
}
-void GrResourceCache::lock(GrResourceEntry* entry) {
- GrAutoResourceCacheValidate atcv(this);
-
- GrAssert(entry);
- GrAssert(fCache.find(entry->key()));
-
- if (!entry->isLocked()) {
- --fUnlockedEntryCount;
- }
-
- entry->lock();
-}
-
-void GrResourceCache::unlock(GrResourceEntry* entry) {
- GrAutoResourceCacheValidate atcv(this);
-
- GrAssert(entry);
- GrAssert(entry->isLocked());
- GrAssert(fCache.find(entry->key()));
-
- entry->unlock();
- if (!entry->isLocked()) {
- ++fUnlockedEntryCount;
-#if GR_CACHE_STATS
- if (fHighWaterUnlockedEntryCount < fUnlockedEntryCount) {
- fHighWaterUnlockedEntryCount = fUnlockedEntryCount;
- }
-#endif
- }
-
- this->purgeAsNeeded();
-}
-
/**
* Destroying a resource may potentially trigger the unlock of additional
* resources which in turn will trigger a nested purge. We block the nested
@@ -331,14 +259,14 @@ void GrResourceCache::purgeAsNeeded() {
if (!fPurging) {
fPurging = true;
bool withinBudget = false;
- int priorUnlockedEntryCount = 0;
+ bool changed = false;
// The purging process is repeated several times since one pass
// may free up other resources
do {
EntryList::Iter iter;
- priorUnlockedEntryCount = fUnlockedEntryCount;
+ changed = false;
// Note: the following code relies on the fact that the
// doubly linked list doesn't invalidate its data/pointers
@@ -346,15 +274,18 @@ void GrResourceCache::purgeAsNeeded() {
// in internalDetach)
GrResourceEntry* entry = iter.init(fList, EntryList::Iter::kTail_IterStart);
- while (entry && fUnlockedEntryCount) {
+ while (NULL != entry) {
GrAutoResourceCacheValidate atcv(this);
+
if (fEntryCount <= fMaxCount && fEntryBytes <= fMaxBytes) {
withinBudget = true;
break;
}
GrResourceEntry* prev = iter.prev();
- if (!entry->isLocked() && entry->fResource->getRefCnt() == 1) {
+ if (1 == entry->fResource->getRefCnt()) {
+ changed = true;
+
// remove from our cache
fCache.remove(entry->key(), entry);
@@ -372,7 +303,7 @@ void GrResourceCache::purgeAsNeeded() {
}
entry = prev;
}
- } while (!withinBudget && (fUnlockedEntryCount != priorUnlockedEntryCount));
+ } while (!withinBudget && changed);
fPurging = false;
}
}
@@ -393,7 +324,6 @@ void GrResourceCache::purgeAllUnlocked() {
#if GR_DEBUG
GrAssert(fExclusiveList.countEntries() == fClientDetachedCount);
GrAssert(countBytes(fExclusiveList) == fClientDetachedBytes);
- GrAssert(!fUnlockedEntryCount);
if (!fCache.count()) {
// Items may have been detached from the cache (such as the backing
// texture for an SkGpuDevice). The above purge would not have removed
@@ -443,25 +373,22 @@ void GrResourceCache::validate() const {
EntryList::Iter iter;
+ // check that the exclusively held entries are okay
const GrResourceEntry* entry = iter.init(const_cast<EntryList&>(fExclusiveList),
EntryList::Iter::kHead_IterStart);
for ( ; NULL != entry; entry = iter.next()) {
entry->validate();
- GrAssert(entry->isLocked());
}
+ // check that the shareable entries are okay
entry = iter.init(const_cast<EntryList&>(fList), EntryList::Iter::kHead_IterStart);
int count = 0;
- int unlockCount = 0;
for ( ; NULL != entry; entry = iter.next()) {
entry->validate();
GrAssert(fCache.find(entry->key()));
count += 1;
- if (!entry->isLocked()) {
- unlockCount += 1;
- }
}
GrAssert(count == fEntryCount - fClientDetachedCount);
@@ -471,8 +398,6 @@ void GrResourceCache::validate() const {
bytes = countBytes(fExclusiveList);
GrAssert(bytes == fClientDetachedBytes);
- GrAssert(unlockCount == fUnlockedEntryCount);
-
GrAssert(fList.countEntries() == fEntryCount - fClientDetachedCount);
GrAssert(fExclusiveList.countEntries() == fClientDetachedCount);
@@ -481,12 +406,22 @@ void GrResourceCache::validate() const {
#if GR_CACHE_STATS
-void GrResourceCache::printStats() const {
+void GrResourceCache::printStats() {
+ int locked = 0;
+
+ EntryList::Iter iter;
+
+ GrResourceEntry* entry = iter.init(fList, EntryList::Iter::kTail_IterStart);
+
+ for ( ; NULL != entry; entry = iter.prev()) {
+ if (entry->fResource->getRefCnt() > 1) {
+ ++locked;
+ }
+ }
+
SkDebugf("Budget: %d items %d bytes\n", fMaxCount, fMaxBytes);
- SkDebugf("\t\tEntry Count: current %d high %d\n",
- fEntryCount, fHighWaterEntryCount);
- SkDebugf("\t\tUnlocked Entry Count: current %d high %d\n",
- fUnlockedEntryCount, fHighWaterUnlockedEntryCount);
+ SkDebugf("\t\tEntry Count: current %d (%d locked) high %d\n",
+ fEntryCount, locked, fHighWaterEntryCount);
SkDebugf("\t\tEntry Bytes: current %d high %d\n",
fEntryBytes, fHighWaterEntryBytes);
SkDebugf("\t\tDetached Entry Count: current %d high %d\n",
diff --git a/src/gpu/GrResourceCache.h b/src/gpu/GrResourceCache.h
index e6b412e48d..7897b7ae47 100644
--- a/src/gpu/GrResourceCache.h
+++ b/src/gpu/GrResourceCache.h
@@ -156,20 +156,9 @@ private:
GrResourceEntry(const GrResourceKey& key, GrResource* resource);
~GrResourceEntry();
- bool isLocked() const { return fLockCount != 0; }
- void lock() { ++fLockCount; }
- void unlock() {
- GrAssert(fLockCount > 0);
- --fLockCount;
- }
-
GrResourceKey fKey;
GrResource* fResource;
- // track if we're in use, used when we need to purge
- // we only purge unlocked entries
- int fLockCount;
-
// we're a dlinklist
SK_DEFINE_DLINKEDLIST_INTERFACE(GrResourceEntry);
@@ -238,19 +227,13 @@ public:
GrResource* find(const GrResourceKey& key);
/**
- * Search for an entry with the same Key. If found, "lock" it and return it.
- * If not found, return null.
- */
- GrResource* findAndLock(const GrResourceKey&);
-
- /**
* Create a new cache entry, based on the provided key and resource, and
* return it.
*
* Ownership of the resource is transferred to the resource cache,
* which will unref() it when it is purged or deleted.
*/
- void createAndLock(const GrResourceKey&, GrResource*);
+ void create(const GrResourceKey&, GrResource*);
/**
* Determines if the cache contains an entry matching a key. If a matching
@@ -273,23 +256,14 @@ public:
void makeNonExclusive(GrResourceEntry* entry);
/**
- * When done with an entry, call unlock(entry) on it, which returns it to
- * a purgable state.
- */
- void unlock(GrResourceEntry*);
-
- /**
- * Make a resource un-purgeable.
- */
- void lock(GrResourceEntry* entry);
-
- /**
* Removes every resource in the cache that isn't locked.
*/
void purgeAllUnlocked();
/**
* Allow cache to purge unused resources to obey resource limitations
+ * Note: this entry point will be hidden (again) once totally ref-driven
+ * cache maintenance is implemented
*/
void purgeAsNeeded();
@@ -300,7 +274,7 @@ public:
#endif
#if GR_CACHE_STATS
- void printStats() const;
+ void printStats();
#endif
private:
@@ -328,14 +302,12 @@ private:
// our current stats, related to our budget
#if GR_CACHE_STATS
int fHighWaterEntryCount;
- int fHighWaterUnlockedEntryCount;
size_t fHighWaterEntryBytes;
int fHighWaterClientDetachedCount;
size_t fHighWaterClientDetachedBytes;
#endif
int fEntryCount;
- int fUnlockedEntryCount;
size_t fEntryBytes;
int fClientDetachedCount;
size_t fClientDetachedBytes;
@@ -343,8 +315,6 @@ private:
// prevents recursive purging
bool fPurging;
- void create(const GrResourceKey& key, GrResource* resource);
-
#if GR_DEBUG
static size_t countBytes(const SkTDLinkedList<GrResourceEntry>& list);
#endif
diff --git a/src/gpu/GrStencilBuffer.cpp b/src/gpu/GrStencilBuffer.cpp
index 2b7dfedc64..da597626d3 100644
--- a/src/gpu/GrStencilBuffer.cpp
+++ b/src/gpu/GrStencilBuffer.cpp
@@ -14,10 +14,10 @@
GR_DEFINE_RESOURCE_CACHE_TYPE(GrStencilBuffer)
-void GrStencilBuffer::transferToCacheAndLock() {
+void GrStencilBuffer::transferToCache() {
GrAssert(NULL == this->getCacheEntry());
- this->getGpu()->getContext()->addAndLockStencilBuffer(this);
+ this->getGpu()->getContext()->addStencilBuffer(this);
}
namespace {
diff --git a/src/gpu/GrStencilBuffer.h b/src/gpu/GrStencilBuffer.h
index 690fa329a8..2a0dbc022a 100644
--- a/src/gpu/GrStencilBuffer.h
+++ b/src/gpu/GrStencilBuffer.h
@@ -59,9 +59,8 @@ public:
return fLastClipData;
}
- // Places the sb in the cache and locks it. The cache takes a ref
- // of the stencil buffer.
- void transferToCacheAndLock();
+ // Places the sb in the cache. The cache takes a ref of the stencil buffer.
+ void transferToCache();
static GrResourceKey ComputeKey(int width, int height, int sampleCnt);
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 8701178ccc..79bc75daf0 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -92,9 +92,9 @@ static GrTexture* sk_gr_create_bitmap_texture(GrContext* ctx,
// "rowBytes", since they are the same now.
if (GrCacheData::kScratch_CacheID != key) {
- return ctx->createAndLockTexture(params, desc, cacheData,
- storage.get(),
- bitmap->width());
+ return ctx->createTexture(params, desc, cacheData,
+ storage.get(),
+ bitmap->width());
} else {
GrTexture* result = ctx->lockScratchTexture(desc,
GrContext::kExact_ScratchTexMatch);
@@ -115,9 +115,9 @@ static GrTexture* sk_gr_create_bitmap_texture(GrContext* ctx,
if (GrCacheData::kScratch_CacheID != key) {
// This texture is likely to be used again so leave it in the cache
// but locked.
- return ctx->createAndLockTexture(params, desc, cacheData,
- bitmap->getPixels(),
- bitmap->rowBytes());
+ return ctx->createTexture(params, desc, cacheData,
+ bitmap->getPixels(),
+ bitmap->rowBytes());
} else {
// This texture is unlikely to be used again (in its present form) so
// just use a scratch texture. This will remove the texture from the
@@ -154,8 +154,9 @@ GrTexture* GrLockCachedBitmapTexture(GrContext* ctx,
GrCacheData cacheData(key);
- result = ctx->findAndLockTexture(desc, cacheData, params);
+ result = ctx->findTexture(desc, cacheData, params);
if (NULL == result) {
+ // didn't find a cached copy so create one
result = sk_gr_create_bitmap_texture(ctx, key, params, bitmap);
}
} else {
@@ -171,7 +172,7 @@ GrTexture* GrLockCachedBitmapTexture(GrContext* ctx,
void GrUnlockCachedBitmapTexture(GrTexture* texture) {
GrAssert(NULL != texture->getContext());
- texture->getContext()->unlockTexture(texture);
+ texture->getContext()->unlockScratchTexture(texture);
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/SkGrPixelRef.cpp b/src/gpu/SkGrPixelRef.cpp
index bb36d32f98..e770ef09b6 100644
--- a/src/gpu/SkGrPixelRef.cpp
+++ b/src/gpu/SkGrPixelRef.cpp
@@ -110,7 +110,7 @@ SkGrPixelRef::~SkGrPixelRef() {
GrContext* context = fSurface->getContext();
GrTexture* texture = fSurface->asTexture();
if (NULL != context && NULL != texture) {
- context->unlockTexture(texture);
+ context->unlockScratchTexture(texture);
}
}
GrSafeUnref(fSurface);
diff --git a/src/gpu/effects/GrTextureStripAtlas.cpp b/src/gpu/effects/GrTextureStripAtlas.cpp
index 86c4645e31..3a2942b375 100644
--- a/src/gpu/effects/GrTextureStripAtlas.cpp
+++ b/src/gpu/effects/GrTextureStripAtlas.cpp
@@ -179,9 +179,9 @@ void GrTextureStripAtlas::lockTexture() {
texDesc.fConfig = fDesc.fConfig;
GrCacheData cacheData(fCacheID);
cacheData.fResourceDomain = GetTextureStripAtlasDomain();
- fTexture = fDesc.fContext->findAndLockTexture(texDesc, cacheData, &params);
+ fTexture = fDesc.fContext->findTexture(texDesc, cacheData, &params);
if (NULL == fTexture) {
- fTexture = fDesc.fContext->createAndLockTexture(&params, texDesc, cacheData, NULL, 0);
+ fTexture = fDesc.fContext->createTexture(&params, texDesc, cacheData, NULL, 0);
// This is a new texture, so all of our cache info is now invalid
this->initLRU();
fKeyTable.rewind();
@@ -192,7 +192,6 @@ void GrTextureStripAtlas::lockTexture() {
void GrTextureStripAtlas::unlockTexture() {
GrAssert(NULL != fTexture && 0 == fLockedRows);
- fDesc.fContext->unlockTexture(fTexture);
fTexture->unref();
fTexture = NULL;
fDesc.fContext->purgeCache();
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index 887ed7650a..845d1f860b 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -1110,7 +1110,7 @@ bool GrGpuGL::createStencilBufferForRenderTarget(GrRenderTarget* rt,
samples, format)));
if (this->attachStencilBufferToRenderTarget(sb, rt)) {
fLastSuccessfulStencilFmtIdx = sIdx;
- sb->transferToCacheAndLock();
+ sb->transferToCache();
rt->setStencilBuffer(sb);
return true;
}