aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-09-07 19:44:33 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-09-07 19:44:33 +0000
commit50a035ddbb068446645b0978f4c092dec87a1a02 (patch)
tree99e9534267ee9394d8a336301e37750c85b5e1a7 /src
parent5fd07ec782faaf4b47cc5a15a911b320ae95bcb2 (diff)
Added explicit cache clearing
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrContext.cpp6
-rw-r--r--src/gpu/GrRenderTarget.cpp4
-rw-r--r--src/gpu/GrResourceCache.h6
-rw-r--r--src/gpu/effects/GrTextureStripAtlas.cpp3
4 files changed, 18 insertions, 1 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index f91f4206c2..9b01eb27e2 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -494,6 +494,7 @@ void GrContext::addExistingTextureToCache(GrTexture* texture) {
// and it should still be locked
fTextureCache->unlock(texture->getCacheEntry());
+ this->purgeCache();
}
void GrContext::lockTexture(GrTexture* texture) {
@@ -519,6 +520,11 @@ void GrContext::unlockTexture(GrTexture* texture) {
}
fTextureCache->unlock(texture->getCacheEntry());
+ this->purgeCache();
+}
+
+void GrContext::purgeCache() {
+ fTextureCache->purgeAsNeeded();
}
GrTexture* GrContext::createUncachedTexture(const GrTextureDesc& descIn,
diff --git a/src/gpu/GrRenderTarget.cpp b/src/gpu/GrRenderTarget.cpp
index 761966400c..f8f9e3c796 100644
--- a/src/gpu/GrRenderTarget.cpp
+++ b/src/gpu/GrRenderTarget.cpp
@@ -101,6 +101,10 @@ void GrRenderTarget::setStencilBuffer(GrStencilBuffer* stencilBuffer) {
context->unlockStencilBuffer(fStencilBuffer);
}
fStencilBuffer->unref();
+
+ if (NULL != context) {
+ context->purgeCache();
+ }
}
fStencilBuffer = stencilBuffer;
diff --git a/src/gpu/GrResourceCache.h b/src/gpu/GrResourceCache.h
index 59320b0379..e6b412e48d 100644
--- a/src/gpu/GrResourceCache.h
+++ b/src/gpu/GrResourceCache.h
@@ -288,6 +288,11 @@ public:
*/
void purgeAllUnlocked();
+ /**
+ * Allow cache to purge unused resources to obey resource limitations
+ */
+ void purgeAsNeeded();
+
#if GR_DEBUG
void validate() const;
#else
@@ -301,7 +306,6 @@ public:
private:
void internalDetach(GrResourceEntry*, bool);
void attachToHead(GrResourceEntry*, bool);
- void purgeAsNeeded();
void removeInvalidResource(GrResourceEntry* entry);
diff --git a/src/gpu/effects/GrTextureStripAtlas.cpp b/src/gpu/effects/GrTextureStripAtlas.cpp
index a43f9d6f68..86c4645e31 100644
--- a/src/gpu/effects/GrTextureStripAtlas.cpp
+++ b/src/gpu/effects/GrTextureStripAtlas.cpp
@@ -187,12 +187,15 @@ void GrTextureStripAtlas::lockTexture() {
fKeyTable.rewind();
}
GrAssert(NULL != fTexture);
+ fTexture->ref();
}
void GrTextureStripAtlas::unlockTexture() {
GrAssert(NULL != fTexture && 0 == fLockedRows);
fDesc.fContext->unlockTexture(fTexture);
+ fTexture->unref();
fTexture = NULL;
+ fDesc.fContext->purgeCache();
}
void GrTextureStripAtlas::initLRU() {