Changeset 142112 in webkit


Ignore:
Timestamp:
Feb 7, 2013 6:47:50 AM (11 years ago)
Author:
caio.oliveira@openbossa.org
Message:

[CoordinatedGraphics] Use ScrollingCoordinator to track fixed layers
https://bugs.webkit.org/show_bug.cgi?id=108990

.:

Reviewed by Noam Rosenthal.

Add a new test that allow us to remove the fixed positioning of a layer but still keeping
it compositing. Coordinated Graphics had a bug where the CoordinatedSceneGraph would still
count this layer as fixed position.

  • ManualTests/remove-fixed-position-but-keep-compositing.html: Added.

Source/WebCore:

Reviewed by Noam Rosenthal.

WebCore keeps ScrollingCoordinator up-to-date about whether layers are fixed or not, so we
don't need to traverse the tree every frame to get this information.

The function ScrollingCoordinator::setLayerIsFixedToContainerLayer() is called when
RenderLayerBacking is updating its graphics layers.

The new code also works in new situations where the previous was broken: if a layer changed
from being fixed to not fixed (but still kept as a layer for other reasons), the layer will
be correctly updated. Previous implementation only had logic to mark layers as fixed, but
not the other way round. A manual test was added to illustrate the solved problem.

Testing was done with the existing manual tests that make use of "position:fixed". Automatic
tests are mostly not affected by this because usage of this information affects only the
UseFixedLayout mode, not used by default in WebKitTestRunner. Work to improve this situation
will be tracked in bug https://bugs.webkit.org/show_bug.cgi?id=109175.

  • CMakeLists.txt:
  • Target.pri:
  • WebCore.pri:
  • page/scrolling/ScrollingCoordinator.cpp:

(WebCore::ScrollingCoordinator::create): create specific version of ScrollingCoordinator.

  • page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp: Added.

(WebCore):
(WebCore::ScrollingCoordinatorCoordinatedGraphics::ScrollingCoordinatorCoordinatedGraphics):
(WebCore::ScrollingCoordinatorCoordinatedGraphics::setLayerIsFixedToContainerLayer):
update layer information using existing hook in ScrollingCoordinator.

  • page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.h: Added.

(WebCore):
(ScrollingCoordinatorCoordinatedGraphics):

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

(WebCore::CoordinatedGraphicsLayer::setFixedToViewport): now that setting viewport is not
embedded in the synchronization work, we need to mark the layer so it is updated in the
next frame.
(WebCore):
(WebCore::CoordinatedGraphicsLayer::flushCompositingState): remove call to syncFixedLayers().

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

(CoordinatedGraphicsLayerClient): remove now unused syncFixedLayers() from client.
(CoordinatedGraphicsLayer):

Source/WebKit2:

Reviewed by Noam Rosenthal.
Signed off for WebKit2 by Simon Fraser.

WebCore keeps ScrollingCoordinator up-to-date about whether layers are fixed or not, so we
don't need to traverse the tree every frame to get this information.

  • WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp: remove

syncFixedLayers() and its helper functions. Those were used to identify the fixed layers
and are not needed anymore.

  • WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
  • WebProcess/WebPage/DrawingAreaImpl.cpp:

(WebKit::DrawingAreaImpl::DrawingAreaImpl): enable the scrolling coordinator usage for
Coordinated Graphics.

