Changeset 149292 in webkit


Ignore:
Timestamp:
Apr 29, 2013 9:24:18 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Get rid of "non-composited contents" in CoordinatedLayerTreeHost
https://bugs.webkit.org/show_bug.cgi?id=110355

Patch by Noam Rosenthal <Noam Rosenthal> on 2013-04-29
Reviewed by Jocelyn Turcotte.

Source/WebCore:

When in force compositing mode, always assume that the main layer needs
a backing store. Make setVisibleContentRectTrajectoryVector and accumulatedCoverRect
recursive so that they don't rely on a specialized layer.

No new testable behavior, changes to coverRect and trajectory vector only
affect tiling latency in rare cases that are not trivial to test.

  • platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:

(WebCore::CoordinatedGraphicsLayer:setVisibleContentRectTrajectoryVector):

Make the trajectory vector recursive, though limited only to layers with
translate/identity. This allows us to keep the trajectory vector while removing
the non-composited contents specialization.

(WebCore::CoordinatedGraphicsLayer::accumulatedCoverRect):

Added accumulatedCoverRect, so that the coverRect calculations for the UI process
are not bound to the non-composited contents layer.

(WebCore::CoordinatedGraphicsLayer::findDescendantWithContentsRecursively):

Instead of saving a reference to the non-composited contents layer, we assume that
the first layer we found recursively which has contents is the one to be used for
coverRect/trajectory calculations.

(WebCore):

  • platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:

(CoordinatedGraphicsLayer):

  • rendering/RenderLayerBacking.cpp:

(WebCore::RenderLayerBacking::paintsIntoWindow):

Always create a layer for the non-composited contents when in forceCompositing mode.

Source/WebKit2:

Instead of using a special non-composited contents layer, we let RenderLayerCompositor create
a proper GraphicsLayer for that content.
CoordinatedLayerTreeHost now needs to find the main contents layer for the purpose of setting
the trajectory vector and applying the cover rect.

  • WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:

(WebKit::CoordinatedLayerTreeHost::CoordinatedLayerTreeHost):
(WebKit::CoordinatedLayerTreeHost::setRootCompositingLayer):

Don't create the non-composited layer, instead keep a raw pointer to the root
compositing layer created by the WebCore compositor.

(WebKit::CoordinatedLayerTreeHost::setNonCompositedContentsNeedDisplay):
(WebKit::CoordinatedLayerTreeHost::setNonCompositedContentsNeedDisplayInRect):
(WebKit::CoordinatedLayerTreeHost::scrollNonCompositedContents):
(WebKit::CoordinatedLayerTreeHost::sizeDidChange):
(WebKit::CoordinatedLayerTreeHost::paintContents):
(WebKit::CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged):
(WebKit::CoordinatedLayerTreeHost::setVisibleContentsRect):

