Changeset 101854 in webkit
- Timestamp:
- Dec 2, 2011 2:30:08 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r101848 r101854 1 2011-12-02 Grace Kloba <klobag@chromium.org> 2 3 [chromium] Recycle tile-sized textures during commit to prevent reallocations 4 https://bugs.webkit.org/show_bug.cgi?id=70645 5 6 Reviewed by James Robinson. 7 8 Currently texture request is capped by the high limit while we reclaim the 9 textures in each commit. This triggers new tiles always allocated when scrolling. 10 The proposal is to recycle the texture during request if the total used memory 11 is about to exceed the reclaim limit. 12 13 * platform/graphics/chromium/ManagedTexture.cpp: 14 (WebCore::ManagedTexture::reserve): 15 * platform/graphics/chromium/TextureManager.cpp: 16 (WebCore::TextureManager::setMemoryLimitBytes): 17 (WebCore::TextureManager::replaceTexture): 18 (WebCore::TextureManager::requestTexture): 19 * platform/graphics/chromium/TextureManager.h: 20 1 21 2011-12-02 Kent Tamura <tkent@chromium.org> 2 22 -
trunk/Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp
r96186 r101854 63 63 else { 64 64 m_textureId = 0; 65 reserved = m_textureManager->requestTexture(m_token, size, format );65 reserved = m_textureManager->requestTexture(m_token, size, format, m_textureId); 66 66 if (reserved) { 67 67 m_size = size; -
trunk/Source/WebCore/platform/graphics/chromium/TextureManager.cpp
r101586 r101854 72 72 { 73 73 reduceMemoryToLimit(memoryLimitBytes); 74 ASSERT(currentMemoryUseBytes() < memoryLimitBytes);74 ASSERT(currentMemoryUseBytes() <= memoryLimitBytes); 75 75 m_memoryLimitBytes = memoryLimitBytes; 76 76 } … … 142 142 } 143 143 144 unsigned TextureManager::replaceTexture(TextureToken newToken, TextureInfo newInfo) 145 { 146 for (ListHashSet<TextureToken>::iterator lruIt = m_textureLRUSet.begin(); lruIt != m_textureLRUSet.end(); ++lruIt) { 147 TextureToken token = *lruIt; 148 TextureInfo info = m_textures.get(token); 149 if (info.isProtected) 150 continue; 151 if (!info.textureId) 152 continue; 153 if (newInfo.size != info.size || newInfo.format != info.format) 154 continue; 155 newInfo.textureId = info.textureId; 156 #ifndef NDEBUG 157 newInfo.allocator = info.allocator; 158 #endif 159 m_textures.remove(token); 160 m_textureLRUSet.remove(token); 161 m_textures.set(newToken, newInfo); 162 m_textureLRUSet.add(newToken); 163 return info.textureId; 164 } 165 return 0; 166 } 167 144 168 void TextureManager::addTexture(TextureToken token, TextureInfo info) 145 169 { … … 206 230 } 207 231 208 bool TextureManager::requestTexture(TextureToken token, IntSize size, unsigned format) 209 { 232 bool TextureManager::requestTexture(TextureToken token, IntSize size, unsigned format, unsigned& textureId) 233 { 234 textureId = 0; 235 210 236 if (size.width() > m_maxTextureSize || size.height() > m_maxTextureSize) 211 237 return false; … … 233 259 info.allocator = 0; 234 260 #endif 261 // Avoid churning by reusing the texture if it is about to be reclaimed and 262 // it has the same size and format as the requesting texture. 263 if (m_memoryUseBytes + memoryRequiredBytes > reclaimLimitBytes()) { 264 textureId = replaceTexture(token, info); 265 if (textureId) 266 return true; 267 } 235 268 addTexture(token, info); 236 269 return true; -
trunk/Source/WebCore/platform/graphics/chromium/TextureManager.h
r96186 r101854 70 70 bool hasTexture(TextureToken); 71 71 72 bool requestTexture(TextureToken, IntSize, GC3Denum textureFormat );72 bool requestTexture(TextureToken, IntSize, GC3Denum textureFormat, unsigned& textureId); 73 73 74 74 void protectTexture(TextureToken); … … 100 100 void addTexture(TextureToken, TextureInfo); 101 101 void removeTexture(TextureToken, TextureInfo); 102 unsigned replaceTexture(TextureToken, TextureInfo); 102 103 103 104 typedef HashMap<TextureToken, TextureInfo> TextureMap;
Note: See TracChangeset
for help on using the changeset viewer.