diff options
author | Nicolas Roard <nicolas@android.com> | 2011-02-18 16:35:20 -0800 |
---|---|---|
committer | Shimeng (Simon) Wang <swang@google.com> | 2011-02-18 17:31:46 -0800 |
commit | 227fffee9ee9b07919a140866fda1ee7445d3f5a (patch) | |
tree | 241dc7982ef740113b10a717ca374f1cb1f922e5 | |
parent | 704eaca6f77288587c438291bc15a967515eaa8e (diff) | |
download | external_webkit-227fffee9ee9b07919a140866fda1ee7445d3f5a.zip external_webkit-227fffee9ee9b07919a140866fda1ee7445d3f5a.tar.gz external_webkit-227fffee9ee9b07919a140866fda1ee7445d3f5a.tar.bz2 |
Fix potential bug in setMaxTextureCount and limit
the number of textures to 154
Change-Id: I39409e938b6b4bff23d6f1f0dc44648d63443f59
-rw-r--r-- | WebCore/platform/graphics/android/TilesManager.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/WebCore/platform/graphics/android/TilesManager.cpp b/WebCore/platform/graphics/android/TilesManager.cpp index 0fb3b1b..8bea60c 100644 --- a/WebCore/platform/graphics/android/TilesManager.cpp +++ b/WebCore/platform/graphics/android/TilesManager.cpp @@ -55,10 +55,11 @@ // We need n textures for one TiledPage, and another n textures for the // second page used when scaling. // In our case, we use 300x300 textures. On the tablet, this equates to -// at least 5 * 3 = 15 textures. We can also enable offscreen textures +// at least 5 * 3 = 15 textures. We also enable offscreen textures to a maximum +// of 154 textures used (i.e. ~106Mb max, accounting for the double buffer textures) #define EXPANDED_TILE_BOUNDS_X 1 #define EXPANDED_TILE_BOUNDS_Y 4 -#define MAX_TEXTURE_ALLOCATION (5+1+EXPANDED_TILE_BOUNDS_X*2)*(3+1+EXPANDED_TILE_BOUNDS_Y*2)*2 +#define MAX_TEXTURE_ALLOCATION (5+EXPANDED_TILE_BOUNDS_X*2)*(3+EXPANDED_TILE_BOUNDS_Y*2)*2 #define TILE_WIDTH 300 #define TILE_HEIGHT 300 @@ -373,13 +374,20 @@ int TilesManager::maxTextureCount() void TilesManager::setMaxTextureCount(int max) { - XLOG("setMaxTextureCount: %d", max); - if (max > MAX_TEXTURE_ALLOCATION || - (m_maxTextureCount >= max && m_maxTextureCount)) + XLOG("setMaxTextureCount: %d (current: %d, total:%d)", + max, m_maxTextureCount, MAX_TEXTURE_ALLOCATION); + if (m_maxTextureCount && + (max > MAX_TEXTURE_ALLOCATION || + max <= m_maxTextureCount)) return; android::Mutex::Autolock lock(m_texturesLock); - m_maxTextureCount = max; + + if (max < MAX_TEXTURE_ALLOCATION) + m_maxTextureCount = max; + else + m_maxTextureCount = MAX_TEXTURE_ALLOCATION; + allocateTiles(); } |