WebKit Bugzilla
Attachment 346895 Details for
Bug 187385
: [Nicosia] Add a platform layer concept
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
WIP
platform-layers.patch (text/plain), 114.88 KB, created by
Zan Dobersek
on 2018-08-09 23:23:52 PDT
(
hide
)
Description:
WIP
Filename:
MIME Type:
Creator:
Zan Dobersek
Created:
2018-08-09 23:23:52 PDT
Size:
114.88 KB
patch
obsolete
>diff --git a/Source/WebCore/page/scrolling/ScrollingStateTree.cpp b/Source/WebCore/page/scrolling/ScrollingStateTree.cpp >index b33aa0cdafe..0f2dd4cfa96 100644 >--- a/Source/WebCore/page/scrolling/ScrollingStateTree.cpp >+++ b/Source/WebCore/page/scrolling/ScrollingStateTree.cpp >@@ -263,7 +263,6 @@ ScrollingStateNode* ScrollingStateTree::stateNodeForID(ScrollingNodeID scrollLay > > } // namespace WebCore > >-#ifndef NDEBUG > void showScrollingStateTree(const WebCore::ScrollingStateTree* tree) > { > if (!tree) >@@ -287,6 +286,4 @@ void showScrollingStateTree(const WebCore::ScrollingStateNode* node) > showScrollingStateTree(&node->scrollingStateTree()); > } > >-#endif >- > #endif // ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS) >diff --git a/Source/WebCore/page/scrolling/ScrollingStateTree.h b/Source/WebCore/page/scrolling/ScrollingStateTree.h >index 3b256151ad7..6ae6f33db86 100644 >--- a/Source/WebCore/page/scrolling/ScrollingStateTree.h >+++ b/Source/WebCore/page/scrolling/ScrollingStateTree.h >@@ -99,9 +99,7 @@ private: > > } // namespace WebCore > >-#ifndef NDEBUG > void showScrollingStateTree(const WebCore::ScrollingStateTree*); > void showScrollingStateTree(const WebCore::ScrollingStateNode*); >-#endif > > #endif // ENABLE(ASYNC_SCROLLING) || USE(COORDINATED_GRAPHICS) >diff --git a/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp b/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp >index 830353648ce..ac3d99856a7 100644 >--- a/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp >+++ b/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp >@@ -87,6 +87,7 @@ void ScrollingCoordinatorCoordinatedGraphics::commitTreeState() > > auto treeState = scrollingStateTree()->commit(LayerRepresentation::PlatformLayerRepresentation); > ScrollingThread::dispatch([threadedScrollingTree, treeState = WTFMove(treeState)]() mutable { >+ // showScrollingStateTree(treeState.get()); > threadedScrollingTree->commitTreeState(WTFMove(treeState)); > }); > } >diff --git a/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingStateNodeCoordinatedGraphics.cpp b/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingStateNodeCoordinatedGraphics.cpp >index 3d68ae66a8f..190e58aaedc 100644 >--- a/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingStateNodeCoordinatedGraphics.cpp >+++ b/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingStateNodeCoordinatedGraphics.cpp >@@ -26,22 +26,23 @@ > #include "config.h" > #include "ScrollingStateNode.h" > >-#include "GraphicsLayer.h" >-#include "NotImplemented.h" >-#include "ScrollingStateTree.h" >+#if ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) && USE(NICOSIA) > >-#if USE(COORDINATED_GRAPHICS) >+#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) >@@ -56,4 +57,4 @@ void* LayerRepresentation::makePlatformLayerTypeless(PlatformLayer* layer) > > } // namespace WebCore > >-#endif // USE(COORDINATED_GRAPHICS) >+#endif // ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) && USE(NICOSIA) >diff --git a/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingTreeCoordinatedGraphics.cpp b/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingTreeCoordinatedGraphics.cpp >index 6bfca4dfd51..0412a6792dd 100644 >--- a/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingTreeCoordinatedGraphics.cpp >+++ b/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingTreeCoordinatedGraphics.cpp >@@ -28,7 +28,7 @@ > #include "config.h" > #include "ScrollingTreeCoordinatedGraphics.h" > >-#if ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) >+#if ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) && USE(NICOSIA) > > #include "ScrollingTreeFixedNode.h" > #include "ScrollingTreeFrameScrollingNodeCoordinatedGraphics.h" >@@ -66,4 +66,4 @@ Ref<ScrollingTreeNode> ScrollingTreeCoordinatedGraphics::createScrollingTreeNode > > } // namespace WebCore > >-#endif // ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) >+#endif // ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) && USE(NICOSIA) >diff --git a/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingTreeFixedNode.cpp b/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingTreeFixedNode.cpp >index 22cd1ff7719..55d33de07a5 100644 >--- a/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingTreeFixedNode.cpp >+++ b/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingTreeFixedNode.cpp >@@ -28,9 +28,11 @@ > #include "config.h" > #include "ScrollingTreeFixedNode.h" > >-#if ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) >+#if ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) && USE(NICOSIA) > >+#include "ScrollingStateFixedNode.h" > #include "ScrollingTree.h" >+#include "NicosiaPlatformLayer.h" > > namespace WebCore { > >@@ -50,14 +52,44 @@ ScrollingTreeFixedNode::~ScrollingTreeFixedNode() > scrollingTree().fixedOrStickyNodeRemoved(); > } > >-void ScrollingTreeFixedNode::commitStateBeforeChildren(const ScrollingStateNode&) >+void ScrollingTreeFixedNode::commitStateBeforeChildren(const ScrollingStateNode& stateNode) > { >+ auto& fixedNode = downcast<ScrollingStateFixedNode>(stateNode); >+ >+ if (fixedNode.hasChangedProperty(ScrollingStateNode::ScrollLayer)) { >+ Nicosia::PlatformLayer* layer = fixedNode.layer(); >+ m_scrollLayer = downcast<Nicosia::CompositionLayer>(layer); >+ } >+ >+ if (stateNode.hasChangedProperty(ScrollingStateFixedNode::ViewportConstraints)) >+ m_constraints = fixedNode.viewportConstraints(); > } > >-void ScrollingTreeFixedNode::updateLayersAfterAncestorChange(const ScrollingTreeNode&, const FloatRect&, const FloatSize&) >+void ScrollingTreeFixedNode::updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& fixedPositionRect, const FloatSize& cumulativeDelta) > { >+ FloatPoint layerPosition = m_constraints.layerPositionForViewportRect(fixedPositionRect); >+ layerPosition -= cumulativeDelta; >+ >+ ASSERT(m_scrollLayer); >+ m_scrollLayer->accessState( >+ [this, &layerPosition](Nicosia::CompositionLayer::LayerState& state) >+ { >+ auto& anchorPoint = state.anchorPoint; >+ auto& size = state.size; >+ >+ FloatPoint position = layerPosition - m_constraints.alignmentOffset() >+ + FloatPoint(anchorPoint.x() * size.width(), anchorPoint.y() * size.height()); >+ state.position = position; >+ state.delta.positionChanged = true; >+ }); >+ >+ if (m_children) { >+ FloatSize newDelta = layerPosition - m_constraints.layerPositionAtLastLayout() + cumulativeDelta; >+ for (auto& child : *m_children) >+ child->updateLayersAfterAncestorChange(changedNode, fixedPositionRect, newDelta); >+ } > } > > } // namespace WebCore > >-#endif // ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) >+#endif // ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) && USE(NICOSIA) >diff --git a/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingTreeFixedNode.h b/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingTreeFixedNode.h >index d0aa8792422..3d5dbb51091 100644 >--- a/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingTreeFixedNode.h >+++ b/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingTreeFixedNode.h >@@ -27,10 +27,13 @@ > > #pragma once > >-#if ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) >+#if ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) && USE(NICOSIA) > > #include "ScrollingTreeNode.h" > >+#include "ScrollingConstraints.h" >+#include <wtf/RefPtr.h> >+ > namespace WebCore { > > class ScrollingTreeFixedNode final : public ScrollingTreeNode { >@@ -43,8 +46,11 @@ private: > > void commitStateBeforeChildren(const ScrollingStateNode&) override; > void updateLayersAfterAncestorChange(const ScrollingTreeNode&, const FloatRect&, const FloatSize&) override; >+ >+ RefPtr<Nicosia::CompositionLayer> m_scrollLayer; >+ FixedPositionViewportConstraints m_constraints; > }; > > } // namespace WebCore > >-#endif // ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) >+#endif // ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) && USE(NICOSIA) >diff --git a/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingTreeFrameScrollingNodeCoordinatedGraphics.cpp b/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingTreeFrameScrollingNodeCoordinatedGraphics.cpp >index ecc6f317306..83c3f25635b 100644 >--- a/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingTreeFrameScrollingNodeCoordinatedGraphics.cpp >+++ b/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingTreeFrameScrollingNodeCoordinatedGraphics.cpp >@@ -28,7 +28,10 @@ > #include "config.h" > #include "ScrollingTreeFrameScrollingNodeCoordinatedGraphics.h" > >-#if ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) >+#if ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) && USE(NICOSIA) >+ >+#include "NicosiaPlatformLayer.h" >+#include "FrameView.h" > > namespace WebCore { > >@@ -44,25 +47,140 @@ ScrollingTreeFrameScrollingNodeCoordinatedGraphics::ScrollingTreeFrameScrollingN > > ScrollingTreeFrameScrollingNodeCoordinatedGraphics::~ScrollingTreeFrameScrollingNodeCoordinatedGraphics() = default; > >-void ScrollingTreeFrameScrollingNodeCoordinatedGraphics::handleWheelEvent(const PlatformWheelEvent&) >+void ScrollingTreeFrameScrollingNodeCoordinatedGraphics::commitStateBeforeChildren(const ScrollingStateNode& stateNode) >+{ >+ //fprintf(stderr, "ScrollingTreeFrameScrollingNodeCoordinatedGraphics::commitStateBeforeChildren() changed properties %d\n", >+ // stateNode.changedProperties()); >+ ScrollingTreeFrameScrollingNode::commitStateBeforeChildren(stateNode); >+ const auto& scrollingStateNode = downcast<ScrollingStateFrameScrollingNode>(stateNode); >+ >+ if (scrollingStateNode.hasChangedProperty(ScrollingStateNode::ScrollLayer)) { >+ Nicosia::PlatformLayer* layer = scrollingStateNode.layer(); >+ m_scrollLayer = downcast<Nicosia::CompositionLayer>(layer); >+ //fprintf(stderr, "\tchanged property: ScrollLayer %p id %lu\n", m_scrollLayer.get(), m_scrollLayer ? m_scrollLayer->id() : 0); >+ } >+ if (scrollingStateNode.hasChangedProperty(ScrollingStateScrollingNode::ScrolledContentsLayer)) { >+ Nicosia::PlatformLayer* layer = scrollingStateNode.scrolledContentsLayer(); >+ m_scrolledContentsLayer = downcast<Nicosia::CompositionLayer>(layer); >+ //fprintf(stderr, "\tchanged property: ScrolledContentsLayer %p id %lu\n", m_scrolledContentsLayer.get(), m_scrolledContentsLayer ? m_scrolledContentsLayer->id() : 0); >+ } >+ if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::CounterScrollingLayer)) { >+ Nicosia::PlatformLayer* layer = scrollingStateNode.counterScrollingLayer(); >+ m_counterScrollingLayer = downcast<Nicosia::CompositionLayer>(layer); >+ //fprintf(stderr, "\tchanged property: CounterScrollingLayer %p\n", m_counterScrollingLayer.get()); >+ } >+ if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::InsetClipLayer)) { >+ Nicosia::PlatformLayer* layer = scrollingStateNode.insetClipLayer(); >+ m_insetClipLayer = downcast<Nicosia::CompositionLayer>(layer); >+ //fprintf(stderr, "\tchanged property: InsetClipLayer %p\n", m_insetClipLayer.get()); >+ } >+ if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::ContentShadowLayer)) { >+ Nicosia::PlatformLayer* layer = scrollingStateNode.contentShadowLayer(); >+ m_contentShadowLayer = downcast<Nicosia::CompositionLayer>(layer); >+ //fprintf(stderr, "\tchanged property: ContentShadowLayer %p\n", m_contentShadowLayer.get()); >+ } >+ if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::HeaderLayer)) { >+ Nicosia::PlatformLayer* layer = scrollingStateNode.headerLayer(); >+ m_headerLayer = downcast<Nicosia::CompositionLayer>(layer); >+ //fprintf(stderr, "\tchanged property: HeaderLayer %p\n", m_headerLayer.get()); >+ } >+ if (scrollingStateNode.hasChangedProperty(ScrollingStateFrameScrollingNode::FooterLayer)) { >+ Nicosia::PlatformLayer* layer = scrollingStateNode.footerLayer(); >+ m_footerLayer = downcast<Nicosia::CompositionLayer>(layer); >+ //fprintf(stderr, "\tchanged property: FooterLayer %p\n", m_footerLayer.get()); >+ } >+} >+ >+void ScrollingTreeFrameScrollingNodeCoordinatedGraphics::commitStateAfterChildren(const ScrollingStateNode& stateNode) > { >+ //fprintf(stderr, "ScrollingTreeFrameScrollingNodeCoordinatedGraphics::commitStateAfterChildren() changed properties %d\n", >+ // stateNode.changedProperties()); >+} >+ >+void ScrollingTreeFrameScrollingNodeCoordinatedGraphics::handleWheelEvent(const PlatformWheelEvent& wheelEvent) >+{ >+ if (!canHaveScrollbars()) >+ return; >+ >+ scrollBy({ wheelEvent.deltaX(), -wheelEvent.deltaY() }); >+ >+ // TODO: >+ // scrollingTree().setOrClearLatchedNode(wheelEvent, scrollingNodeID()); >+ // scrollingTree().handleWheelEventPhase(wheelEvent.phase()); > } > > FloatPoint ScrollingTreeFrameScrollingNodeCoordinatedGraphics::scrollPosition() const > { >- return { }; >+ ASSERT(m_scrollLayer); >+ >+ FloatPoint scrollPosition; >+ m_scrollLayer->accessState( >+ [&scrollPosition](const Nicosia::CompositionLayer::LayerState& state) >+ { >+ scrollPosition = -state.position; >+ }); >+ return scrollPosition; > } > >-void ScrollingTreeFrameScrollingNodeCoordinatedGraphics::setScrollPosition(const FloatPoint&) >+void ScrollingTreeFrameScrollingNodeCoordinatedGraphics::setScrollPosition(const FloatPoint& position) > { >+ ScrollingTreeFrameScrollingNode::setScrollPosition(position); > } > >-void ScrollingTreeFrameScrollingNodeCoordinatedGraphics::setScrollPositionWithoutContentEdgeConstraints(const FloatPoint&) >+void ScrollingTreeFrameScrollingNodeCoordinatedGraphics::setScrollPositionWithoutContentEdgeConstraints(const FloatPoint& scrollPosition) > { >+ std::optional<FloatPoint> layoutViewportOrigin; >+ if (scrollingTree().visualViewportEnabled()) { >+ FloatPoint visibleContentOrigin = scrollPosition; >+ FloatRect newLayoutViewport = layoutViewportForScrollPosition(visibleContentOrigin, frameScaleFactor()); >+ setLayoutViewport(newLayoutViewport); >+ layoutViewportOrigin = newLayoutViewport.location(); >+ } >+ >+ setScrollLayerPosition(scrollPosition, layoutViewport()); >+ scrollingTree().scrollingTreeNodeDidScroll(scrollingNodeID(), scrollPosition, layoutViewportOrigin); > } > >-void ScrollingTreeFrameScrollingNodeCoordinatedGraphics::setScrollLayerPosition(const FloatPoint&, const FloatRect&) >+void ScrollingTreeFrameScrollingNodeCoordinatedGraphics::setScrollLayerPosition(const FloatPoint& scrollPosition, const FloatRect& layoutViewport) > { >+ //fprintf(stderr, "ScrollingTreeFrameScrollingNodeCoordinatedGraphics::setScrollLayerPosition() position (%.2f,%.2f) layoutViewport (%.2f,%.2f)x(%.2f,%.2f)\n", >+ // scrollPosition.x(), scrollPosition.y(), >+ // layoutViewport.x(), layoutViewport.y(), layoutViewport.width(), layoutViewport.height()); >+ >+ auto updateScope = m_scrollLayer->createUpdateScope(); >+ >+ ASSERT(m_scrollLayer); >+ m_scrollLayer->accessState( >+ [&scrollPosition](Nicosia::CompositionLayer::LayerState& state) >+ { >+ state.position = -scrollPosition; >+ state.delta.positionChanged = true; >+ }); >+ >+ FloatRect visibleContentRect(scrollPosition, scrollableAreaSize()); >+ FloatRect fixedPositionRect; >+ ScrollBehaviorForFixedElements behaviorForFixed = StickToViewportBounds; >+ >+ if (scrollingTree().visualViewportEnabled()) >+ fixedPositionRect = layoutViewport; >+ else { >+ behaviorForFixed = scrollBehaviorForFixedElements(); >+ >+ FloatPoint scrollPositionForFixedChildren = FrameView::scrollPositionForFixedPosition(enclosingLayoutRect(visibleContentRect), LayoutSize(totalContentsSize()), >+ LayoutPoint(scrollPosition), scrollOrigin(), frameScaleFactor(), fixedElementsLayoutRelativeToFrame(), behaviorForFixed, headerHeight(), footerHeight()); >+ >+ fixedPositionRect = { scrollPositionForFixedChildren, visibleContentRect.size() }; >+ } >+ >+ float topContentInset = this->topContentInset(); >+ if (m_insetClipLayer && m_scrolledContentsLayer && topContentInset) { >+ // TODO: ... >+ } >+ >+ if (m_children) { >+ for (auto& child : *m_children) >+ child->updateLayersAfterAncestorChange(*this, fixedPositionRect, FloatSize()); >+ } > } > > void ScrollingTreeFrameScrollingNodeCoordinatedGraphics::updateLayersAfterViewportChange(const FloatRect&, double) >@@ -71,4 +189,4 @@ void ScrollingTreeFrameScrollingNodeCoordinatedGraphics::updateLayersAfterViewpo > > } // namespace WebCore > >-#endif // ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) >+#endif // ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) && USE(NICOSIA) >diff --git a/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingTreeFrameScrollingNodeCoordinatedGraphics.h b/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingTreeFrameScrollingNodeCoordinatedGraphics.h >index 65086cc92bd..be7bd676ab2 100644 >--- a/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingTreeFrameScrollingNodeCoordinatedGraphics.h >+++ b/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingTreeFrameScrollingNodeCoordinatedGraphics.h >@@ -27,10 +27,12 @@ > > #pragma once > >-#if ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) >+#if ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) && USE(NICOSIA) > > #include "ScrollingTreeFrameScrollingNode.h" > >+#include <wtf/RefPtr.h> >+ > namespace WebCore { > > class ScrollingTreeFrameScrollingNodeCoordinatedGraphics final : public ScrollingTreeFrameScrollingNode { >@@ -41,6 +43,9 @@ public: > private: > ScrollingTreeFrameScrollingNodeCoordinatedGraphics(ScrollingTree&, ScrollingNodeType, ScrollingNodeID); > >+ void commitStateBeforeChildren(const ScrollingStateNode&) override; >+ void commitStateAfterChildren(const ScrollingStateNode&) override; >+ > void handleWheelEvent(const PlatformWheelEvent&) override; > > FloatPoint scrollPosition() const override; >@@ -49,8 +54,16 @@ private: > void setScrollLayerPosition(const FloatPoint&, const FloatRect&) override; > > void updateLayersAfterViewportChange(const FloatRect&, double) 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 > >-#endif // ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) >+#endif // ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) && USE(NICOSIA) >diff --git a/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingTreeStickyNode.cpp b/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingTreeStickyNode.cpp >index 0322e676a68..9ed58ea0b0a 100644 >--- a/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingTreeStickyNode.cpp >+++ b/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingTreeStickyNode.cpp >@@ -28,9 +28,13 @@ > #include "config.h" > #include "ScrollingTreeStickyNode.h" > >-#if ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) >+#if ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) && USE(NICOSIA) > >+#include "ScrollingStateStickyNode.h" > #include "ScrollingTree.h" >+#include "ScrollingTreeFrameScrollingNode.h" >+#include "ScrollingTreeOverflowScrollingNode.h" >+#include "NicosiaPlatformLayer.h" > > namespace WebCore { > >@@ -50,14 +54,59 @@ ScrollingTreeStickyNode::~ScrollingTreeStickyNode() > scrollingTree().fixedOrStickyNodeRemoved(); > } > >-void ScrollingTreeStickyNode::commitStateBeforeChildren(const ScrollingStateNode&) >+void ScrollingTreeStickyNode::commitStateBeforeChildren(const ScrollingStateNode& stateNode) > { >+ auto& stickyNode = downcast<ScrollingStateStickyNode>(stateNode); >+ >+ if (stickyNode.hasChangedProperty(ScrollingStateNode::ScrollLayer)) { >+ Nicosia::PlatformLayer* layer = stickyNode.layer(); >+ m_scrollLayer = downcast<Nicosia::CompositionLayer>(layer); >+ } >+ >+ if (stateNode.hasChangedProperty(ScrollingStateStickyNode::ViewportConstraints)) >+ m_constraints = stickyNode.viewportConstraints(); > } > >-void ScrollingTreeStickyNode::updateLayersAfterAncestorChange(const ScrollingTreeNode&, const FloatRect&, const FloatSize&) >+void ScrollingTreeStickyNode::updateLayersAfterAncestorChange(const ScrollingTreeNode& changedNode, const FloatRect& fixedPositionRect, const FloatSize& cumulativeDelta) > { >+ bool adjustStickyLayer = false; >+ FloatRect constrainingRect; >+ >+ if (is<ScrollingTreeOverflowScrollingNode>(*parent())) { >+ constrainingRect = FloatRect(downcast<ScrollingTreeOverflowScrollingNode>(*parent()).scrollPosition(), m_constraints.constrainingRectAtLastLayout().size()); >+ adjustStickyLayer = true; >+ } else if (is<ScrollingTreeFrameScrollingNode>(*parent())) { >+ constrainingRect = fixedPositionRect; >+ adjustStickyLayer = true; >+ } >+ >+ FloatSize deltaForDescendants = cumulativeDelta; >+ >+ if (adjustStickyLayer) { >+ FloatPoint layerPosition = m_constraints.layerPositionForConstrainingRect(constrainingRect); >+ >+ ASSERT(m_scrollLayer); >+ m_scrollLayer->accessState( >+ [this, &layerPosition](Nicosia::CompositionLayer::LayerState& state) >+ { >+ auto& anchorPoint = state.anchorPoint; >+ auto& size = state.size; >+ >+ FloatPoint position = layerPosition - m_constraints.alignmentOffset() >+ + FloatPoint(anchorPoint.x() * size.width(), anchorPoint.y() * size.height()); >+ state.position = position; >+ state.delta.positionChanged = true; >+ }); >+ >+ deltaForDescendants = layerPosition - m_constraints.layerPositionAtLastLayout() + cumulativeDelta; >+ } >+ >+ if (m_children) { >+ for (auto& child : *m_children) >+ child->updateLayersAfterAncestorChange(changedNode, fixedPositionRect, deltaForDescendants); >+ } > } > > } // namespace WebCore > >-#endif // ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) >+#endif // ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) && USE(NICOSIA) >diff --git a/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingTreeStickyNode.h b/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingTreeStickyNode.h >index f3133a708c7..eb18f4cefe2 100644 >--- a/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingTreeStickyNode.h >+++ b/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingTreeStickyNode.h >@@ -27,10 +27,13 @@ > > #pragma once > >-#if ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) >+#if ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) && USE(NICOSIA) > > #include "ScrollingTreeNode.h" > >+#include "ScrollingConstraints.h" >+#include <wtf/RefPtr.h> >+ > namespace WebCore { > > class ScrollingTreeStickyNode final : public ScrollingTreeNode { >@@ -43,8 +46,11 @@ private: > > void commitStateBeforeChildren(const ScrollingStateNode&) override; > void updateLayersAfterAncestorChange(const ScrollingTreeNode&, const FloatRect&, const FloatSize&) override; >+ >+ RefPtr<Nicosia::CompositionLayer> m_scrollLayer; >+ StickyPositionViewportConstraints m_constraints; > }; > > } // namespace WebCore > >-#endif // ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) >+#endif // ENABLE(ASYNC_SCROLLING) && USE(COORDINATED_GRAPHICS) && USE(NICOSIA) >diff --git a/Source/WebCore/platform/TextureMapper.cmake b/Source/WebCore/platform/TextureMapper.cmake >index 3c78fea50c0..3cd0ce2e6c1 100644 >--- a/Source/WebCore/platform/TextureMapper.cmake >+++ b/Source/WebCore/platform/TextureMapper.cmake >@@ -54,13 +54,16 @@ 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 > >+ platform/graphics/nicosia/texmap/NicosiaBackingStoreTextureMapperImpl.cpp > platform/graphics/nicosia/texmap/NicosiaCompositionLayerTextureMapperImpl.cpp > platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp > platform/graphics/nicosia/texmap/NicosiaGC3DLayer.cpp >+ platform/graphics/nicosia/texmap/NicosiaImageBackingTextureMapperImpl.cpp > ) > else () > list(APPEND WebCore_SOURCES >diff --git a/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.h b/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.h >index 780aceb7274..dd935c2d507 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> >@@ -52,6 +53,27 @@ public: > > uint64_t 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; >+ } >+ >+ void requestUpdate() >+ { >+ LockHolder locker(m_state.lock); >+ if (m_state.sceneIntegration) >+ m_state.sceneIntegration->requestUpdate(); >+ } >+ > protected: > explicit PlatformLayer(uint64_t); > >@@ -59,6 +81,7 @@ protected: > > struct { > Lock lock; >+ RefPtr<SceneIntegration> sceneIntegration; > } m_state; > }; > >@@ -173,6 +196,24 @@ public: > } debugBorder; > }; > >+ template<typename T> >+ void accessState(const T& functor) >+ { >+ LockHolder locker(PlatformLayer::m_state.lock); >+ functor(m_state.pending); >+ } >+ >+ template<typename T> >+ void accessStateAndUpdate(const T& functor) >+ { >+ LockHolder locker(PlatformLayer::m_state.lock); >+ functor(m_state.pending); >+ >+ auto& sceneIntegration = PlatformLayer::m_state.sceneIntegration; >+ if (sceneIntegration) >+ sceneIntegration->requestUpdate(); >+ } >+ > template<typename T> > void updateState(const T& functor) > { >@@ -180,6 +221,89 @@ public: > functor(m_state.pending); > } > >+ void flushState() >+ { >+ LockHolder locker(PlatformLayer::m_state.lock); >+ auto& pending = m_state.pending; >+ auto& staging = m_state.staging; >+ >+ staging.delta.value |= pending.delta.value; >+ >+ if (pending.delta.positionChanged) >+ staging.position = pending.position; >+ if (pending.delta.anchorPointChanged) >+ staging.anchorPoint = pending.anchorPoint; >+ if (pending.delta.sizeChanged) >+ staging.size = pending.size; >+ >+ if (pending.delta.transformChanged) >+ staging.transform = pending.transform; >+ if (pending.delta.childrenTransformChanged) >+ staging.childrenTransform = pending.childrenTransform; >+ >+ if (pending.delta.contentsRectChanged) >+ staging.contentsRect = pending.contentsRect; >+ if (pending.delta.contentsTilingChanged) { >+ staging.contentsTilePhase = pending.contentsTilePhase; >+ staging.contentsTileSize = pending.contentsTileSize; >+ } >+ >+ if (pending.delta.opacityChanged) >+ staging.opacity = pending.opacity; >+ if (pending.delta.solidColorChanged) >+ staging.solidColor = pending.solidColor; >+ >+ if (pending.delta.filtersChanged) >+ staging.filters = pending.filters; >+ if (pending.delta.animationsChanged) >+ staging.animations = pending.animations; >+ >+ if (pending.delta.childrenChanged) >+ staging.children = pending.children; >+ if (pending.delta.maskChanged) >+ staging.mask = pending.mask; >+ if (pending.delta.replicaChanged) >+ staging.replica = pending.replica; >+ >+ if (pending.delta.flagsChanged) >+ staging.flags.value = pending.flags.value; >+ >+ if (pending.delta.repaintCounterChanged) >+ staging.repaintCounter = pending.repaintCounter; >+ if (pending.delta.debugBorderChanged) >+ staging.debugBorder = pending.debugBorder; >+ >+ if (pending.delta.contentLayerChanged) >+ staging.contentLayer = pending.contentLayer; >+ if (pending.delta.backingStoreChanged) >+ staging.backingStore = pending.backingStore; >+ if (pending.delta.imageBackingChanged) >+ staging.imageBacking = pending.imageBacking; >+ >+ pending.delta = { }; >+ } >+ >+ template<typename T> >+ void commitState(const T& functor) >+ { >+ const LayerState& state = >+ [this] { >+ LockHolder locker(PlatformLayer::m_state.lock); >+ m_state.committed = m_state.staging; >+ m_state.staging.delta = { }; >+ return m_state.committed; >+ }(); >+ >+ functor(state); >+ } >+ >+ template<typename T> >+ void accessCommitted(const T& functor) >+ { >+ LockHolder locker(PlatformLayer::m_state.lock); >+ functor(m_state.committed); >+ } >+ > private: > CompositionLayer(uint64_t, const Impl::Factory&); > >@@ -187,6 +311,8 @@ private: > > struct { > LayerState pending; >+ LayerState staging; >+ LayerState committed; > } m_state; > }; > >diff --git a/Source/WebCore/platform/graphics/nicosia/NicosiaSceneIntegration.cpp b/Source/WebCore/platform/graphics/nicosia/NicosiaSceneIntegration.cpp >new file mode 100644 >index 00000000000..6892e664f10 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/nicosia/NicosiaSceneIntegration.cpp >@@ -0,0 +1,49 @@ >+#include "config.h" >+#include "NicosiaSceneIntegration.h" >+ >+namespace Nicosia { >+ >+SceneIntegration::SceneIntegration(Client& client) >+{ >+ m_client.object = &client; >+} >+ >+SceneIntegration::~SceneIntegration() >+{ >+ ASSERT(!m_client.object); >+} >+ >+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..bf59fd336fa >--- /dev/null >+++ b/Source/WebCore/platform/graphics/nicosia/NicosiaSceneIntegration.h >@@ -0,0 +1,45 @@ >+#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(Client&); >+ ~SceneIntegration(); >+ >+ 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/nicosia/texmap/NicosiaBackingStoreTextureMapperImpl.cpp b/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaBackingStoreTextureMapperImpl.cpp >new file mode 100644 >index 00000000000..db5622edbeb >--- /dev/null >+++ b/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaBackingStoreTextureMapperImpl.cpp >@@ -0,0 +1,77 @@ >+#include "config.h" >+#include "NicosiaBackingStoreTextureMapperImpl.h" >+ >+#if USE(TEXTURE_MAPPER) >+ >+namespace Nicosia { >+ >+auto BackingStoreTextureMapperImpl::createFactory() -> Factory >+{ >+ return Factory( >+ [](BackingStore&) { >+ return std::make_unique<BackingStoreTextureMapperImpl>(); >+ }); >+} >+ >+BackingStoreTextureMapperImpl::BackingStoreTextureMapperImpl() = default; >+BackingStoreTextureMapperImpl::~BackingStoreTextureMapperImpl() = default; >+ >+void BackingStoreTextureMapperImpl::tiledBackingStoreHasPendingTileCreation() >+{ >+ m_layerState.hasPendingTileCreation = true; >+} >+ >+void BackingStoreTextureMapperImpl::createTile(uint32_t tileID, float scale) >+{ >+ ASSERT(m_layerState.isFlushing); >+ m_layerState.update.tilesToCreate.append({ tileID, scale }); >+} >+ >+void BackingStoreTextureMapperImpl::updateTile(uint32_t tileID, const WebCore::SurfaceUpdateInfo& updateInfo, const WebCore::IntRect& tileRect) >+{ >+ ASSERT(m_layerState.isFlushing); >+ m_layerState.update.tilesToUpdate.append({ tileID, tileRect, updateInfo }); >+} >+ >+void BackingStoreTextureMapperImpl::removeTile(uint32_t tileID) >+{ >+ ASSERT(m_layerState.isFlushing || m_layerState.isPurging); >+ m_layerState.update.tilesToRemove.append(TileUpdate::RemovalData { tileID }); >+} >+ >+void BackingStoreTextureMapperImpl::flushUpdate() >+{ >+ ASSERT(m_layerState.isFlushing); >+ m_layerState.isFlushing = false; >+ m_layerState.hasPendingTileCreation = false; >+ >+ { >+ LockHolder locker(m_update.lock); >+ m_update.pending.tilesToCreate.appendVector(m_layerState.update.tilesToCreate); >+ m_update.pending.tilesToUpdate.appendVector(m_layerState.update.tilesToUpdate); >+ m_update.pending.tilesToRemove.appendVector(m_layerState.update.tilesToRemove); >+ } >+ >+ m_layerState.update = { }; >+} >+ >+void BackingStoreTextureMapperImpl::applyUpdate() >+{ >+ ASSERT(m_compositionState.backingStore); >+ auto& backingStore = *m_compositionState.backingStore; >+ >+ LockHolder locker(m_update.lock); >+ for (auto& tile : m_update.pending.tilesToCreate) >+ backingStore.createTile(tile.tileID, tile.scale); >+ for (auto& tile : m_update.pending.tilesToRemove) >+ backingStore.removeTile(tile.tileID); >+ for (auto& tile : m_update.pending.tilesToUpdate) { >+ backingStore.updateTile(tile.tileID, tile.updateInfo.updateRect, >+ tile.tileRect, tile.updateInfo.buffer.copyRef(), { 0, 0 }); >+ } >+ m_update.pending = { }; >+} >+ >+} // namespace Nicosia >+ >+#endif // USE(TEXTURE_MAPPER) >diff --git a/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaBackingStoreTextureMapperImpl.h b/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaBackingStoreTextureMapperImpl.h >new file mode 100644 >index 00000000000..a630fa1c0db >--- /dev/null >+++ b/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaBackingStoreTextureMapperImpl.h >@@ -0,0 +1,84 @@ >+#pragma once >+ >+#if USE(TEXTURE_MAPPER) >+ >+#include "CoordinatedBackingStore.h" >+#include "NicosiaPlatformLayer.h" >+#include "SurfaceUpdateInfo.h" >+#include "TiledBackingStore.h" >+#include "TiledBackingStoreClient.h" >+#include <memory> >+#include <wtf/Lock.h> >+ >+namespace Nicosia { >+ >+class BackingStoreTextureMapperImpl final : public BackingStore::Impl, public WebCore::TiledBackingStoreClient { >+public: >+ static Factory createFactory(); >+ >+ BackingStoreTextureMapperImpl(); >+ virtual ~BackingStoreTextureMapperImpl(); >+ bool isTextureMapperImpl() const override { return true; } >+ >+ struct TileUpdate { >+ struct CreationData { >+ uint32_t tileID; >+ float scale; >+ }; >+ Vector<CreationData> tilesToCreate; >+ >+ struct UpdateData { >+ uint32_t tileID; >+ WebCore::IntRect tileRect; >+ WebCore::SurfaceUpdateInfo updateInfo; >+ }; >+ Vector<UpdateData> tilesToUpdate; >+ >+ struct RemovalData { >+ uint32_t tileID; >+ }; >+ Vector<RemovalData> tilesToRemove; >+ }; >+ >+ struct LayerState { >+ std::unique_ptr<WebCore::TiledBackingStore> mainBackingStore; >+ std::unique_ptr<WebCore::TiledBackingStore> previousBackingStore; >+ >+ TileUpdate update; >+ bool isFlushing { false }; >+ bool isPurging { false }; >+ bool hasPendingTileCreation { false }; >+ }; >+ LayerState& layerState() { return m_layerState; } >+ >+ void flushUpdate(); >+ >+ struct CompositionState { >+ RefPtr<WebCore::CoordinatedBackingStore> backingStore; >+ }; >+ CompositionState& compositionState() { return m_compositionState; } >+ >+ void applyUpdate(); >+ >+ // TiledBackingStoreClient >+ void tiledBackingStoreHasPendingTileCreation() override; >+ void createTile(uint32_t, float) override; >+ void updateTile(uint32_t, const WebCore::SurfaceUpdateInfo&, const WebCore::IntRect&) override; >+ void removeTile(uint32_t) override; >+ >+private: >+ LayerState m_layerState; >+ CompositionState m_compositionState; >+ >+ struct { >+ Lock lock; >+ TileUpdate pending; >+ TileUpdate committed; >+ } m_update; >+}; >+ >+} // namespace Nicosia >+ >+SPECIALIZE_TYPE_TRAITS_NICOSIA_BACKINGSTORE_IMPL(BackingStoreTextureMapperImpl, isTextureMapperImpl()); >+ >+#endif // USE(TEXTURE_MAPPER) >diff --git a/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaImageBackingTextureMapperImpl.cpp b/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaImageBackingTextureMapperImpl.cpp >new file mode 100644 >index 00000000000..e9a0309e0bb >--- /dev/null >+++ b/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaImageBackingTextureMapperImpl.cpp >@@ -0,0 +1,46 @@ >+#include "config.h" >+#include "NicosiaImageBackingTextureMapperImpl.h" >+ >+#if USE(TEXTURE_MAPPER) >+ >+namespace Nicosia { >+ >+auto ImageBackingTextureMapperImpl::createFactory() -> Factory >+{ >+ return Factory( >+ [](ImageBacking&) { >+ return std::make_unique<ImageBackingTextureMapperImpl>(); >+ }); >+} >+ >+ImageBackingTextureMapperImpl::ImageBackingTextureMapperImpl() = default; >+ImageBackingTextureMapperImpl::~ImageBackingTextureMapperImpl() = default; >+ >+void ImageBackingTextureMapperImpl::flushUpdate() >+{ >+ LockHolder locker(m_update.lock); >+ m_update.isVisible = m_layerState.isVisible; >+ m_update.buffer = WTFMove(m_layerState.buffer); >+} >+ >+void ImageBackingTextureMapperImpl::applyUpdate() >+{ >+ ASSERT(m_compositionState.backingStore); >+ auto& backingStore = *m_compositionState.backingStore; >+ >+ LockHolder locker(m_update.lock); >+ fprintf(stderr, "ImageBackingTextureMapperImpl::applyUpdate() isVisible %d buffer %p\n", >+ m_update.isVisible, m_update.buffer.get()); >+ if (!m_update.isVisible || !m_update.buffer) >+ return; >+ >+ backingStore.createTile(1, 1); >+ WebCore::IntRect rect { { }, m_update.buffer->size() }; >+ ASSERT(2000 >= std::max(rect.width(), rect.height())); >+ backingStore.setSize(rect.size()); >+ backingStore.updateTile(1, rect, rect, WTFMove(m_update.buffer), rect.location()); >+} >+ >+} // namespace Nicosia >+ >+#endif >diff --git a/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaImageBackingTextureMapperImpl.h b/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaImageBackingTextureMapperImpl.h >new file mode 100644 >index 00000000000..47b20d95abf >--- /dev/null >+++ b/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaImageBackingTextureMapperImpl.h >@@ -0,0 +1,56 @@ >+#pragma once >+ >+#if USE(TEXTURE_MAPPER) >+ >+#include "CoordinatedBackingStore.h" >+#include "NicosiaBuffer.h" >+#include "NicosiaPlatformLayer.h" >+#include <wtf/Lock.h> >+ >+namespace WebCore { >+class Image; >+} >+ >+namespace Nicosia { >+ >+class ImageBackingTextureMapperImpl final : public ImageBacking::Impl { >+public: >+ static Factory createFactory(); >+ >+ ImageBackingTextureMapperImpl(); >+ virtual ~ImageBackingTextureMapperImpl(); >+ bool isTextureMapperImpl() const override { return true; } >+ >+ struct LayerState { >+ uintptr_t imageID { 0 }; >+ uintptr_t nativeImageID { 0 }; >+ bool isVisible { false }; >+ RefPtr<Nicosia::Buffer> buffer; >+ }; >+ LayerState& layerState() { return m_layerState; } >+ >+ void flushUpdate(); >+ >+ struct CompositionState { >+ RefPtr<WebCore::CoordinatedBackingStore> backingStore; >+ }; >+ CompositionState& compositionState() { return m_compositionState; } >+ >+ void applyUpdate(); >+ >+private: >+ LayerState m_layerState; >+ CompositionState m_compositionState; >+ >+ struct { >+ Lock lock; >+ bool isVisible { false }; >+ RefPtr<Nicosia::Buffer> buffer; >+ } m_update; >+}; >+ >+} // namespace Nicosia >+ >+SPECIALIZE_TYPE_TRAITS_NICOSIA_IMAGEBACKING_IMPL(ImageBackingTextureMapperImpl, isTextureMapperImpl()); >+ >+#endif // USE(TEXTURE_MAPPER) >diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp >index be21680fbd2..bf193723756 100644 >--- a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp >+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp >@@ -30,7 +30,11 @@ > #include "GraphicsContext.h" > #include "GraphicsLayer.h" > #include "GraphicsLayerFactory.h" >+#include "NicosiaBackingStoreTextureMapperImpl.h" > #include "NicosiaCompositionLayerTextureMapperImpl.h" >+#include "NicosiaContentLayerTextureMapperImpl.h" >+#include "NicosiaImageBackingTextureMapperImpl.h" >+#include "NicosiaPaintingContext.h" > #include "NicosiaPaintingEngine.h" > #include "ScrollableArea.h" > #include "TextureMapperPlatformLayerProxyProvider.h" >@@ -160,6 +164,8 @@ CoordinatedGraphicsLayer::~CoordinatedGraphicsLayer() > } > ASSERT(!m_coordinatedImageBacking); > ASSERT(!m_mainBackingStore); >+ ASSERT(!m_nicosia.imageBacking); >+ ASSERT(!m_nicosia.backingStore); > willBeDestroyed(); > } > >@@ -228,6 +234,17 @@ void CoordinatedGraphicsLayer::setPosition(const FloatPoint& p) > didChangeGeometry(); > } > >+void CoordinatedGraphicsLayer::syncPosition(const FloatPoint& p) >+{ >+ if (position() == p) >+ return; >+ >+ GraphicsLayer::syncPosition(p); >+ m_nicosia.delta.positionChanged = true; >+ m_shouldSyncLayerState = true; >+ setShouldUpdateVisibleRect(); >+} >+ > void CoordinatedGraphicsLayer::setAnchorPoint(const FloatPoint3D& p) > { > if (anchorPoint() == p) >@@ -421,8 +438,13 @@ bool GraphicsLayer::supportsContentsTiling() > void CoordinatedGraphicsLayer::setContentsNeedsDisplay() > { > #if USE(COORDINATED_GRAPHICS_THREADED) >+#if USE(NICOSIA) >+ if (m_nicosia.contentLayer) >+ m_shouldUpdatePlatformLayer = true; >+#else > if (m_platformLayer) > m_shouldUpdatePlatformLayer = true; >+#endif > #endif > > notifyFlushRequired(); >@@ -433,6 +455,13 @@ void CoordinatedGraphicsLayer::setContentsToPlatformLayer(PlatformLayer* platfor > { > #if USE(COORDINATED_GRAPHICS_THREADED) > #if USE(NICOSIA) >+ auto* contentLayer = downcast<Nicosia::ContentLayer>(platformLayer); >+ if (m_nicosia.contentLayer != contentLayer) { >+ m_shouldSyncPlatformLayer = true; >+ m_nicosia.delta.contentLayerChanged = true; >+ } >+ >+ m_nicosia.contentLayer = contentLayer; > #else > if (m_platformLayer != platformLayer) > m_shouldSyncPlatformLayer = true; >@@ -677,6 +706,7 @@ void CoordinatedGraphicsLayer::syncImageBacking() > m_layerState.imageChanged = true; > } else > releaseImageBackingIfNeeded(); >+ > } > > void CoordinatedGraphicsLayer::syncLayerState() >@@ -798,6 +828,66 @@ void CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly() > if (!hasActiveTransformAnimation) > m_movingVisibleRect = false; > >+ if (m_nicosia.contentLayer) >+ downcast<Nicosia::ContentLayerTextureMapperImpl>(m_nicosia.contentLayer->impl()).swapBuffersIfNeeded(); >+ >+ if (!shouldHaveBackingStore()) { >+ if (m_nicosia.backingStore) { >+ auto& layerState = downcast<Nicosia::BackingStoreTextureMapperImpl>(m_nicosia.backingStore->impl()).layerState(); >+ layerState.isPurging = true; >+ layerState.mainBackingStore = nullptr; >+ layerState.previousBackingStore = nullptr; >+ >+ m_nicosia.backingStore = nullptr; >+ m_nicosia.delta.backingStoreChanged = true; >+ } >+ } else { >+ if (!m_nicosia.backingStore) { >+ m_nicosia.backingStore = Nicosia::BackingStore::create(Nicosia::BackingStoreTextureMapperImpl::createFactory()); >+ m_nicosia.delta.backingStoreChanged = true; >+ } >+ } >+ >+ if (m_compositedNativeImagePtr) { >+ ASSERT(m_compositedImage); >+ auto& image = *m_compositedImage; >+ if (m_nicosia.imageBacking) { >+ auto& impl = downcast<Nicosia::ImageBackingTextureMapperImpl>(m_nicosia.imageBacking->impl()); >+ if (impl.layerState().imageID != reinterpret_cast<uintptr_t>(&image)) >+ m_nicosia.imageBacking = nullptr; >+ } >+ if (!m_nicosia.imageBacking) { >+ m_nicosia.imageBacking = Nicosia::ImageBacking::create(Nicosia::ImageBackingTextureMapperImpl::createFactory()); >+ m_nicosia.delta.imageBackingChanged = true; >+ } >+ >+ auto& impl = downcast<Nicosia::ImageBackingTextureMapperImpl>(m_nicosia.imageBacking->impl()); >+ auto& layerState = impl.layerState(); >+ layerState.imageID = reinterpret_cast<uintptr_t>(&image); >+ layerState.isVisible = transformedVisibleRect().intersects(IntRect(contentsRect())); >+ if (layerState.isVisible && layerState.nativeImageID != reinterpret_cast<uintptr_t>(m_compositedNativeImagePtr.get())) { >+ auto buffer = Nicosia::Buffer::create(IntSize(image.size()), >+ !image.currentFrameKnownToBeOpaque() ? Nicosia::Buffer::SupportsAlpha : Nicosia::Buffer::NoFlags); >+ Nicosia::PaintingContext::paint(buffer, >+ [&image](GraphicsContext& context) >+ { >+ IntRect rect { { }, IntSize { image.size() } }; >+ context.drawImage(image, rect, rect, ImagePaintingOptions(CompositeCopy)); >+ }); >+ layerState.nativeImageID = reinterpret_cast<uintptr_t>(m_compositedNativeImagePtr.get()); >+ layerState.buffer = WTFMove(buffer); >+ m_nicosia.delta.imageBackingChanged = true; >+ >+ fprintf(stderr, "::flushCompositingStateForThisLayerOnly() m_compositedNativeImagePtr %p imageID %lu isVisible %d buffer %p\n", >+ m_compositedNativeImagePtr.get(), layerState.imageID, layerState.isVisible, layerState.buffer.get()); >+ } >+ >+ impl.flushUpdate(); >+ } else if (m_nicosia.imageBacking) { >+ m_nicosia.imageBacking = nullptr; >+ m_nicosia.delta.imageBackingChanged = true; >+ } >+ > { > m_nicosia.layer->updateState( > [this](Nicosia::CompositionLayer::LayerState& state) >@@ -854,6 +944,13 @@ void CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly() > state.replica = replica ? replica->m_nicosia.layer : nullptr; > } > >+ if (localDelta.contentLayerChanged) >+ state.contentLayer = m_nicosia.contentLayer; >+ if (localDelta.backingStoreChanged) >+ state.backingStore = m_nicosia.backingStore; >+ if (localDelta.imageBackingChanged) >+ state.imageBacking = m_nicosia.imageBacking; >+ > if (localDelta.flagsChanged) { > state.flags.contentsOpaque = contentsOpaque(); > state.flags.drawsContent = drawsContent(); >@@ -923,27 +1020,6 @@ float CoordinatedGraphicsLayer::effectiveContentsScale() > return selfOrAncestorHaveNonAffineTransforms() ? 1 : deviceScaleFactor() * pageScaleFactor(); > } > >-void CoordinatedGraphicsLayer::adjustContentsScale() >-{ >- ASSERT(shouldHaveBackingStore()); >- if (!m_mainBackingStore || m_mainBackingStore->contentsScale() == effectiveContentsScale()) >- return; >- >- // Between creating the new backing store and painting the content, >- // we do not want to drop the previous one as that might result in >- // briefly seeing flickering as the old tiles may be dropped before >- // something replaces them. >- m_previousBackingStore = WTFMove(m_mainBackingStore); >- >- // No reason to save the previous backing store for non-visible areas. >- m_previousBackingStore->removeAllNonVisibleTiles(transformedVisibleRect(), IntRect(0, 0, size().width(), size().height())); >-} >- >-void CoordinatedGraphicsLayer::createBackingStore() >-{ >- m_mainBackingStore = std::make_unique<TiledBackingStore>(*this, effectiveContentsScale()); >-} >- > void CoordinatedGraphicsLayer::tiledBackingStoreHasPendingTileCreation() > { > setNeedsVisibleRectAdjustment(); >@@ -1011,12 +1087,13 @@ void CoordinatedGraphicsLayer::removeTile(uint32_t tileID) > void CoordinatedGraphicsLayer::updateContentBuffersIncludingSubLayers() > { > if (CoordinatedGraphicsLayer* mask = downcast<CoordinatedGraphicsLayer>(maskLayer())) >- mask->updateContentBuffers(); >+ mask->updateContentBuffers2(); > > if (CoordinatedGraphicsLayer* replica = downcast<CoordinatedGraphicsLayer>(replicaLayer())) >- replica->updateContentBuffers(); >+ replica->updateContentBuffers2(); > >- updateContentBuffers(); >+ // updateContentBuffers(); >+ updateContentBuffers2(); > > for (auto& child : children()) > downcast<CoordinatedGraphicsLayer>(*child).updateContentBuffersIncludingSubLayers(); >@@ -1031,14 +1108,22 @@ void CoordinatedGraphicsLayer::updateContentBuffers() > } > > if (m_pendingContentsScaleAdjustment) { >- adjustContentsScale(); >+ if (m_mainBackingStore && m_mainBackingStore->contentsScale() != effectiveContentsScale()) { >+ // Between creating the new backing store and painting the content, we do not >+ // want to drop the previous one as that might result in briefly seeing flickering >+ // as the old tiles may be dropped before something replaces them. >+ m_previousBackingStore = WTFMove(m_mainBackingStore); >+ >+ // No reason to save the previous backing store for non-visible areas. >+ m_previousBackingStore->removeAllNonVisibleTiles(transformedVisibleRect(), IntRect(0, 0, size().width(), size().height())); >+ } > m_pendingContentsScaleAdjustment = false; > } > > // This is the only place we (re)create the main tiled backing store, once we > // have a remote client and we are ready to send our data to the UI process. > if (!m_mainBackingStore) { >- createBackingStore(); >+ m_mainBackingStore = std::make_unique<TiledBackingStore>(*this, effectiveContentsScale()); > m_pendingVisibleRectAdjustment = true; > } > >@@ -1100,6 +1185,99 @@ void CoordinatedGraphicsLayer::updateContentBuffers() > m_previousBackingStore = nullptr; > } > >+void CoordinatedGraphicsLayer::updateContentBuffers2() >+{ >+ if (!m_nicosia.backingStore) >+ return; >+ >+ auto& impl = downcast<Nicosia::BackingStoreTextureMapperImpl>(m_nicosia.backingStore->impl()); >+ auto& layerState = impl.layerState(); >+ layerState.isFlushing = true; >+ >+ if (m_pendingContentsScaleAdjustment) { >+ if (layerState.mainBackingStore && layerState.mainBackingStore->contentsScale() != effectiveContentsScale()) { >+ // Between creating the new backing store and painting the content, we do not >+ // want to drop the previous one as that might result in briefly seeing flickering >+ // as the old tiles may be dropped before something replaces them. >+ layerState.previousBackingStore = WTFMove(layerState.mainBackingStore); >+ >+ // No reason to save the previous backing store for non-visible areas. >+ layerState.previousBackingStore->removeAllNonVisibleTiles(transformedVisibleRect(), IntRect(0, 0, size().width(), size().height())); >+ } >+ m_pendingContentsScaleAdjustment = false; >+ } >+ >+ if (!layerState.mainBackingStore) { >+ layerState.mainBackingStore = std::make_unique<TiledBackingStore>(impl, effectiveContentsScale()); >+ m_pendingVisibleRectAdjustment = true; >+ } >+ >+ if (!m_pendingVisibleRectAdjustment && !m_needsDisplay.completeLayer && m_needsDisplay.rects.isEmpty()) { >+ impl.flushUpdate(); >+ return; >+ } >+ >+ if (!m_needsDisplay.completeLayer) { >+ for (auto& rect : m_needsDisplay.rects) >+ layerState.mainBackingStore->invalidate(IntRect { rect }); >+ } else >+ layerState.mainBackingStore->invalidate({ { }, IntSize { m_size } }); >+ >+ m_needsDisplay.completeLayer = false; >+ m_needsDisplay.rects.clear(); >+ >+ if (m_pendingVisibleRectAdjustment) { >+ m_pendingVisibleRectAdjustment = false; >+ layerState.mainBackingStore->createTilesIfNeeded(transformedVisibleRect(), IntRect(0, 0, m_size.width(), m_size.height())); >+ } >+ >+ ASSERT(m_coordinator && m_coordinator->isFlushingLayerChanges()); >+ >+ auto dirtyTiles = layerState.mainBackingStore->dirtyTiles(); >+ if (!dirtyTiles.isEmpty()) { >+ bool didUpdateTiles = false; >+ >+ for (auto& tileReference : dirtyTiles) { >+ auto& tile = tileReference.get(); >+ tile.ensureTileID(); >+ >+ auto& tileRect = tile.rect(); >+ auto& dirtyRect = tile.dirtyRect(); >+ >+ auto coordinatedBuffer = Nicosia::Buffer::create(dirtyRect.size(), contentsOpaque() ? Nicosia::Buffer::NoFlags : Nicosia::Buffer::SupportsAlpha); >+ SurfaceUpdateInfo updateInfo; >+ updateInfo.updateRect = dirtyRect; >+ updateInfo.updateRect.move(-tileRect.x(), -tileRect.y()); >+ updateInfo.buffer = coordinatedBuffer.copyRef(); >+ >+ if (!m_coordinator->paintingEngine().paint(*this, WTFMove(coordinatedBuffer), >+ dirtyRect, layerState.mainBackingStore->mapToContents(dirtyRect), >+ IntRect { { 0, 0 }, dirtyRect.size() }, layerState.mainBackingStore->contentsScale())) >+ continue; >+ >+ impl.updateTile(tile.tileID(), updateInfo, tileRect); >+ >+ tile.markClean(); >+ didUpdateTiles |= true; >+ } >+ >+ if (didUpdateTiles) >+ didUpdateTileBuffers(); >+ } >+ >+ // The previous backing store is kept around to avoid flickering between >+ // removing the existing tiles and painting the new ones. The first time >+ // the visibleRect is full painted we remove the previous backing store. >+ if (layerState.previousBackingStore && layerState.mainBackingStore->visibleAreaIsCovered()) >+ layerState.previousBackingStore = nullptr; >+ >+ if (layerState.hasPendingTileCreation) { >+ setNeedsVisibleRectAdjustment(); >+ notifyFlushRequired(); >+ } >+ impl.flushUpdate(); >+} >+ > void CoordinatedGraphicsLayer::purgeBackingStores() > { > #ifndef NDEBUG >@@ -1107,6 +1285,14 @@ void CoordinatedGraphicsLayer::purgeBackingStores() > #endif > m_mainBackingStore = nullptr; > m_previousBackingStore = nullptr; >+ if (m_nicosia.backingStore) { >+ auto& layerState = downcast<Nicosia::BackingStoreTextureMapperImpl>(m_nicosia.backingStore->impl()).layerState(); >+ layerState.isPurging = true; >+ layerState.mainBackingStore = nullptr; >+ layerState.previousBackingStore = nullptr; >+ >+ m_nicosia.backingStore = nullptr; >+ } > > releaseImageBackingIfNeeded(); > >@@ -1325,6 +1511,13 @@ void CoordinatedGraphicsLayer::animationStartedTimerFired() > client().notifyAnimationStarted(this, "", m_lastAnimationStartTime); > } > >+#if USE(NICOSIA) >+PlatformLayer* CoordinatedGraphicsLayer::platformLayer() const >+{ >+ return m_nicosia.layer.get(); >+} >+#endif >+ > } // 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 8b9f9a92278..6b5bdd8dc9d 100644 >--- a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h >+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h >@@ -76,6 +76,7 @@ public: > bool replaceChild(GraphicsLayer*, GraphicsLayer*) override; > void removeFromParent() override; > void setPosition(const FloatPoint&) override; >+ void syncPosition(const FloatPoint&) override; > void setAnchorPoint(const FloatPoint3D&) override; > void setSize(const FloatSize&) override; > void setTransform(const TransformationMatrix&) override; >@@ -110,7 +111,11 @@ public: > void removeAnimation(const String&) override; > void suspendAnimations(MonotonicTime) override; > void resumeAnimations() override; >- bool usesContentsLayer() const override { return m_platformLayer || m_compositedImage; } >+ bool usesContentsLayer() const override { return m_platformLayer || m_nicosia.contentLayer || m_compositedImage; } >+ >+#if USE(NICOSIA) >+ PlatformLayer* platformLayer() const override; >+#endif > > void syncPendingStateChangesIncludingSubLayers(); > void updateContentBuffersIncludingSubLayers(); >@@ -160,8 +165,8 @@ private: > void syncImageBacking(); > void computeTransformedVisibleRect(); > void updateContentBuffers(); >+ void updateContentBuffers2(); > >- void createBackingStore(); > void releaseImageBackingIfNeeded(); > > void notifyFlushRequired(); >@@ -171,7 +176,6 @@ private: > bool shouldHaveBackingStore() const; > bool selfOrAncestorHasActiveTransformAnimation() const; > bool selfOrAncestorHaveNonAffineTransforms(); >- void adjustContentsScale(); > > void setShouldUpdateVisibleRect(); > float effectiveContentsScale(); >@@ -231,6 +235,10 @@ private: > Nicosia::CompositionLayer::LayerState::Delta delta; > Nicosia::CompositionLayer::LayerState::RepaintCounter repaintCounter; > Nicosia::CompositionLayer::LayerState::DebugBorder debugBorder; >+ >+ RefPtr<Nicosia::ContentLayer> contentLayer; >+ RefPtr<Nicosia::BackingStore> backingStore; >+ RefPtr<Nicosia::ImageBacking> imageBacking; > } m_nicosia; > }; > >diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h >index 6f9624f4e5d..025c1ea42dd 100644 >--- a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h >+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h >@@ -171,9 +171,11 @@ struct CoordinatedGraphicsLayerState { > }; > > struct CoordinatedGraphicsState { >+#if USE(NICOSIA) > struct NicosiaState { > RefPtr<Nicosia::Scene> scene; > } nicosia; >+#endif > > uint32_t rootCompositingLayer; > >diff --git a/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp b/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp >index fea28ea0b06..27f9be3ff77 100644 >--- a/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp >+++ b/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp >@@ -26,6 +26,10 @@ > > #include <WebCore/CoordinatedBackingStore.h> > #include <WebCore/NicosiaBuffer.h> >+#include <WebCore/NicosiaBackingStoreTextureMapperImpl.h> >+#include <WebCore/NicosiaCompositionLayerTextureMapperImpl.h> >+#include <WebCore/NicosiaContentLayerTextureMapperImpl.h> >+#include <WebCore/NicosiaImageBackingTextureMapperImpl.h> > #include <WebCore/TextureMapper.h> > #include <WebCore/TextureMapperBackingStore.h> > #include <WebCore/TextureMapperGL.h> >@@ -57,20 +61,17 @@ void CoordinatedGraphicsScene::applyStateChanges(const Vector<CoordinatedGraphic > ensureRootLayer(); > > for (auto& state : states) >- commitSceneState(state); >+ commitSceneState(state.nicosia); > } > > void CoordinatedGraphicsScene::paintToCurrentGLContext(const TransformationMatrix& matrix, float opacity, const FloatRect& clipRect, const Color& backgroundColor, bool drawsBackground, TextureMapper::PaintFlags PaintFlags) > { >+ updateSceneState(); >+ > TextureMapperLayer* currentRootLayer = rootLayer(); > if (!currentRootLayer) > return; > >-#if USE(COORDINATED_GRAPHICS_THREADED) >- for (auto& proxy : m_platformLayerProxies.values()) >- proxy->swapBuffer(); >-#endif >- > currentRootLayer->setTextureMapper(m_textureMapper.get()); > bool sceneHasRunningAnimations = currentRootLayer->applyAnimationsRecursively(MonotonicTime::now()); > m_textureMapper->beginPainting(PaintFlags); >@@ -104,23 +105,6 @@ void CoordinatedGraphicsScene::updateViewport() > m_client->updateViewport(); > } > >-void CoordinatedGraphicsScene::syncPlatformLayerIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state) >-{ >-#if USE(COORDINATED_GRAPHICS_THREADED) >- if (!state.platformLayerChanged) >- return; >- >- if (state.platformLayerProxy) { >- m_platformLayerProxies.set(layer, state.platformLayerProxy); >- state.platformLayerProxy->activateOnCompositingThread(this, layer); >- } else >- m_platformLayerProxies.remove(layer); >-#else >- UNUSED_PARAM(layer); >- UNUSED_PARAM(state); >-#endif >-} >- > #if USE(COORDINATED_GRAPHICS_THREADED) > void CoordinatedGraphicsScene::onNewBufferAvailable() > { >@@ -128,320 +112,219 @@ void CoordinatedGraphicsScene::onNewBufferAvailable() > } > #endif > >-void CoordinatedGraphicsScene::setLayerChildrenIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state) >-{ >- if (!state.childrenChanged) >- return; >- >- Vector<TextureMapperLayer*> children; >- children.reserveCapacity(state.children.size()); >- for (auto& child : state.children) >- children.append(layerByID(child)); >- >- layer->setChildren(children); >-} >- >-void CoordinatedGraphicsScene::setLayerFiltersIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state) >-{ >- if (!state.filtersChanged) >- return; >- >- layer->setFilters(state.filters); >-} >- >-void CoordinatedGraphicsScene::setLayerState(CoordinatedLayerID id, const CoordinatedGraphicsLayerState& layerState, CommitScope& commitScope) >-{ >- ASSERT(m_rootLayerID != InvalidCoordinatedLayerID); >- TextureMapperLayer* layer = layerByID(id); >- >- if (layerState.positionChanged) >- layer->setPosition(layerState.pos); >- >- if (layerState.anchorPointChanged) >- layer->setAnchorPoint(layerState.anchorPoint); >- >- if (layerState.sizeChanged) >- layer->setSize(layerState.size); >- >- if (layerState.transformChanged) >- layer->setTransform(layerState.transform); >- >- if (layerState.childrenTransformChanged) >- layer->setChildrenTransform(layerState.childrenTransform); >- >- if (layerState.contentsRectChanged) >- layer->setContentsRect(layerState.contentsRect); >- >- if (layerState.contentsTilingChanged) { >- layer->setContentsTilePhase(layerState.contentsTilePhase); >- layer->setContentsTileSize(layerState.contentsTileSize); >- } >- >- if (layerState.opacityChanged) >- layer->setOpacity(layerState.opacity); >- >- if (layerState.solidColorChanged) >- layer->setSolidColor(layerState.solidColor); >- >- if (layerState.debugVisualsChanged) >- layer->setDebugVisuals(layerState.debugVisuals.showDebugBorders, layerState.debugVisuals.debugBorderColor, layerState.debugVisuals.debugBorderWidth); >- if (layerState.repaintCountChanged) >- layer->setRepaintCounter(layerState.repaintCount.showRepaintCounter, layerState.repaintCount.count); >- >- if (layerState.replicaChanged) >- layer->setReplicaLayer(getLayerByIDIfExists(layerState.replica)); >- >- if (layerState.maskChanged) >- layer->setMaskLayer(getLayerByIDIfExists(layerState.mask)); >- >- if (layerState.imageChanged) >- assignImageBackingToLayer(layer, layerState.imageID); >- >- if (layerState.flagsChanged) { >- layer->setContentsOpaque(layerState.contentsOpaque); >- layer->setDrawsContent(layerState.drawsContent); >- layer->setContentsVisible(layerState.contentsVisible); >- layer->setBackfaceVisibility(layerState.backfaceVisible); >- >- // Never clip the root layer. >- layer->setMasksToBounds(id == m_rootLayerID ? false : layerState.masksToBounds); >- layer->setPreserves3D(layerState.preserves3D); >- } >- >- // Apply Operations. >- setLayerChildrenIfNeeded(layer, layerState); >- setLayerFiltersIfNeeded(layer, layerState); >- setLayerAnimationsIfNeeded(layer, layerState); >- prepareContentBackingStore(layer, commitScope); >- createTilesIfNeeded(layer, layerState); >- removeTilesIfNeeded(layer, layerState, commitScope); >- updateTilesIfNeeded(layer, layerState, commitScope); >- syncPlatformLayerIfNeeded(layer, layerState); >-} >- >-TextureMapperLayer* CoordinatedGraphicsScene::getLayerByIDIfExists(CoordinatedLayerID id) >-{ >- return (id != InvalidCoordinatedLayerID) ? layerByID(id) : 0; >-} >- >-void CoordinatedGraphicsScene::createLayers(const Vector<CoordinatedLayerID>& layerIDs) >-{ >- for (auto& layerID : layerIDs) >- createLayer(layerID); >-} >- >-void CoordinatedGraphicsScene::createLayer(CoordinatedLayerID id) >+Nicosia::CompositionLayerTextureMapperImpl& compositionLayerImpl(Nicosia::CompositionLayer& compositionLayer) > { >- std::unique_ptr<TextureMapperLayer> newLayer = std::make_unique<TextureMapperLayer>(); >- newLayer->setID(id); >- m_layers.add(id, WTFMove(newLayer)); >+ return downcast<Nicosia::CompositionLayerTextureMapperImpl>(compositionLayer.impl()); > } > >-void CoordinatedGraphicsScene::deleteLayers(const Vector<CoordinatedLayerID>& layerIDs) >+Nicosia::ContentLayerTextureMapperImpl& contentLayerImpl(Nicosia::ContentLayer& contentLayer) > { >- for (auto& layerID : layerIDs) >- deleteLayer(layerID); >+ return downcast<Nicosia::ContentLayerTextureMapperImpl>(contentLayer.impl()); > } > >-void CoordinatedGraphicsScene::deleteLayer(CoordinatedLayerID layerID) >+Nicosia::BackingStoreTextureMapperImpl& backingStoreImpl(Nicosia::BackingStore& backingStore) > { >- std::unique_ptr<TextureMapperLayer> layer = m_layers.take(layerID); >- ASSERT(layer); >- >- m_backingStores.remove(layer.get()); >-#if USE(COORDINATED_GRAPHICS_THREADED) >- if (auto platformLayerProxy = m_platformLayerProxies.take(layer.get())) >- platformLayerProxy->invalidate(); >-#endif >+ return downcast<Nicosia::BackingStoreTextureMapperImpl>(backingStore.impl()); > } > >-void CoordinatedGraphicsScene::setRootLayerID(CoordinatedLayerID layerID) >+Nicosia::ImageBackingTextureMapperImpl& imageBackingImpl(Nicosia::ImageBacking& imageBacking) > { >- ASSERT(layerID != InvalidCoordinatedLayerID); >- ASSERT(m_rootLayerID == InvalidCoordinatedLayerID); >- >- m_rootLayerID = layerID; >- >- TextureMapperLayer* layer = layerByID(layerID); >- ASSERT(m_rootLayer->children().isEmpty()); >- m_rootLayer->addChild(layer); >+ return downcast<Nicosia::ImageBackingTextureMapperImpl>(imageBacking.impl()); > } > >-void CoordinatedGraphicsScene::prepareContentBackingStore(TextureMapperLayer* layer, CommitScope& commitScope) >+TextureMapperLayer& texmapLayer(Nicosia::CompositionLayer& compositionLayer) > { >- if (!layerShouldHaveBackingStore(layer)) { >- removeBackingStoreIfNeeded(layer); >- return; >+ auto& compositionState = compositionLayerImpl(compositionLayer).compositionState(); >+ if (!compositionState.layer) { >+ compositionState.layer = std::make_unique<TextureMapperLayer>(); >+ compositionState.layer->setID(compositionLayer.id()); > } >- >- createBackingStoreIfNeeded(layer); >- resetBackingStoreSizeToLayerSize(layer, commitScope); >-} >- >-void CoordinatedGraphicsScene::createBackingStoreIfNeeded(TextureMapperLayer* layer) >-{ >- if (m_backingStores.contains(layer)) >- return; >- >- auto backingStore = CoordinatedBackingStore::create(); >- m_backingStores.add(layer, backingStore.copyRef()); >- layer->setBackingStore(backingStore.ptr()); >-} >- >-void CoordinatedGraphicsScene::removeBackingStoreIfNeeded(TextureMapperLayer* layer) >-{ >- RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.take(layer); >- if (!backingStore) >- return; >- >- layer->setBackingStore(nullptr); >-} >- >-void CoordinatedGraphicsScene::resetBackingStoreSizeToLayerSize(TextureMapperLayer* layer, CommitScope& commitScope) >-{ >- RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.get(layer); >- ASSERT(backingStore); >- backingStore->setSize(layer->size()); >- commitScope.backingStoresWithPendingBuffers.add(backingStore); >-} >- >-void CoordinatedGraphicsScene::createTilesIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state) >-{ >- if (state.tilesToCreate.isEmpty()) >- return; >- >- RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.get(layer); >- ASSERT(backingStore || !layerShouldHaveBackingStore(layer)); >- if (!backingStore) >- return; >- >- for (auto& tile : state.tilesToCreate) >- backingStore->createTile(tile.tileID, tile.scale); >+ return *compositionState.layer; > } > >-void CoordinatedGraphicsScene::removeTilesIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state, CommitScope& commitScope) >+void CoordinatedGraphicsScene::updateBackingStore(TextureMapperLayer& layer, const RefPtr<Nicosia::BackingStore>& backingStore, CommitScope& commitScope) > { >- if (state.tilesToRemove.isEmpty()) >+ if (!backingStore) { >+ layer.setBackingStore(nullptr); > return; >+ } >+ auto& impl = backingStoreImpl(*backingStore); >+ auto& compositionState = impl.compositionState(); > >- RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.get(layer); >- if (!backingStore) >+ if (!layerShouldHaveBackingStore(&layer)) { >+ layer.setBackingStore(nullptr); >+ compositionState.backingStore = nullptr; > return; >+ } > >- for (auto& tile : state.tilesToRemove) >- backingStore->removeTile(tile); >+ if (!compositionState.backingStore) >+ compositionState.backingStore = CoordinatedBackingStore::create(); > >- commitScope.backingStoresWithPendingBuffers.add(backingStore); >+ layer.setBackingStore(compositionState.backingStore.get()); >+ compositionState.backingStore->setSize(layer.size()); >+ impl.applyUpdate(); >+ commitScope.backingStoresWithPendingBuffers.add(compositionState.backingStore); > } > >-void CoordinatedGraphicsScene::updateTilesIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state, CommitScope& commitScope) >+void CoordinatedGraphicsScene::updateImageBacking(TextureMapperLayer& layer, const RefPtr<Nicosia::ImageBacking>& imageBacking, CommitScope& commitScope) > { >- if (state.tilesToUpdate.isEmpty()) >+ if (!imageBacking) { >+ layer.setContentsLayer(nullptr); > return; >- >- RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.get(layer); >- ASSERT(backingStore || !layerShouldHaveBackingStore(layer)); >- if (!backingStore) >- return; >- >- for (auto& tile : state.tilesToUpdate) { >- const SurfaceUpdateInfo& surfaceUpdateInfo = tile.updateInfo; >- >- backingStore->updateTile(tile.tileID, surfaceUpdateInfo.updateRect, tile.tileRect, surfaceUpdateInfo.buffer.copyRef(), { 0, 0 }); >- commitScope.backingStoresWithPendingBuffers.add(backingStore); > } >-} >- >-void CoordinatedGraphicsScene::syncImageBackings(const CoordinatedGraphicsState& state, CommitScope& commitScope) >-{ >- for (auto& image : state.imagesToRemove) >- removeImageBacking(image, commitScope); >- >- for (auto& image : state.imagesToCreate) >- createImageBacking(image); >+ auto& impl = imageBackingImpl(*imageBacking); >+ auto& compositionState = impl.compositionState(); > >- for (auto& image : state.imagesToUpdate) >- updateImageBacking(image.first, image.second.copyRef(), commitScope); >+ if (!compositionState.backingStore) >+ compositionState.backingStore = CoordinatedBackingStore::create(); > >- for (auto& image : state.imagesToClear) >- clearImageBackingContents(image, commitScope); >-} >- >-void CoordinatedGraphicsScene::createImageBacking(CoordinatedImageBackingID imageID) >-{ >- ASSERT(!m_imageBackings.contains(imageID)); >- m_imageBackings.add(imageID, CoordinatedBackingStore::create()); >+ impl.applyUpdate(); >+ layer.setContentsLayer(compositionState.backingStore.get()); >+ commitScope.backingStoresWithPendingBuffers.add(compositionState.backingStore); > } > >-void CoordinatedGraphicsScene::updateImageBacking(CoordinatedImageBackingID imageID, RefPtr<Nicosia::Buffer>&& buffer, CommitScope& commitScope) >+void CoordinatedGraphicsScene::removeLayer(Nicosia::CompositionLayer& layer) > { >- ASSERT(m_imageBackings.contains(imageID)); >- auto it = m_imageBackings.find(imageID); >- RefPtr<CoordinatedBackingStore> backingStore = it->value; >- >- // CoordinatedImageBacking is realized to CoordinatedBackingStore with only one tile in UI Process. >- backingStore->createTile(1 /* id */, 1 /* scale */); >- IntRect rect(IntPoint::zero(), buffer->size()); >- // See CoordinatedGraphicsLayer::shouldDirectlyCompositeImage() >- ASSERT(2000 >= std::max(rect.width(), rect.height())); >- backingStore->setSize(rect.size()); >- backingStore->updateTile(1 /* id */, rect, rect, WTFMove(buffer), rect.location()); >- >- commitScope.backingStoresWithPendingBuffers.add(backingStore); >-} >+ layer.accessCommitted( >+ [](const Nicosia::CompositionLayer::LayerState& committed) >+ { >+ if (committed.contentLayer) >+ contentLayerImpl(*committed.contentLayer).proxy().invalidate(); > >-void CoordinatedGraphicsScene::clearImageBackingContents(CoordinatedImageBackingID imageID, CommitScope& commitScope) >-{ >- ASSERT(m_imageBackings.contains(imageID)); >- auto it = m_imageBackings.find(imageID); >- RefPtr<CoordinatedBackingStore> backingStore = it->value; >- backingStore->removeAllTiles(); >- commitScope.backingStoresWithPendingBuffers.add(backingStore); >-} >+ if (committed.backingStore) { >+ auto& compositionState = backingStoreImpl(*committed.backingStore).compositionState(); >+ compositionState.backingStore = nullptr; >+ } > >-void CoordinatedGraphicsScene::removeImageBacking(CoordinatedImageBackingID imageID, CommitScope& commitScope) >-{ >- ASSERT(m_imageBackings.contains(imageID)); >+ if (committed.imageBacking) { >+ auto& compositionState = imageBackingImpl(*committed.imageBacking).compositionState(); >+ compositionState.backingStore = nullptr; >+ } >+ }); > >- // We don't want TextureMapperLayer refers a dangling pointer. >- commitScope.releasedImageBackings.append(m_imageBackings.take(imageID)); >+ auto& compositionState = compositionLayerImpl(layer).compositionState(); >+ compositionState.layer = nullptr; > } > >-void CoordinatedGraphicsScene::assignImageBackingToLayer(TextureMapperLayer* layer, CoordinatedImageBackingID imageID) >+void CoordinatedGraphicsScene::commitSceneState(const CoordinatedGraphicsState::NicosiaState& state) > { >- if (imageID == InvalidCoordinatedImageBackingID) { >- layer->setContentsLayer(0); >+ if (!m_client) > return; >- } > >- auto it = m_imageBackings.find(imageID); >- ASSERT(it != m_imageBackings.end()); >- layer->setContentsLayer(it->value.get()); >+ m_nicosia.scene = state.scene; > } > >-void CoordinatedGraphicsScene::commitSceneState(const CoordinatedGraphicsState& state) >+void CoordinatedGraphicsScene::updateSceneState() > { >- if (!m_client) >+ if (!m_nicosia.scene) > return; > >- m_nicosia = state.nicosia; >- // FIXME: Start using the Nicosia layer state for updates. >- > CommitScope commitScope; > >- createLayers(state.layersToCreate); >- deleteLayers(state.layersToRemove); >- >- if (state.rootCompositingLayer != m_rootLayerID) >- setRootLayerID(state.rootCompositingLayer); >- >- syncImageBackings(state, commitScope); >- >- for (auto& layer : state.layersToUpdate) >- setLayerState(layer.first, layer.second, commitScope); >+ m_nicosia.scene->accessState( >+ [this, &commitScope](Nicosia::Scene::State& state) >+ { >+ if (state.id == m_nicosia.state.id) >+ return; >+ >+ { >+ auto& rootLayer = texmapLayer(*state.rootLayer); >+ if (rootLayer.id() != m_rootLayerID) { >+ m_rootLayerID = rootLayer.id(); >+ RELEASE_ASSERT(m_rootLayer->children().isEmpty()); >+ m_rootLayer->addChild(&rootLayer); >+ } >+ } >+ >+ HashSet<RefPtr<Nicosia::CompositionLayer>> removedLayers; >+ for (auto& layer : m_nicosia.state.layers) { >+ if (!state.layers.contains(layer)) >+ removedLayers.add(layer); >+ } >+ >+ m_nicosia.state = state; >+ >+ for (auto& layer : removedLayers) >+ removeLayer(*layer); >+ >+ for (auto& compositionLayer : m_nicosia.state.layers) { >+ auto& layer = texmapLayer(*compositionLayer); >+ compositionLayer->commitState( >+ [this, &layer, &commitScope](const Nicosia::CompositionLayer::LayerState& layerState) >+ { >+ if (layerState.delta.positionChanged) >+ layer.setPosition(layerState.position); >+ if (layerState.delta.anchorPointChanged) >+ layer.setAnchorPoint(layerState.anchorPoint); >+ if (layerState.delta.sizeChanged) >+ layer.setSize(layerState.size); >+ >+ if (layerState.delta.transformChanged) >+ layer.setTransform(layerState.transform); >+ if (layerState.delta.childrenTransformChanged) >+ layer.setChildrenTransform(layerState.childrenTransform); >+ >+ if (layerState.delta.contentsRectChanged) >+ layer.setContentsRect(layerState.contentsRect); >+ if (layerState.delta.contentsTilingChanged) { >+ layer.setContentsTilePhase(layerState.contentsTilePhase); >+ layer.setContentsTileSize(layerState.contentsTileSize); >+ } >+ >+ if (layerState.delta.opacityChanged) >+ layer.setOpacity(layerState.opacity); >+ if (layerState.delta.solidColorChanged) >+ layer.setSolidColor(layerState.solidColor); >+ >+ if (layerState.delta.filtersChanged) >+ layer.setFilters(layerState.filters); >+ if (layerState.delta.animationsChanged) >+ layer.setAnimations(layerState.animations); >+ >+ if (layerState.delta.childrenChanged) { >+ layer.setChildren(WTF::map(layerState.children, >+ [](auto& child) { return &texmapLayer(*child); })); >+ } >+ >+ if (layerState.delta.maskChanged) >+ layer.setMaskLayer(layerState.mask ? &texmapLayer(*layerState.mask) : nullptr); >+ if (layerState.delta.replicaChanged) >+ layer.setReplicaLayer(layerState.replica ? &texmapLayer(*layerState.replica) : nullptr); >+ >+ if (layerState.delta.contentLayerChanged) { >+ if (layerState.contentLayer) { >+ auto& impl = contentLayerImpl(*layerState.contentLayer); >+ impl.proxy().activateOnCompositingThread(this, &layer); >+ } >+ } >+ >+ if (layerState.delta.flagsChanged) { >+ layer.setContentsOpaque(layerState.flags.contentsOpaque); >+ layer.setDrawsContent(layerState.flags.drawsContent); >+ layer.setContentsVisible(layerState.flags.contentsVisible); >+ layer.setBackfaceVisibility(layerState.flags.backfaceVisible); >+ layer.setMasksToBounds(layerState.flags.masksToBounds); >+ layer.setPreserves3D(layerState.flags.preserves3D); >+ } >+ >+ if (layerState.contentLayer) { >+ auto& impl = contentLayerImpl(*layerState.contentLayer); >+ commitScope.proxies.add(makeRef(impl.proxy())); >+ } >+ >+ updateBackingStore(layer, layerState.backingStore, commitScope); >+ >+ if (layerState.delta.imageBackingChanged) >+ updateImageBacking(layer, layerState.imageBacking, commitScope); >+ }); >+ } >+ }); > > for (auto& backingStore : commitScope.backingStoresWithPendingBuffers) > backingStore->commitTileOperations(*m_textureMapper); >+ >+ for (auto& proxy : commitScope.proxies) >+ proxy->swapBuffer(); > } > > void CoordinatedGraphicsScene::ensureRootLayer() >@@ -465,26 +348,17 @@ void CoordinatedGraphicsScene::purgeGLResources() > { > ASSERT(!m_client); > >- m_imageBackings.clear(); >-#if USE(COORDINATED_GRAPHICS_THREADED) >- for (auto& proxy : m_platformLayerProxies.values()) >- proxy->invalidate(); >- m_platformLayerProxies.clear(); >-#endif >+ { >+ for (auto& layer : m_nicosia.state.layers) >+ removeLayer(*layer); >+ m_nicosia.state.layers = { }; >+ m_nicosia.state.rootLayer = nullptr; >+ m_nicosia.scene = nullptr; >+ } > > m_rootLayer = nullptr; > m_rootLayerID = InvalidCoordinatedLayerID; >- m_layers.clear(); > m_textureMapper = nullptr; >- m_backingStores.clear(); >-} >- >-void CoordinatedGraphicsScene::setLayerAnimationsIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state) >-{ >- if (!state.animationsChanged) >- return; >- >- layer->setAnimations(state.animations); > } > > void CoordinatedGraphicsScene::detach() >diff --git a/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h b/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h >index 2f3b4f33975..45b24479f53 100644 >--- a/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h >+++ b/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h >@@ -28,6 +28,7 @@ > #include <WebCore/GraphicsLayer.h> > #include <WebCore/IntRect.h> > #include <WebCore/IntSize.h> >+#include <WebCore/NicosiaScene.h> > #include <WebCore/TextureMapper.h> > #include <WebCore/TextureMapperBackingStore.h> > #include <WebCore/TextureMapperFPSCounter.h> >@@ -81,8 +82,6 @@ public: > bool isActive() const { return m_isActive; } > void setActive(bool active) { m_isActive = active; } > >- void commitSceneState(const WebCore::CoordinatedGraphicsState&); >- > void setViewBackgroundColor(const WebCore::Color& color) { m_viewBackgroundColor = color; } > WebCore::Color viewBackgroundColor() const { return m_viewBackgroundColor; } > >@@ -92,72 +91,40 @@ private: > CommitScope(CommitScope&) = delete; > CommitScope& operator=(const CommitScope&) = delete; > >- Vector<RefPtr<WebCore::CoordinatedBackingStore>> releasedImageBackings; > HashSet<RefPtr<WebCore::CoordinatedBackingStore>> backingStoresWithPendingBuffers; >+ HashSet<RefPtr<WebCore::TextureMapperPlatformLayerProxy>> proxies; > }; > >- void setRootLayerID(WebCore::CoordinatedLayerID); >- void createLayers(const Vector<WebCore::CoordinatedLayerID>&); >- void deleteLayers(const Vector<WebCore::CoordinatedLayerID>&); >- void setLayerState(WebCore::CoordinatedLayerID, const WebCore::CoordinatedGraphicsLayerState&, CommitScope&); >- void setLayerChildrenIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&); >- void updateTilesIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&, CommitScope&); >- void createTilesIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&); >- void removeTilesIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&, CommitScope&); >- void setLayerFiltersIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&); >- void setLayerAnimationsIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&); >- void syncPlatformLayerIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&); >- >- void syncImageBackings(const WebCore::CoordinatedGraphicsState&, CommitScope&); >- void createImageBacking(WebCore::CoordinatedImageBackingID); >- void updateImageBacking(WebCore::CoordinatedImageBackingID, RefPtr<Nicosia::Buffer>&&, CommitScope&); >- void clearImageBackingContents(WebCore::CoordinatedImageBackingID, CommitScope&); >- void removeImageBacking(WebCore::CoordinatedImageBackingID, CommitScope&); >- >- WebCore::TextureMapperLayer* layerByID(WebCore::CoordinatedLayerID id) >- { >- ASSERT(m_layers.contains(id)); >- ASSERT(id != WebCore::InvalidCoordinatedLayerID); >- return m_layers.get(id); >- } >- WebCore::TextureMapperLayer* getLayerByIDIfExists(WebCore::CoordinatedLayerID); >+ void commitSceneState(const WebCore::CoordinatedGraphicsState::NicosiaState&); >+ void updateSceneState(); >+ > WebCore::TextureMapperLayer* rootLayer() { return m_rootLayer.get(); } > > void updateViewport(); > >- void createLayer(WebCore::CoordinatedLayerID); >- void deleteLayer(WebCore::CoordinatedLayerID); >- >- void assignImageBackingToLayer(WebCore::TextureMapperLayer*, WebCore::CoordinatedImageBackingID); > void ensureRootLayer(); > >- void prepareContentBackingStore(WebCore::TextureMapperLayer*, CommitScope&); >- void createBackingStoreIfNeeded(WebCore::TextureMapperLayer*); >- void removeBackingStoreIfNeeded(WebCore::TextureMapperLayer*); >- void resetBackingStoreSizeToLayerSize(WebCore::TextureMapperLayer*, CommitScope&); >+ void updateBackingStore(WebCore::TextureMapperLayer&, const RefPtr<Nicosia::BackingStore>&, CommitScope&); >+ void updateImageBacking(WebCore::TextureMapperLayer&, const RefPtr<Nicosia::ImageBacking>&, CommitScope&); >+ void removeLayer(Nicosia::CompositionLayer&); > > #if USE(COORDINATED_GRAPHICS_THREADED) > void onNewBufferAvailable() override; > #endif > >- WebCore::CoordinatedGraphicsState::NicosiaState m_nicosia; >+ struct { >+ RefPtr<Nicosia::Scene> scene; >+ Nicosia::Scene::State state; >+ } m_nicosia; > > std::unique_ptr<WebCore::TextureMapper> m_textureMapper; > >- HashMap<WebCore::CoordinatedImageBackingID, RefPtr<WebCore::CoordinatedBackingStore>> m_imageBackings; >- HashMap<WebCore::TextureMapperLayer*, RefPtr<WebCore::CoordinatedBackingStore>> m_backingStores; >- >-#if USE(COORDINATED_GRAPHICS_THREADED) >- HashMap<WebCore::TextureMapperLayer*, RefPtr<WebCore::TextureMapperPlatformLayerProxy>> m_platformLayerProxies; >-#endif >- > // Below two members are accessed by only the main thread. The painting thread must lock the main thread to access both members. > CoordinatedGraphicsSceneClient* m_client; > bool m_isActive { false }; > > std::unique_ptr<WebCore::TextureMapperLayer> m_rootLayer; > >- HashMap<WebCore::CoordinatedLayerID, std::unique_ptr<WebCore::TextureMapperLayer>> m_layers; > WebCore::CoordinatedLayerID m_rootLayerID { WebCore::InvalidCoordinatedLayerID }; > WebCore::Color m_viewBackgroundColor { WebCore::Color::white }; > >diff --git a/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp b/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp >index 2cdc1ffb9a3..6e0bd99c4ac 100644 >--- a/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp >+++ b/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp >@@ -220,7 +220,7 @@ void ThreadedCompositor::renderLayerTree() > for (auto& state : states) > coordinateUpdate |= std::any_of(state.layersToUpdate.begin(), state.layersToUpdate.end(), > [](auto& it) { return it.second.platformLayerChanged || it.second.platformLayerUpdated; }); >- m_attributes.coordinateUpdateCompletionWithClient = coordinateUpdate; >+ m_attributes.coordinateUpdateCompletionWithClient = /* coordinateUpdate */ false; > } > } > >@@ -298,6 +298,11 @@ void ThreadedCompositor::updateSceneState(const CoordinatedGraphicsState& state) > m_compositingRunLoop->scheduleUpdate(); > } > >+void ThreadedCompositor::requestUpdate() >+{ >+ 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 42b246d2b06..134892c039c 100644 >--- a/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h >+++ b/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.h >@@ -72,6 +72,7 @@ public: > void setDrawsBackground(bool); > > void updateSceneState(const WebCore::CoordinatedGraphicsState&); >+ void requestUpdate(); > > void invalidate(); > >diff --git a/Source/WebKit/UIProcess/API/wpe/PageClientImpl.cpp b/Source/WebKit/UIProcess/API/wpe/PageClientImpl.cpp >index d87f2fdbafe..d670fb251bc 100644 >--- a/Source/WebKit/UIProcess/API/wpe/PageClientImpl.cpp >+++ b/Source/WebKit/UIProcess/API/wpe/PageClientImpl.cpp >@@ -40,7 +40,7 @@ namespace WebKit { > > PageClientImpl::PageClientImpl(WKWPE::View& view) > : m_view(view) >- , m_scrollGestureController(std::make_unique<ScrollGestureController>()) >+ , m_scrollGestureController(m_view.scrollGestureController()) > { > } > >@@ -192,8 +192,8 @@ void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent& touchEvent, b > > auto& page = m_view.page(); > >- if (m_scrollGestureController->handleEvent(touchPoint)) { >- struct wpe_input_axis_event* axisEvent = m_scrollGestureController->axisEvent(); >+ if (m_scrollGestureController.handleEvent(touchPoint)) { >+ struct wpe_input_axis_event* axisEvent = m_scrollGestureController.axisEvent(); > if (axisEvent->type != wpe_input_axis_event_type_null) > page.handleWheelEvent(WebKit::NativeWebWheelEvent(axisEvent, m_view.page().deviceScaleFactor())); > return; >diff --git a/Source/WebKit/UIProcess/API/wpe/PageClientImpl.h b/Source/WebKit/UIProcess/API/wpe/PageClientImpl.h >index 24d9f833fc1..c6fa1c49acf 100644 >--- a/Source/WebKit/UIProcess/API/wpe/PageClientImpl.h >+++ b/Source/WebKit/UIProcess/API/wpe/PageClientImpl.h >@@ -142,8 +142,7 @@ private: > WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override; > > WKWPE::View& m_view; >- >- std::unique_ptr<ScrollGestureController> m_scrollGestureController; >+ ScrollGestureController& m_scrollGestureController; > }; > > } // namespace WebKit >diff --git a/Source/WebKit/UIProcess/API/wpe/ScrollGestureController.cpp b/Source/WebKit/UIProcess/API/wpe/ScrollGestureController.cpp >index da12c8eb351..a313ce7a2ee 100644 >--- a/Source/WebKit/UIProcess/API/wpe/ScrollGestureController.cpp >+++ b/Source/WebKit/UIProcess/API/wpe/ScrollGestureController.cpp >@@ -27,19 +27,38 @@ > #include "ScrollGestureController.h" > > #include <WebCore/Scrollbar.h> >+#include <glib.h> >+#include <numeric> > > namespace WebKit { > >+ScrollGestureController::Client::~Client() = default; >+ >+ScrollGestureController::ScrollGestureController(Client& client) >+ : m_client(client) >+{ >+ m_kinetics.timer = std::make_unique<RunLoop::Timer<ScrollGestureController>>(RunLoop::main(), this, &ScrollGestureController::dispatchCallback); >+} >+ >+ScrollGestureController::~ScrollGestureController() >+{ >+} >+ > bool ScrollGestureController::handleEvent(const struct wpe_input_touch_event_raw* touchPoint) > { > switch (touchPoint->type) { > case wpe_input_touch_event_type_down: >- m_start.time = touchPoint->time; >- m_start.x = touchPoint->x; >- m_start.y = touchPoint->y; >- m_offset.x = touchPoint->x; >- m_offset.y = touchPoint->y; >+ { >+ int32_t x = touchPoint->x; >+ int32_t y = touchPoint->y; >+ m_start = { touchPoint->time, x, y }; >+ m_offset = { x, y }; >+ m_kinetics.last = { touchPoint->time, x, y }; >+ m_kinetics.velocity = { }; >+ m_kinetics.application = { }; >+ m_kinetics.timer->stop(); > return false; >+ } > case wpe_input_touch_event_type_motion: > if (!m_handling) { > int32_t deltaX = touchPoint->x - m_start.x; >@@ -49,7 +68,7 @@ bool ScrollGestureController::handleEvent(const struct wpe_input_touch_event_raw > int pixelsPerLineStep = WebCore::Scrollbar::pixelsPerLineStep(); > m_handling = std::abs(deltaX) >= pixelsPerLineStep > || std::abs(deltaY) >= pixelsPerLineStep >- || deltaTime >= 200; >+ || deltaTime >= 64; > } > if (m_handling) { > m_axisEvent = { >@@ -59,8 +78,25 @@ bool ScrollGestureController::handleEvent(const struct wpe_input_touch_event_raw > }; > m_offset.x = touchPoint->x; > m_offset.y = touchPoint->y; >+ >+ { >+ auto& last = m_kinetics.last; >+ auto& velocity = m_kinetics.velocity; >+ std::rotate(velocity.x.begin(), velocity.x.begin() + 1, velocity.x.end()); >+ std::rotate(velocity.y.begin(), velocity.y.begin() + 1, velocity.y.end()); >+ std::rotate(velocity.time.begin(), velocity.time.begin() + 1, velocity.time.end()); >+ >+ velocity.x.back() = touchPoint->x - last.x; >+ velocity.y.back() = touchPoint->y - last.y; >+ velocity.time.back() = touchPoint->time - last.time; >+ >+ last = { touchPoint->time, touchPoint->x, touchPoint->y }; >+ } >+ > return true; > } >+ >+ m_kinetics.last = { touchPoint->time, touchPoint->x, touchPoint->y }; > return false; > case wpe_input_touch_event_type_up: > if (m_handling) { >@@ -69,6 +105,20 @@ bool ScrollGestureController::handleEvent(const struct wpe_input_touch_event_raw > wpe_input_axis_event_type_null, > 0, 0, 0, 0, 0 > }; >+ >+ auto& velocity = m_kinetics.velocity; >+ uint32_t accumulatedTime = std::accumulate(velocity.time.begin(), velocity.time.end(), 0); >+ int32_t accumulatedX = std::accumulate(velocity.x.begin(), velocity.x.end(), 0); >+ int32_t accumulatedY = std::accumulate(velocity.y.begin(), velocity.y.end(), 0); >+ double trajectoryX = 1000.0 * accumulatedX / accumulatedTime; >+ double trajectoryY = 1000.0 * accumulatedY / accumulatedTime; >+ >+ m_kinetics.application = { >+ g_get_monotonic_time(), touchPoint->time, touchPoint->time, >+ { m_start.x, trajectoryX, std::abs(trajectoryX * 0.2) }, >+ { m_start.y, trajectoryY, std::abs(trajectoryY * 0.2) } >+ }; >+ m_kinetics.timer->startOneShot(Seconds::fromMilliseconds(15)); > return true; > } > return false; >@@ -77,4 +127,42 @@ bool ScrollGestureController::handleEvent(const struct wpe_input_touch_event_raw > } > } > >+void ScrollGestureController::dispatchCallback() >+{ >+ uint32_t timeOffset = (g_get_monotonic_time() - m_kinetics.application.baseMonotonicTime) / 1000; >+ uint32_t time = m_kinetics.application.baseTime + timeOffset; >+ uint32_t timeDelta = time - m_kinetics.application.lastTime; >+ m_kinetics.application.lastTime = time; >+ >+ double trajectoryXValue = 0; >+ if (timeOffset < m_kinetics.application.x.duration) { >+ trajectoryXValue = -std::pow(double(timeOffset) / m_kinetics.application.x.duration, 2) + 1; >+ trajectoryXValue = std::max<double>(trajectoryXValue, 0); >+ } >+ >+ double trajectoryYValue = 0; >+ if (timeOffset < m_kinetics.application.y.duration) { >+ trajectoryYValue = -std::pow(double(timeOffset) / m_kinetics.application.y.duration, 2) + 1; >+ trajectoryYValue = std::max<double>(trajectoryYValue, 0); >+ } >+ >+ bool activeTrajectories = !!trajectoryXValue || !!trajectoryYValue; >+ >+ int32_t trajectoryYChange = m_kinetics.application.y.trajectory * trajectoryYValue * timeDelta / 1000.0; >+ if (trajectoryYChange) { >+ struct wpe_input_axis_event axisEvent = { >+ wpe_input_axis_event_type_motion, >+ m_kinetics.application.baseTime + timeOffset, >+ m_kinetics.application.x.coordinate, m_kinetics.application.y.coordinate, >+ 2, trajectoryYChange >+ }; >+ m_client.dispatchAxisEvent(&axisEvent); >+ } >+ >+ // FIXME: Also handle change in the horizontal trajectory. >+ >+ if (activeTrajectories) >+ m_kinetics.timer->startOneShot(Seconds::fromMilliseconds(15)); >+} >+ > } // namespace WebKit >diff --git a/Source/WebKit/UIProcess/API/wpe/ScrollGestureController.h b/Source/WebKit/UIProcess/API/wpe/ScrollGestureController.h >index 9c9f6e9e3b1..626e118aecf 100644 >--- a/Source/WebKit/UIProcess/API/wpe/ScrollGestureController.h >+++ b/Source/WebKit/UIProcess/API/wpe/ScrollGestureController.h >@@ -25,19 +25,34 @@ > > #pragma once > >+#include <array> > #include <wpe/wpe.h> >+#include <wtf/RunLoop.h> > > namespace WebKit { > > class ScrollGestureController { > public: >- ScrollGestureController() = default; >+ class Client { >+ public: >+ virtual ~Client(); >+ >+ virtual void dispatchAxisEvent(struct wpe_input_axis_event*) = 0; >+ }; >+ >+ ScrollGestureController(Client&); >+ ~ScrollGestureController(); > > struct wpe_input_axis_event* axisEvent() { return &m_axisEvent; } > >+ bool isHandling() const { return m_handling; } > bool handleEvent(const struct wpe_input_touch_event_raw*); > > private: >+ void dispatchCallback(); >+ >+ Client& m_client; >+ > struct { > uint32_t time { 0 }; > int32_t x { 0 }; >@@ -49,6 +64,32 @@ private: > int32_t y { 0 }; > } m_offset; > >+ struct { >+ struct { >+ uint32_t time { 0 }; >+ int32_t x { 0 }; >+ int32_t y { 0 }; >+ } last; >+ struct { >+ std::array<int32_t, 4> x; >+ std::array<int32_t, 4> y; >+ std::array<uint32_t, 4> time; >+ } velocity; >+ >+ struct { >+ int64_t baseMonotonicTime { 0 }; >+ uint32_t baseTime { 0 }; >+ uint32_t lastTime { 0 }; >+ struct { >+ int32_t coordinate { 0 }; >+ double trajectory { 0 }; >+ double duration { 0 }; >+ } x, y; >+ } application; >+ >+ std::unique_ptr<RunLoop::Timer<ScrollGestureController>> timer; >+ } m_kinetics; >+ > bool m_handling { false }; > struct wpe_input_axis_event m_axisEvent; > }; >diff --git a/Source/WebKit/UIProcess/API/wpe/WPEView.cpp b/Source/WebKit/UIProcess/API/wpe/WPEView.cpp >index 85bed5fe16b..ac0c7d5a373 100644 >--- a/Source/WebKit/UIProcess/API/wpe/WPEView.cpp >+++ b/Source/WebKit/UIProcess/API/wpe/WPEView.cpp >@@ -43,6 +43,7 @@ namespace WKWPE { > > View::View(struct wpe_view_backend* backend, const API::PageConfiguration& baseConfiguration) > : m_client(std::make_unique<API::ViewClient>()) >+ , m_scrollGestureController(std::make_unique<ScrollGestureController>(*this)) > , m_pageClient(std::make_unique<PageClientImpl>(*this)) > , m_size { 800, 600 } > , m_viewStateFlags(WebCore::ActivityState::WindowIsActive | WebCore::ActivityState::IsFocused | WebCore::ActivityState::IsVisible | WebCore::ActivityState::IsInWindow) >@@ -126,8 +127,27 @@ View::View(struct wpe_view_backend* backend, const API::PageConfiguration& baseC > // handle_touch_event > [](void* data, struct wpe_input_touch_event* event) > { >- auto& page = reinterpret_cast<View*>(data)->page(); >- page.handleTouchEvent(WebKit::NativeWebTouchEvent(event, page.deviceScaleFactor())); >+ auto& view = *reinterpret_cast<View*>(data); >+ auto& page = view.page(); >+ >+ bool handled = false; >+ >+ WebKit::NativeWebTouchEvent nativeEvent(event, page.deviceScaleFactor()); >+ >+ auto& scrollGestureController = *view.m_scrollGestureController; >+ if (scrollGestureController.isHandling()) { >+ const struct wpe_input_touch_event_raw* touchPoint = nativeEvent.nativeFallbackTouchPoint(); >+ if (touchPoint->type != wpe_input_touch_event_type_null && >+ scrollGestureController.handleEvent(touchPoint)) { >+ handled = true; >+ struct wpe_input_axis_event* axisEvent = scrollGestureController.axisEvent(); >+ if (axisEvent->type != wpe_input_axis_event_type_null) >+ page.handleWheelEvent(WebKit::NativeWebWheelEvent(axisEvent, page.deviceScaleFactor())); >+ } >+ } >+ >+ if (!handled) >+ page.handleTouchEvent(nativeEvent); > }, > // padding > nullptr, >@@ -188,4 +208,10 @@ void View::close() > m_pageProxy->close(); > } > >+void View::dispatchAxisEvent(struct wpe_input_axis_event* axisEvent) >+{ >+ auto& page = this->page(); >+ page.handleWheelEvent(WebKit::NativeWebWheelEvent(axisEvent, page.deviceScaleFactor())); >+} >+ > } // namespace WKWPE >diff --git a/Source/WebKit/UIProcess/API/wpe/WPEView.h b/Source/WebKit/UIProcess/API/wpe/WPEView.h >index 2ad18fff742..246d0c68adf 100644 >--- a/Source/WebKit/UIProcess/API/wpe/WPEView.h >+++ b/Source/WebKit/UIProcess/API/wpe/WPEView.h >@@ -28,12 +28,14 @@ > #include "APIObject.h" > #include "CompositingManagerProxy.h" > #include "PageClientImpl.h" >+#include "ScrollGestureController.h" > #include "WebPageProxy.h" > #include <WebCore/ActivityState.h> > #include <memory> > #include <wtf/RefPtr.h> > > typedef struct OpaqueJSContext* JSGlobalContextRef; >+struct wpe_input_axis_event; > struct wpe_view_backend; > > namespace API { >@@ -42,13 +44,14 @@ class ViewClient; > > namespace WebKit { > class DownloadProxy; >+class ScrollGestureController; > class WebPageGroup; > class WebProcessPool; > } > > namespace WKWPE { > >-class View : public API::ObjectImpl<API::Object::Type::View> { >+class View : public API::ObjectImpl<API::Object::Type::View>, public WebKit::ScrollGestureController::Client { > public: > static View* create(struct wpe_view_backend* backend, const API::PageConfiguration& configuration) > { >@@ -77,13 +80,19 @@ public: > void setFullScreen(bool fullScreenState) { m_fullScreenModeActive = fullScreenState; }; > #endif > >+ WebKit::ScrollGestureController& scrollGestureController() const { return *m_scrollGestureController; } >+ > private: > View(struct wpe_view_backend*, const API::PageConfiguration&); > > void setSize(const WebCore::IntSize&); > >+ // ScrollGestureController::Client >+ void dispatchAxisEvent(struct wpe_input_axis_event*) override; >+ > std::unique_ptr<API::ViewClient> m_client; > >+ std::unique_ptr<WebKit::ScrollGestureController> m_scrollGestureController; > std::unique_ptr<WebKit::PageClientImpl> m_pageClient; > RefPtr<WebKit::WebPageProxy> m_pageProxy; > WebCore::IntSize m_size; >diff --git a/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.cpp b/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.cpp >index ce937d7fc39..953647087d8 100644 >--- a/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.cpp >+++ b/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.cpp >@@ -171,6 +171,11 @@ void AcceleratedDrawingArea::mainFrameContentSizeChanged(const IntSize& size) > #endif > } > >+bool AcceleratedDrawingArea::supportsAsyncScrolling() >+{ >+ return false; >+} >+ > void AcceleratedDrawingArea::layerHostDidFlushLayers() > { > ASSERT(m_layerTreeHost); >diff --git a/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.h b/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.h >index 771af0a2051..ebd35b9e423 100644 >--- a/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.h >+++ b/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.h >@@ -54,6 +54,8 @@ protected: > void updatePreferences(const WebPreferencesStore&) override; > void mainFrameContentSizeChanged(const WebCore::IntSize&) override; > >+ bool supportsAsyncScrolling() override; >+ > WebCore::GraphicsLayerFactory* graphicsLayerFactory() override; > void setRootCompositingLayer(WebCore::GraphicsLayer*) override; > void scheduleCompositingLayerFlush() override; >diff --git a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp >index 4ec0f5ea1a3..a1361fd3d92 100644 >--- a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp >+++ b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp >@@ -104,6 +104,36 @@ void CompositingCoordinator::sizeDidChange(const IntSize& newSize) > notifyFlushRequired(m_rootLayer.get()); > } > >+void dumpPlatformLayer(Nicosia::CompositionLayer& layer, unsigned indentation) >+{ >+ auto writeIndentation = >+ [](unsigned id) >+ { >+ for (unsigned i = 0; i < id; ++i) >+ fprintf(stderr, " |"); >+ }; >+ >+ layer.accessState( >+ [&layer, &writeIndentation, indentation](const Nicosia::CompositionLayer::LayerState& state) >+ { >+ writeIndentation(indentation); >+ fprintf(stderr, "layer(%p): id %lu position (%.2f,%.2f) anchorPoint (%.2f,%.2f,%.2f) size (%.2f,%.2f)\n", >+ &layer, layer.id(), state.position.x(), state.position.y(), >+ state.anchorPoint.x(), state.anchorPoint.y(), state.anchorPoint.z(), >+ state.size.width(), state.size.height()); >+ writeIndentation(indentation); >+ fprintf(stderr, " children[%zu] replica %p mask %p\n", >+ state.children.size(), state.replica.get(), state.mask.get()); >+ writeIndentation(indentation); >+ fprintf(stderr, " flags { %d, %d, %d, %d, %d, %d }\n", >+ state.flags.contentsOpaque, state.flags.drawsContent, state.flags.contentsVisible, >+ state.flags.backfaceVisible, state.flags.masksToBounds, state.flags.preserves3D); >+ >+ for (auto& child : state.children) >+ dumpPlatformLayer(*child, indentation + 1); >+ }); >+} >+ > bool CompositingCoordinator::flushPendingLayerChanges() > { > SetForScope<bool> protector(m_isFlushingLayerChanges, true); >@@ -124,17 +154,26 @@ bool CompositingCoordinator::flushPendingLayerChanges() > > flushPendingImageBackingChanges(); > >+#if 0 >+ fprintf(stderr, "CompositingCoordinator::flushPendingLayerChanges()\n"); >+ fprintf(stderr, "\tm_rootLayer %p, m_rootLayer.platformLayer() %p\n", >+ m_rootLayer.get(), m_rootLayer->platformLayer()); >+ dumpPlatformLayer(*m_rootLayer->platformLayer(), 1); >+#endif >+ > if (m_shouldSyncFrame) { > didSync = true; > > m_state.nicosia.scene->accessState( > [this](Nicosia::Scene::State& state) > { >+ for (auto& compositionLayer : m_nicosia.state.layers) >+ compositionLayer->flushState(); >+ > ++state.id; > state.layers = m_nicosia.state.layers; > state.rootLayer = m_nicosia.state.rootLayer; > }); >- > m_client.commitSceneState(m_state); > > clearPendingStateChanges(); >diff --git a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h >index 4308eae2ff6..281262b5143 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 { >@@ -61,6 +62,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/CoordinatedLayerTreeHost.h b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h >index 0a8bec8a398..2a1ccf32f18 100644 >--- a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h >+++ b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.h >@@ -70,6 +70,7 @@ protected: > void didFlushRootLayer(const WebCore::FloatRect& visibleContentRect) override; > void notifyFlushRequired() override { scheduleLayerFlush(); }; > void commitSceneState(const WebCore::CoordinatedGraphicsState&) override; >+ RefPtr<Nicosia::SceneIntegration> sceneIntegration() override { return nullptr; } > > void flushLayersAndForceRepaint(); > >diff --git a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp >index d99f16bce75..3e706642256 100644 >--- a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp >+++ b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.cpp >@@ -35,6 +35,7 @@ > #include "WebPage.h" > #include <WebCore/Frame.h> > #include <WebCore/FrameView.h> >+#include <WebCore/NicosiaSceneIntegration.h> > > namespace WebKit { > using namespace WebCore; >@@ -59,6 +60,7 @@ ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost(WebPage& webP > : CoordinatedLayerTreeHost(webPage) > , m_compositorClient(*this) > , m_surface(AcceleratedSurface::create(webPage, *this)) >+ , m_sceneIntegration(adoptRef(*new Nicosia::SceneIntegration(*this))) > , m_viewportController(webPage.size()) > { > if (FrameView* frameView = m_webPage.mainFrameView()) { >@@ -89,6 +91,7 @@ ThreadedCoordinatedLayerTreeHost::ThreadedCoordinatedLayerTreeHost(WebPage& webP > > void ThreadedCoordinatedLayerTreeHost::invalidate() > { >+ m_sceneIntegration->invalidate(); > m_compositor->invalidate(); > CoordinatedLayerTreeHost::invalidate(); > m_surface = nullptr; >@@ -121,6 +124,11 @@ void ThreadedCoordinatedLayerTreeHost::handleDisplayRefreshMonitorUpdate(bool ha > m_compositor->handleDisplayRefreshMonitorUpdate(); > } > >+RefPtr<Nicosia::SceneIntegration> ThreadedCoordinatedLayerTreeHost::sceneIntegration() >+{ >+ return m_sceneIntegration.copyRef(); >+} >+ > uint64_t ThreadedCoordinatedLayerTreeHost::nativeSurfaceHandleForCompositing() > { > if (!m_surface) >@@ -273,6 +281,11 @@ void ThreadedCoordinatedLayerTreeHost::commitSceneState(const CoordinatedGraphic > m_compositor->updateSceneState(state); > } > >+void ThreadedCoordinatedLayerTreeHost::requestUpdate() >+{ >+ m_compositor->requestUpdate(); >+} >+ > void ThreadedCoordinatedLayerTreeHost::setIsDiscardable(bool discardable) > { > m_isDiscardable = discardable; >diff --git a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h >index 87a7da717cd..b8408b52961 100644 >--- a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h >+++ b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/ThreadedCoordinatedLayerTreeHost.h >@@ -34,6 +34,7 @@ > #include "SimpleViewportController.h" > #include "ThreadedCompositor.h" > #include "ThreadedDisplayRefreshMonitor.h" >+#include <WebCore/NicosiaSceneIntegration.h> > #include <wtf/OptionSet.h> > > namespace WebCore { >@@ -46,7 +47,10 @@ namespace WebKit { > > class WebPage; > >-class ThreadedCoordinatedLayerTreeHost final : public CoordinatedLayerTreeHost, public AcceleratedSurface::Client { >+class ThreadedCoordinatedLayerTreeHost final >+ : public CoordinatedLayerTreeHost >+ , public AcceleratedSurface::Client >+ , public Nicosia::SceneIntegration::Client { > public: > static Ref<ThreadedCoordinatedLayerTreeHost> create(WebPage&); > virtual ~ThreadedCoordinatedLayerTreeHost(); >@@ -120,6 +124,9 @@ private: > void didFlushRootLayer(const WebCore::FloatRect&) override { } > void commitSceneState(const WebCore::CoordinatedGraphicsState&) override; > >+ // Nicosia::SceneIntegration::Client >+ void requestUpdate() override; >+ > #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) > RefPtr<WebCore::DisplayRefreshMonitor> createDisplayRefreshMonitor(WebCore::PlatformDisplayID) override; > #endif >@@ -127,6 +134,9 @@ private: > // AcceleratedSurface::Client > void frameComplete() override; > >+ // CompositingCoordinator::Client >+ RefPtr<Nicosia::SceneIntegration> sceneIntegration() override; >+ > uint64_t nativeSurfaceHandleForCompositing(); > void didDestroyGLContext(); > void willRenderFrame(); >@@ -144,6 +154,7 @@ private: > CompositorClient m_compositorClient; > std::unique_ptr<AcceleratedSurface> m_surface; > RefPtr<ThreadedCompositor> m_compositor; >+ Ref<Nicosia::SceneIntegration> m_sceneIntegration; > SimpleViewportController m_viewportController; > float m_lastPageScaleFactor { 1 }; > WebCore::IntPoint m_lastScrollPosition; >diff --git a/Source/cmake/OptionsGTK.cmake b/Source/cmake/OptionsGTK.cmake >index 945dedec22e..452451084eb 100644 >--- a/Source/cmake/OptionsGTK.cmake >+++ b/Source/cmake/OptionsGTK.cmake >@@ -277,6 +277,7 @@ if (ENABLE_OPENGL) > > SET_AND_EXPOSE_TO_BUILD(USE_COORDINATED_GRAPHICS TRUE) > SET_AND_EXPOSE_TO_BUILD(USE_COORDINATED_GRAPHICS_THREADED TRUE) >+ SET_AND_EXPOSE_TO_BUILD(USE_NICOSIA TRUE) > endif () > > if (ENABLE_PLUGIN_PROCESS_GTK2) >diff --git a/Source/cmake/OptionsWPE.cmake b/Source/cmake/OptionsWPE.cmake >index e87011d52d6..fcb59d8808e 100644 >--- a/Source/cmake/OptionsWPE.cmake >+++ b/Source/cmake/OptionsWPE.cmake >@@ -134,6 +134,7 @@ SET_AND_EXPOSE_TO_BUILD(USE_TEXTURE_MAPPER_GL TRUE) > SET_AND_EXPOSE_TO_BUILD(USE_TILED_BACKING_STORE TRUE) > SET_AND_EXPOSE_TO_BUILD(USE_COORDINATED_GRAPHICS TRUE) > SET_AND_EXPOSE_TO_BUILD(USE_COORDINATED_GRAPHICS_THREADED TRUE) >+SET_AND_EXPOSE_TO_BUILD(USE_NICOSIA TRUE) > > set(FORWARDING_HEADERS_DIR ${DERIVED_SOURCES_DIR}/ForwardingHeaders) > set(FORWARDING_HEADERS_WPE_DIR ${FORWARDING_HEADERS_DIR}/wpe)
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 187385
:
344418
|
346471
|
346895
|
347274
|
347805
|
351378