WebKit Bugzilla
Attachment 371176 Details for
Bug 198475
: [Nicosia] support async scrolling
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
WIP
asyncscroll.patch (text/plain), 51.84 KB, created by
Zan Dobersek
on 2019-06-02 23:15:23 PDT
(
hide
)
Description:
WIP
Filename:
MIME Type:
Creator:
Zan Dobersek
Created:
2019-06-02 23:15:23 PDT
Size:
51.84 KB
patch
obsolete
>diff --git a/Source/WebCore/PlatformPlayStation.cmake b/Source/WebCore/PlatformPlayStation.cmake >index 7193bc5ae10..d968e6c64e2 100644 >--- a/Source/WebCore/PlatformPlayStation.cmake >+++ b/Source/WebCore/PlatformPlayStation.cmake >@@ -21,6 +21,7 @@ list(APPEND WebCore_SOURCES > page/scrolling/nicosia/ScrollingTreeFixedNode.cpp > page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.cpp > page/scrolling/nicosia/ScrollingTreeNicosia.cpp >+ page/scrolling/nicosia/ScrollingTreePositionedNode.cpp > page/scrolling/nicosia/ScrollingTreeStickyNode.cpp > > page/scrolling/generic/ScrollingThreadGeneric.cpp >diff --git a/Source/WebCore/SourcesGTK.txt b/Source/WebCore/SourcesGTK.txt >index 75fc0a5d3d8..3c151f3fc64 100644 >--- a/Source/WebCore/SourcesGTK.txt >+++ b/Source/WebCore/SourcesGTK.txt >@@ -51,6 +51,7 @@ page/scrolling/nicosia/ScrollingStateNodeNicosia.cpp > page/scrolling/nicosia/ScrollingTreeFixedNode.cpp > page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.cpp > page/scrolling/nicosia/ScrollingTreeNicosia.cpp >+page/scrolling/nicosia/ScrollingTreePositionedNode.cpp > page/scrolling/nicosia/ScrollingTreeStickyNode.cpp > > page/scrolling/generic/ScrollingThreadGeneric.cpp >diff --git a/Source/WebCore/SourcesWPE.txt b/Source/WebCore/SourcesWPE.txt >index dbbd995ae49..f0762f32be6 100644 >--- a/Source/WebCore/SourcesWPE.txt >+++ b/Source/WebCore/SourcesWPE.txt >@@ -52,6 +52,7 @@ page/scrolling/nicosia/ScrollingStateNodeNicosia.cpp > page/scrolling/nicosia/ScrollingTreeFixedNode.cpp > page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.cpp > page/scrolling/nicosia/ScrollingTreeNicosia.cpp >+page/scrolling/nicosia/ScrollingTreePositionedNode.cpp > page/scrolling/nicosia/ScrollingTreeStickyNode.cpp > > page/scrolling/generic/ScrollingThreadGeneric.cpp >diff --git a/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp b/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp >index 4b03db85956..e6edf58f09d 100644 >--- a/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp >+++ b/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp >@@ -47,7 +47,7 @@ > > namespace WebCore { > >-#if !PLATFORM(MAC) && !USE(COORDINATED_GRAPHICS) >+#if !PLATFORM(MAC) && !USE(NICOSIA) > Ref<ScrollingCoordinator> ScrollingCoordinator::create(Page* page) > { > return adoptRef(*new ScrollingCoordinator(page)); >diff --git a/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp b/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp >index 8c1423cad76..41f60bab76e 100644 >--- a/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp >+++ b/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp >@@ -34,6 +34,10 @@ > #include "ScrollingTree.h" > #include <wtf/text/TextStream.h> > >+#if USE(NICOSIA) >+#include "NicosiaPlatformLayer.h" >+#endif >+ > namespace WebCore { > > ScrollingTreeScrollingNode::ScrollingTreeScrollingNode(ScrollingTree& scrollingTree, ScrollingNodeType nodeType, ScrollingNodeID nodeID) >@@ -97,7 +101,7 @@ void ScrollingTreeScrollingNode::commitStateBeforeChildren(const ScrollingStateN > if (state.hasChangedProperty(ScrollingStateScrollingNode::ExpectsWheelEventTestTrigger)) > m_expectsWheelEventTestTrigger = state.expectsWheelEventTestTrigger(); > >-#if PLATFORM(COCOA) >+#if PLATFORM(COCOA) || USE(NICOSIA) > if (state.hasChangedProperty(ScrollingStateScrollingNode::ScrollContainerLayer)) > m_scrollContainerLayer = state.scrollContainerLayer(); > >diff --git a/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h b/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h >index 6bd82fd2c5c..86b1d09f7b0 100644 >--- a/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h >+++ b/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h >@@ -28,6 +28,7 @@ > #if ENABLE(ASYNC_SCROLLING) > > #include "IntRect.h" >+#include "PlatformLayer.h" > #include "ScrollSnapOffsetsInfo.h" > #include "ScrollTypes.h" > #include "ScrollingCoordinator.h" >@@ -127,6 +128,9 @@ protected: > > bool expectsWheelEventTestTrigger() const { return m_expectsWheelEventTestTrigger; } > >+ PlatformLayer* scrollContainerLayer() const { return m_scrollContainerLayer.get(); } >+ PlatformLayer* scrolledContentsLayer() const { return m_scrolledContentsLayer.get(); } >+ > LayoutPoint parentToLocalPoint(LayoutPoint) const override; > LayoutPoint localToContentsPoint(LayoutPoint) const override; > >@@ -152,6 +156,9 @@ private: > #if PLATFORM(COCOA) > RetainPtr<CALayer> m_scrollContainerLayer; > RetainPtr<CALayer> m_scrolledContentsLayer; >+#elif USE(NICOSIA) >+ RefPtr<Nicosia::PlatformLayer> m_scrollContainerLayer; >+ RefPtr<Nicosia::PlatformLayer> m_scrolledContentsLayer; > #endif > }; > >diff --git a/Source/WebCore/page/scrolling/nicosia/ScrollingCoordinatorNicosia.cpp b/Source/WebCore/page/scrolling/nicosia/ScrollingCoordinatorNicosia.cpp >index 0d343ab6408..470ae5a6d9b 100644 >--- a/Source/WebCore/page/scrolling/nicosia/ScrollingCoordinatorNicosia.cpp >+++ b/Source/WebCore/page/scrolling/nicosia/ScrollingCoordinatorNicosia.cpp >@@ -58,7 +58,9 @@ void ScrollingCoordinatorNicosia::pageDestroyed() > > m_scrollingStateTreeCommitterTimer.stop(); > >- releaseScrollingTree(); >+ // Invalidating the scrolling tree will break the reference cycle between the ScrollingCoordinator and ScrollingTree objects. >+ RefPtr<ThreadedScrollingTree> scrollingTree = static_pointer_cast<ThreadedScrollingTree>(releaseScrollingTree()); >+ ScrollingThread::dispatch([scrollingTree] { scrollingTree->invalidate(); }); > } > > void ScrollingCoordinatorNicosia::commitTreeStateIfNeeded() >@@ -80,12 +82,16 @@ void ScrollingCoordinatorNicosia::scheduleTreeStateCommit() > > void ScrollingCoordinatorNicosia::commitTreeState() > { >+ willCommitTree(); >+ > if (!scrollingStateTree()->hasChangedProperties()) > return; > > RefPtr<ThreadedScrollingTree> threadedScrollingTree = downcast<ThreadedScrollingTree>(scrollingTree()); > > auto treeState = scrollingStateTree()->commit(LayerRepresentation::PlatformLayerRepresentation); >+ threadedScrollingTree->incrementPendingCommitCount(); >+ > ScrollingThread::dispatch([threadedScrollingTree, treeState = WTFMove(treeState)]() mutable { > threadedScrollingTree->commitTreeState(WTFMove(treeState)); > }); >diff --git a/Source/WebCore/page/scrolling/nicosia/ScrollingStateNodeNicosia.cpp b/Source/WebCore/page/scrolling/nicosia/ScrollingStateNodeNicosia.cpp >index b5328eb4372..55c5e60596e 100644 >--- a/Source/WebCore/page/scrolling/nicosia/ScrollingStateNodeNicosia.cpp >+++ b/Source/WebCore/page/scrolling/nicosia/ScrollingStateNodeNicosia.cpp >@@ -26,21 +26,23 @@ > #include "config.h" > #include "ScrollingStateNode.h" > >-#include "GraphicsLayer.h" >-#include "NotImplemented.h" >- > #if ENABLE(ASYNC_SCROLLING) && USE(NICOSIA) > >+#include "NicosiaPlatformLayer.h" >+#include "PlatformLayer.h" >+ > namespace WebCore { > >-void LayerRepresentation::retainPlatformLayer(void*) >+void LayerRepresentation::retainPlatformLayer(void* typelessLayer) > { >- notImplemented(); >+ if (auto* layer = makePlatformLayerTyped(typelessLayer)) >+ layer->ref(); > } > >-void LayerRepresentation::releasePlatformLayer(void*) >+void LayerRepresentation::releasePlatformLayer(void* typelessLayer) > { >- notImplemented(); >+ if (auto* layer = makePlatformLayerTyped(typelessLayer)) >+ layer->deref(); > } > > PlatformLayer* LayerRepresentation::makePlatformLayerTyped(void* typelessLayer) >diff --git a/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.cpp b/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.cpp >index c90dbf81e28..70211272c3e 100644 >--- a/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.cpp >+++ b/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.cpp >@@ -30,7 +30,12 @@ > > #if ENABLE(ASYNC_SCROLLING) && USE(NICOSIA) > >+#include "Logging.h" >+#include "ScrollingStateFixedNode.h" > #include "ScrollingTree.h" >+#include "ScrollingTreeOverflowScrollingNode.h" >+#include "NicosiaPlatformLayer.h" >+#include <wtf/text/TextStream.h> > > namespace WebCore { > >@@ -50,12 +55,72 @@ ScrollingTreeFixedNode::~ScrollingTreeFixedNode() > scrollingTree().fixedOrStickyNodeRemoved(); > } > >-void ScrollingTreeFixedNode::commitStateBeforeChildren(const ScrollingStateNode&) >+void ScrollingTreeFixedNode::commitStateBeforeChildren(const ScrollingStateNode& stateNode) > { >+ auto& fixedStateNode = downcast<ScrollingStateFixedNode>(stateNode); >+ >+ if (fixedStateNode.hasChangedProperty(ScrollingStateNode::Layer)) { >+ Nicosia::PlatformLayer* layer = fixedStateNode.layer(); >+ m_scrollLayer = downcast<Nicosia::CompositionLayer>(layer); >+ } >+ >+ if (stateNode.hasChangedProperty(ScrollingStateFixedNode::ViewportConstraints)) >+ m_constraints = fixedStateNode.viewportConstraints(); > } > > void ScrollingTreeFixedNode::applyLayerPositions() > { >+ auto computeLayerPosition = [&] { >+ FloatSize overflowScrollDelta; >+ // FIXME: This code is wrong in complex cases where the fixed element is inside a positioned node as >+ // the scroll container order does not match the scrolling tree ancestor order. >+ for (auto* node = parent(); node; node = node->parent()) { >+ if (is<ScrollingTreeFrameScrollingNode>(*node)) { >+ // Fixed nodes are positioned relative to the containing frame scrolling node. >+ // We bail out after finding one. >+ auto layoutViewport = downcast<ScrollingTreeFrameScrollingNode>(*node).layoutViewport(); >+ return m_constraints.layerPositionForViewportRect(layoutViewport) - overflowScrollDelta; >+ } >+ >+ if (is<ScrollingTreeOverflowScrollingNode>(*node)) { >+ // To keep the layer still during async scrolling we adjust by how much the position has changed since layout. >+ auto& overflowNode = downcast<ScrollingTreeOverflowScrollingNode>(*node); >+ auto localDelta = overflowNode.lastCommittedScrollPosition() - overflowNode.currentScrollPosition(); >+ overflowScrollDelta += localDelta; >+ } >+ } >+ ASSERT_NOT_REACHED(); >+ return FloatPoint(); >+ }; >+ >+ auto layerPosition = computeLayerPosition(); >+ >+ LOG_WITH_STREAM(Scrolling, stream << "ScrollingTreeFixedNode " << scrollingNodeID() << " relatedNodeScrollPositionDidChange: viewportRectAtLastLayout " << m_constraints.viewportRectAtLastLayout() << " last layer pos " << m_constraints.layerPositionAtLastLayout() << " layerPosition " << layerPosition); >+ >+ ASSERT(m_scrollLayer); >+ m_scrollLayer->accessStaging( >+ [this, &layerPosition](Nicosia::CompositionLayer::LayerState& state) >+ { >+ state.position = layerPosition; >+ state.delta.positionChanged = true; >+ }); >+} >+ >+void ScrollingTreeFixedNode::dumpProperties(TextStream& ts, ScrollingStateTreeAsTextBehavior behavior) const >+{ >+ ts << "fixed node"; >+ ScrollingTreeNode::dumpProperties(ts, behavior); >+ ts.dumpProperty("fixed constraints", m_constraints); >+ >+#if 0 >+ if (behavior & ScrollingStateTreeAsTextBehaviorIncludeLayerPositions) { >+ FloatRect layerBounds = [m_layer bounds]; >+ FloatPoint anchorPoint = [m_layer anchorPoint]; >+ FloatPoint position = [m_layer position]; >+ FloatPoint layerTopLeft = position - toFloatSize(anchorPoint) * layerBounds.size() + m_constraints.alignmentOffset(); >+ ts.dumpProperty("layer top left", layerTopLeft); >+ } >+#endif > } > > } // namespace WebCore >diff --git a/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.h b/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.h >index 9f8e1e251be..685d97ddd9c 100644 >--- a/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.h >+++ b/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFixedNode.h >@@ -31,6 +31,13 @@ > > #include "ScrollingTreeNode.h" > >+#include "ScrollingConstraints.h" >+#include <wtf/RefPtr.h> >+ >+namespace Nicosia { >+class CompositionLayer; >+} >+ > namespace WebCore { > > class ScrollingTreeFixedNode final : public ScrollingTreeNode { >@@ -43,8 +50,15 @@ private: > > void commitStateBeforeChildren(const ScrollingStateNode&) override; > void applyLayerPositions() override; >+ >+ void dumpProperties(WTF::TextStream&, ScrollingStateTreeAsTextBehavior) const override; >+ >+ FixedPositionViewportConstraints m_constraints; >+ RefPtr<Nicosia::CompositionLayer> m_scrollLayer; > }; > > } // namespace WebCore > >+SPECIALIZE_TYPE_TRAITS_SCROLLING_NODE(ScrollingTreeFixedNode, isFixedNode()) >+ > #endif // ENABLE(ASYNC_SCROLLING) && USE(NICOSIA) >diff --git a/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.cpp b/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.cpp >index 1ce4a1adad8..e32f2ddb896 100644 >--- a/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.cpp >+++ b/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.cpp >@@ -30,6 +30,11 @@ > > #if ENABLE(ASYNC_SCROLLING) && USE(NICOSIA) > >+#include "FrameView.h" >+#include "ScrollingStateFrameScrollingNode.h" >+#include "ScrollingTree.h" >+#include "NicosiaPlatformLayer.h" >+ > namespace WebCore { > > Ref<ScrollingTreeFrameScrollingNode> ScrollingTreeFrameScrollingNodeNicosia::create(ScrollingTree& scrollingTree, ScrollingNodeType nodeType, ScrollingNodeID nodeID) >@@ -44,12 +49,91 @@ ScrollingTreeFrameScrollingNodeNicosia::ScrollingTreeFrameScrollingNodeNicosia(S > > ScrollingTreeFrameScrollingNodeNicosia::~ScrollingTreeFrameScrollingNodeNicosia() = default; > >-ScrollingEventResult ScrollingTreeFrameScrollingNodeNicosia::handleWheelEvent(const PlatformWheelEvent&) >+void ScrollingTreeFrameScrollingNodeNicosia::commitStateBeforeChildren(const ScrollingStateNode& stateNode) >+{ >+ ScrollingTreeFrameScrollingNode::commitStateBeforeChildren(stateNode); >+ const auto& scrollingStateNode = downcast<ScrollingStateFrameScrollingNode>(stateNode); >+ >+ if (scrollingStateNode.hasChangedProperty(ScrollingStateNode::Layer)) { >+ Nicosia::PlatformLayer* layer = scrollingStateNode.layer(); >+ m_scrollLayer = downcast<Nicosia::CompositionLayer>(layer); >+ } >+ if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrolledContentsLayer)) { >+ Nicosia::PlatformLayer* layer = scrollingStateNode.scrolledContentsLayer(); >+ m_scrolledContentsLayer = downcast<Nicosia::CompositionLayer>(layer); >+ } >+ if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::CounterScrollingLayer)) { >+ Nicosia::PlatformLayer* layer = scrollingStateNode.counterScrollingLayer(); >+ m_counterScrollingLayer = downcast<Nicosia::CompositionLayer>(layer); >+ } >+ if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::InsetClipLayer)) { >+ Nicosia::PlatformLayer* layer = scrollingStateNode.insetClipLayer(); >+ m_insetClipLayer = downcast<Nicosia::CompositionLayer>(layer); >+ } >+ if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::ContentShadowLayer)) { >+ Nicosia::PlatformLayer* layer = scrollingStateNode.contentShadowLayer(); >+ m_contentShadowLayer = downcast<Nicosia::CompositionLayer>(layer); >+ } >+ if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::HeaderLayer)) { >+ Nicosia::PlatformLayer* layer = scrollingStateNode.headerLayer(); >+ m_headerLayer = downcast<Nicosia::CompositionLayer>(layer); >+ } >+ if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::FooterLayer)) { >+ Nicosia::PlatformLayer* layer = scrollingStateNode.footerLayer(); >+ m_footerLayer = downcast<Nicosia::CompositionLayer>(layer); >+ } >+} >+ >+void ScrollingTreeFrameScrollingNodeNicosia::commitStateAfterChildren(const ScrollingStateNode& stateNode) >+{ >+ ScrollingTreeFrameScrollingNode::commitStateAfterChildren(stateNode); >+ >+ const auto& scrollingStateNode = downcast<ScrollingStateScrollingNode>(stateNode); >+ >+ // Update the scroll position after child nodes have been updated, because they need to have updated their constraints before any scrolling happens. >+ if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::RequestedScrollPosition)) { >+ auto scrollType = scrollingStateNode.requestedScrollPositionRepresentsProgrammaticScroll() ? ScrollType::Programmatic : ScrollType::User; >+ scrollTo(scrollingStateNode.requestedScrollPosition(), scrollType); >+ } >+} >+ >+ScrollingEventResult ScrollingTreeFrameScrollingNodeNicosia::handleWheelEvent(const PlatformWheelEvent& wheelEvent) > { >- return ScrollingEventResult::DidNotHandleEvent; >+ if (!canHaveScrollbars()) >+ return ScrollingEventResult::DidNotHandleEvent; >+ >+ if (wheelEvent.deltaX() || wheelEvent.deltaY()) { >+ auto* scrollLayer = scrolledContentsLayer(); >+ ASSERT(scrollLayer); >+ auto& compositionLayer = downcast<Nicosia::CompositionLayer>(*scrollLayer); >+ >+ auto updateScope = compositionLayer.createUpdateScope(); >+ scrollBy({ wheelEvent.deltaX(), -wheelEvent.deltaY() }); >+ } >+ >+ // TODO: >+ // scrollingTree().setOrClearLatchedNode(wheelEvent, scrollingNodeID()); >+ // scrollingTree().handleWheelEventPhase(wheelEvent.phase()); >+ return ScrollingEventResult::DidHandleEvent; > } > > void ScrollingTreeFrameScrollingNodeNicosia::repositionScrollingLayers() >+{ >+ auto* scrollLayer = scrolledContentsLayer(); >+ ASSERT(scrollLayer); >+ auto& compositionLayer = downcast<Nicosia::CompositionLayer>(*scrollLayer); >+ >+ auto scrollPosition = currentScrollPosition(); >+ >+ compositionLayer.accessStaging( >+ [&scrollPosition](Nicosia::CompositionLayer::LayerState& state) >+ { >+ state.position = -scrollPosition; >+ state.delta.positionChanged = true; >+ }); >+} >+ >+void ScrollingTreeFrameScrollingNodeNicosia::applyLayerPositions() > { > } > >diff --git a/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.h b/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.h >index 2b5a2be3bce..f7b567eca74 100644 >--- a/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.h >+++ b/Source/WebCore/page/scrolling/nicosia/ScrollingTreeFrameScrollingNodeNicosia.h >@@ -31,6 +31,12 @@ > > #include "ScrollingTreeFrameScrollingNode.h" > >+#include <wtf/RefPtr.h> >+ >+namespace Nicosia { >+class CompositionLayer; >+} >+ > namespace WebCore { > > class ScrollingTreeFrameScrollingNodeNicosia final : public ScrollingTreeFrameScrollingNode { >@@ -41,9 +47,21 @@ public: > private: > ScrollingTreeFrameScrollingNodeNicosia(ScrollingTree&, ScrollingNodeType, ScrollingNodeID); > >+ void commitStateBeforeChildren(const ScrollingStateNode&) override; >+ void commitStateAfterChildren(const ScrollingStateNode&) override; >+ > ScrollingEventResult handleWheelEvent(const PlatformWheelEvent&) override; > > void repositionScrollingLayers() override; >+ void applyLayerPositions() override; >+ >+ RefPtr<Nicosia::CompositionLayer> m_scrollLayer; >+ RefPtr<Nicosia::CompositionLayer> m_scrolledContentsLayer; >+ RefPtr<Nicosia::CompositionLayer> m_counterScrollingLayer; >+ RefPtr<Nicosia::CompositionLayer> m_insetClipLayer; >+ RefPtr<Nicosia::CompositionLayer> m_contentShadowLayer; >+ RefPtr<Nicosia::CompositionLayer> m_headerLayer; >+ RefPtr<Nicosia::CompositionLayer> m_footerLayer; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/page/scrolling/nicosia/ScrollingTreeNicosia.cpp b/Source/WebCore/page/scrolling/nicosia/ScrollingTreeNicosia.cpp >index cea7146f118..97f886a680e 100644 >--- a/Source/WebCore/page/scrolling/nicosia/ScrollingTreeNicosia.cpp >+++ b/Source/WebCore/page/scrolling/nicosia/ScrollingTreeNicosia.cpp >@@ -33,6 +33,7 @@ > #include "ScrollingTreeFixedNode.h" > #include "ScrollingTreeFrameHostingNode.h" > #include "ScrollingTreeFrameScrollingNodeNicosia.h" >+#include "ScrollingTreePositionedNode.h" > #include "ScrollingTreeStickyNode.h" > > namespace WebCore { >@@ -55,18 +56,18 @@ Ref<ScrollingTreeNode> ScrollingTreeNicosia::createScrollingTreeNode(ScrollingNo > return ScrollingTreeFrameScrollingNodeNicosia::create(*this, nodeType, nodeID); > case ScrollingNodeType::FrameHosting: > return ScrollingTreeFrameHostingNode::create(*this, nodeID); >- case ScrollingNodeType::Overflow: >- // Should not be reached -- caught by ASSERT_NOT_REACHED() below. >+ case ScrollingNodeType::Overflow: // FIXME > break; > case ScrollingNodeType::Fixed: > return ScrollingTreeFixedNode::create(*this, nodeID); > case ScrollingNodeType::Sticky: > return ScrollingTreeStickyNode::create(*this, nodeID); > case ScrollingNodeType::Positioned: >- RELEASE_ASSERT_NOT_REACHED(); >+ return ScrollingTreePositionedNode::create(*this, nodeID); > } > >- RELEASE_ASSERT_NOT_REACHED(); >+ // FIXME: ASSERT_NOT_REACHED(); >+ return ScrollingTreeFixedNode::create(*this, nodeID); > } > > } // namespace WebCore >diff --git a/Source/WebCore/page/scrolling/nicosia/ScrollingTreePositionedNode.cpp b/Source/WebCore/page/scrolling/nicosia/ScrollingTreePositionedNode.cpp >new file mode 100644 >index 00000000000..8cbc04ecb77 >--- /dev/null >+++ b/Source/WebCore/page/scrolling/nicosia/ScrollingTreePositionedNode.cpp >@@ -0,0 +1,136 @@ >+/* >+ * Copyright (C) 2018 Igalia S.L. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above >+ * copyright notice, this list of conditions and the following >+ * disclaimer in the documentation and/or other materials provided >+ * with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "ScrollingTreePositionedNode.h" >+ >+#if ENABLE(ASYNC_SCROLLING) && USE(NICOSIA) >+ >+#include "Logging.h" >+#include "ScrollingStatePositionedNode.h" >+#include <wtf/text/TextStream.h> >+ >+namespace WebCore { >+ >+Ref<ScrollingTreePositionedNode> ScrollingTreePositionedNode::create(ScrollingTree& scrollingTree, ScrollingNodeID nodeID) >+{ >+ return adoptRef(*new ScrollingTreePositionedNode(scrollingTree, nodeID)); >+} >+ >+ScrollingTreePositionedNode::ScrollingTreePositionedNode(ScrollingTree& scrollingTree, ScrollingNodeID nodeID) >+ : ScrollingTreeNode(scrollingTree, ScrollingNodeType::Positioned, nodeID) >+{ >+} >+ >+ScrollingTreePositionedNode::~ScrollingTreePositionedNode() = default; >+ >+void ScrollingTreePositionedNode::commitStateBeforeChildren(const ScrollingStateNode& stateNode) >+{ >+ const ScrollingStatePositionedNode& positionedStateNode = downcast<ScrollingStatePositionedNode>(stateNode); >+ >+ if (positionedStateNode.hasChangedProperty(ScrollingStateNode::Layer)) { >+ Nicosia::PlatformLayer* layer = positionedStateNode.layer(); >+ m_scrollLayer = downcast<Nicosia::CompositionLayer>(layer); >+ } >+ >+ if (positionedStateNode.hasChangedProperty(ScrollingStatePositionedNode::RelatedOverflowScrollingNodes)) >+ m_relatedOverflowScrollingNodes = positionedStateNode.relatedOverflowScrollingNodes(); >+ >+ if (positionedStateNode.hasChangedProperty(ScrollingStatePositionedNode::LayoutConstraintData)) >+ m_constraints = positionedStateNode.layoutConstraints(); >+ >+ // Tell the ScrollingTree about non-ancestor overflow nodes which affect this node. >+ if (m_constraints.scrollPositioningBehavior() == ScrollPositioningBehavior::Moves) { >+ auto& relatedNodes = scrollingTree().overflowRelatedNodes(); >+ for (auto overflowNodeID : m_relatedOverflowScrollingNodes) { >+ relatedNodes.ensure(overflowNodeID, [] { >+ return Vector<ScrollingNodeID>(); >+ }).iterator->value.append(scrollingNodeID()); >+ } >+ } >+ if (!m_relatedOverflowScrollingNodes.isEmpty() && m_constraints.scrollPositioningBehavior() != ScrollPositioningBehavior::None) >+ scrollingTree().positionedNodesWithRelatedOverflow().add(scrollingNodeID()); >+} >+ >+void ScrollingTreePositionedNode::applyLayerPositions() >+{ >+ FloatSize scrollOffsetSinceLastCommit; >+ for (auto nodeID : m_relatedOverflowScrollingNodes) { >+ if (auto* node = scrollingTree().nodeForID(nodeID)) { >+ if (is<ScrollingTreeOverflowScrollingNode>(node)) { >+ auto& overflowNode = downcast<ScrollingTreeOverflowScrollingNode>(*node); >+ scrollOffsetSinceLastCommit += overflowNode.lastCommittedScrollPosition() - overflowNode.currentScrollPosition(); >+ } >+ } >+ } >+ auto layerOffset = -scrollOffsetSinceLastCommit; >+ if (m_constraints.scrollPositioningBehavior() == ScrollPositioningBehavior::Stationary) { >+ // Stationary nodes move in the opposite direction. >+ layerOffset = -layerOffset; >+ } >+ >+ FloatPoint layerPosition = m_constraints.layerPositionAtLastLayout() - layerOffset; >+ >+ LOG_WITH_STREAM(Scrolling, stream << "ScrollingTreePositionedNode " << scrollingNodeID() << " applyLayerPositions: overflow delta " << scrollOffsetSinceLastCommit << " moving layer to " << layerPosition); >+ >+ m_scrollLayer->accessStaging( >+ [this, &layerPosition](Nicosia::CompositionLayer::LayerState& state) >+ { >+ state.position = layerPosition; >+ state.delta.positionChanged = true; >+ }); >+} >+ >+void ScrollingTreePositionedNode::relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode& changedNode) >+{ >+ if (!m_relatedOverflowScrollingNodes.contains(changedNode.scrollingNodeID())) >+ return; >+ >+ applyLayerPositions(); >+} >+ >+void ScrollingTreePositionedNode::dumpProperties(TextStream& ts, ScrollingStateTreeAsTextBehavior behavior) const >+{ >+ ts << "positioned node"; >+ ScrollingTreeNode::dumpProperties(ts, behavior); >+ >+ ts.dumpProperty("layout constraints", m_constraints); >+ ts.dumpProperty("related overflow nodes", m_relatedOverflowScrollingNodes.size()); >+ >+ if (behavior & ScrollingStateTreeAsTextBehaviorIncludeNodeIDs) { >+ if (!m_relatedOverflowScrollingNodes.isEmpty()) { >+ TextStream::GroupScope scope(ts); >+ ts << "overflow nodes"; >+ for (auto nodeID : m_relatedOverflowScrollingNodes) >+ ts << "\n" << indent << "nodeID " << nodeID; >+ } >+ } >+} >+ >+} // namespace WebCore >+ >+#endif // ENABLE(ASYNC_SCROLLING) && USE(NICOSIA) >diff --git a/Source/WebCore/page/scrolling/nicosia/ScrollingTreePositionedNode.h b/Source/WebCore/page/scrolling/nicosia/ScrollingTreePositionedNode.h >new file mode 100644 >index 00000000000..6951a1fcd06 >--- /dev/null >+++ b/Source/WebCore/page/scrolling/nicosia/ScrollingTreePositionedNode.h >@@ -0,0 +1,69 @@ >+/* >+ * Copyright (C) 2018 Igalia S.L. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above >+ * copyright notice, this list of conditions and the following >+ * disclaimer in the documentation and/or other materials provided >+ * with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(ASYNC_SCROLLING) && USE(NICOSIA) >+ >+#include "ScrollingConstraints.h" >+#include "ScrollingTreeNode.h" >+#include <wtf/RefPtr.h> >+ >+namespace Nicosia { >+class CompositionLayer; >+} >+ >+namespace WebCore { >+ >+class ScrollingTreePositionedNode : public ScrollingTreeNode { >+public: >+ static Ref<ScrollingTreePositionedNode> create(ScrollingTree&, ScrollingNodeID); >+ virtual ~ScrollingTreePositionedNode(); >+ >+ ScrollPositioningBehavior scrollPositioningBehavior() const { return m_constraints.scrollPositioningBehavior(); } >+ const Vector<ScrollingNodeID>& relatedOverflowScrollingNodes() const { return m_relatedOverflowScrollingNodes; } >+ >+private: >+ ScrollingTreePositionedNode(ScrollingTree&, ScrollingNodeID); >+ >+ void commitStateBeforeChildren(const ScrollingStateNode&) override; >+ void relatedNodeScrollPositionDidChange(const ScrollingTreeScrollingNode& changedNode) override; >+ >+ void applyLayerPositions() override; >+ >+ void dumpProperties(WTF::TextStream&, ScrollingStateTreeAsTextBehavior) const override; >+ >+ Vector<ScrollingNodeID> m_relatedOverflowScrollingNodes; >+ LayoutConstraints m_constraints; >+ RefPtr<Nicosia::CompositionLayer> m_scrollLayer; >+}; >+ >+} // namespace WebCore >+ >+SPECIALIZE_TYPE_TRAITS_SCROLLING_NODE(ScrollingTreePositionedNode, isPositionedNode()) >+ >+#endif // ENABLE(ASYNC_SCROLLING) && USE(NICOSIA) >diff --git a/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.cpp b/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.cpp >index d63eaaecf2c..320e9150fa9 100644 >--- a/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.cpp >+++ b/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.cpp >@@ -30,7 +30,13 @@ > > #if ENABLE(ASYNC_SCROLLING) && USE(NICOSIA) > >+#include "Logging.h" >+#include "ScrollingStateStickyNode.h" > #include "ScrollingTree.h" >+#include "ScrollingTreeFrameScrollingNode.h" >+#include "ScrollingTreeOverflowScrollingNode.h" >+#include "NicosiaPlatformLayer.h" >+#include <wtf/text/TextStream.h> > > namespace WebCore { > >@@ -50,12 +56,60 @@ ScrollingTreeStickyNode::~ScrollingTreeStickyNode() > scrollingTree().fixedOrStickyNodeRemoved(); > } > >-void ScrollingTreeStickyNode::commitStateBeforeChildren(const ScrollingStateNode&) >+void ScrollingTreeStickyNode::commitStateBeforeChildren(const ScrollingStateNode& stateNode) > { >+ auto& stickyStateNode = downcast<ScrollingStateStickyNode>(stateNode); >+ >+ if (stickyStateNode.hasChangedProperty(ScrollingStateNode::Layer)) { >+ Nicosia::PlatformLayer* layer = stickyStateNode.layer(); >+ m_scrollLayer = downcast<Nicosia::CompositionLayer>(layer); >+ } >+ >+ if (stateNode.hasChangedProperty(ScrollingStateStickyNode::ViewportConstraints)) >+ m_constraints = stickyStateNode.viewportConstraints(); > } > > void ScrollingTreeStickyNode::applyLayerPositions() > { >+ FloatRect constrainingRect; >+ >+ auto* enclosingScrollingNode = parent(); >+ if (is<ScrollingTreeOverflowScrollingNode>(enclosingScrollingNode)) >+ constrainingRect = FloatRect(downcast<ScrollingTreeOverflowScrollingNode>(*enclosingScrollingNode).currentScrollPosition(), m_constraints.constrainingRectAtLastLayout().size()); >+ else if (is<ScrollingTreeFrameScrollingNode>(enclosingScrollingNode)) >+ constrainingRect = downcast<ScrollingTreeFrameScrollingNode>(enclosingScrollingNode)->layoutViewport(); >+ else >+ return; >+ >+ FloatPoint layerPosition = m_constraints.layerPositionForConstrainingRect(constrainingRect) - m_constraints.alignmentOffset(); >+ >+ LOG_WITH_STREAM(Scrolling, stream << "ScrollingTreeStickyNode " << scrollingNodeID() << " constrainingRect " << constrainingRect << " constrainingRectAtLastLayout " << m_constraints.constrainingRectAtLastLayout() << " last layer pos " << m_constraints.layerPositionAtLastLayout() << " layerPosition " << layerPosition); >+ >+ ASSERT(m_scrollLayer); >+ m_scrollLayer->accessStaging( >+ [this, &layerPosition](Nicosia::CompositionLayer::LayerState& state) >+ { >+ state.position = layerPosition; >+ state.delta.positionChanged = true; >+ }); >+} >+ >+void ScrollingTreeStickyNode::dumpProperties(TextStream& ts, ScrollingStateTreeAsTextBehavior behavior) const >+{ >+ ts << "sticky node"; >+ >+ ScrollingTreeNode::dumpProperties(ts, behavior); >+ ts.dumpProperty("sticky constraints", m_constraints); >+ >+#if 0 >+ if (behavior & ScrollingStateTreeAsTextBehaviorIncludeLayerPositions) { >+ FloatRect layerBounds = [m_layer bounds]; >+ FloatPoint anchorPoint = [m_layer anchorPoint]; >+ FloatPoint position = [m_layer position]; >+ FloatPoint layerTopLeft = position - toFloatSize(anchorPoint) * layerBounds.size() + m_constraints.alignmentOffset(); >+ ts.dumpProperty("layer top left", layerTopLeft); >+ } >+#endif > } > > } // namespace WebCore >diff --git a/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.h b/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.h >index a3d191ea9b9..f9521474128 100644 >--- a/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.h >+++ b/Source/WebCore/page/scrolling/nicosia/ScrollingTreeStickyNode.h >@@ -31,6 +31,13 @@ > > #include "ScrollingTreeNode.h" > >+#include "ScrollingConstraints.h" >+#include <wtf/RefPtr.h> >+ >+namespace Nicosia { >+class CompositionLayer; >+} >+ > namespace WebCore { > > class ScrollingTreeStickyNode final : public ScrollingTreeNode { >@@ -44,8 +51,14 @@ private: > void commitStateBeforeChildren(const ScrollingStateNode&) override; > void applyLayerPositions() override; > >+ void dumpProperties(WTF::TextStream&, ScrollingStateTreeAsTextBehavior) const override; >+ >+ RefPtr<Nicosia::CompositionLayer> m_scrollLayer; >+ StickyPositionViewportConstraints m_constraints; > }; > > } // namespace WebCore > >+SPECIALIZE_TYPE_TRAITS_SCROLLING_NODE(ScrollingTreeStickyNode, isStickyNode()) >+ > #endif // ENABLE(ASYNC_SCROLLING) && USE(NICOSIA) >diff --git a/Source/WebCore/platform/TextureMapper.cmake b/Source/WebCore/platform/TextureMapper.cmake >index 28b7e177a10..9198e20a14f 100644 >--- a/Source/WebCore/platform/TextureMapper.cmake >+++ b/Source/WebCore/platform/TextureMapper.cmake >@@ -82,6 +82,7 @@ if (USE_COORDINATED_GRAPHICS) > platform/graphics/nicosia/NicosiaPaintingEngineThreaded.cpp > platform/graphics/nicosia/NicosiaPlatformLayer.cpp > platform/graphics/nicosia/NicosiaScene.cpp >+ platform/graphics/nicosia/NicosiaSceneIntegration.cpp > > platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp > platform/graphics/nicosia/cairo/NicosiaPaintingContextCairo.cpp >@@ -100,6 +101,7 @@ if (USE_COORDINATED_GRAPHICS) > platform/graphics/nicosia/NicosiaPaintingEngine.h > platform/graphics/nicosia/NicosiaPlatformLayer.h > platform/graphics/nicosia/NicosiaScene.h >+ platform/graphics/nicosia/NicosiaSceneIntegration.h > > platform/graphics/nicosia/texmap/NicosiaBackingStoreTextureMapperImpl.h > platform/graphics/nicosia/texmap/NicosiaCompositionLayerTextureMapperImpl.h >diff --git a/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.h b/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.h >index be3a5257a4b..01f6a9a994e 100644 >--- a/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.h >+++ b/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.h >@@ -34,6 +34,7 @@ > #include "FloatPoint3D.h" > #include "FloatRect.h" > #include "FloatSize.h" >+#include "NicosiaSceneIntegration.h" > #include "TextureMapperAnimation.h" > #include "TransformationMatrix.h" > #include <wtf/Function.h> >@@ -53,6 +54,20 @@ public: > using LayerID = uint64_t; > LayerID id() const { return m_id; } > >+ void setSceneIntegration(RefPtr<SceneIntegration>&& sceneIntegration) >+ { >+ LockHolder locker(m_state.lock); >+ m_state.sceneIntegration = WTFMove(sceneIntegration); >+ } >+ >+ std::unique_ptr<SceneIntegration::UpdateScope> createUpdateScope() >+ { >+ LockHolder locker(m_state.lock); >+ if (m_state.sceneIntegration) >+ return m_state.sceneIntegration->createUpdateScope(); >+ return nullptr; >+ } >+ > protected: > explicit PlatformLayer(uint64_t); > >@@ -60,6 +75,7 @@ protected: > > struct { > Lock lock; >+ RefPtr<SceneIntegration> sceneIntegration; > } m_state; > }; > >@@ -256,6 +272,13 @@ public: > functor(m_state.committed); > } > >+ template<typename T> >+ void accessStaging(const T& functor) >+ { >+ LockHolder locker(PlatformLayer::m_state.lock); >+ functor(m_state.staging); >+ } >+ > template<typename T> > void accessCommitted(const T& functor) > { >diff --git a/Source/WebCore/platform/graphics/nicosia/NicosiaSceneIntegration.cpp b/Source/WebCore/platform/graphics/nicosia/NicosiaSceneIntegration.cpp >new file mode 100644 >index 00000000000..0af3df425e5 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/nicosia/NicosiaSceneIntegration.cpp >@@ -0,0 +1,85 @@ >+/* >+ * Copyright (C) 2019 Metrological Group B.V. >+ * Copyright (C) 2019 Igalia S.L. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above >+ * copyright notice, this list of conditions and the following >+ * disclaimer in the documentation and/or other materials provided >+ * with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "NicosiaSceneIntegration.h" >+ >+namespace Nicosia { >+ >+SceneIntegration::SceneIntegration() = default; >+ >+SceneIntegration::SceneIntegration(Client& client) >+{ >+ m_client.object = &client; >+} >+ >+SceneIntegration::~SceneIntegration() >+{ >+ ASSERT(!m_client.object); >+} >+ >+void SceneIntegration::setClient(Client& client) >+{ >+ LockHolder locker(m_client.lock); >+ m_client.object = &client; >+} >+ >+void SceneIntegration::invalidate() >+{ >+ LockHolder locker(m_client.lock); >+ m_client.object = nullptr; >+} >+ >+void SceneIntegration::requestUpdate() >+{ >+ LockHolder locker(m_client.lock); >+ if (m_client.object) >+ m_client.object->requestUpdate(); >+} >+ >+std::unique_ptr<SceneIntegration::UpdateScope> SceneIntegration::createUpdateScope() >+{ >+ return std::make_unique<UpdateScope>(makeRef(*this)); >+} >+ >+SceneIntegration::Client::~Client() = default; >+ >+SceneIntegration::UpdateScope::UpdateScope(Ref<SceneIntegration>&& sceneIntegration) >+ : m_sceneIntegration(WTFMove(sceneIntegration)) >+ , m_locker(m_sceneIntegration->m_client.lock) >+{ >+} >+ >+SceneIntegration::UpdateScope::~UpdateScope() >+{ >+ auto& sceneIntegrationObj = m_sceneIntegration.get(); >+ if (sceneIntegrationObj.m_client.object) >+ sceneIntegrationObj.m_client.object->requestUpdate(); >+} >+ >+} // namespace Nicosia >diff --git a/Source/WebCore/platform/graphics/nicosia/NicosiaSceneIntegration.h b/Source/WebCore/platform/graphics/nicosia/NicosiaSceneIntegration.h >new file mode 100644 >index 00000000000..7af390ba51c >--- /dev/null >+++ b/Source/WebCore/platform/graphics/nicosia/NicosiaSceneIntegration.h >@@ -0,0 +1,75 @@ >+/* >+ * Copyright (C) 2019 Metrological Group B.V. >+ * Copyright (C) 2019 Igalia S.L. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above >+ * copyright notice, this list of conditions and the following >+ * disclaimer in the documentation and/or other materials provided >+ * with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include <memory> >+#include <wtf/Lock.h> >+#include <wtf/Ref.h> >+#include <wtf/ThreadSafeRefCounted.h> >+ >+namespace Nicosia { >+ >+class SceneIntegration : public ThreadSafeRefCounted<SceneIntegration> { >+public: >+ class Client { >+ public: >+ virtual ~Client(); >+ >+ virtual void requestUpdate() = 0; >+ }; >+ >+ SceneIntegration(); >+ SceneIntegration(Client&); >+ ~SceneIntegration(); >+ >+ void setClient(Client&); >+ void invalidate(); >+ >+ void requestUpdate(); >+ >+ class UpdateScope { >+ public: >+ UpdateScope(Ref<SceneIntegration>&&); >+ ~UpdateScope(); >+ >+ private: >+ Ref<SceneIntegration> m_sceneIntegration; >+ LockHolder m_locker; >+ }; >+ >+ std::unique_ptr<UpdateScope> createUpdateScope(); >+ >+private: >+ struct { >+ Lock lock; >+ Client* object { nullptr }; >+ } m_client; >+}; >+ >+} // namespace Nicosia >diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp >index a95382c9d74..7e65aa62405 100644 >--- a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp >+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp >@@ -1206,6 +1206,11 @@ bool CoordinatedGraphicsLayer::usesContentsLayer() const > return m_nicosia.contentLayer || m_compositedImage; > } > >+PlatformLayer* CoordinatedGraphicsLayer::platformLayer() const >+{ >+ return m_nicosia.layer.get(); >+} >+ > } // namespace WebCore > > #endif // USE(COORDINATED_GRAPHICS) >diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h >index b5177de8cec..ca89de50af5 100644 >--- a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h >+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h >@@ -108,6 +108,10 @@ public: > void resumeAnimations() override; > bool usesContentsLayer() const override; > >+#if USE(NICOSIA) >+ PlatformLayer* platformLayer() const override; >+#endif >+ > void syncPendingStateChangesIncludingSubLayers(); > void updateContentBuffersIncludingSubLayers(); > >diff --git a/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp b/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp >index 530da864898..4bf3ff6c84e 100644 >--- a/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp >+++ b/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp >@@ -292,6 +292,11 @@ void ThreadedCompositor::updateSceneState(const CoordinatedGraphicsState& state) > m_compositingRunLoop->scheduleUpdate(); > } > >+void ThreadedCompositor::updateScene() >+{ >+ m_compositingRunLoop->scheduleUpdate(); >+} >+ > #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) > RefPtr<WebCore::DisplayRefreshMonitor> ThreadedCompositor::displayRefreshMonitor(PlatformDisplayID) > { >diff --git a/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h b/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h >index 7e16738f30a..30b89d2d207 100644 >--- a/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h >+++ b/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h >@@ -72,6 +72,7 @@ public: > void setViewportSize(const WebCore::IntSize&, float scale); > > void updateSceneState(const WebCore::CoordinatedGraphicsState&); >+ void updateScene(); > > void invalidate(); > >diff --git a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp >index be640e9ccf3..e601df64ea3 100644 >--- a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp >+++ b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp >@@ -235,7 +235,11 @@ Ref<GraphicsLayer> CompositingCoordinator::createGraphicsLayer(GraphicsLayer::Ty > { > auto layer = adoptRef(*new CoordinatedGraphicsLayer(layerType, client)); > layer->setCoordinator(this); >- m_nicosia.state.layers.add(layer->compositionLayer()); >+ { >+ auto& compositionLayer = layer->compositionLayer(); >+ m_nicosia.state.layers.add(compositionLayer); >+ compositionLayer->setSceneIntegration(m_client.sceneIntegration()); >+ } > m_registeredLayers.add(layer->id(), layer.ptr()); > layer->setNeedsVisibleRectAdjustment(); > notifyFlushRequired(layer.ptr()); >diff --git a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h >index b4a0d1544d5..79ccccb1df4 100644 >--- a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h >+++ b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h >@@ -40,6 +40,7 @@ > > namespace Nicosia { > class PaintingEngine; >+class SceneIntegration; > } > > namespace WebCore { >@@ -60,6 +61,7 @@ public: > virtual void didFlushRootLayer(const WebCore::FloatRect& visibleContentRect) = 0; > virtual void notifyFlushRequired() = 0; > virtual void commitSceneState(const WebCore::CoordinatedGraphicsState&) = 0; >+ virtual RefPtr<Nicosia::SceneIntegration> sceneIntegration() = 0; > }; > > CompositingCoordinator(WebCore::Page*, CompositingCoordinator::Client&); >diff --git a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp >index 90f74f2fdf3..b63468be76f 100644 >--- a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp >+++ b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp >@@ -257,6 +257,11 @@ void DrawingAreaCoordinatedGraphics::didChangeViewportAttributes(ViewportAttribu > m_previousLayerTreeHost->didChangeViewportAttributes(WTFMove(attrs)); > } > >+bool DrawingAreaCoordinatedGraphics::supportsAsyncScrolling() >+{ >+ return true; >+} >+ > GraphicsLayerFactory* DrawingAreaCoordinatedGraphics::graphicsLayerFactory() > { > if (!m_layerTreeHost) >diff --git a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h >index e684f75d645..19ece79e13f 100644 >--- a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h >+++ b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h >@@ -62,6 +62,8 @@ private: > void deviceOrPageScaleFactorChanged() override; > void didChangeViewportAttributes(WebCore::ViewportAttributes&&) override; > >+ bool supportsAsyncScrolling() override; >+ > WebCore::GraphicsLayerFactory* graphicsLayerFactory() override; > void setRootCompositingLayer(WebCore::GraphicsLayer*) override; > void scheduleInitialDeferredPaint() override { }; >diff --git a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp >index 2cb82f7a55c..19618c8af52 100644 >--- a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp >+++ b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp >@@ -59,6 +59,7 @@ LayerTreeHost::LayerTreeHost(WebPage& webPage) > , m_surface(AcceleratedSurface::create(webPage, *this)) > , m_viewportController(webPage.size()) > , m_layerFlushTimer(RunLoop::main(), this, &LayerTreeHost::layerFlushTimerFired) >+ , m_sceneIntegration(*new Nicosia::SceneIntegration(*this)) > { > #if USE(GLIB_EVENT_LOOP) > m_layerFlushTimer.setPriority(RunLoopSourcePriority::LayerFlushTimer); >@@ -389,11 +390,21 @@ void LayerTreeHost::commitSceneState(const CoordinatedGraphicsState& state) > m_compositor->updateSceneState(state); > } > >+RefPtr<Nicosia::SceneIntegration> LayerTreeHost::sceneIntegration() >+{ >+ return m_sceneIntegration.copyRef(); >+} >+ > void LayerTreeHost::frameComplete() > { > m_compositor->frameComplete(); > } > >+void LayerTreeHost::requestUpdate() >+{ >+ m_compositor->updateScene(); >+} >+ > uint64_t LayerTreeHost::nativeSurfaceHandleForCompositing() > { > if (!m_surface) >diff --git a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h >index 38f3b7fabd4..ac928dda2a0 100644 >--- a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h >+++ b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h >@@ -39,6 +39,10 @@ > #include <wtf/OptionSet.h> > #include <wtf/RunLoop.h> > >+#if USE(COORDINATED_GRAPHICS) >+#include <WebCore/NicosiaSceneIntegration.h> >+#endif >+ > namespace WebCore { > class IntRect; > class IntSize; >@@ -54,7 +58,7 @@ class WebPage; > > class LayerTreeHost > #if USE(COORDINATED_GRAPHICS) >- final : public CompositingCoordinator::Client, public AcceleratedSurface::Client >+ final : public CompositingCoordinator::Client, public AcceleratedSurface::Client, public Nicosia::SceneIntegration::Client > #endif > { > WTF_MAKE_FAST_ALLOCATED; >@@ -107,10 +111,14 @@ private: > void didFlushRootLayer(const WebCore::FloatRect& visibleContentRect) override; > void notifyFlushRequired() override { scheduleLayerFlush(); }; > void commitSceneState(const WebCore::CoordinatedGraphicsState&) override; >+ RefPtr<Nicosia::SceneIntegration> sceneIntegration() override; > > // AcceleratedSurface::Client > void frameComplete() override; > >+ // Nicosia::SceneIntegration::Client >+ void requestUpdate() override; >+ > uint64_t nativeSurfaceHandleForCompositing(); > void didDestroyGLContext(); > void willRenderFrame(); >@@ -197,6 +205,7 @@ private: > bool needsFreshFlush { false }; > } m_forceRepaintAsync; > RunLoop::Timer<LayerTreeHost> m_layerFlushTimer; >+ Ref<Nicosia::SceneIntegration> m_sceneIntegration; > #endif // USE(COORDINATED_GRAPHICS) > }; >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198475
:
371176
|
371726
|
372735
|
377119