summaryrefslogtreecommitdiffstats
path: root/Source/WebCore
diff options
context:
space:
mode:
authorTeng-Hui Zhu <ztenghui@google.com>2012-02-21 15:34:03 -0800
committerTeng-Hui Zhu <ztenghui@google.com>2012-02-21 16:48:49 -0800
commit50359a67e1503b5d416cae7e64d46e3f3389442a (patch)
treee689dd3ca2bdbdebfe3c83a51564cd5ce2baa35d /Source/WebCore
parenta54eb7fa1e850d7096f97065f35ed00bcb5384d3 (diff)
downloadexternal_webkit-50359a67e1503b5d416cae7e64d46e3f3389442a.zip
external_webkit-50359a67e1503b5d416cae7e64d46e3f3389442a.tar.gz
external_webkit-50359a67e1503b5d416cae7e64d46e3f3389442a.tar.bz2
Reset the upper limit when onTrimMemory
bug:6009351 Change-Id: I2619a4adc965014a749d575292137cf23c59b8c3
Diffstat (limited to 'Source/WebCore')
-rw-r--r--Source/WebCore/platform/graphics/android/TilesManager.cpp22
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,