Changeset 128344 in webkit


Ignore:
Timestamp:
Sep 12, 2012 11:49:25 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[chromium] Evict textures through the texture manager instead of the resource provider
https://bugs.webkit.org/show_bug.cgi?id=96463

Patch by Christopher Cameron <ccameron@chromium.org> on 2012-09-12
Reviewed by James Robinson.

Source/WebCore:

When deleting contents textures' resources on the impl thread, do the
deletion through the CCPrioritizedTextureManager instead of the
CCResourceProvider.

This requires traversing the backings list on the impl thread while
the main thread is running, so remove the one remaining traversal of
the backings list by the main thread. This traversal happens when
unlinking textures that were evicted by the impl thread, so explicitly
send the list of evicted backings from the impl thread to the main thread.

Unify all resource deletion paths in the CCPrioritizedTextureManager.
Always perform the sequence of eviction (deleting the GL resource) and
then destruction of evicted backings (deleting the objects). Also,
use the same function (evictBackingsToReduceMemory) to reduce memory
consumption both during commit and when done by the impl thread in response
to a request by the GPU memory manager.

Note that destroying only some of the resources at a time during texture
eviction (as opposed all resources) is still not supported because the
texture upload queues cannot be only-partially invalidated yet.

Updated tests to take this behavior into account.

  • platform/graphics/chromium/cc/CCLayerTreeHost.cpp:

(WebCore::CCLayerTreeHost::reduceContentsTexturesMemoryOnImplThread):
(WebCore):
(WebCore::CCLayerTreeHost::getEvictedContentTexturesBackings):
(WebCore::CCLayerTreeHost::unlinkEvictedContentTexturesBackings):
(WebCore::CCLayerTreeHost::deleteEvictedContentTexturesBackings):

  • platform/graphics/chromium/cc/CCLayerTreeHost.h:

(CCLayerTreeHost):

  • platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:

(WebCore::CCLayerTreeHostImpl::releaseContentsTextures):
(WebCore::CCLayerTreeHostImpl::setContentsTexturesPurged):
(WebCore):

  • platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:

(CCLayerTreeHostImplClient):
(CCLayerTreeHostImpl):

  • platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp:

(WebCore::CCPrioritizedTextureManager::~CCPrioritizedTextureManager):
(WebCore::CCPrioritizedTextureManager::acquireBackingTextureIfNeeded):
(WebCore::CCPrioritizedTextureManager::evictBackingsToReduceMemory):
(WebCore::CCPrioritizedTextureManager::reduceMemory):
(WebCore::CCPrioritizedTextureManager::clearAllMemory):
(WebCore::CCPrioritizedTextureManager::reduceMemoryOnImplThread):
(WebCore::CCPrioritizedTextureManager::getEvictedBackings):
(WebCore::CCPrioritizedTextureManager::unlinkEvictedBackings):
(WebCore):
(WebCore::CCPrioritizedTextureManager::deleteEvictedBackings):
(WebCore::CCPrioritizedTextureManager::evictBackingResource):

  • platform/graphics/chromium/cc/CCPrioritizedTextureManager.h:

(CCPrioritizedTextureManager):

  • platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:

(WebCore::CCSingleThreadProxy::releaseContentsTexturesOnImplThread):
(WebCore):
(WebCore::CCSingleThreadProxy::commitAndComposite):

  • platform/graphics/chromium/cc/CCSingleThreadProxy.h:
  • platform/graphics/chromium/cc/CCThreadProxy.cpp:

(WebCore::CCThreadProxy::releaseContentsTexturesOnImplThread):
(WebCore):
(WebCore::CCThreadProxy::scheduledActionBeginFrame):
(WebCore::CCThreadProxy::beginFrame):
(WebCore::CCThreadProxy::beginFrameCompleteOnImplThread):
(WebCore::CCThreadProxy::layerTreeHostClosedOnImplThread):
(WebCore::CCThreadProxy::recreateContextOnImplThread):

  • platform/graphics/chromium/cc/CCThreadProxy.h:

(BeginFrameAndCommitState):
(CCThreadProxy):

Source/WebKit/chromium:

Update layer tree host impl test to include the extra interface functions
added to CCLayerTreeHostImplClient.

  • tests/CCLayerTreeHostImplTest.cpp:
