Changeset 98360 in webkit


Ignore:
Timestamp:
Oct 25, 2011, 10:44:31 AM (14 years ago)
Author:
enne@google.com
Message:

[chromium] Batch up texture uploads so that they can be updated incrementally
https://bugs.webkit.org/show_bug.cgi?id=70454

Reviewed by James Robinson.

Because texture uploads can sometimes take more than a frame to
complete, collect all the uploads that need to occur in a
CCTextureUpdater so that we can easily incrementally upload some of
them, interleaving input and drawing so that the compositor thread
continues to appear responsive during a commit.

This change doesn't actually interleave the commits, it just pushes
the infrastructure for doing so up to the CCProxy level so that a
future scheduler can make this decision.

VideoLayerChromium is the only layer type to not use this system. It
needs to be converted to use a texture updater first and it is less of
a priority than the tiled layers.

  • WebCore.gypi:
  • platform/graphics/chromium/Canvas2DLayerChromium.cpp:

(WebCore::Canvas2DLayerChromium::updateCompositorResources):

  • platform/graphics/chromium/Canvas2DLayerChromium.h:
  • platform/graphics/chromium/LayerChromium.h:

(WebCore::LayerChromium::updateCompositorResources):

  • platform/graphics/chromium/TiledLayerChromium.cpp:

(WebCore::TiledLayerChromium::updateCompositorResources):

  • platform/graphics/chromium/TiledLayerChromium.h:
  • platform/graphics/chromium/VideoLayerChromium.cpp:

(WebCore::VideoLayerChromium::updateCompositorResources):

  • platform/graphics/chromium/VideoLayerChromium.h:
  • platform/graphics/chromium/WebGLLayerChromium.cpp:

(WebCore::WebGLLayerChromium::updateCompositorResources):

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

(WebCore::CCLayerTreeHost::beginCommitOnImplThread):
(WebCore::CCLayerTreeHost::finishCommitOnImplThread):
(WebCore::CCLayerTreeHost::updateCompositorResources):

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

(WebCore::CCSingleThreadProxy::setNeedsCommit):
(WebCore::CCSingleThreadProxy::doCommit):
(WebCore::CCSingleThreadProxy::commitIfNeeded):

  • platform/graphics/chromium/cc/CCSingleThreadProxy.h:
  • platform/graphics/chromium/cc/CCTextureUpdater.cpp: Added.

(WebCore::CCTextureUpdater::CCTextureUpdater):
(WebCore::CCTextureUpdater::~CCTextureUpdater):
(WebCore::CCTextureUpdater::append):
(WebCore::CCTextureUpdater::update):
(WebCore::CCTextureUpdater::clear):

  • platform/graphics/chromium/cc/CCTextureUpdater.h: Added.

(WebCore::CCTextureUpdater::allocator):

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

(WebCore::CCThreadProxy::commitOnImplThread):

