Changeset 101854 in webkit


Ignore:
Timestamp:
Dec 2, 2011 2:30:08 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[chromium] Recycle tile-sized textures during commit to prevent reallocations
https://bugs.webkit.org/show_bug.cgi?id=70645

Patch by Grace Kloba <klobag@chromium.org> on 2011-12-02
Reviewed by James Robinson.

Currently texture request is capped by the high limit while we reclaim the
textures in each commit. This triggers new tiles always allocated when scrolling.
The proposal is to recycle the texture during request if the total used memory
is about to exceed the reclaim limit.

  • platform/graphics/chromium/ManagedTexture.cpp:

(WebCore::ManagedTexture::reserve):

  • platform/graphics/chromium/TextureManager.cpp:

(WebCore::TextureManager::setMemoryLimitBytes):
(WebCore::TextureManager::replaceTexture):
(WebCore::TextureManager::requestTexture):

  • platform/graphics/chromium/TextureManager.h:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r101848 r101854  
     12011-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
    1212011-12-02  Kent Tamura  <tkent@chromium.org>
    222
  • trunk/Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp

    r96186 r101854  
    6363    else {
    6464        m_textureId = 0;
    65         reserved = m_textureManager->requestTexture(m_token, size, format);
     65        reserved = m_textureManager->requestTexture(m_token, size, format, m_textureId);
    6666        if (reserved) {
    6767            m_size = size;
  • trunk/Source/WebCore/platform/graphics/chromium/TextureManager.cpp

    r101586 r101854  
    7272{
    7373    reduceMemoryToLimit(memoryLimitBytes);
    74     ASSERT(currentMemoryUseBytes() < memoryLimitBytes);
     74    ASSERT(currentMemoryUseBytes() <= memoryLimitBytes);
    7575    m_memoryLimitBytes = memoryLimitBytes;
    7676}
     
    142142}
    143143
     144unsigned 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
    144168void TextureManager::addTexture(TextureToken token, TextureInfo info)
    145169{
     
    206230}
    207231
    208 bool TextureManager::requestTexture(TextureToken token, IntSize size, unsigned format)
    209 {
     232bool TextureManager::requestTexture(TextureToken token, IntSize size, unsigned format, unsigned& textureId)
     233{
     234    textureId = 0;
     235
    210236    if (size.width() > m_maxTextureSize || size.height() > m_maxTextureSize)
    211237        return false;
     
    233259    info.allocator = 0;
    234260#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    }
    235268    addTexture(token, info);
    236269    return true;
  • trunk/Source/WebCore/platform/graphics/chromium/TextureManager.h

    r96186 r101854  
    7070    bool hasTexture(TextureToken);
    7171
    72     bool requestTexture(TextureToken, IntSize, GC3Denum textureFormat);
     72    bool requestTexture(TextureToken, IntSize, GC3Denum textureFormat, unsigned& textureId);
    7373
    7474    void protectTexture(TextureToken);
     
    100100    void addTexture(TextureToken, TextureInfo);
    101101    void removeTexture(TextureToken, TextureInfo);
     102    unsigned replaceTexture(TextureToken, TextureInfo);
    102103
    103104    typedef HashMap<TextureToken, TextureInfo> TextureMap;
Note: See TracChangeset for help on using the changeset viewer.