Location:
trunk/Source
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r128341 r128344  
     12012-09-12  Christopher Cameron  <ccameron@chromium.org>
     2
     3        [chromium] Evict textures through the texture manager instead of the resource provider
     4        https://bugs.webkit.org/show_bug.cgi?id=96463
     5
     6        Reviewed by James Robinson.
     7
     8        When deleting contents textures' resources on the impl thread, do the
     9        deletion through the CCPrioritizedTextureManager instead of the
     10        CCResourceProvider.
     11
     12        This requires traversing the backings list on the impl thread while
     13        the main thread is running, so remove the one remaining traversal of
     14        the backings list by the main thread. This traversal happens when
     15        unlinking textures that were evicted by the impl thread, so explicitly
     16        send the list of evicted backings from the impl thread to the main thread.
     17
     18        Unify all resource deletion paths in the CCPrioritizedTextureManager.
     19        Always perform the sequence of eviction (deleting the GL resource) and
     20        then destruction of evicted backings (deleting the objects).  Also,
     21        use the same function (evictBackingsToReduceMemory) to reduce memory
     22        consumption both during commit and when done by the impl thread in response
     23        to a request by the GPU memory manager.
     24
     25        Note that destroying only some of the resources at a time during texture
     26        eviction (as opposed all resources) is still not supported because the
     27        texture upload queues cannot be only-partially invalidated yet.
     28
     29        Updated tests to take this behavior into account.
     30
     31        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
     32        (WebCore::CCLayerTreeHost::reduceContentsTexturesMemoryOnImplThread):
     33        (WebCore):
     34        (WebCore::CCLayerTreeHost::getEvictedContentTexturesBackings):
     35        (WebCore::CCLayerTreeHost::unlinkEvictedContentTexturesBackings):
     36        (WebCore::CCLayerTreeHost::deleteEvictedContentTexturesBackings):
     37        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
     38        (CCLayerTreeHost):
     39        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
     40        (WebCore::CCLayerTreeHostImpl::releaseContentsTextures):
     41        (WebCore::CCLayerTreeHostImpl::setContentsTexturesPurged):
     42        (WebCore):
     43        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
     44        (CCLayerTreeHostImplClient):
     45        (CCLayerTreeHostImpl):
     46        * platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp:
     47        (WebCore::CCPrioritizedTextureManager::~CCPrioritizedTextureManager):
     48        (WebCore::CCPrioritizedTextureManager::acquireBackingTextureIfNeeded):
     49        (WebCore::CCPrioritizedTextureManager::evictBackingsToReduceMemory):
     50        (WebCore::CCPrioritizedTextureManager::reduceMemory):
     51        (WebCore::CCPrioritizedTextureManager::clearAllMemory):
     52        (WebCore::CCPrioritizedTextureManager::reduceMemoryOnImplThread):
     53        (WebCore::CCPrioritizedTextureManager::getEvictedBackings):
     54        (WebCore::CCPrioritizedTextureManager::unlinkEvictedBackings):
     55        (WebCore):
     56        (WebCore::CCPrioritizedTextureManager::deleteEvictedBackings):
     57        (WebCore::CCPrioritizedTextureManager::evictBackingResource):
     58        * platform/graphics/chromium/cc/CCPrioritizedTextureManager.h:
     59        (CCPrioritizedTextureManager):
     60        * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
     61        (WebCore::CCSingleThreadProxy::releaseContentsTexturesOnImplThread):
     62        (WebCore):
     63        (WebCore::CCSingleThreadProxy::commitAndComposite):
     64        * platform/graphics/chromium/cc/CCSingleThreadProxy.h:
     65        * platform/graphics/chromium/cc/CCThreadProxy.cpp:
     66        (WebCore::CCThreadProxy::releaseContentsTexturesOnImplThread):
     67        (WebCore):
     68        (WebCore::CCThreadProxy::scheduledActionBeginFrame):
     69        (WebCore::CCThreadProxy::beginFrame):
     70        (WebCore::CCThreadProxy::beginFrameCompleteOnImplThread):
     71        (WebCore::CCThreadProxy::layerTreeHostClosedOnImplThread):
     72        (WebCore::CCThreadProxy::recreateContextOnImplThread):
     73        * platform/graphics/chromium/cc/CCThreadProxy.h:
     74        (BeginFrameAndCommitState):
     75        (CCThreadProxy):
     76
    1772012-09-12  Mike Fenton  <mifenton@rim.com>
    278
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp

    r128005 r128344  
    415415}
    416416
    417 void CCLayerTreeHost::unlinkAllContentTextures()
     417void CCLayerTreeHost::reduceContentsTexturesMemoryOnImplThread(size_t limitBytes, CCResourceProvider* resourceProvider)
     418{
     419    ASSERT(CCProxy::isImplThread());
     420    ASSERT(m_contentsTextureManager.get());
     421    m_contentsTextureManager->reduceMemoryOnImplThread(limitBytes, resourceProvider);
     422}
     423
     424void CCLayerTreeHost::getEvictedContentTexturesBackings(CCPrioritizedTextureManager::BackingVector& evictedBackings)
     425{
     426    ASSERT(CCProxy::isImplThread());
     427    evictedBackings.clear();
     428    if (m_rendererInitialized)
     429        m_contentsTextureManager->getEvictedBackings(evictedBackings);
     430}
     431
     432void CCLayerTreeHost::unlinkEvictedContentTexturesBackings(const CCPrioritizedTextureManager::BackingVector& evictedBackings)
    418433{
    419434    ASSERT(CCProxy::isMainThread());
    420435    ASSERT(m_contentsTextureManager.get());
    421     m_contentsTextureManager->unlinkAllBackings();
    422 }
    423 
    424 void CCLayerTreeHost::deleteUnlinkedTextures()
     436    m_contentsTextureManager->unlinkEvictedBackings(evictedBackings);
     437}
     438
     439bool CCLayerTreeHost::deleteEvictedContentTexturesBackings()
    425440{
    426441    ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked());
    427442    ASSERT(m_contentsTextureManager.get());
    428     m_contentsTextureManager->deleteAllUnlinkedBackings();
     443    return m_contentsTextureManager->deleteEvictedBackings();
    429444}
    430445
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h

    r128005 r128344  
    212212    CCPrioritizedTextureManager* contentsTextureManager() const;
    213213
    214     void unlinkAllContentTextures();
    215     void deleteUnlinkedTextures();
     214    // Delete contents textures' backing resources until they use only bytesLimit bytes. This may
     215    // be called on the impl thread while the main thread is running.
     216    void reduceContentsTexturesMemoryOnImplThread(size_t bytesLimit, CCResourceProvider*);
     217    // Retrieve the list of all contents textures' backings that have been evicted, to pass to the
     218    // main thread to unlink them from their owning textures.
     219    void getEvictedContentTexturesBackings(CCPrioritizedTextureManager::BackingVector&);
     220    // Unlink the list of contents textures' backings from their owning textures on the main thread
     221    // before updating layers.
     222    void unlinkEvictedContentTexturesBackings(const CCPrioritizedTextureManager::BackingVector&);
     223    // Deletes all evicted backings, unlinking them from their owning textures if needed.
     224    // Returns true if this function had to unlink any backings from their owning texture when
     225    // destroying them. If this was the case, the impl layer tree may contain invalid resources.
     226    bool deleteEvictedContentTexturesBackings();
    216227
    217228    bool visible() const { return m_visible; }
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp

    r127907 r128344  
    522522    if (m_contentsTexturesPurged)
    523523        return;
    524     m_resourceProvider->deleteOwnedResources(CCRenderer::ContentPool);
    525     m_contentsTexturesPurged = true;
     524    m_client->releaseContentsTexturesOnImplThread();
     525    setContentsTexturesPurged();
    526526    m_client->setNeedsCommitOnImplThread();
    527527    m_client->onCanDrawStateChanged(canDraw());
     
    732732
    733733    return m_renderer;
     734}
     735
     736void CCLayerTreeHostImpl::setContentsTexturesPurged()
     737{
     738    m_contentsTexturesPurged = true;
     739    m_client->onCanDrawStateChanged(canDraw());
    734740}
    735741
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h

    r127891 r128344  
    6161    virtual void setNeedsCommitOnImplThread() = 0;
    6262    virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimationEventsVector>, double wallClockTime) = 0;
     63    virtual void releaseContentsTexturesOnImplThread() = 0;
    6364};
    6465
     
    158159
    159160    bool contentsTexturesPurged() const { return m_contentsTexturesPurged; }
     161    void setContentsTexturesPurged();
    160162    void resetContentsTexturesPurged();
    161163    size_t memoryAllocationLimitBytes() const { return m_memoryAllocationLimitBytes; }
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.cpp

    r128253 r128344  
    5252        unregisterTexture(*m_textures.begin());
    5353
    54     // Each remaining backing is a leaked opengl texture. We don't have the resourceProvider
    55     // to delete the textures at this time so clearMemory() needs to be called before this.
    56     while (m_backings.size() > 0)
    57         destroyBacking(*m_backings.begin(), 0);
     54    deleteEvictedBackings();
     55
     56    // Each remaining backing is a leaked opengl texture. There should be none.
     57    ASSERT(m_backings.isEmpty());
    5858}
    5959
     
    212212    // Otherwise reduce memory and just allocate a new backing texures.
    213213    if (!backing) {
    214         reduceMemory(m_memoryAvailableBytes - texture->bytes(), resourceProvider);
     214        evictBackingsToReduceMemory(m_memoryAvailableBytes - texture->bytes(), RespectManagerPriorityCutoff, resourceProvider);
    215215        backing = createBacking(texture->size(), texture->format(), resourceProvider);
    216216    }
     
    227227}
    228228
    229 void CCPrioritizedTextureManager::reduceMemory(size_t limitBytes, CCResourceProvider* resourceProvider)
    230 {
    231     ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked());
     229void CCPrioritizedTextureManager::evictBackingsToReduceMemory(size_t limitBytes, EvictionPriorityPolicy evictionPolicy, CCResourceProvider* resourceProvider)
     230{
     231    ASSERT(CCProxy::isImplThread());
    232232    if (memoryUseBytes() <= limitBytes)
    233233        return;
     234
    234235    // Destroy backings until we are below the limit,
    235236    // or until all backings remaining are above the cutoff.
    236237    while (memoryUseBytes() > limitBytes && m_backings.size() > 0) {
    237         BackingSet::iterator it = m_backings.begin();
    238         if ((*it)->hadOwnerAtLastPriorityUpdate() && (*it)->wasAbovePriorityCutoffAtLastPriorityUpdate())
    239             break;
    240         destroyBacking((*it), resourceProvider);
     238        CCPrioritizedTexture::Backing* backing = *m_backings.begin();
     239        if (evictionPolicy == RespectManagerPriorityCutoff)
     240            if (backing->hadOwnerAtLastPriorityUpdate() && backing->wasAbovePriorityCutoffAtLastPriorityUpdate())
     241                break;
     242        evictBackingResource(backing, resourceProvider);
    241243    }
    242244}
     
    249251    updateBackingsPriorities();
    250252
    251     reduceMemory(m_memoryAvailableBytes, resourceProvider);
     253    evictBackingsToReduceMemory(m_memoryAvailableBytes, RespectManagerPriorityCutoff, resourceProvider);
    252254    ASSERT(memoryUseBytes() <= maxMemoryLimitBytes());
    253255
     
    264266    }
    265267    size_t tenPercentOfMemory = m_memoryAvailableBytes / 10;
    266     if (wastedMemory <= tenPercentOfMemory)
    267         return;
    268     reduceMemory(memoryUseBytes() - (wastedMemory - tenPercentOfMemory), resourceProvider);
     268    if (wastedMemory > tenPercentOfMemory)
     269        evictBackingsToReduceMemory(memoryUseBytes() - (wastedMemory - tenPercentOfMemory), RespectManagerPriorityCutoff, resourceProvider);
     270
     271    deleteEvictedBackings();
    269272}
    270273
     
    273276    ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked());
    274277    ASSERT(resourceProvider);
    275     // Unlink and destroy all backing textures.
    276     while (m_backings.size() > 0) {
    277         BackingSet::iterator it = m_backings.begin();
    278         if ((*it)->owner())
    279             (*it)->owner()->unlink();
    280         destroyBacking((*it), resourceProvider);
    281     }
    282 }
    283 
    284 void CCPrioritizedTextureManager::unlinkAllBackings()
     278    evictBackingsToReduceMemory(0, DoNotRespectManagerPriorityCutoff, resourceProvider);
     279    deleteEvictedBackings();
     280}
     281
     282void CCPrioritizedTextureManager::reduceMemoryOnImplThread(size_t limitBytes, CCResourceProvider* resourceProvider)
     283{
     284    ASSERT(CCProxy::isImplThread());
     285    ASSERT(resourceProvider);
     286
     287    evictBackingsToReduceMemory(limitBytes, DoNotRespectManagerPriorityCutoff, resourceProvider);
     288
     289    // Deleting just some (not all) resources is not supported yet because we do not clear
     290    // only the deleted resources from the texture upload queues (rather, we clear all uploads).
     291    // Make sure that if we evict all resources.
     292    ASSERT(m_backings.isEmpty());
     293}
     294
     295void CCPrioritizedTextureManager::getEvictedBackings(BackingVector& evictedBackings)
     296{
     297    ASSERT(CCProxy::isImplThread());
     298    evictedBackings.clear();
     299    evictedBackings.append(m_evictedBackings);
     300}
     301
     302void CCPrioritizedTextureManager::unlinkEvictedBackings(const BackingVector& evictedBackings)
    285303{
    286304    ASSERT(CCProxy::isMainThread());
    287     for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); ++it)
    288         if ((*it)->owner())
    289             (*it)->owner()->unlink();
    290 }
    291 
    292 void CCPrioritizedTextureManager::deleteAllUnlinkedBackings()
    293 {
    294     ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked());
    295     BackingVector backingsToDelete;
    296     for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); ++it)
    297         if (!(*it)->owner())
    298             backingsToDelete.append((*it));
    299 
    300     for (BackingVector::iterator it = backingsToDelete.begin(); it != backingsToDelete.end(); ++it)
    301         destroyBacking((*it), 0);
     305    for (BackingVector::const_iterator it = evictedBackings.begin(); it != evictedBackings.end(); ++it) {
     306        CCPrioritizedTexture::Backing* backing = (*it);
     307        if (backing->owner())
     308            backing->owner()->unlink();
     309    }
     310}
     311
     312bool CCPrioritizedTextureManager::deleteEvictedBackings()
     313{
     314    ASSERT(CCProxy::isMainThread() || (CCProxy::isImplThread() && CCProxy::isMainThreadBlocked()));
     315    bool linkedEvictedBackingsExisted = false;
     316    for (BackingVector::const_iterator it = m_evictedBackings.begin(); it != m_evictedBackings.end(); ++it) {
     317        CCPrioritizedTexture::Backing* backing = (*it);
     318        if (backing->owner()) {
     319            linkedEvictedBackingsExisted = true;
     320            backing->owner()->unlink();
     321        }
     322        delete backing;
     323    }
     324    m_evictedBackings.clear();
     325    return linkedEvictedBackingsExisted;
    302326}
    303327
     
    348372}
    349373
    350 void CCPrioritizedTextureManager::destroyBacking(CCPrioritizedTexture::Backing* backing, CCResourceProvider* resourceProvider)
    351 {
    352     ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked());
     374void CCPrioritizedTextureManager::evictBackingResource(CCPrioritizedTexture::Backing* backing, CCResourceProvider* resourceProvider)
     375{
     376    ASSERT(CCProxy::isImplThread());
    353377    ASSERT(backing);
    354     ASSERT(!backing->owner() || !backing->owner()->isAbovePriorityCutoff());
    355     ASSERT(!backing->owner() || !backing->owner()->isSelfManaged());
     378    ASSERT(resourceProvider);
    356379    ASSERT(m_backings.find(backing) != m_backings.end());
    357380
    358     if (resourceProvider)
    359         resourceProvider->deleteResource(backing->id());
    360     if (backing->owner())
    361         backing->owner()->unlink();
     381    resourceProvider->deleteResource(backing->id());
     382    backing->setId(0);
    362383    m_memoryUseBytes -= backing->bytes();
    363384    m_backings.remove(backing);
    364 
    365     delete backing;
     385    m_evictedBackings.append(backing);
    366386}
    367387
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCPrioritizedTextureManager.h

    r128253 r128344  
    5454    ~CCPrioritizedTextureManager();
    5555
     56    typedef Vector<CCPrioritizedTexture::Backing*> BackingVector;
     57
    5658    // FIXME (http://crbug.com/137094): This 64MB default is a straggler from the
    5759    // old texture manager and is just to give us a default memory allocation before
     
    7577    void clearPriorities();
    7678
     79    void reduceMemoryOnImplThread(size_t limitBytes, CCResourceProvider*);
     80    void getEvictedBackings(BackingVector& evictedBackings);
     81    void unlinkEvictedBackings(const BackingVector& evictedBackings);
     82    // Deletes all evicted backings, unlinking them from their owning textures if needed.
     83    // Returns true if this function to unlinked any backings from their owning texture while
     84    // destroying them.
     85    bool deleteEvictedBackings();
     86
    7787    bool requestLate(CCPrioritizedTexture*);
    7888
    7989    void reduceMemory(CCResourceProvider*);
    8090    void clearAllMemory(CCResourceProvider*);
    81     void unlinkAllBackings();
    82     void deleteAllUnlinkedBackings();
    8391
    8492    void acquireBackingTextureIfNeeded(CCPrioritizedTexture*, CCResourceProvider*);
     
    9098private:
    9199    friend class CCPrioritizedTextureTest;
     100
     101    enum EvictionPriorityPolicy {
     102        RespectManagerPriorityCutoff,
     103        DoNotRespectManagerPriorityCutoff,
     104    };
    92105
    93106    // Compare textures. Highest priority first.
     
    117130
    118131    void updateBackingsPriorities();
    119     void reduceMemory(size_t limit, CCResourceProvider*);
     132    void evictBackingsToReduceMemory(size_t limitBytes, EvictionPriorityPolicy, CCResourceProvider*);
    120133    CCPrioritizedTexture::Backing* createBacking(IntSize, GC3Denum format, CCResourceProvider*);
    121     void destroyBacking(CCPrioritizedTexture::Backing*, CCResourceProvider*);
     134    void evictBackingResource(CCPrioritizedTexture::Backing*, CCResourceProvider*);
    122135
    123136#if !ASSERT_DISABLED
     
    135148    typedef ListHashSet<CCPrioritizedTexture::Backing*> BackingSet;
    136149    typedef Vector<CCPrioritizedTexture*> TextureVector;
    137     typedef Vector<CCPrioritizedTexture::Backing*> BackingVector;
    138150
    139151    TextureSet m_textures;
    140152    BackingSet m_backings;
     153    BackingVector m_evictedBackings;
    141154
    142155    TextureVector m_tempTextureVector;
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp

    r128005 r128344  
    276276}
    277277
     278void CCSingleThreadProxy::releaseContentsTexturesOnImplThread()
     279{
     280    ASSERT(isImplThread());
     281    m_layerTreeHost->reduceContentsTexturesMemoryOnImplThread(0, m_layerTreeHostImpl->resourceProvider());
     282}
     283
    278284// Called by the legacy scheduling path (e.g. where render_widget does the scheduling)
    279285void CCSingleThreadProxy::compositeImmediately()
     
    301307        return false;
    302308
    303     if (m_layerTreeHostImpl->contentsTexturesPurged()) {
    304         m_layerTreeHost->unlinkAllContentTextures();
     309    // Unlink any texture backings that were deleted
     310    CCPrioritizedTextureManager::BackingVector evictedContentsTexturesBackings;
     311    {
     312        DebugScopedSetImplThread implThread;
     313        m_layerTreeHost->getEvictedContentTexturesBackings(evictedContentsTexturesBackings);
     314    }
     315    m_layerTreeHost->unlinkEvictedContentTexturesBackings(evictedContentsTexturesBackings);
     316    {
    305317        DebugScopedSetImplThreadAndMainThreadBlocked implAndMainBlocked;
    306         m_layerTreeHost->deleteUnlinkedTextures();
     318        m_layerTreeHost->deleteEvictedContentTexturesBackings();
    307319    }
    308320
    309321    CCTextureUpdateQueue queue;
    310322    m_layerTreeHost->updateLayers(queue, m_layerTreeHostImpl->memoryAllocationLimitBytes());
    311     m_layerTreeHostImpl->resetContentsTexturesPurged();
     323
     324    if (m_layerTreeHostImpl->contentsTexturesPurged())
     325        m_layerTreeHostImpl->resetContentsTexturesPurged();
    312326
    313327    m_layerTreeHost->willCommit();
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h

    r127948 r128344  
    7373    virtual void setNeedsCommitOnImplThread() OVERRIDE { m_layerTreeHost->scheduleComposite(); }
    7474    virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimationEventsVector>, double wallClockTime) OVERRIDE;
     75    virtual void releaseContentsTexturesOnImplThread() OVERRIDE;
    7576
    7677    // Called by the legacy path where RenderWidget does the scheduling.
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp

    r128005 r128344  
    375375}
    376376
     377void CCThreadProxy::releaseContentsTexturesOnImplThread()
     378{
     379    ASSERT(isImplThread());
     380    m_layerTreeHost->reduceContentsTexturesMemoryOnImplThread(0, m_layerTreeHostImpl->resourceProvider());
     381    // Make sure that we get a new commit before drawing again.
     382    m_resetContentsTexturesPurgedAfterCommitOnImplThread = false;
     383    // The texture upload queue may reference textures that were just purged, so clear it.
     384    m_currentTextureUpdateControllerOnImplThread.clear();
     385}
     386
    377387void CCThreadProxy::setNeedsRedraw()
    378388{
     
    477487    m_pendingBeginFrameRequest->monotonicFrameBeginTime = monotonicallyIncreasingTime();
    478488    m_pendingBeginFrameRequest->scrollInfo = m_layerTreeHostImpl->processScrollDeltas();
    479     m_pendingBeginFrameRequest->contentsTexturesWereDeleted = m_layerTreeHostImpl->contentsTexturesPurged();
    480489    m_pendingBeginFrameRequest->memoryAllocationLimitBytes = m_layerTreeHostImpl->memoryAllocationLimitBytes();
     490    m_layerTreeHost->getEvictedContentTexturesBackings(m_pendingBeginFrameRequest->evictedContentsTexturesBackings);
    481491
    482492    m_mainThreadProxy->postTask(createCCThreadTask(this, &CCThreadProxy::beginFrame));
     
    549559    }
    550560
    551     if (request->contentsTexturesWereDeleted)
    552         m_layerTreeHost->unlinkAllContentTextures();
     561    m_layerTreeHost->unlinkEvictedContentTexturesBackings(request->evictedContentsTexturesBackings);
    553562
    554563    OwnPtr<CCTextureUpdateQueue> queue = adoptPtr(new CCTextureUpdateQueue);
     
    580589
    581590        CCCompletionEvent completion;
    582         CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::beginFrameCompleteOnImplThread, &completion, queue.release(), request->contentsTexturesWereDeleted));
     591        CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::beginFrameCompleteOnImplThread, &completion, queue.release()));
    583592        completion.wait();
    584593    }
     
    588597}
    589598
    590 void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion, PassOwnPtr<CCTextureUpdateQueue> queue, bool contentsTexturesWereDeleted)
     599void CCThreadProxy::beginFrameCompleteOnImplThread(CCCompletionEvent* completion, PassOwnPtr<CCTextureUpdateQueue> queue)
    591600{
    592601    TRACE_EVENT0("cc", "CCThreadProxy::beginFrameCompleteOnImplThread");
     
    602611    }
    603612
    604     if (contentsTexturesWereDeleted) {
    605         ASSERT(m_layerTreeHostImpl->contentsTexturesPurged());
    606         // We unlinked all textures on the main thread, delete them now.
    607         m_layerTreeHost->deleteUnlinkedTextures();
    608         // Mark that we can start drawing again when this commit is complete.
    609         m_resetContentsTexturesPurgedAfterCommitOnImplThread = true;
    610     } else if (m_layerTreeHostImpl->contentsTexturesPurged()) {
    611         // We purged the content textures on the impl thread between the time we
    612         // posted the beginFrame task and now, meaning we have a bunch of
    613         // uploads that are now invalid. Clear the uploads (they all go to
    614         // content textures), and kick another commit to fill them again.
     613    // If we unlinked evicted textures on the main thread, delete them now.
     614    if (m_layerTreeHost->deleteEvictedContentTexturesBackings()) {
     615
     616        // Deleting the evicted textures' backings resulted in some textures in the
     617        // layer tree being invalidated (unliked from their backings). The upload queue
     618        // may contain references to these textures, so clear the queue and kick off
     619        // another commit to fill them again.
    615620        queue->clearUploads();
    616621        setNeedsCommitOnImplThread();
     622    } else {
     623        // The layer tree does not reference evicted textures, so mark that we
     624        // can draw this tree once this commit is complete.
     625        if (m_layerTreeHostImpl->contentsTexturesPurged())
     626            m_resetContentsTexturesPurgedAfterCommitOnImplThread = true;
    617627    }
    618628
     
    903913    TRACE_EVENT0("cc", "CCThreadProxy::layerTreeHostClosedOnImplThread");
    904914    ASSERT(isImplThread());
    905     if (!m_layerTreeHostImpl->contentsTexturesPurged())
    906         m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->resourceProvider());
     915    m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->resourceProvider());
    907916    m_inputHandlerOnImplThread.clear();
    908917    m_layerTreeHostImpl.clear();
     
    926935    TRACE_EVENT0("cc", "CCThreadProxy::recreateContextOnImplThread");
    927936    ASSERT(isImplThread());
    928     if (!m_layerTreeHostImpl->contentsTexturesPurged())
    929         m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->resourceProvider());
     937    m_layerTreeHost->deleteContentsTexturesOnImplThread(m_layerTreeHostImpl->resourceProvider());
    930938    *recreateSucceeded = m_layerTreeHostImpl->initializeRenderer(adoptPtr(contextPtr), textureUploader);
    931939    if (*recreateSucceeded) {
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.h

    r127948 r128344  
    8282    virtual void setNeedsCommitOnImplThread() OVERRIDE;
    8383    virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimationEventsVector>, double wallClockTime) OVERRIDE;
     84    virtual void releaseContentsTexturesOnImplThread() OVERRIDE;
    8485
    8586    // CCSchedulerClient implementation
     
    107108        double monotonicFrameBeginTime;
    108109        OwnPtr<CCScrollAndScaleSet> scrollInfo;
    109         bool contentsTexturesWereDeleted;
     110        CCPrioritizedTextureManager::BackingVector evictedContentsTexturesBackings;
    110111        size_t memoryAllocationLimitBytes;
    111112    };
     
    128129    };
    129130    void forceBeginFrameOnImplThread(CCCompletionEvent*);
    130     void beginFrameCompleteOnImplThread(CCCompletionEvent*, PassOwnPtr<CCTextureUpdateQueue>, bool contentsTexturesWereDeleted);
     131    void beginFrameCompleteOnImplThread(CCCompletionEvent*, PassOwnPtr<CCTextureUpdateQueue>);
    131132    void beginFrameAbortedOnImplThread();
    132133    void requestReadbackOnImplThread(ReadbackRequest*);
  • trunk/Source/WebKit/chromium/ChangeLog

    r128300 r128344  
     12012-09-12  Christopher Cameron  <ccameron@chromium.org>
     2
     3        [chromium] Evict textures through the texture manager instead of the resource provider
     4        https://bugs.webkit.org/show_bug.cgi?id=96463
     5
     6        Reviewed by James Robinson.
     7
     8        Update layer tree host impl test to include the extra interface functions
     9        added to CCLayerTreeHostImplClient.
     10
     11        * tests/CCLayerTreeHostImplTest.cpp:
     12
    1132012-09-12  Ilya Tikhonovsky  <loislo@chromium.org>
    214
  • trunk/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp

    r127907 r128344  
    9090    virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = true; }
    9191    virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimationEventsVector>, double wallClockTime) OVERRIDE { }
     92    virtual void releaseContentsTexturesOnImplThread() OVERRIDE { }
    9293
    9394    PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHost(bool partialSwap, PassOwnPtr<CCGraphicsContext> graphicsContext, PassOwnPtr<CCLayerImpl> rootPtr)
Note: See TracChangeset for help on using the changeset viewer.