summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics/android/TilesManager.cpp
diff options
context:
space:
mode:
authorChris Craik <ccraik@google.com>2011-09-08 13:40:18 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-09-08 13:40:18 -0700
commit3dbec40108fe6f94e4eff7c84979b6c3a5340c64 (patch)
tree606827fca495e229be45ecda6acf72dd64e668d7 /Source/WebCore/platform/graphics/android/TilesManager.cpp
parent0ae24ff51fd869435c30e14d192c4416cc089498 (diff)
parent2986d27084d881dbe6f9c3ae35430a5978b7e659 (diff)
downloadexternal_webkit-3dbec40108fe6f94e4eff7c84979b6c3a5340c64.zip
external_webkit-3dbec40108fe6f94e4eff7c84979b6c3a5340c64.tar.gz
external_webkit-3dbec40108fe6f94e4eff7c84979b6c3a5340c64.tar.bz2
Merge "Deallocate graphics memory with onTrimMemory signals"
Diffstat (limited to 'Source/WebCore/platform/graphics/android/TilesManager.cpp')
-rw-r--r--Source/WebCore/platform/graphics/android/TilesManager.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/Source/WebCore/platform/graphics/android/TilesManager.cpp b/Source/WebCore/platform/graphics/android/TilesManager.cpp
index 2c263e3..769d9e3 100644
--- a/Source/WebCore/platform/graphics/android/TilesManager.cpp
+++ b/Source/WebCore/platform/graphics/android/TilesManager.cpp
@@ -149,6 +149,41 @@ void TilesManager::allocateTiles()
m_tilesTextures.size() * LAYER_TILE_WIDTH * LAYER_TILE_HEIGHT * 4 / 1024 / 1024);
}
+void TilesManager::deallocateTextures(bool allTextures)
+{
+ const unsigned int max = m_textures.size();
+ const unsigned int maxLayer = m_tilesTextures.size();
+
+ unsigned long long sparedDrawCount = ~0; // by default, spare no textures
+ if (!allTextures) {
+ // if we're not deallocating all textures, spare those with max drawcount
+ sparedDrawCount = 0;
+ for (unsigned int i = 0; i < max; i++) {
+ TextureOwner* owner = m_textures[i]->owner();
+ if (owner)
+ sparedDrawCount = std::max(sparedDrawCount, owner->drawCount());
+ }
+ }
+
+ int dealloc = 0;
+ for (unsigned int i = 0; i < max; i++) {
+ TextureOwner* owner = m_textures[i]->owner();
+ if (!owner || owner->drawCount() < sparedDrawCount) {
+ m_textures[i]->discardTexture();
+ dealloc++;
+ }
+ }
+ for (unsigned int i = 0; i < maxLayer; i++) {
+ TextureOwner* owner = m_tilesTextures[i]->owner();
+ if (!owner || owner->drawCount() < sparedDrawCount) {
+ m_tilesTextures[i]->discardTexture();
+ dealloc++;
+ }
+ }
+ XLOG("Deallocated %d gl textures (out of %d base tiles and %d layer tiles)",
+ dealloc, max, maxLayer);
+}
+
void TilesManager::printTextures()
{
#ifdef DEBUG