Location:
trunk/Source/WebCore
Files:
2 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r98359 r98360  
     12011-10-25  Adrienne Walker  <enne@google.com>
     2
     3        [chromium] Batch up texture uploads so that they can be updated incrementally
     4        https://bugs.webkit.org/show_bug.cgi?id=70454
     5
     6        Reviewed by James Robinson.
     7
     8        Because texture uploads can sometimes take more than a frame to
     9        complete, collect all the uploads that need to occur in a
     10        CCTextureUpdater so that we can easily incrementally upload some of
     11        them, interleaving input and drawing so that the compositor thread
     12        continues to appear responsive during a commit.
     13
     14        This change doesn't actually interleave the commits, it just pushes
     15        the infrastructure for doing so up to the CCProxy level so that a
     16        future scheduler can make this decision.
     17
     18        VideoLayerChromium is the only layer type to not use this system. It
     19        needs to be converted to use a texture updater first and it is less of
     20        a priority than the tiled layers.
     21
     22        * WebCore.gypi:
     23        * platform/graphics/chromium/Canvas2DLayerChromium.cpp:
     24        (WebCore::Canvas2DLayerChromium::updateCompositorResources):
     25        * platform/graphics/chromium/Canvas2DLayerChromium.h:
     26        * platform/graphics/chromium/LayerChromium.h:
     27        (WebCore::LayerChromium::updateCompositorResources):
     28        * platform/graphics/chromium/TiledLayerChromium.cpp:
     29        (WebCore::TiledLayerChromium::updateCompositorResources):
     30        * platform/graphics/chromium/TiledLayerChromium.h:
     31        * platform/graphics/chromium/VideoLayerChromium.cpp:
     32        (WebCore::VideoLayerChromium::updateCompositorResources):
     33        * platform/graphics/chromium/VideoLayerChromium.h:
     34        * platform/graphics/chromium/WebGLLayerChromium.cpp:
     35        (WebCore::WebGLLayerChromium::updateCompositorResources):
     36        * platform/graphics/chromium/WebGLLayerChromium.h:
     37        * platform/graphics/chromium/cc/CCLayerTreeHost.cpp:
     38        (WebCore::CCLayerTreeHost::beginCommitOnImplThread):
     39        (WebCore::CCLayerTreeHost::finishCommitOnImplThread):
     40        (WebCore::CCLayerTreeHost::updateCompositorResources):
     41        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
     42        * platform/graphics/chromium/cc/CCSingleThreadProxy.cpp:
     43        (WebCore::CCSingleThreadProxy::setNeedsCommit):
     44        (WebCore::CCSingleThreadProxy::doCommit):
     45        (WebCore::CCSingleThreadProxy::commitIfNeeded):
     46        * platform/graphics/chromium/cc/CCSingleThreadProxy.h:
     47        * platform/graphics/chromium/cc/CCTextureUpdater.cpp: Added.
     48        (WebCore::CCTextureUpdater::CCTextureUpdater):
     49        (WebCore::CCTextureUpdater::~CCTextureUpdater):
     50        (WebCore::CCTextureUpdater::append):
     51        (WebCore::CCTextureUpdater::update):
     52        (WebCore::CCTextureUpdater::clear):
     53        * platform/graphics/chromium/cc/CCTextureUpdater.h: Added.
     54        (WebCore::CCTextureUpdater::allocator):
     55        * platform/graphics/chromium/cc/CCThreadProxy.cpp:
     56        (WebCore::CCThreadProxy::commitOnImplThread):
     57
    1582011-10-24  Jer Noble  <jer.noble@apple.com>
    259
  • trunk/Source/WebCore/WebCore.gypi

    r98305 r98360  
    35603560            'platform/graphics/chromium/cc/CCSingleThreadProxy.cpp',
    35613561            'platform/graphics/chromium/cc/CCSingleThreadProxy.h',
     3562            'platform/graphics/chromium/cc/CCTextureUpdater.cpp',
     3563            'platform/graphics/chromium/cc/CCTextureUpdater.h',
    35623564            'platform/graphics/chromium/cc/CCThread.h',
    35633565            'platform/graphics/chromium/cc/CCThreadProxy.cpp',
  • trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp

    r97780 r98360  
    6565}
    6666
    67 void Canvas2DLayerChromium::updateCompositorResources(GraphicsContext3D*, TextureAllocator*)
     67void Canvas2DLayerChromium::updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&)
    6868{
    6969    if (m_dirtyRect.isEmpty() || !drawsContent())
  • trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h

    r96186 r98360  
    4747    virtual ~Canvas2DLayerChromium();
    4848    virtual bool drawsContent() const;
    49     virtual void updateCompositorResources(GraphicsContext3D*, TextureAllocator*);
     49    virtual void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&);
    5050
    5151    void setTextureChanged();
  • trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h

    r97924 r98360  
    5454class CCLayerImpl;
    5555class CCLayerTreeHost;
     56class CCTextureUpdater;
    5657class GraphicsContext3D;
    5758
     
    160161    virtual bool drawsContent() const { return false; }
    161162    virtual void paintContentsIfDirty() { }
    162     virtual void updateCompositorResources(GraphicsContext3D*, TextureAllocator*) { }
     163    virtual void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&) { }
    163164    virtual void setIsMask(bool) { }
    164165    virtual void unreserveContentsTexture() { }
  • trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp

    r97809 r98360  
    3535#include "TextStream.h"
    3636#include "cc/CCLayerImpl.h"
     37#include "cc/CCTextureUpdater.h"
    3738#include "cc/CCTiledLayerImpl.h"
    3839#include <wtf/CurrentTime.h>
     
    151152}
    152153
    153 void TiledLayerChromium::updateCompositorResources(GraphicsContext3D* context, TextureAllocator* allocator)
     154void TiledLayerChromium::updateCompositorResources(GraphicsContext3D* context, CCTextureUpdater& updater)
    154155{
    155156    // Painting could cause compositing to get turned off, which may cause the tiler to become invalidated mid-update.
     
    197198                CRASH();
    198199
    199             tile->texture()->bindTexture(context, allocator);
     200            tile->texture()->bindTexture(context, updater.allocator());
    200201            const GC3Dint filter = m_tiler->hasBorderTexels() ? GraphicsContext3D::LINEAR : GraphicsContext3D::NEAREST;
    201202            GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, filter));
    202203            GLC(context, context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, filter));
    203             GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0));
    204 
    205             textureUpdater()->updateTextureRect(context, allocator, tile->texture(), sourceRect, destRect);
     204
     205            updater.append(tile->texture(), textureUpdater(), sourceRect, destRect);
    206206            tile->clearDirty();
    207207        }
  • trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h

    r97809 r98360  
    4444    virtual ~TiledLayerChromium();
    4545
    46     virtual void updateCompositorResources(GraphicsContext3D*, TextureAllocator*);
     46    virtual void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&);
    4747    virtual void setIsMask(bool);
    4848
  • trunk/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp

    r97780 r98360  
    4141#include "VideoFrameProvider.h"
    4242#include "cc/CCLayerImpl.h"
     43#include "cc/CCTextureUpdater.h"
    4344#include "cc/CCVideoLayerImpl.h"
    4445
     
    7778}
    7879
    79 void VideoLayerChromium::updateCompositorResources(GraphicsContext3D* context, TextureAllocator* allocator)
     80void VideoLayerChromium::updateCompositorResources(GraphicsContext3D* context, CCTextureUpdater& updater)
    8081{
    8182    if (!m_delegate || !m_provider)
     
    129130        ASSERT(texture.m_texture);
    130131        ASSERT(frame->requiredTextureSize(plane) == texture.m_texture->size());
    131         updateTexture(context, allocator, texture, frame->data(plane));
     132        updateTexture(context, updater.allocator(), texture, frame->data(plane));
    132133    }
    133134
  • trunk/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.h

    r97451 r98360  
    5151    virtual PassRefPtr<CCLayerImpl> createCCLayerImpl();
    5252
    53     virtual void updateCompositorResources(GraphicsContext3D*, TextureAllocator*);
     53    virtual void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&);
    5454    virtual bool drawsContent() const { return true; }
    5555
  • trunk/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp

    r97780 r98360  
    6666}
    6767
    68 void WebGLLayerChromium::updateCompositorResources(GraphicsContext3D* rendererContext, TextureAllocator*)
     68void WebGLLayerChromium::updateCompositorResources(GraphicsContext3D* rendererContext, CCTextureUpdater&)
    6969{
    7070    if (!drawsContent())
  • trunk/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.h

    r96186 r98360  
    5151
    5252    virtual bool drawsContent() const;
    53     virtual void updateCompositorResources(GraphicsContext3D*, TextureAllocator*);
     53    virtual void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&);
    5454    void setTextureUpdated();
    5555    bool paintRenderedResultsToCanvas(ImageBuffer*);
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp

    r98313 r98360  
    110110}
    111111
     112void CCLayerTreeHost::beginCommitOnImplThread(CCLayerTreeHostImpl* hostImpl)
     113{
     114    ASSERT(CCProxy::isImplThread());
     115    TRACE_EVENT("CCLayerTreeHost::commitTo", this, 0);
     116
     117    contentsTextureManager()->reduceMemoryToLimit(TextureManager::reclaimLimitBytes());
     118    contentsTextureManager()->deleteEvictedTextures(hostImpl->contentsTextureAllocator());
     119}
     120
    112121// This function commits the CCLayerTreeHost to an impl tree. When modifying
    113122// this function, keep in mind that the function *runs* on the impl thread! Any
     
    115124// should be delayed until the CCLayerTreeHost::commitComplete, which will run
    116125// after the commit, but on the main thread.
    117 void CCLayerTreeHost::commitToOnImplThread(CCLayerTreeHostImpl* hostImpl)
     126void CCLayerTreeHost::finishCommitOnImplThread(CCLayerTreeHostImpl* hostImpl)
    118127{
    119128    ASSERT(CCProxy::isImplThread());
    120     TRACE_EVENT("CCLayerTreeHost::commitTo", this, 0);
    121129    hostImpl->setSourceFrameNumber(frameNumber());
    122 
    123     contentsTextureManager()->reduceMemoryToLimit(TextureManager::reclaimLimitBytes());
    124     contentsTextureManager()->deleteEvictedTextures(hostImpl->contentsTextureAllocator());
    125 
    126     updateCompositorResources(m_updateList, hostImpl->context(), hostImpl->contentsTextureAllocator());
    127 
    128130    hostImpl->setVisible(m_visible);
    129131    hostImpl->setZoomAnimatorTransform(m_zoomAnimatorTransform);
     
    363365}
    364366
    365 void CCLayerTreeHost::updateCompositorResources(const LayerList& renderSurfaceLayerList, GraphicsContext3D* context, TextureAllocator* allocator)
    366 {
    367     for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) {
    368         LayerChromium* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex].get();
     367void CCLayerTreeHost::updateCompositorResources(GraphicsContext3D* context, CCTextureUpdater& updater)
     368{
     369    for (int surfaceIndex = m_updateList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) {
     370        LayerChromium* renderSurfaceLayer = m_updateList[surfaceIndex].get();
    369371        RenderSurfaceChromium* renderSurface = renderSurfaceLayer->renderSurface();
    370372        ASSERT(renderSurface);
     
    374376
    375377        if (renderSurfaceLayer->maskLayer())
    376             updateCompositorResources(renderSurfaceLayer->maskLayer(), context, allocator);
     378            updateCompositorResources(renderSurfaceLayer->maskLayer(), context, updater);
    377379
    378380        if (renderSurfaceLayer->replicaLayer()) {
    379             updateCompositorResources(renderSurfaceLayer->replicaLayer(), context, allocator);
     381            updateCompositorResources(renderSurfaceLayer->replicaLayer(), context, updater);
    380382           
    381383            if (renderSurfaceLayer->replicaLayer()->maskLayer())
    382                 updateCompositorResources(renderSurfaceLayer->replicaLayer()->maskLayer(), context, allocator);
     384                updateCompositorResources(renderSurfaceLayer->replicaLayer()->maskLayer(), context, updater);
    383385        }
    384386       
     
    390392                continue;
    391393
    392             updateCompositorResources(layer, context, allocator);
     394            updateCompositorResources(layer, context, updater);
    393395        }
    394396    }
    395397}
    396398
    397 void CCLayerTreeHost::updateCompositorResources(LayerChromium* layer, GraphicsContext3D* context, TextureAllocator* allocator)
     399void CCLayerTreeHost::updateCompositorResources(LayerChromium* layer, GraphicsContext3D* context, CCTextureUpdater& updater)
    398400{
    399401    // For normal layers, these conditions should have already been checked while creating the render surface layer lists.
     
    402404        return;
    403405
    404     layer->updateCompositorResources(context, allocator);
     406    layer->updateCompositorResources(context, updater);
    405407}
    406408
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h

    r98313 r98360  
    4343
    4444class CCLayerTreeHostImpl;
     45class CCTextureUpdater;
    4546class GraphicsContext3D;
    4647class LayerChromium;
     
    103104    // CCLayerTreeHost interface to CCProxy.
    104105    void animateAndLayout(double frameBeginTime);
     106    void beginCommitOnImplThread(CCLayerTreeHostImpl*);
     107    void finishCommitOnImplThread(CCLayerTreeHostImpl*);
    105108    void commitComplete();
    106     void commitToOnImplThread(CCLayerTreeHostImpl*);
    107109    PassRefPtr<GraphicsContext3D> createLayerTreeHostContext3D();
    108110    virtual PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHostImpl(CCLayerTreeHostImplClient*);
     
    157159    void updateLayers();
    158160
     161    void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&);
    159162    void applyScrollDeltas(const CCScrollUpdateSet&);
    160163protected:
     
    169172
    170173    void updateLayers(LayerChromium*);
    171     void updateCompositorResources(const LayerList&, GraphicsContext3D*, TextureAllocator*);
    172     void updateCompositorResources(LayerChromium*, GraphicsContext3D*, TextureAllocator*);
    173     void updateMaskResourcesForRenderSurface(LayerChromium*, GraphicsContext3D*, TextureAllocator*);
     174    void updateCompositorResources(LayerChromium*, GraphicsContext3D*, CCTextureUpdater&);
    174175    void clearPendingUpdate();
    175176
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.cpp

    r98039 r98360  
    3333#include "cc/CCMainThreadTask.h"
    3434#include "cc/CCScrollController.h"
     35#include "cc/CCTextureUpdater.h"
    3536#include <wtf/CurrentTime.h>
    3637
     
    148149{
    149150    ASSERT(CCProxy::isMainThread());
     151    doCommit();
     152}
     153
     154void CCSingleThreadProxy::doCommit()
     155{
     156    ASSERT(CCProxy::isMainThread());
    150157    // Commit immediately
    151158    {
    152159        DebugScopedSetImplThread impl;
    153160        m_layerTreeHostImpl->beginCommit();
    154         m_layerTreeHost->commitToOnImplThread(m_layerTreeHostImpl.get());
     161
     162        m_layerTreeHost->beginCommitOnImplThread(m_layerTreeHostImpl.get());
     163        CCTextureUpdater updater(m_layerTreeHostImpl->contentsTextureAllocator());
     164        m_layerTreeHost->updateCompositorResources(m_layerTreeHostImpl->context(), updater);
     165        while (updater.update(m_layerTreeHostImpl->context(), 1)) { }
     166        m_layerTreeHost->finishCommitOnImplThread(m_layerTreeHostImpl.get());
     167
    155168        m_layerTreeHostImpl->commitComplete();
    156169
     
    254267    ASSERT(CCProxy::isMainThread());
    255268
    256     // Update
    257269    m_layerTreeHost->updateLayers();
    258270
    259     // Commit
    260     {
    261         DebugScopedSetImplThread impl;
    262         m_layerTreeHostImpl->beginCommit();
    263         m_layerTreeHost->commitToOnImplThread(m_layerTreeHostImpl.get());
    264         m_layerTreeHostImpl->commitComplete();
    265     }
    266     m_layerTreeHost->commitComplete();
     271    doCommit();
    267272}
    268273
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCSingleThreadProxy.h

    r98039 r98360  
    6868    bool recreateContextIfNeeded();
    6969    void commitIfNeeded();
     70    void doCommit();
    7071    bool doComposite();
    7172
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCThreadProxy.cpp

    r98039 r98360  
    3535#include "cc/CCScopedMainThreadProxy.h"
    3636#include "cc/CCScrollController.h"
     37#include "cc/CCTextureUpdater.h"
    3738#include "cc/CCThreadTask.h"
    3839#include <wtf/CurrentTime.h>
     
    420421    }
    421422    m_layerTreeHostImpl->beginCommit();
    422     m_layerTreeHost->commitToOnImplThread(m_layerTreeHostImpl.get());
     423
     424    m_layerTreeHost->beginCommitOnImplThread(m_layerTreeHostImpl.get());
     425    CCTextureUpdater updater(m_layerTreeHostImpl->contentsTextureAllocator());
     426    m_layerTreeHost->updateCompositorResources(m_layerTreeHostImpl->context(), updater);
     427    while (updater.update(m_layerTreeHostImpl->context(), 1)) { }
     428    m_layerTreeHost->finishCommitOnImplThread(m_layerTreeHostImpl.get());
     429
    423430    m_layerTreeHostImpl->commitComplete();
    424431
Note: See TracChangeset for help on using the changeset viewer.