Remove non-composited layer specialization.

Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r149288 r149292  
     12013-04-29  Noam Rosenthal  <noam@webkit.org>
     2
     3        Get rid of "non-composited contents" in CoordinatedLayerTreeHost
     4        https://bugs.webkit.org/show_bug.cgi?id=110355
     5
     6        Reviewed by Jocelyn Turcotte.
     7
     8        When in force compositing mode, always assume that the main layer needs
     9        a backing store. Make setVisibleContentRectTrajectoryVector and accumulatedCoverRect
     10        recursive so that they don't rely on a specialized layer.
     11
     12        No new testable behavior, changes to coverRect and trajectory vector only
     13        affect tiling latency in rare cases that are not trivial to test.
     14
     15        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
     16        (WebCore::CoordinatedGraphicsLayer:setVisibleContentRectTrajectoryVector):
     17            Make the trajectory vector recursive, though limited only to layers with
     18            translate/identity. This allows us to keep the trajectory vector while removing
     19            the non-composited contents specialization.
     20
     21        (WebCore::CoordinatedGraphicsLayer::accumulatedCoverRect):
     22            Added accumulatedCoverRect, so that the coverRect calculations for the UI process
     23            are not bound to the non-composited contents layer.
     24
     25        (WebCore::CoordinatedGraphicsLayer::findDescendantWithContentsRecursively):
     26            Instead of saving a reference to the non-composited contents layer, we assume that
     27            the first layer we found recursively which has contents is the one to be used for
     28            coverRect/trajectory calculations.
     29
     30        (WebCore):
     31        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
     32        (CoordinatedGraphicsLayer):
     33        * rendering/RenderLayerBacking.cpp:
     34        (WebCore::RenderLayerBacking::paintsIntoWindow):
     35            Always create a layer for the non-composited contents when in forceCompositing mode.
     36
    1372013-04-29  Dirk Schulze  <krit@webkit.org>
    238
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp

    r148748 r149292  
    837837}
    838838
     839CoordinatedGraphicsLayer* CoordinatedGraphicsLayer::findFirstDescendantWithContentsRecursively()
     840{
     841    if (shouldHaveBackingStore())
     842        return this;
     843
     844    for (size_t i = 0; i < children().size(); ++i) {
     845        CoordinatedGraphicsLayer* layer = toCoordinatedGraphicsLayer(children()[i])->findFirstDescendantWithContentsRecursively();
     846        if (layer)
     847            return layer;
     848    }
     849
     850    return 0;
     851}
     852
    839853void CoordinatedGraphicsLayer::setVisibleContentRectTrajectoryVector(const FloatPoint& trajectoryVector)
    840854{
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h

    r148748 r149292  
    149149
    150150    static void setShouldSupportContentsTiling(bool);
     151    CoordinatedGraphicsLayer* findFirstDescendantWithContentsRecursively();
    151152
    152153private:
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r149105 r149292  
    18461846
    18471847    if (m_owningLayer->isRootLayer()) {
    1848 #if PLATFORM(BLACKBERRY)
     1848#if PLATFORM(BLACKBERRY) || USE(COORDINATED_GRAPHICS)
    18491849        if (compositor()->inForcedCompositingMode())
    18501850            return false;
  • trunk/Source/WebKit2/ChangeLog

    r149291 r149292  
     12013-04-29  Noam Rosenthal  <noam@webkit.org>
     2
     3        Get rid of "non-composited contents" in CoordinatedLayerTreeHost
     4        https://bugs.webkit.org/show_bug.cgi?id=110355
     5
     6        Reviewed by Jocelyn Turcotte.
     7
     8        Instead of using a special non-composited contents layer, we let RenderLayerCompositor create
     9        a proper GraphicsLayer for that content.
     10        CoordinatedLayerTreeHost now needs to find the main contents layer for the purpose of setting
     11        the trajectory vector and applying the cover rect.
     12
     13        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp:
     14        (WebKit::CoordinatedLayerTreeHost::CoordinatedLayerTreeHost):
     15        (WebKit::CoordinatedLayerTreeHost::setRootCompositingLayer):
     16            Don't create the non-composited layer, instead keep a raw pointer to the root
     17            compositing layer created by the WebCore compositor.
     18
     19        (WebKit::CoordinatedLayerTreeHost::setNonCompositedContentsNeedDisplay):
     20        (WebKit::CoordinatedLayerTreeHost::setNonCompositedContentsNeedDisplayInRect):
     21        (WebKit::CoordinatedLayerTreeHost::scrollNonCompositedContents):
     22        (WebKit::CoordinatedLayerTreeHost::sizeDidChange):
     23        (WebKit::CoordinatedLayerTreeHost::paintContents):
     24        (WebKit::CoordinatedLayerTreeHost::deviceOrPageScaleFactorChanged):
     25        (WebKit::CoordinatedLayerTreeHost::setVisibleContentsRect):
     26            Remove non-composited layer specialization.
     27
    1282013-04-29  Zoltan Arvai  <zarvai@inf.u-szeged.hu>
    229
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp

    r149008 r149292  
    8181CoordinatedLayerTreeHost::CoordinatedLayerTreeHost(WebPage* webPage)
    8282    : LayerTreeHost(webPage)
     83    , m_rootCompositingLayer(0)
    8384    , m_notifyAfterScheduledLayerFlush(false)
    8485    , m_isValid(true)
     
    100101    // Create a root layer.
    101102    m_rootLayer = GraphicsLayer::create(this, this);
    102     CoordinatedGraphicsLayer* coordinatedRootLayer = toCoordinatedGraphicsLayer(m_rootLayer.get());
    103103#ifndef NDEBUG
    104104    m_rootLayer->setName("CoordinatedLayerTreeHost root layer");
     
    106106    m_rootLayer->setDrawsContent(false);
    107107    m_rootLayer->setSize(m_webPage->size());
    108     m_layerTreeContext.coordinatedLayerID = toCoordinatedGraphicsLayer(coordinatedRootLayer)->id();
    109 
    110     m_nonCompositedContentLayer = GraphicsLayer::create(this, this);
    111 #ifndef NDEBUG
    112     m_nonCompositedContentLayer->setName("CoordinatedLayerTreeHost non-composited content");
    113 #endif
    114     m_nonCompositedContentLayer->setDrawsContent(true);
    115     m_nonCompositedContentLayer->setSize(m_webPage->size());
    116 
    117     m_nonCompositedContentLayer->setShowDebugBorder(m_webPage->corePage()->settings()->showDebugBorders());
    118     m_nonCompositedContentLayer->setShowRepaintCounter(m_webPage->corePage()->settings()->showRepaintCounter());
    119 
    120     m_rootLayer->addChild(m_nonCompositedContentLayer.get());
     108    m_layerTreeContext.coordinatedLayerID = toCoordinatedGraphicsLayer(m_rootLayer.get())->id();
    121109
    122110    CoordinatedSurface::setFactory(createCoordinatedSurface);
     
    168156void CoordinatedLayerTreeHost::setRootCompositingLayer(WebCore::GraphicsLayer* graphicsLayer)
    169157{
    170     m_nonCompositedContentLayer->removeAllChildren();
    171     m_nonCompositedContentLayer->setContentsOpaque(m_webPage->drawsBackground() && !m_webPage->drawsTransparentBackground());
    172 
    173     // Add the accelerated layer tree hierarchy.
    174     if (graphicsLayer)
    175         m_nonCompositedContentLayer->addChild(graphicsLayer);
     158    if (m_rootCompositingLayer)
     159        m_rootCompositingLayer->removeFromParent();
     160
     161    m_rootCompositingLayer = graphicsLayer;
     162    if (m_rootCompositingLayer)
     163        m_rootLayer->addChildAtIndex(m_rootCompositingLayer, 0);
    176164}
    177165
     
    185173}
    186174
    187 void CoordinatedLayerTreeHost::setNonCompositedContentsNeedDisplay()
    188 {
    189     m_nonCompositedContentLayer->setNeedsDisplay();
    190     if (m_pageOverlayLayer)
    191         m_pageOverlayLayer->setNeedsDisplay();
    192 
    193     scheduleLayerFlush();
    194 }
    195 
    196 void CoordinatedLayerTreeHost::setNonCompositedContentsNeedDisplayInRect(const WebCore::IntRect& rect)
    197 {
    198     m_nonCompositedContentLayer->setNeedsDisplayInRect(rect);
    199     if (m_pageOverlayLayer)
    200         m_pageOverlayLayer->setNeedsDisplayInRect(rect);
    201 
    202     scheduleLayerFlush();
    203 }
    204 
    205 void CoordinatedLayerTreeHost::scrollNonCompositedContents(const WebCore::IntRect&)
    206 {
    207     if (!m_webPage->useFixedLayout())
    208         setNonCompositedContentsNeedDisplay();
    209 
    210     scheduleLayerFlush();
    211 }
    212 
    213175void CoordinatedLayerTreeHost::forceRepaint()
    214176{
     
    234196void CoordinatedLayerTreeHost::sizeDidChange(const WebCore::IntSize& newSize)
    235197{
    236     if (m_rootLayer->size() == newSize)
    237         return;
    238 
    239198    m_rootLayer->setSize(newSize);
    240 
    241     // If the newSize exposes new areas of the non-composited content a setNeedsDisplay is needed
    242     // for those newly exposed areas.
    243     FloatSize oldSize = m_nonCompositedContentLayer->size();
    244     m_nonCompositedContentLayer->setSize(newSize);
    245 
    246     if (newSize.width() > oldSize.width()) {
    247         float height = std::min(static_cast<float>(newSize.height()), oldSize.height());
    248         m_nonCompositedContentLayer->setNeedsDisplayInRect(FloatRect(oldSize.width(), 0, newSize.width() - oldSize.width(), height));
    249     }
    250 
    251     if (newSize.height() > oldSize.height())
    252         m_nonCompositedContentLayer->setNeedsDisplayInRect(FloatRect(0, oldSize.height(), newSize.width(), newSize.height() - oldSize.height()));
    253 
    254     if (m_pageOverlayLayer)
    255         m_pageOverlayLayer->setSize(newSize);
    256 
    257199    scheduleLayerFlush();
    258200}
     
    297239
    298240    createCompositingLayers();
    299 
    300241    initializeRootCompositingLayerIfNeeded();
    301242
    302243    m_rootLayer->flushCompositingStateForThisLayerOnly();
    303     m_nonCompositedContentLayer->flushCompositingStateForThisLayerOnly();
    304244    if (m_pageOverlayLayer)
    305245        m_pageOverlayLayer->flushCompositingStateForThisLayerOnly();
     
    308248
    309249    flushPendingImageBackingChanges();
    310 
    311250    deleteCompositingLayers();
    312251
     
    314253        didSync = true;
    315254
    316         m_state.contentsSize = roundedIntSize(m_nonCompositedContentLayer->size());
    317         m_state.coveredRect = toCoordinatedGraphicsLayer(m_nonCompositedContentLayer.get())->coverRect();
     255        if (m_rootCompositingLayer) {
     256            m_state.contentsSize = roundedIntSize(m_rootCompositingLayer->size());
     257            if (CoordinatedGraphicsLayer* contentsLayer = mainContentsLayer())
     258                m_state.coveredRect = contentsLayer->coverRect();
     259        }
     260
    318261        m_state.scrollPosition = m_visibleContentsRect.location();
    319262
     
    595538void CoordinatedLayerTreeHost::paintContents(const WebCore::GraphicsLayer* graphicsLayer, WebCore::GraphicsContext& graphicsContext, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect)
    596539{
    597     if (graphicsLayer == m_nonCompositedContentLayer) {
    598         m_webPage->drawRect(graphicsContext, clipRect);
    599         return;
    600     }
    601 
    602540    if (graphicsLayer == m_pageOverlayLayer) {
    603541        // Overlays contain transparent contents and won't clear the context as part of their rendering, so we do it here.
     
    661599}
    662600
     601CoordinatedGraphicsLayer* CoordinatedLayerTreeHost::mainContentsLayer()
     602{
     603    if (!m_rootCompositingLayer)
     604        return 0;
     605
     606    return toCoordinatedGraphicsLayer(m_rootCompositingLayer)->findFirstDescendantWithContentsRecursively();
     607}
     608
    663609void CoordinatedLayerTreeHost::setVisibleContentsRect(const FloatRect& rect, const FloatPoint& trajectoryVector)
    664610{
    665611    // A zero trajectoryVector indicates that tiles all around the viewport are requested.
    666     toCoordinatedGraphicsLayer(m_nonCompositedContentLayer.get())->setVisibleContentRectTrajectoryVector(trajectoryVector);
     612    if (CoordinatedGraphicsLayer* contentsLayer = mainContentsLayer())
     613        contentsLayer->setVisibleContentRectTrajectoryVector(trajectoryVector);
    667614
    668615    bool contentsRectDidChange = rect != m_visibleContentsRect;
     
    687634{
    688635    m_rootLayer->deviceOrPageScaleFactorChanged();
    689     m_nonCompositedContentLayer->deviceOrPageScaleFactorChanged();
    690636    if (m_pageOverlayLayer)
    691637        m_pageOverlayLayer->deviceOrPageScaleFactorChanged();
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h

    r149008 r149292  
    6666    virtual void invalidate();
    6767
    68     virtual void setNonCompositedContentsNeedDisplay() OVERRIDE;
    69     virtual void setNonCompositedContentsNeedDisplayInRect(const WebCore::IntRect&) OVERRIDE;
    70     virtual void scrollNonCompositedContents(const WebCore::IntRect&) OVERRIDE;
     68    virtual void setNonCompositedContentsNeedDisplay() OVERRIDE { }
     69    virtual void setNonCompositedContentsNeedDisplayInRect(const WebCore::IntRect&) OVERRIDE { }
     70    virtual void scrollNonCompositedContents(const WebCore::IntRect&) OVERRIDE { }
    7171    virtual void forceRepaint();
    7272    virtual bool forceRepaintAsync(uint64_t callbackID);
     
    8989    virtual void didReceiveCoordinatedLayerTreeHostMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&);
    9090    virtual WebCore::GraphicsLayerFactory* graphicsLayerFactory() OVERRIDE;
     91    WebCore::CoordinatedGraphicsLayer* mainContentsLayer();
    9192
    9293#if ENABLE(REQUEST_ANIMATION_FRAME)
     
    144145    void didPerformScheduledLayerFlush();
    145146    void syncDisplayState();
    146 
    147147    void layerFlushTimerFired(WebCore::Timer<CoordinatedLayerTreeHost>*);
    148148
     
    165165
    166166    OwnPtr<WebCore::GraphicsLayer> m_rootLayer;
    167 
    168     // The layer which contains all non-composited content.
    169     OwnPtr<WebCore::GraphicsLayer> m_nonCompositedContentLayer;
     167    WebCore::GraphicsLayer* m_rootCompositingLayer;
    170168
    171169    // The page overlay layer. Will be null if there's no page overlay.
Note: See TracChangeset for help on using the changeset viewer.