Register scrolling layers with ScrollingCoordinator

https://bugs.webkit.org/show_bug.cgi?id=78862

Patch by Sami Kyostila <skyostil@google.com> on 2012-09-04
Reviewed by James Robinson.

In order to allow scrollable child layers to be scrolled off the main
thread, register them with the ScrollingCoordinator. These layers are
also removed from the non-fast scrollable region.

Whenever the scroll offset or other scroll geometry related attribute of
a compositor scrolled layer changes, the ScrollingCoordinator is
informed to allow it to update its internal representation of the
scrollable layer.

No tests because the ScrollingCoordinator is currently not testable.

* page/scrolling/ScrollingCoordinator.cpp:
(WebCore::computeNonFastScrollableRegion): Composited scrolling layers
can be scrolled off the main thread.
(WebCore):
(WebCore::ScrollingCoordinator::scrollableAreaScrollLayerDidChange):
Callback to ScrollingCoordinator about changes the composited scrolling layers.
* page/scrolling/ScrollingCoordinator.h:
(WebCore):
(ScrollingCoordinator):
* page/scrolling/ScrollingCoordinatorNone.cpp:
(WebCore):
(WebCore::ScrollingCoordinator::scrollableAreaScrollLayerDidChange):
* platform/ScrollableArea.h:
(WebCore::ScrollableArea::usesCompositedScrolling):
* rendering/RenderLayer.cpp:
(WebCore):
(WebCore::RenderLayer::usesCompositedScrolling):
* rendering/RenderLayer.h:
(RenderLayer):
(WebCore::RenderLayer::usesCompositedScrolling):
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateGraphicsLayerGeometry):
(WebCore::RenderLayerBacking::updateScrollingLayers):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::scrollingLayerDidChange):
(WebCore):
* rendering/RenderLayerCompositor.h:
(RenderLayerCompositor):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@127480 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent db8065f2
2012-09-04 Sami Kyostila <skyostil@google.com>
Register scrolling layers with ScrollingCoordinator
https://bugs.webkit.org/show_bug.cgi?id=78862
Reviewed by James Robinson.
In order to allow scrollable child layers to be scrolled off the main
thread, register them with the ScrollingCoordinator. These layers are
also removed from the non-fast scrollable region.
Whenever the scroll offset or other scroll geometry related attribute of
a compositor scrolled layer changes, the ScrollingCoordinator is
informed to allow it to update its internal representation of the
scrollable layer.
No tests because the ScrollingCoordinator is currently not testable.
* page/scrolling/ScrollingCoordinator.cpp:
(WebCore::computeNonFastScrollableRegion): Composited scrolling layers
can be scrolled off the main thread.
(WebCore):
(WebCore::ScrollingCoordinator::scrollableAreaScrollLayerDidChange):
Callback to ScrollingCoordinator about changes the composited scrolling layers.
* page/scrolling/ScrollingCoordinator.h:
(WebCore):
(ScrollingCoordinator):
* page/scrolling/ScrollingCoordinatorNone.cpp:
(WebCore):
(WebCore::ScrollingCoordinator::scrollableAreaScrollLayerDidChange):
* platform/ScrollableArea.h:
(WebCore::ScrollableArea::usesCompositedScrolling):
* rendering/RenderLayer.cpp:
(WebCore):
(WebCore::RenderLayer::usesCompositedScrolling):
* rendering/RenderLayer.h:
(RenderLayer):
(WebCore::RenderLayer::usesCompositedScrolling):
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateGraphicsLayerGeometry):
(WebCore::RenderLayerBacking::updateScrollingLayers):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::scrollingLayerDidChange):
(WebCore):
* rendering/RenderLayerCompositor.h:
(RenderLayerCompositor):
2012-09-04 Brian Anderson <brianderson@chromium.org>
[chromium] Do not allow infinite pending frames in CCFrameRateController
......@@ -118,6 +118,11 @@ static Region computeNonFastScrollableRegion(Frame* frame, const IntPoint& frame
if (const FrameView::ScrollableAreaSet* scrollableAreas = frameView->scrollableAreas()) {
for (FrameView::ScrollableAreaSet::const_iterator it = scrollableAreas->begin(), end = scrollableAreas->end(); it != end; ++it) {
ScrollableArea* scrollableArea = *it;
#if USE(ACCELERATED_COMPOSITING)
// Composited scrollable areas can be scrolled off the main thread.
if (scrollableArea->usesCompositedScrolling())
continue;
#endif
IntRect box = scrollableArea->scrollableAreaBoundingBox();
box.moveBy(offset);
nonFastScrollableRegion.unite(box);
......@@ -488,6 +493,11 @@ void ScrollingCoordinator::setLayerIsFixedToContainerLayer(GraphicsLayer*, bool)
{
// FIXME: Implement!
}
void ScrollingCoordinator::scrollableAreaScrollLayerDidChange(ScrollableArea*, GraphicsLayer*)
{
// FIXME: Implement.
}
#endif // !ENABLE(THREADED_SCROLLING)
} // namespace WebCore
......@@ -48,6 +48,7 @@ class FrameView;
class GraphicsLayer;
class Page;
class Region;
class ScrollableArea;
class ScrollingCoordinatorPrivate;
class ScrollingTreeState;
......@@ -92,6 +93,9 @@ public:
// Should be called whenever the vertical scrollbar layer for the given frame view changes.
void frameViewVerticalScrollbarLayerDidChange(FrameView*, GraphicsLayer* verticalScrollbarLayer);
// Should be called whenever the scrollable layer for the given scroll area changes.
void scrollableAreaScrollLayerDidChange(ScrollableArea*, GraphicsLayer*);
// Requests that the scrolling coordinator updates the scroll position of the given frame view. If this function returns true, it means that the
// position will be updated asynchronously. If it returns false, the caller should update the scrolling position itself.
bool requestScrollPositionUpdate(FrameView*, const IntPoint&);
......
......@@ -83,6 +83,10 @@ void ScrollingCoordinator::setLayerIsContainerForFixedPositionLayers(GraphicsLay
void ScrollingCoordinator::setLayerIsFixedToContainerLayer(GraphicsLayer*, bool)
{
}
void ScrollingCoordinator::scrollableAreaScrollLayerDidChange(ScrollableArea*, GraphicsLayer*)
{
}
#endif // !ENABLE(THREADED_SCROLLING)
}
......@@ -246,4 +246,9 @@ void ScrollingCoordinator::setLayerIsFixedToContainerLayer(GraphicsLayer* layer,
scrollableLayer->setFixedToContainerLayer(enable);
}
void ScrollingCoordinator::scrollableAreaScrollLayerDidChange(ScrollableArea*, GraphicsLayer*)
{
// FIXME: Implement.
}
}
......@@ -169,6 +169,7 @@ public:
#if USE(ACCELERATED_COMPOSITING)
virtual TiledBacking* tiledBacking() { return 0; }
virtual bool usesCompositedScrolling() const { return false; }
#endif
protected:
......
......@@ -1567,9 +1567,9 @@ void RenderLayer::convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutR
rect.move(-delta.x(), -delta.y());
}
#if USE(ACCELERATED_COMPOSITING)
bool RenderLayer::usesCompositedScrolling() const
{
#if USE(ACCELERATED_COMPOSITING)
if (!scrollsOverflow() || !allowsScrolling())
return false;
......@@ -1578,10 +1578,8 @@ bool RenderLayer::usesCompositedScrolling() const
#else
return false;
#endif
#else
return false;
#endif
}
#endif
static inline int adjustedScrollDelta(int beginningDelta) {
// This implemention matches Firefox's.
......
......@@ -363,7 +363,6 @@ public:
void paintResizer(GraphicsContext*, const IntPoint&, const IntRect& damageRect);
void updateScrollInfoAfterLayout();
bool usesCompositedScrolling() const;
bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1);
void autoscroll();
......@@ -635,9 +634,11 @@ public:
virtual GraphicsLayer* layerForHorizontalScrollbar() const;
virtual GraphicsLayer* layerForVerticalScrollbar() const;
virtual GraphicsLayer* layerForScrollCorner() const;
virtual bool usesCompositedScrolling() const OVERRIDE;
#else
bool isComposited() const { return false; }
bool hasCompositedMask() const { return false; }
bool usesCompositedScrolling() const { return false; }
#endif
bool paintsWithTransparency(PaintBehavior paintBehavior) const
......
......@@ -671,10 +671,14 @@ void RenderLayerBacking::updateGraphicsLayerGeometry()
if (scrollSize != m_scrollingContentsLayer->size() || paddingBoxOffsetChanged)
m_scrollingContentsLayer->setNeedsDisplay();
IntSize scrollingContentsOffset = paddingBox.location() - IntPoint() - scrollOffset;
if (scrollingContentsOffset != m_scrollingContentsLayer->offsetFromRenderer() || scrollSize != m_scrollingContentsLayer->size())
compositor()->scrollingLayerDidChange(m_owningLayer);
m_scrollingContentsLayer->setSize(scrollSize);
// FIXME: Scrolling the content layer does not need to trigger a repaint. The offset will be compensated away during painting.
// FIXME: The paint offset and the scroll offset should really be separate concepts.
m_scrollingContentsLayer->setOffsetFromRenderer(paddingBox.location() - IntPoint() - scrollOffset);
m_scrollingContentsLayer->setOffsetFromRenderer(scrollingContentsOffset);
}
m_graphicsLayer->setContentsRect(contentsBox());
......@@ -917,6 +921,8 @@ bool RenderLayerBacking::updateScrollingLayers(bool needsScrollingLayers)
updateInternalHierarchy();
m_graphicsLayer->setPaintingPhase(paintingPhaseForPrimaryLayer());
m_graphicsLayer->setNeedsDisplay();
if (renderer()->view())
compositor()->scrollingLayerDidChange(m_owningLayer);
}
return layerChanged;
......
......@@ -1092,6 +1092,13 @@ void RenderLayerCompositor::frameViewDidScroll()
m_scrollLayer->setPosition(FloatPoint(-scrollPosition.x(), -scrollPosition.y()));
}
void RenderLayerCompositor::scrollingLayerDidChange(RenderLayer* layer)
{
RenderLayerBacking* backing = layer->backing();
if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator())
scrollingCoordinator->scrollableAreaScrollLayerDidChange(layer, backing ? backing->scrollingContentsLayer() : 0);
}
String RenderLayerCompositor::layerTreeAsText(bool showDebugInfo)
{
updateCompositingLayers(CompositingUpdateAfterLayout);
......
......@@ -192,6 +192,8 @@ public:
void frameViewDidChangeSize();
void frameViewDidScroll();
void scrollingLayerDidChange(RenderLayer*);
String layerTreeAsText(bool showDebugInfo = false);
// These are named to avoid conflicts with the functions in GraphicsLayerClient
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment