Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Unified Diff: src/gpu/GrContext.cpp

Issue 19591003: Add purgeAsNeeded calls before addResource calls (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: added extraCount & extraSize to account for future memory requirements Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/gpu/GrResourceCache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrContext.cpp
===================================================================
--- src/gpu/GrContext.cpp (revision 10123)
+++ src/gpu/GrContext.cpp (working copy)
@@ -390,6 +390,9 @@
}
if (NULL != texture) {
+ // Adding a resource could put us overbudget. Try to free up the
+ // necessary space before adding it.
+ fTextureCache->purgeAsNeeded(1, texture->sizeInBytes());
fTextureCache->addResource(resourceKey, texture);
}
@@ -449,6 +452,9 @@
GrTexture* texture = fGpu->createTexture(desc, NULL, 0);
if (NULL != texture) {
GrResourceKey key = GrTexture::ComputeScratchKey(texture->desc());
+ // Adding a resource could put us overbudget. Try to free up the
+ // necessary space before adding it.
+ fTextureCache->purgeAsNeeded(1, texture->sizeInBytes());
// Make the resource exclusive so future 'find' calls don't return it
fTextureCache->addResource(key, texture, GrResourceCache::kHide_OwnershipFlag);
resource = texture;
@@ -489,9 +495,9 @@
// the same texture).
if (texture->getCacheEntry()->key().isScratch()) {
fTextureCache->makeNonExclusive(texture->getCacheEntry());
+ this->purgeCache();
}
- this->purgeCache();
}
void GrContext::purgeCache() {
« no previous file with comments | « no previous file | src/gpu/GrResourceCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698