Location:
trunk
Files:
4 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r142105 r142112  
     12013-02-07  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
     2
     3        [CoordinatedGraphics] Use ScrollingCoordinator to track fixed layers
     4        https://bugs.webkit.org/show_bug.cgi?id=108990
     5
     6        Reviewed by Noam Rosenthal.
     7
     8        Add a new test that allow us to remove the fixed positioning of a layer but still keeping
     9        it compositing. Coordinated Graphics had a bug where the CoordinatedSceneGraph would still
     10        count this layer as fixed position.
     11
     12        * ManualTests/remove-fixed-position-but-keep-compositing.html: Added.
     13
    1142013-02-07  Gustavo Noronha Silva  <gns@gnome.org>
    215
  • trunk/Source/WebCore/CMakeLists.txt

    r142072 r142112  
    4545    "${WEBCORE_DIR}/page/animation"
    4646    "${WEBCORE_DIR}/page/scrolling"
     47    "${WEBCORE_DIR}/page/scrolling/coordinatedgraphics"
    4748    "${WEBCORE_DIR}/platform"
    4849    "${WEBCORE_DIR}/platform/animation"
     
    18211822    page/scrolling/ScrollingConstraints.cpp
    18221823    page/scrolling/ScrollingCoordinator.cpp
     1824    page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp
    18231825
    18241826    platform/Arena.cpp
  • trunk/Source/WebCore/ChangeLog

    r142111 r142112  
     12013-02-07  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
     2
     3        [CoordinatedGraphics] Use ScrollingCoordinator to track fixed layers
     4        https://bugs.webkit.org/show_bug.cgi?id=108990
     5
     6        Reviewed by Noam Rosenthal.
     7
     8        WebCore keeps ScrollingCoordinator up-to-date about whether layers are fixed or not, so we
     9        don't need to traverse the tree every frame to get this information.
     10
     11        The function ScrollingCoordinator::setLayerIsFixedToContainerLayer() is called when
     12        RenderLayerBacking is updating its graphics layers.
     13
     14        The new code also works in new situations where the previous was broken: if a layer changed
     15        from being fixed to not fixed (but still kept as a layer for other reasons), the layer will
     16        be correctly updated. Previous implementation only had logic to mark layers as fixed, but
     17        not the other way round. A manual test was added to illustrate the solved problem.
     18
     19        Testing was done with the existing manual tests that make use of "position:fixed". Automatic
     20        tests are mostly not affected by this because usage of this information affects only the
     21        UseFixedLayout mode, not used by default in WebKitTestRunner. Work to improve this situation
     22        will be tracked in bug https://bugs.webkit.org/show_bug.cgi?id=109175.
     23
     24        * CMakeLists.txt:
     25        * Target.pri:
     26        * WebCore.pri:
     27        * page/scrolling/ScrollingCoordinator.cpp:
     28        (WebCore::ScrollingCoordinator::create): create specific version of ScrollingCoordinator.
     29        * page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp: Added.
     30        (WebCore):
     31        (WebCore::ScrollingCoordinatorCoordinatedGraphics::ScrollingCoordinatorCoordinatedGraphics):
     32        (WebCore::ScrollingCoordinatorCoordinatedGraphics::setLayerIsFixedToContainerLayer):
     33        update layer information using existing hook in ScrollingCoordinator.
     34        * page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.h: Added.
     35        (WebCore):
     36        (ScrollingCoordinatorCoordinatedGraphics):
     37        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
     38        (WebCore::CoordinatedGraphicsLayer::setFixedToViewport): now that setting viewport is not
     39        embedded in the synchronization work, we need to mark the layer so it is updated in the
     40        next frame.
     41        (WebCore):
     42        (WebCore::CoordinatedGraphicsLayer::flushCompositingState): remove call to syncFixedLayers().
     43        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
     44        (CoordinatedGraphicsLayerClient): remove now unused syncFixedLayers() from client.
     45        (CoordinatedGraphicsLayer):
     46
    1472013-02-07  Keishi Hattori  <keishi@webkit.org>
    248
  • trunk/Source/WebCore/Target.pri

    r142072 r142112  
    40674067use?(3D_GRAPHICS) {
    40684068    HEADERS += \
     4069        page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.h \
    40694070        platform/graphics/cpu/arm/GraphicsContext3DNEON.h \
    40704071        platform/graphics/ANGLEWebKitBridge.h \
     
    40914092
    40924093    SOURCES += \
     4094        page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp \
    40934095        platform/graphics/ANGLEWebKitBridge.cpp \
    40944096        platform/graphics/GraphicsContext3D.cpp \
  • trunk/Source/WebCore/WebCore.pri

    r140675 r142112  
    5151    $$SOURCE_DIR/page/qt \
    5252    $$SOURCE_DIR/page/scrolling \
     53    $$SOURCE_DIR/page/scrolling/coordinatedgraphics \
    5354    $$SOURCE_DIR/platform \
    5455    $$SOURCE_DIR/platform/animation \
     
    6465    $$SOURCE_DIR/platform/graphics/surfaces \
    6566    $$SOURCE_DIR/platform/graphics/texmap \
     67    $$SOURCE_DIR/platform/graphics/texmap/coordinated \
    6668    $$SOURCE_DIR/platform/graphics/transforms \
    6769    $$SOURCE_DIR/platform/image-decoders \
  • trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp

    r140732 r142112  
    5353#endif
    5454
     55#if USE(COORDINATED_GRAPHICS)
     56#include "ScrollingCoordinatorCoordinatedGraphics.h"
     57#endif
     58
    5559namespace WebCore {
    5660
     
    6367#if PLATFORM(CHROMIUM)
    6468    return adoptRef(new ScrollingCoordinatorChromium(page));
     69#endif
     70
     71#if USE(COORDINATED_GRAPHICS)
     72    return adoptRef(new ScrollingCoordinatorCoordinatedGraphics(page));
    6573#endif
    6674
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp

    r141543 r142112  
    465465}
    466466
     467void CoordinatedGraphicsLayer::setFixedToViewport(bool isFixed)
     468{
     469    if (m_fixedToViewport == isFixed)
     470        return;
     471
     472    m_fixedToViewport = isFixed;
     473    didChangeLayerState();
     474}
     475
    467476void CoordinatedGraphicsLayer::flushCompositingState(const FloatRect& rect)
    468477{
     
    478487    if (CoordinatedGraphicsLayer* replica = toCoordinatedGraphicsLayer(replicaLayer()))
    479488        replica->flushCompositingStateForThisLayerOnly();
    480 
    481     m_coordinator->syncFixedLayers();
    482489
    483490    flushCompositingStateForThisLayerOnly();
  • trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h

    r141543 r142112  
    7373
    7474    virtual void detachLayer(CoordinatedGraphicsLayer*) = 0;
    75     virtual void syncFixedLayers() = 0;
    7675    virtual PassOwnPtr<GraphicsContext> beginContentUpdate(const IntSize&, CoordinatedSurface::Flags, uint32_t& atlasID, IntPoint&) = 0;
    7776};
     
    138137    CoordinatedLayerID id() const;
    139138
    140     void setFixedToViewport(bool isFixed) { m_fixedToViewport = isFixed; }
     139    void setFixedToViewport(bool isFixed);
    141140
    142141    IntRect coverRect() const { return m_mainBackingStore ? m_mainBackingStore->mapToContents(m_mainBackingStore->coverRect()) : IntRect(); }
  • trunk/Source/WebKit2/ChangeLog

    r142095 r142112  
     12013-02-07  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
     2
     3        [CoordinatedGraphics] Use ScrollingCoordinator to track fixed layers
     4        https://bugs.webkit.org/show_bug.cgi?id=108990
     5
     6        Reviewed by Noam Rosenthal.
     7        Signed off for WebKit2 by Simon Fraser.
     8
     9        WebCore keeps ScrollingCoordinator up-to-date about whether layers are fixed or not, so we
     10        don't need to traverse the tree every frame to get this information.
     11
     12        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp: remove
     13        syncFixedLayers() and its helper functions. Those were used to identify the fixed layers
     14        and are not needed anymore.
     15        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h:
     16        * WebProcess/WebPage/DrawingAreaImpl.cpp:
     17        (WebKit::DrawingAreaImpl::DrawingAreaImpl): enable the scrolling coordinator usage for
     18        Coordinated Graphics.
     19
    1202013-02-07  Michael Brüning  <michael.bruning@digia.com>
    221
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp

    r141853 r142112  
    470470}
    471471
    472 static void updateOffsetFromViewportForSelf(RenderLayer* renderLayer)
    473 {
    474     // These conditions must match the conditions in RenderLayerCompositor::requiresCompositingForPosition.
    475     RenderLayerBacking* backing = renderLayer->backing();
    476     if (!backing)
    477         return;
    478 
    479     RenderStyle* style = renderLayer->renderer()->style();
    480     if (!style)
    481         return;
    482 
    483     if (!renderLayer->renderer()->isOutOfFlowPositioned() || renderLayer->renderer()->style()->position() != FixedPosition)
    484         return;
    485 
    486     if (!renderLayer->renderer()->container()->isRenderView())
    487         return;
    488 
    489     if (!renderLayer->isStackingContainer())
    490         return;
    491 
    492     CoordinatedGraphicsLayer* graphicsLayer = toCoordinatedGraphicsLayer(backing->graphicsLayer());
    493     graphicsLayer->setFixedToViewport(true);
    494 }
    495 
    496 static void updateOffsetFromViewportForLayer(RenderLayer* renderLayer)
    497 {
    498     updateOffsetFromViewportForSelf(renderLayer);
    499 
    500     if (renderLayer->firstChild())
    501         updateOffsetFromViewportForLayer(renderLayer->firstChild());
    502     if (renderLayer->nextSibling())
    503         updateOffsetFromViewportForLayer(renderLayer->nextSibling());
    504 }
    505 
    506 void CoordinatedLayerTreeHost::syncFixedLayers()
    507 {
    508     if (!m_webPage->corePage()->settings() || !m_webPage->corePage()->settings()->acceleratedCompositingForFixedPositionEnabled())
    509         return;
    510 
    511     if (!m_webPage->mainFrame()->view()->hasViewportConstrainedObjects())
    512         return;
    513 
    514     RenderLayer* rootRenderLayer = m_webPage->mainFrame()->contentRenderer()->compositor()->rootRenderLayer();
    515     ASSERT(rootRenderLayer);
    516     if (rootRenderLayer->firstChild())
    517         updateOffsetFromViewportForLayer(rootRenderLayer->firstChild());
    518 }
    519 
    520472void CoordinatedLayerTreeHost::lockAnimations()
    521473{
  • trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h

    r141543 r142112  
    106106    virtual void setLayerRepaintCount(WebCore::CoordinatedLayerID, int) OVERRIDE;
    107107    virtual void detachLayer(WebCore::CoordinatedGraphicsLayer*);
    108     virtual void syncFixedLayers();
    109108
    110109    virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, WebCore::CoordinatedSurface::Flags, uint32_t& atlasID, WebCore::IntPoint&);
  • trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp

    r141366 r142112  
    7474#if USE(COORDINATED_GRAPHICS)
    7575    m_alwaysUseCompositing = true;
     76    webPage->corePage()->settings()->setScrollingCoordinatorEnabled(true);
    7677#endif
    7778
Note: See TracChangeset for help on using the changeset viewer.