diff options
author | Teng-Hui Zhu <ztenghui@google.com> | 2012-02-22 10:12:07 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-02-22 10:12:07 -0800 |
commit | 41e58683e2ccc7c1928deedfc2e3a9be3d58ad5e (patch) | |
tree | b6a61b2440bae46ba1ba561be469d94a2aa30b9d /Source | |
parent | fa20d5d7a15b724e0209ba319750249dcd540402 (diff) | |
parent | 50359a67e1503b5d416cae7e64d46e3f3389442a (diff) | |
download | external_webkit-41e58683e2ccc7c1928deedfc2e3a9be3d58ad5e.zip external_webkit-41e58683e2ccc7c1928deedfc2e3a9be3d58ad5e.tar.gz external_webkit-41e58683e2ccc7c1928deedfc2e3a9be3d58ad5e.tar.bz2 |
Merge "Reset the upper limit when onTrimMemory"
Diffstat (limited to 'Source')
-rw-r--r-- | Source/WebCore/platform/graphics/android/TilesManager.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/Source/WebCore/platform/graphics/android/TilesManager.cpp b/Source/WebCore/platform/graphics/android/TilesManager.cpp index 7fe856b..184d80c 100644 --- a/Source/WebCore/platform/graphics/android/TilesManager.cpp +++ b/Source/WebCore/platform/graphics/android/TilesManager.cpp @@ -183,12 +183,14 @@ void TilesManager::discardTexturesVector(unsigned long long sparedDrawCount, { const unsigned int max = textures.size(); int dealloc = 0; + WTF::Vector<int> discardedIndex; for (unsigned int i = 0; i < max; i++) { TextureOwner* owner = textures[i]->owner(); if (!owner || owner->drawCount() < sparedDrawCount) { if (deallocateGLTextures) { // deallocate textures' gl memory textures[i]->discardGLTexture(); + discardedIndex.append(i); } else if (owner) { // simply detach textures from owner static_cast<BaseTile*>(owner)->discardTextures(); @@ -196,9 +198,27 @@ void TilesManager::discardTexturesVector(unsigned long long sparedDrawCount, dealloc++; } } + + bool base = textures == m_textures; + // Clean up the vector of BaseTileTextures and reset the max texture count. + if (discardedIndex.size()) { + android::Mutex::Autolock lock(m_texturesLock); + for (int i = discardedIndex.size() - 1; i >= 0; i--) + textures.remove(discardedIndex[i]); + + int remainedTextureNumber = textures.size(); + int* countPtr = base ? &m_maxTextureCount : &m_maxLayerTextureCount; + if (remainedTextureNumber < *countPtr) { + XLOG("reset maxTextureCount for %s tiles from %d to %d", + base ? "base" : "layer", *countPtr, remainedTextureNumber); + *countPtr = remainedTextureNumber; + } + + } + XLOG("Discarded %d %s textures (out of %d %s tiles)", dealloc, (deallocateGLTextures ? "gl" : ""), - max, (textures == m_textures) ? "base" : "layer"); + max, base ? "base" : "layer"); } void TilesManager::gatherTexturesNumbers(int* nbTextures, int* nbAllocatedTextures, |