WebKit Bugzilla
Attachment 346471 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), 158.26 KB, created by
Zan Dobersek
on 2018-08-03 03:37:11 PDT
(
hide
)
Description:
WIP
Filename:
MIME Type:
Creator:
Zan Dobersek
Created:
2018-08-03 03:37:11 PDT
Size:
158.26 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 861085f829e..4dadb8df548 100644 >--- a/Source/WebCore/platform/TextureMapper.cmake >+++ b/Source/WebCore/platform/TextureMapper.cmake >@@ -44,17 +44,26 @@ if (USE_COORDINATED_GRAPHICS) > list(APPEND WebCore_INCLUDE_DIRECTORIES > "${WEBCORE_DIR}/platform/graphics/nicosia" > "${WEBCORE_DIR}/platform/graphics/nicosia/cairo" >+ "${WEBCORE_DIR}/platform/graphics/nicosia/texmap" > ) > list(APPEND WebCore_SOURCES > platform/graphics/nicosia/NicosiaBuffer.cpp >+ platform/graphics/nicosia/NicosiaGC3DLayer.cpp > platform/graphics/nicosia/NicosiaPaintingContext.cpp > platform/graphics/nicosia/NicosiaPaintingEngine.cpp > platform/graphics/nicosia/NicosiaPaintingEngineBasic.cpp > 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/NicosiaImageBackingTextureMapperImpl.cpp > ) > else () > list(APPEND WebCore_SOURCES >diff --git a/Source/WebCore/platform/graphics/GraphicsContext3D.h b/Source/WebCore/platform/graphics/GraphicsContext3D.h >index 4308acf1425..8e472457aff 100644 >--- a/Source/WebCore/platform/graphics/GraphicsContext3D.h >+++ b/Source/WebCore/platform/graphics/GraphicsContext3D.h >@@ -84,6 +84,12 @@ typedef void* PlatformGraphicsSurface3D; > const PlatformGraphicsContext3D NullPlatformGraphicsContext3D = 0; > const Platform3DObject NullPlatform3DObject = 0; > >+#if USE(NICOSIA) >+namespace Nicosia { >+class GC3DLayer; >+} >+#endif >+ > namespace WebCore { > class Extensions3D; > #if !PLATFORM(COCOA) && USE(OPENGL_ES) >@@ -1481,7 +1487,10 @@ private: > // Errors raised by synthesizeGLError(). > ListHashSet<GC3Denum> m_syntheticErrors; > >-#if USE(TEXTURE_MAPPER) >+#if USE(NICOSIA) >+ friend class Nicosia::GC3DLayer; >+ RefPtr<Nicosia::GC3DLayer> m_contentLayer; >+#elif USE(TEXTURE_MAPPER) > friend class TextureMapperGC3DPlatformLayer; > std::unique_ptr<TextureMapperGC3DPlatformLayer> m_texmapLayer; > #else >diff --git a/Source/WebCore/platform/graphics/PlatformLayer.h b/Source/WebCore/platform/graphics/PlatformLayer.h >index 10fcf1485ec..92ba32d1017 100644 >--- a/Source/WebCore/platform/graphics/PlatformLayer.h >+++ b/Source/WebCore/platform/graphics/PlatformLayer.h >@@ -30,6 +30,11 @@ OBJC_CLASS CALayer; > typedef CALayer PlatformLayer; > #elif PLATFORM(WIN) && USE(CA) > typedef struct _CACFLayer PlatformLayer; >+#elif USE(NICOSIA) >+namespace Nicosia { >+class PlatformLayer; >+} >+typedef Nicosia::PlatformLayer PlatformLayer; > #elif USE(COORDINATED_GRAPHICS_THREADED) > namespace WebCore { > class TextureMapperPlatformLayerProxyProvider; >diff --git a/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp b/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp >index 89a41f1f578..33663dd3f55 100644 >--- a/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp >+++ b/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp >@@ -90,10 +90,15 @@ ImageBufferData::ImageBufferData(const IntSize& size, RenderingMode renderingMod > , m_texture(0) > #endif > { >+ if (m_renderingMode == RenderingMode::Accelerated) { > #if ENABLE(ACCELERATED_2D_CANVAS) && USE(COORDINATED_GRAPHICS_THREADED) >- if (m_renderingMode == RenderingMode::Accelerated) >+#if USE(NICOSIA) >+ m_contentLayer = Nicosia::ContentLayer::create(Nicosia::ContentLayerTextureMapperImpl::createFactory(*this)); >+#else > m_platformLayerProxy = adoptRef(new TextureMapperPlatformLayerProxy); > #endif >+#endif >+ } > } > > ImageBufferData::~ImageBufferData() >@@ -139,6 +144,31 @@ void ImageBufferData::createCompositorBuffer() > cairo_set_antialias(m_compositorCr.get(), CAIRO_ANTIALIAS_NONE); > } > >+#if USE(NICOSIA) >+void ImageBufferData::swapBuffersIfNeeded() >+{ >+ GLContext* previousActiveContext = GLContext::current(); >+ >+ if (!m_compositorTexture) { >+ createCompositorBuffer(); >+ >+ auto& proxy = *downcast<Nicosia::ContentLayerTextureMapperImpl>(m_contentLayer->impl()).proxy(); >+ >+ LockHolder holder(proxy.lock()); >+ proxy.pushNextBuffer(std::make_unique<TextureMapperPlatformLayerBuffer>(m_compositorTexture, m_size, TextureMapperGL::ShouldBlend, GL_RGBA)); >+ } >+ >+ // It would be great if we could just swap the buffers here as we do with webgl, but that breaks the cases >+ // where one frame uses the content already rendered in the previous frame. So we just copy the content >+ // into the compositor buffer. >+ cairo_set_source_surface(m_compositorCr.get(), m_surface.get(), 0, 0); >+ cairo_set_operator(m_compositorCr.get(), CAIRO_OPERATOR_SOURCE); >+ cairo_paint(m_compositorCr.get()); >+ >+ if (previousActiveContext) >+ previousActiveContext->makeContextCurrent(); >+} >+#else > RefPtr<TextureMapperPlatformLayerProxy> ImageBufferData::proxy() const > { > return m_platformLayerProxy.copyRef(); >@@ -165,6 +195,7 @@ void ImageBufferData::swapBuffersIfNeeded() > previousActiveContext->makeContextCurrent(); > } > #endif >+#endif > > void clearSurface(cairo_surface_t* surface) > { >@@ -671,8 +702,13 @@ void ImageBufferData::paintToTextureMapper(TextureMapper& textureMapper, const F > PlatformLayer* ImageBuffer::platformLayer() const > { > #if ENABLE(ACCELERATED_2D_CANVAS) >+#if USE(NICOSIA) >+ if (m_data.m_renderingMode == RenderingMode::Accelerated) >+ return m_data.m_contentLayer.get(); >+#else > if (m_data.m_texture) > return const_cast<ImageBufferData*>(&m_data); >+#endif > #endif > return 0; > } >diff --git a/Source/WebCore/platform/graphics/cairo/ImageBufferDataCairo.h b/Source/WebCore/platform/graphics/cairo/ImageBufferDataCairo.h >index 120528fd4a0..778b3494c01 100644 >--- a/Source/WebCore/platform/graphics/cairo/ImageBufferDataCairo.h >+++ b/Source/WebCore/platform/graphics/cairo/ImageBufferDataCairo.h >@@ -38,6 +38,10 @@ > #include "TextureMapperPlatformLayerProxyProvider.h" > #endif > >+#if ENABLE(ACCELERATED_2D_CANVAS) && USE(NICOSIA) >+#include "NicosiaContentLayerTextureMapperImpl.h" >+#endif >+ > namespace WebCore { > > class IntSize; >@@ -45,8 +49,12 @@ class TextureMapperPlatformLayerProxy; > > class ImageBufferData > #if ENABLE(ACCELERATED_2D_CANVAS) >+#if USE(NICOSIA) >+ : public Nicosia::ContentLayerTextureMapperImpl::Client >+#else > : public PlatformLayer > #endif >+#endif > { > public: > ImageBufferData(const IntSize&, RenderingMode); >@@ -62,14 +70,23 @@ public: > void createCairoGLSurface(); > > #if USE(COORDINATED_GRAPHICS_THREADED) >+#if USE(NICOSIA) >+ void swapBuffersIfNeeded() override; >+#else > RefPtr<TextureMapperPlatformLayerProxy> proxy() const override; > void swapBuffersIfNeeded() override; >+#endif > void createCompositorBuffer(); > >- RefPtr<TextureMapperPlatformLayerProxy> m_platformLayerProxy; > RefPtr<cairo_surface_t> m_compositorSurface; > uint32_t m_compositorTexture; > RefPtr<cairo_t> m_compositorCr; >+ >+#if USE(NICOSIA) >+ RefPtr<Nicosia::ContentLayer> m_contentLayer; >+#else >+ RefPtr<TextureMapperPlatformLayerProxy> m_platformLayerProxy; >+#endif > #else > virtual void paintToTextureMapper(TextureMapper&, const FloatRect& target, const TransformationMatrix&, float opacity); > #endif >diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp >index e3635d221f9..a957167e743 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp >+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp >@@ -284,13 +284,21 @@ MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase(MediaPlayer* pl > , m_networkState(MediaPlayer::Empty) > , m_drawTimer(RunLoop::main(), this, &MediaPlayerPrivateGStreamerBase::repaint) > #if USE(TEXTURE_MAPPER_GL) >+#if USE(NICOSIA) >+ , m_contentLayer(Nicosia::ContentLayer::create(Nicosia::ContentLayerTextureMapperImpl::createFactory(*this))) >+#else > , m_platformLayerProxy(adoptRef(new TextureMapperPlatformLayerProxy())) > #endif >+#endif > { > } > > MediaPlayerPrivateGStreamerBase::~MediaPlayerPrivateGStreamerBase() > { >+#if USE(TEXTURE_MAPPER_GL) && USE(NICOSIA) >+ downcast<Nicosia::ContentLayerTextureMapperImpl>(m_contentLayer->impl()).invalidateClient(); >+#endif >+ > #if ENABLE(ENCRYPTED_MEDIA) > m_protectionCondition.notifyAll(); > #endif >@@ -735,6 +743,20 @@ void MediaPlayerPrivateGStreamerBase::acceleratedRenderingStateChanged() > } > > #if USE(TEXTURE_MAPPER_GL) >+PlatformLayer* MediaPlayerPrivateGStreamerBase::platformLayer() const >+{ >+#if USE(NICOSIA) >+ return m_contentLayer.ptr(); >+#else >+ return const_cast<MediaPlayerPrivateGStreamerBase*>(this); >+#endif >+} >+ >+#if USE(NICOSIA) >+void MediaPlayerPrivateGStreamerBase::swapBuffersIfNeeded() >+{ >+} >+#else > RefPtr<TextureMapperPlatformLayerProxy> MediaPlayerPrivateGStreamerBase::proxy() const > { > return m_platformLayerProxy.copyRef(); >@@ -743,6 +765,7 @@ RefPtr<TextureMapperPlatformLayerProxy> MediaPlayerPrivateGStreamerBase::proxy() > void MediaPlayerPrivateGStreamerBase::swapBuffersIfNeeded() > { > } >+#endif > > void MediaPlayerPrivateGStreamerBase::pushTextureToCompositor() > { >@@ -750,32 +773,42 @@ void MediaPlayerPrivateGStreamerBase::pushTextureToCompositor() > if (!GST_IS_SAMPLE(m_sample.get())) > return; > >- LockHolder holder(m_platformLayerProxy->lock()); >+ auto proxyOperation = >+ [&](TextureMapperPlatformLayerProxy& proxy) >+ { >+ LockHolder holder(proxy.lock()); > >- if (!m_platformLayerProxy->isActive()) >- return; >+ if (!proxy.isActive()) >+ return; > >- std::unique_ptr<GstVideoFrameHolder> frameHolder = std::make_unique<GstVideoFrameHolder>(m_sample.get(), texMapFlagFromOrientation(m_videoSourceOrientation), !m_usingFallbackVideoSink); >+ std::unique_ptr<GstVideoFrameHolder> frameHolder = std::make_unique<GstVideoFrameHolder>(m_sample.get(), texMapFlagFromOrientation(m_videoSourceOrientation), !m_usingFallbackVideoSink); > > #if USE(GSTREAMER_GL) >- GLuint textureID = frameHolder->textureID(); >- if (textureID) { >- std::unique_ptr<TextureMapperPlatformLayerBuffer> layerBuffer = std::make_unique<TextureMapperPlatformLayerBuffer>(textureID, frameHolder->size(), frameHolder->flags(), GraphicsContext3D::RGBA); >- layerBuffer->setUnmanagedBufferDataHolder(WTFMove(frameHolder)); >- m_platformLayerProxy->pushNextBuffer(WTFMove(layerBuffer)); >- } else >+ GLuint textureID = frameHolder->textureID(); >+ if (textureID) { >+ std::unique_ptr<TextureMapperPlatformLayerBuffer> layerBuffer = std::make_unique<TextureMapperPlatformLayerBuffer>(textureID, frameHolder->size(), frameHolder->flags(), GraphicsContext3D::RGBA); >+ layerBuffer->setUnmanagedBufferDataHolder(WTFMove(frameHolder)); >+ proxy.pushNextBuffer(WTFMove(layerBuffer)); >+ } else >+#endif >+ { >+ std::unique_ptr<TextureMapperPlatformLayerBuffer> buffer = proxy.getAvailableBuffer(frameHolder->size(), GL_DONT_CARE); >+ if (UNLIKELY(!buffer)) { >+ auto texture = BitmapTextureGL::create(TextureMapperContextAttributes::get()); >+ texture->reset(frameHolder->size(), frameHolder->hasAlphaChannel() ? BitmapTexture::SupportsAlpha : BitmapTexture::NoFlag); >+ buffer = std::make_unique<TextureMapperPlatformLayerBuffer>(WTFMove(texture)); >+ } >+ frameHolder->updateTexture(buffer->textureGL()); >+ buffer->setExtraFlags(texMapFlagFromOrientation(m_videoSourceOrientation) | (frameHolder->hasAlphaChannel() ? TextureMapperGL::ShouldBlend : 0)); >+ proxy.pushNextBuffer(WTFMove(buffer)); >+ } >+ }; >+ >+#if USE(NICOSIA) >+ proxyOperation(*downcast<Nicosia::ContentLayerTextureMapperImpl>(m_contentLayer->impl()).proxy()); >+#else >+ proxyOperation(*m_platformLayerProxy); > #endif >- { >- std::unique_ptr<TextureMapperPlatformLayerBuffer> buffer = m_platformLayerProxy->getAvailableBuffer(frameHolder->size(), GL_DONT_CARE); >- if (UNLIKELY(!buffer)) { >- auto texture = BitmapTextureGL::create(TextureMapperContextAttributes::get()); >- texture->reset(frameHolder->size(), frameHolder->hasAlphaChannel() ? BitmapTexture::SupportsAlpha : BitmapTexture::NoFlag); >- buffer = std::make_unique<TextureMapperPlatformLayerBuffer>(WTFMove(texture)); >- } >- frameHolder->updateTexture(buffer->textureGL()); >- buffer->setExtraFlags(texMapFlagFromOrientation(m_videoSourceOrientation) | (frameHolder->hasAlphaChannel() ? TextureMapperGL::ShouldBlend : 0)); >- m_platformLayerProxy->pushNextBuffer(WTFMove(buffer)); >- } > } > #endif // USE(TEXTURE_MAPPER_GL) > >@@ -816,14 +849,28 @@ void MediaPlayerPrivateGStreamerBase::triggerRepaint(GstSample* sample) > } > > #if USE(TEXTURE_MAPPER_GL) >- if (m_usingFallbackVideoSink) { >- LockHolder lock(m_drawMutex); >- if (!m_platformLayerProxy->scheduleUpdateOnCompositorThread([this] { this->pushTextureToCompositor(); })) >- return; >- m_drawTimer.startOneShot(0_s); >- m_drawCondition.wait(m_drawMutex); >- } else >- pushTextureToCompositor(); >+#if USE(GSTREAMER_GL) >+ pushTextureToCompositor(); >+#else >+ { >+ auto proxyOperation = >+ [&](TextureMapperPlatformLayerProxy& proxy) >+ { >+ LockHolder lock(m_drawMutex); >+ if (!proxy.scheduleUpdateOnCompositorThread([this] { this->pushTextureToCompositor(); })) >+ return; >+ m_drawCondition.wait(m_drawMutex); >+ }; >+ >+#if 0 >+#if USE(NICOSIA) >+ proxyOperation(*m_contentLayer->proxy()); >+#else >+ proxyOperation(*m_platformLayerProxy); >+#endif >+#endif >+ } >+#endif > #endif // USE(TEXTURE_MAPPER_GL) > } > >@@ -881,12 +928,20 @@ void MediaPlayerPrivateGStreamerBase::flushCurrentBuffer() > m_sample = adoptGRef(gst_sample_new(nullptr, gst_sample_get_caps(m_sample.get()), > gst_sample_get_segment(m_sample.get()), info ? gst_structure_copy(info) : nullptr)); > >- { >- LockHolder locker(m_platformLayerProxy->lock()); >+ auto proxyOperation = >+ [](TextureMapperPlatformLayerProxy& proxy) >+ { >+ LockHolder locker(proxy.lock()); > >- if (m_platformLayerProxy->isActive()) >- m_platformLayerProxy->dropCurrentBufferWhilePreservingTexture(); >- } >+ if (proxy.isActive()) >+ proxy.dropCurrentBufferWhilePreservingTexture(); >+ }; >+ >+#if USE(NICOSIA) >+ proxyOperation(*downcast<Nicosia::ContentLayerTextureMapperImpl>(m_contentLayer->impl()).proxy()); >+#else >+ proxyOperation(*m_platformLayerProxy); >+#endif > } > #endif > >diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h >index 30ca02e29d7..58f6b19088c 100644 >--- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h >+++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h >@@ -37,8 +37,12 @@ > #include <wtf/WeakPtr.h> > > #if USE(TEXTURE_MAPPER_GL) >+#if USE(NICOSIA) >+#include "NicosiaContentLayerTextureMapperImpl.h" >+#else > #include "TextureMapperPlatformLayerProxyProvider.h" > #endif >+#endif > > typedef struct _GstStreamVolume GstStreamVolume; > typedef struct _GstVideoInfo GstVideoInfo; >@@ -63,8 +67,12 @@ void registerWebKitGStreamerElements(); > > class MediaPlayerPrivateGStreamerBase : public MediaPlayerPrivateInterface, public CanMakeWeakPtr<MediaPlayerPrivateGStreamerBase> > #if USE(TEXTURE_MAPPER_GL) >+#if USE(NICOSIA) >+ , public Nicosia::ContentLayerTextureMapperImpl::Client >+#else > , public PlatformLayer > #endif >+#endif > { > > public: >@@ -126,7 +134,7 @@ public: > void acceleratedRenderingStateChanged() override; > > #if USE(TEXTURE_MAPPER_GL) >- PlatformLayer* platformLayer() const override { return const_cast<MediaPlayerPrivateGStreamerBase*>(this); } >+ PlatformLayer* platformLayer() const override; > #if PLATFORM(WIN_CAIRO) > // FIXME: Accelerated rendering has not been implemented for WinCairo yet. > bool supportsAcceleratedRendering() const override { return false; } >@@ -175,9 +183,13 @@ protected: > #endif > > #if USE(TEXTURE_MAPPER_GL) >+ void pushTextureToCompositor(); >+#if USE(NICOSIA) >+ void swapBuffersIfNeeded() override; >+#else > RefPtr<TextureMapperPlatformLayerProxy> proxy() const override; > void swapBuffersIfNeeded() override; >- void pushTextureToCompositor(); >+#endif > #endif > > GstElement* videoSink() const { return m_videoSink.get(); } >@@ -238,8 +250,12 @@ protected: > RunLoop::Timer<MediaPlayerPrivateGStreamerBase> m_drawTimer; > > #if USE(TEXTURE_MAPPER_GL) >+#if USE(NICOSIA) >+ Ref<Nicosia::ContentLayer> m_contentLayer; >+#else > RefPtr<TextureMapperPlatformLayerProxy> m_platformLayerProxy; > #endif >+#endif > > #if USE(GSTREAMER_GL) > GRefPtr<GstGLContext> m_glContext; >diff --git a/Source/WebCore/platform/graphics/nicosia/NicosiaGC3DLayer.cpp b/Source/WebCore/platform/graphics/nicosia/NicosiaGC3DLayer.cpp >new file mode 100644 >index 00000000000..0d6b5fc0af7 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/nicosia/NicosiaGC3DLayer.cpp >@@ -0,0 +1,70 @@ >+#include "config.h" >+#include "NicosiaGC3DLayer.h" >+ >+#if USE(NICOSIA) >+ >+#if USE(COORDINATED_GRAPHICS_THREADED) >+#include "TextureMapperGL.h" >+#include "TextureMapperPlatformLayerBuffer.h" >+#include "TextureMapperPlatformLayerProxy.h" >+#endif >+ >+#include "GLContext.h" >+ >+namespace Nicosia { >+ >+using namespace WebCore; >+ >+GC3DLayer::GC3DLayer(GraphicsContext3D& context, GraphicsContext3D::RenderStyle renderStyle) >+ : m_context(context) >+ , m_contentLayer(Nicosia::ContentLayer::create(Nicosia::ContentLayerTextureMapperImpl::createFactory(*this))) >+{ >+ switch (renderStyle) { >+ case GraphicsContext3D::RenderOffscreen: >+ m_glContext = GLContext::createOffscreenContext(&PlatformDisplay::sharedDisplayForCompositing()); >+ break; >+ case GraphicsContext3D::RenderDirectlyToHostWindow: >+ ASSERT_NOT_REACHED(); >+ break; >+ } >+} >+ >+GC3DLayer::~GC3DLayer() >+{ >+ downcast<ContentLayerTextureMapperImpl>(m_contentLayer->impl()).invalidateClient(); >+} >+ >+bool GC3DLayer::makeContextCurrent() >+{ >+ ASSERT(m_glContext); >+ return m_glContext->makeContextCurrent(); >+} >+ >+PlatformGraphicsContext3D GC3DLayer::platformContext() >+{ >+ ASSERT(m_glContext); >+ return m_glContext->platformContext(); >+} >+ >+void GC3DLayer::swapBuffersIfNeeded() >+{ >+ if (m_context.layerComposited()) >+ return; >+ >+ m_context.prepareTexture(); >+ IntSize textureSize(m_context.m_currentWidth, m_context.m_currentHeight); >+ TextureMapperGL::Flags flags = TextureMapperGL::ShouldFlipTexture | (m_context.m_attrs.alpha ? TextureMapperGL::ShouldBlend : 0); >+ >+ { >+ auto& proxy = *downcast<Nicosia::ContentLayerTextureMapperImpl>(m_contentLayer->impl()).proxy(); >+ >+ LockHolder holder(proxy.lock()); >+ proxy.pushNextBuffer(std::make_unique<TextureMapperPlatformLayerBuffer>(m_context.m_compositorTexture, textureSize, flags, m_context.m_internalColorFormat)); >+ } >+ >+ m_context.markLayerComposited(); >+} >+ >+} // namespace Nicosia >+ >+#endif // USE(NICOSIA) >diff --git a/Source/WebCore/platform/graphics/nicosia/NicosiaGC3DLayer.h b/Source/WebCore/platform/graphics/nicosia/NicosiaGC3DLayer.h >new file mode 100644 >index 00000000000..7ceb8b68309 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/nicosia/NicosiaGC3DLayer.h >@@ -0,0 +1,36 @@ >+#pragma once >+ >+#if USE(NICOSIA) >+ >+#include "GraphicsContext3D.h" >+#include "NicosiaContentLayerTextureMapperImpl.h" >+#include <memory> >+#include <wtf/RefCounted.h> >+ >+namespace WebCore { >+class GLContext; >+} >+ >+namespace Nicosia { >+ >+class GC3DLayer : public RefCounted<GC3DLayer>, public ContentLayerTextureMapperImpl::Client { >+public: >+ GC3DLayer(WebCore::GraphicsContext3D&, WebCore::GraphicsContext3D::RenderStyle); >+ virtual ~GC3DLayer(); >+ >+ ContentLayer& contentLayer() const { return m_contentLayer; } >+ bool makeContextCurrent(); >+ PlatformGraphicsContext3D platformContext(); >+ >+ void swapBuffersIfNeeded() override; >+ >+private: >+ WebCore::GraphicsContext3D& m_context; >+ std::unique_ptr<WebCore::GLContext> m_glContext; >+ >+ Ref<ContentLayer> m_contentLayer; >+}; >+ >+} // namespace Nicosia >+ >+#endif // USE(NICOSIA) >diff --git a/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.cpp b/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.cpp >index 9b328232c94..f808edd93d8 100644 >--- a/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.cpp >+++ b/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.cpp >@@ -38,11 +38,42 @@ PlatformLayer::PlatformLayer(uint64_t id) > > PlatformLayer::~PlatformLayer() = default; > >-CompositionLayer::CompositionLayer(uint64_t id) >+ >+CompositionLayer::CompositionLayer(uint64_t id, const Impl::Factory& factory) > : PlatformLayer(id) >+ , m_impl(factory(id, *this)) > { > } > > CompositionLayer::~CompositionLayer() = default; >+CompositionLayer::Impl::~Impl() = default; >+ >+ >+BackingStore::BackingStore(const Impl::Factory& factory) >+ : m_impl(factory(*this)) >+{ >+} >+ >+BackingStore::~BackingStore() = default; >+BackingStore::Impl::~Impl() = default; >+ >+ >+ContentLayer::ContentLayer(const Impl::Factory& factory) >+ : PlatformLayer(0) >+ , m_impl(factory(*this)) >+{ >+} >+ >+ContentLayer::~ContentLayer() = default; >+ContentLayer::Impl::~Impl() = default; >+ >+ >+ImageBacking::ImageBacking(const Impl::Factory& factory) >+ : m_impl(factory(*this)) >+{ >+} >+ >+ImageBacking::~ImageBacking() = default; >+ImageBacking::Impl::~Impl() = default; > > } // namespace Nicosia >diff --git a/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.h b/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.h >index c206e9b7441..c16fb881697 100644 >--- a/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.h >+++ b/Source/WebCore/platform/graphics/nicosia/NicosiaPlatformLayer.h >@@ -34,12 +34,20 @@ > #include "FloatPoint3D.h" > #include "FloatRect.h" > #include "FloatSize.h" >+#include "NicosiaSceneIntegration.h" > #include "TextureMapperAnimation.h" > #include "TransformationMatrix.h" >+#include <wtf/Function.h> > #include <wtf/Lock.h> > #include <wtf/ThreadSafeRefCounted.h> > #include <wtf/TypeCasts.h> > >+namespace WebCore { >+#if USE(TEXTURE_MAPPER) >+class TextureMapperPlatformLayerProxy; >+#endif >+} >+ > namespace Nicosia { > > class PlatformLayer : public ThreadSafeRefCounted<PlatformLayer> { >@@ -47,9 +55,31 @@ public: > virtual ~PlatformLayer(); > > virtual bool isCompositionLayer() const { return false; } >+ virtual bool isContentLayer() const { return false; } > > 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); > >@@ -57,19 +87,34 @@ protected: > > struct { > Lock lock; >+ RefPtr<SceneIntegration> sceneIntegration; > } m_state; > }; > >+class ContentLayer; >+class BackingStore; >+class ImageBacking; >+ > class CompositionLayer : public PlatformLayer { > public: >- static Ref<CompositionLayer> create(uint64_t id) >+ class Impl { >+ public: >+ using Factory = WTF::Function<std::unique_ptr<Impl>(uint64_t, CompositionLayer&)>; >+ >+ virtual ~Impl(); >+ virtual bool isTextureMapperImpl() const { return false; } >+ }; >+ >+ static Ref<CompositionLayer> create(uint64_t id, const Impl::Factory& factory) > { >- return adoptRef(*new CompositionLayer(id)); >+ return adoptRef(*new CompositionLayer(id, factory)); > } > virtual ~CompositionLayer(); > > bool isCompositionLayer() const override { return true; } > >+ Impl& impl() const { return *m_impl; } >+ > struct LayerState { > struct Delta { > Delta() = default; >@@ -93,6 +138,10 @@ public: > bool flagsChanged : 1; > bool repaintCounterChanged : 1; > bool debugBorderChanged : 1; >+ >+ bool contentLayerChanged : 1; >+ bool backingStoreChanged : 1; >+ bool imageBackingChanged : 1; > }; > uint32_t value { 0 }; > }; >@@ -149,8 +198,30 @@ public: > float width { 0 }; > bool visible { false }; > } debugBorder; >+ >+ RefPtr<ContentLayer> contentLayer; >+ RefPtr<BackingStore> backingStore; >+ RefPtr<ImageBacking> imageBacking; > }; > >+ 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) > { >@@ -158,14 +229,178 @@ 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: >- explicit CompositionLayer(uint64_t); >+ explicit CompositionLayer(uint64_t, const Impl::Factory&); >+ >+ std::unique_ptr<Impl> m_impl; > > struct { > LayerState pending; >+ LayerState staging; >+ LayerState committed; > } m_state; > }; > >+class ContentLayer : public PlatformLayer { >+public: >+ class Impl { >+ public: >+ using Factory = WTF::Function<std::unique_ptr<Impl>(ContentLayer&)>; >+ >+ virtual ~Impl(); >+ virtual bool isTextureMapperImpl() const { return false; } >+ }; >+ >+ static Ref<ContentLayer> create(const Impl::Factory& factory) >+ { >+ return adoptRef(*new ContentLayer(factory)); >+ } >+ virtual ~ContentLayer(); >+ >+ bool isContentLayer() const override { return true; } >+ >+ Impl& impl() const { return *m_impl; } >+ >+protected: >+ ContentLayer(const Impl::Factory&); >+ >+private: >+ std::unique_ptr<Impl> m_impl; >+}; >+ >+class BackingStore : public ThreadSafeRefCounted<BackingStore> { >+public: >+ class Impl { >+ public: >+ using Factory = WTF::Function<std::unique_ptr<Impl>(BackingStore&)>; >+ >+ virtual ~Impl(); >+ virtual bool isTextureMapperImpl() const { return false; } >+ }; >+ >+ static Ref<BackingStore> create(const Impl::Factory& factory) >+ { >+ return adoptRef(*new BackingStore(factory)); >+ } >+ virtual ~BackingStore(); >+ >+ Impl& impl() const { return *m_impl; } >+ >+protected: >+ BackingStore(const Impl::Factory&); >+ >+private: >+ std::unique_ptr<Impl> m_impl; >+}; >+ >+class ImageBacking : public ThreadSafeRefCounted<ImageBacking> { >+public: >+ class Impl { >+ public: >+ using Factory = WTF::Function<std::unique_ptr<Impl>(ImageBacking&)>; >+ >+ virtual ~Impl(); >+ virtual bool isTextureMapperImpl() const { return false; } >+ }; >+ >+ static Ref<ImageBacking> create(const Impl::Factory& factory) >+ { >+ return adoptRef(*new ImageBacking(factory)); >+ } >+ virtual ~ImageBacking(); >+ >+ Impl& impl() const { return *m_impl; } >+ >+protected: >+ ImageBacking(const Impl::Factory&); >+ >+private: >+ std::unique_ptr<Impl> m_impl; >+}; >+ > } // namespace Nicosia > > #define SPECIALIZE_TYPE_TRAITS_NICOSIA_PLATFORMLAYER(ToClassName, predicate) \ >@@ -174,3 +409,24 @@ private: > SPECIALIZE_TYPE_TRAITS_END() > > SPECIALIZE_TYPE_TRAITS_NICOSIA_PLATFORMLAYER(CompositionLayer, isCompositionLayer()); >+SPECIALIZE_TYPE_TRAITS_NICOSIA_PLATFORMLAYER(ContentLayer, isContentLayer()); >+ >+#define SPECIALIZE_TYPE_TRAITS_NICOSIA_COMPOSITIONLAYER_IMPL(ToClassName, predicate) \ >+ SPECIALIZE_TYPE_TRAITS_BEGIN(Nicosia::ToClassName) \ >+ static bool isType(const Nicosia::CompositionLayer::Impl& impl) { return impl.predicate; } \ >+ SPECIALIZE_TYPE_TRAITS_END() >+ >+#define SPECIALIZE_TYPE_TRAITS_NICOSIA_CONTENTLAYER_IMPL(ToClassName, predicate) \ >+ SPECIALIZE_TYPE_TRAITS_BEGIN(Nicosia::ToClassName) \ >+ static bool isType(const Nicosia::ContentLayer::Impl& impl) { return impl.predicate; } \ >+ SPECIALIZE_TYPE_TRAITS_END() >+ >+#define SPECIALIZE_TYPE_TRAITS_NICOSIA_BACKINGSTORE_IMPL(ToClassName, predicate) \ >+ SPECIALIZE_TYPE_TRAITS_BEGIN(Nicosia::ToClassName) \ >+ static bool isType(const Nicosia::BackingStore::Impl& impl) { return impl.predicate; } \ >+ SPECIALIZE_TYPE_TRAITS_END() >+ >+#define SPECIALIZE_TYPE_TRAITS_NICOSIA_IMAGEBACKING_IMPL(ToClassName, predicate) \ >+ SPECIALIZE_TYPE_TRAITS_BEGIN(Nicosia::ToClassName) \ >+ static bool isType(const Nicosia::ImageBacking::Impl& impl) { return impl.predicate; } \ >+ SPECIALIZE_TYPE_TRAITS_END() >diff --git a/Source/WebCore/platform/graphics/nicosia/NicosiaScene.cpp b/Source/WebCore/platform/graphics/nicosia/NicosiaScene.cpp >new file mode 100644 >index 00000000000..9e00b1d0456 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/nicosia/NicosiaScene.cpp >@@ -0,0 +1,18 @@ >+#include "config.h" >+#include "NicosiaScene.h" >+ >+#if USE(NICOSIA) >+ >+#include "NicosiaPlatformLayer.h" >+ >+namespace Nicosia { >+ >+Scene::Scene() = default; >+Scene::~Scene() = default; >+ >+Scene::State::State() = default; >+Scene::State::~State() = default; >+ >+} >+ >+#endif // USE(NICOSIA) >diff --git a/Source/WebCore/platform/graphics/nicosia/NicosiaScene.h b/Source/WebCore/platform/graphics/nicosia/NicosiaScene.h >new file mode 100644 >index 00000000000..909bd87f3ad >--- /dev/null >+++ b/Source/WebCore/platform/graphics/nicosia/NicosiaScene.h >@@ -0,0 +1,50 @@ >+#pragma once >+ >+#if USE(NICOSIA) >+ >+#include <cstdint> >+#include <wtf/HashSet.h> >+#include <wtf/Lock.h> >+#include <wtf/RefPtr.h> >+#include <wtf/ThreadSafeRefCounted.h> >+ >+namespace Nicosia { >+ >+class CompositionLayer; >+ >+class Scene : public ThreadSafeRefCounted<Scene> { >+public: >+ static Ref<Scene> create() >+ { >+ return adoptRef(*new Scene); >+ } >+ ~Scene(); >+ >+ struct State { >+ State(); >+ ~State(); >+ >+ uint32_t id { 0 }; >+ HashSet<RefPtr<Nicosia::CompositionLayer>> layers; >+ RefPtr<Nicosia::CompositionLayer> rootLayer; >+ }; >+ >+ template<typename F> >+ void accessState(const F& functor) >+ { >+ LockHolder locker(m_scene.lock); >+ functor(m_scene.state); >+ } >+ >+private: >+ Scene(); >+ >+ struct { >+ Lock lock; >+ State state; >+ } m_scene; >+}; >+ >+} >+ >+#endif // USE(NICOSIA) >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/NicosiaCompositionLayerTextureMapperImpl.cpp b/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaCompositionLayerTextureMapperImpl.cpp >new file mode 100644 >index 00000000000..d3e46de717c >--- /dev/null >+++ b/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaCompositionLayerTextureMapperImpl.cpp >@@ -0,0 +1,23 @@ >+#include "config.h" >+#include "NicosiaCompositionLayerTextureMapperImpl.h" >+ >+#if USE(TEXTURE_MAPPER) >+ >+#include "TextureMapperLayer.h" >+ >+namespace Nicosia { >+ >+auto CompositionLayerTextureMapperImpl::createFactory() -> Factory >+{ >+ return Factory( >+ [](uint64_t, CompositionLayer&) { >+ return std::make_unique<CompositionLayerTextureMapperImpl>(); >+ }); >+} >+ >+CompositionLayerTextureMapperImpl::CompositionLayerTextureMapperImpl() = default; >+CompositionLayerTextureMapperImpl::~CompositionLayerTextureMapperImpl() = default; >+ >+} // namespace Nicosia >+ >+#endif // USE(TEXTURE_MAPPER) >diff --git a/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaCompositionLayerTextureMapperImpl.h b/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaCompositionLayerTextureMapperImpl.h >new file mode 100644 >index 00000000000..ccc3e80ccca >--- /dev/null >+++ b/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaCompositionLayerTextureMapperImpl.h >@@ -0,0 +1,35 @@ >+#pragma once >+ >+#if USE(TEXTURE_MAPPER) >+ >+#include "NicosiaPlatformLayer.h" >+#include <memory> >+ >+namespace WebCore { >+class TextureMapperLayer; >+} >+ >+namespace Nicosia { >+ >+class CompositionLayerTextureMapperImpl final : public CompositionLayer::Impl { >+public: >+ static Factory createFactory(); >+ >+ CompositionLayerTextureMapperImpl(); >+ virtual ~CompositionLayerTextureMapperImpl(); >+ bool isTextureMapperImpl() const override { return true; } >+ >+ struct CompositionState { >+ std::unique_ptr<WebCore::TextureMapperLayer> layer; >+ }; >+ CompositionState& compositionState() { return m_compositionState; } >+ >+private: >+ CompositionState m_compositionState; >+}; >+ >+} // namespace Nicosia >+ >+SPECIALIZE_TYPE_TRAITS_NICOSIA_COMPOSITIONLAYER_IMPL(CompositionLayerTextureMapperImpl, isTextureMapperImpl()); >+ >+#endif // USE(TEXTURE_MAPPER) >diff --git a/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp b/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp >new file mode 100644 >index 00000000000..f4c1247b9bd >--- /dev/null >+++ b/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp >@@ -0,0 +1,52 @@ >+#include "config.h" >+#include "NicosiaContentLayerTextureMapperImpl.h" >+ >+#if USE(TEXTURE_MAPPER) >+ >+#include "TextureMapperPlatformLayerProxy.h" >+ >+namespace Nicosia { >+ >+auto ContentLayerTextureMapperImpl::createFactory(Client& client) -> Factory >+{ >+ return Factory( >+ [&client](ContentLayer&) { >+ return std::make_unique<ContentLayerTextureMapperImpl>(client); >+ }); >+} >+ >+ContentLayerTextureMapperImpl::ContentLayerTextureMapperImpl(Client& client) >+ : m_client(&client) >+ , m_proxy(adoptRef(new WebCore::TextureMapperPlatformLayerProxy)) >+{ >+} >+ >+ContentLayerTextureMapperImpl::~ContentLayerTextureMapperImpl() >+{ >+ LockHolder locker(m_lock); >+ ASSERT(!m_client); >+} >+ >+void ContentLayerTextureMapperImpl::invalidateClient() >+{ >+ LockHolder locker(m_lock); >+ m_client = nullptr; >+} >+ >+RefPtr<WebCore::TextureMapperPlatformLayerProxy> ContentLayerTextureMapperImpl::proxy() const >+{ >+ return m_proxy.copyRef(); >+} >+ >+void ContentLayerTextureMapperImpl::swapBuffersIfNeeded() >+{ >+ LockHolder locker(m_lock); >+ if (m_client) >+ m_client->swapBuffersIfNeeded(); >+} >+ >+ContentLayerTextureMapperImpl::Client::~Client() = default; >+ >+} // namespace Nicosia >+ >+#endif // USE(TEXTURE_MAPPER) >diff --git a/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.h b/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.h >new file mode 100644 >index 00000000000..919be3a68e0 >--- /dev/null >+++ b/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.h >@@ -0,0 +1,44 @@ >+#pragma once >+ >+#if USE(TEXTURE_MAPPER) >+ >+#include "NicosiaPlatformLayer.h" >+#include <wtf/Lock.h> >+ >+namespace WebCore { >+class TextureMapperPlatformLayerProxy; >+} >+ >+namespace Nicosia { >+ >+class ContentLayerTextureMapperImpl final : public ContentLayer::Impl { >+public: >+ class Client { >+ public: >+ virtual ~Client(); >+ >+ virtual void swapBuffersIfNeeded() = 0; >+ }; >+ >+ static Factory createFactory(Client&); >+ >+ ContentLayerTextureMapperImpl(Client&); >+ virtual ~ContentLayerTextureMapperImpl(); >+ bool isTextureMapperImpl() const override { return true; } >+ >+ void invalidateClient(); >+ >+ RefPtr<WebCore::TextureMapperPlatformLayerProxy> proxy() const; >+ void swapBuffersIfNeeded(); >+ >+private: >+ Lock m_lock; >+ Client* m_client { nullptr }; >+ RefPtr<WebCore::TextureMapperPlatformLayerProxy> m_proxy; >+}; >+ >+} // namespace Nicosia >+ >+SPECIALIZE_TYPE_TRAITS_NICOSIA_CONTENTLAYER_IMPL(ContentLayerTextureMapperImpl, 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/GraphicsContext3DTextureMapper.cpp b/Source/WebCore/platform/graphics/texmap/GraphicsContext3DTextureMapper.cpp >index a026e8cbbaa..547a6f4fb04 100644 >--- a/Source/WebCore/platform/graphics/texmap/GraphicsContext3DTextureMapper.cpp >+++ b/Source/WebCore/platform/graphics/texmap/GraphicsContext3DTextureMapper.cpp >@@ -53,6 +53,8 @@ > #include "Extensions3DOpenGL.h" > #endif > >+#include "NicosiaGC3DLayer.h" >+ > namespace WebCore { > > static const size_t MaxActiveContexts = 16; >@@ -105,7 +107,11 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3DAttributes attributes, Hos > : m_attrs(attributes) > { > ASSERT_UNUSED(sharedContext, !sharedContext); >+#if USE(NICOSIA) >+ m_contentLayer = adoptRef(*new Nicosia::GC3DLayer(*this, renderStyle)); >+#else > m_texmapLayer = std::make_unique<TextureMapperGC3DPlatformLayer>(*this, renderStyle); >+#endif > > makeContextCurrent(); > >@@ -258,6 +264,12 @@ GraphicsContext3D::~GraphicsContext3D() > > auto* activeContext = activeContexts().takeLast([this](auto* it) { return it == this; }); > ASSERT_UNUSED(activeContext, !!activeContext); >+ >+#if USE(NICOSIA) >+ m_contentLayer = nullptr; >+#else >+ m_texmapLayer = nullptr; >+#endif > } > > void GraphicsContext3D::setContextLostCallback(std::unique_ptr<ContextLostCallback>) >@@ -270,7 +282,11 @@ void GraphicsContext3D::setErrorMessageCallback(std::unique_ptr<ErrorMessageCall > > bool GraphicsContext3D::makeContextCurrent() > { >+#if USE(NICOSIA) >+ return m_contentLayer->makeContextCurrent(); >+#else > return m_texmapLayer->makeContextCurrent(); >+#endif > } > > void GraphicsContext3D::checkGPUStatus() >@@ -279,7 +295,11 @@ void GraphicsContext3D::checkGPUStatus() > > PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D() > { >+#if USE(NICOSIA) >+ return m_contentLayer->platformContext(); >+#else > return m_texmapLayer->platformContext(); >+#endif > } > > Platform3DObject GraphicsContext3D::platformTexture() const >@@ -298,7 +318,11 @@ bool GraphicsContext3D::isGLES2Compliant() const > > PlatformLayer* GraphicsContext3D::platformLayer() const > { >+#if USE(NICOSIA) >+ return &m_contentLayer->contentLayer(); >+#else > return m_texmapLayer.get(); >+#endif > } > > #if PLATFORM(GTK) >diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp >index 6c568e4544c..45a181133c4 100644 >--- a/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp >+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.cpp >@@ -20,7 +20,7 @@ > #include "config.h" > #include "TextureMapperGC3DPlatformLayer.h" > >-#if ENABLE(GRAPHICS_CONTEXT_3D) && USE(TEXTURE_MAPPER) >+#if ENABLE(GRAPHICS_CONTEXT_3D) && USE(TEXTURE_MAPPER) && !USE(NICOSIA) > > #include "BitmapTextureGL.h" > #include "GLContext.h" >diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h b/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h >index bab5036c858..ecb8e9d3604 100644 >--- a/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h >+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperGC3DPlatformLayer.h >@@ -19,7 +19,7 @@ > > #pragma once > >-#if ENABLE(GRAPHICS_CONTEXT_3D) && USE(TEXTURE_MAPPER) >+#if ENABLE(GRAPHICS_CONTEXT_3D) && USE(TEXTURE_MAPPER) && !USE(NICOSIA) > > #include "GraphicsContext3D.h" > #include "PlatformLayer.h" >@@ -31,7 +31,8 @@ namespace WebCore { > class GLContext; > class TextureMapperPlatformLayerProxy; > >-class TextureMapperGC3DPlatformLayer : public PlatformLayer { >+class TextureMapperGC3DPlatformLayer : public TextureMapperPlatformLayerProxyProvider >+{ > public: > TextureMapperGC3DPlatformLayer(GraphicsContext3D&, GraphicsContext3D::RenderStyle); > virtual ~TextureMapperGC3DPlatformLayer(); >diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp >index 196297bd85c..c61b7e759fc 100644 >--- a/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp >+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp >@@ -654,4 +654,22 @@ bool TextureMapperLayer::syncAnimations(MonotonicTime time) > return applicationResults.hasRunningAnimations; > } > >+void TextureMapperLayer::dump(unsigned indentation) >+{ >+ for (unsigned i = 0; i < indentation; ++i) >+ fprintf(stderr, " "); >+ fprintf(stderr, "|-TexMapLayer(%u) position (%.2f,%.2f) anchor (%.2f,%.2f,%.2f) size (%.2f,%.2f) opacity %.2f\n", >+ m_id, m_state.pos.x(), m_state.pos.y(), >+ m_state.anchorPoint.x(), m_state.anchorPoint.y(), m_state.anchorPoint.z(), >+ m_state.size.width(), m_state.size.height(), m_state.opacity); >+ >+ for (unsigned i = 0; i < indentation; ++i) >+ fprintf(stderr, " "); >+ fprintf(stderr, "|--- drawsContent %d contentsAreVisible %d\n", >+ m_state.drawsContent, m_state.contentsVisible); >+ >+ for (auto* child : m_children) >+ child->dump(indentation + 1); >+} >+ > } >diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h b/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h >index ea259ba1006..9257a139755 100644 >--- a/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h >+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h >@@ -97,6 +97,8 @@ public: > > void addChild(TextureMapperLayer*); > >+ void dump(unsigned); >+ > private: > const TextureMapperLayer& rootLayer() const > { >diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp b/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp >index c66e4636200..645202d7b40 100644 >--- a/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp >+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerBuffer.cpp >@@ -30,6 +30,8 @@ > > #include "NotImplemented.h" > >+#include "FloatRect.h" >+ > namespace WebCore { > > TextureMapperPlatformLayerBuffer::TextureMapperPlatformLayerBuffer(RefPtr<BitmapTexture>&& texture, TextureMapperGL::Flags flags) >diff --git a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp >index 98158c753e4..e6400943c98 100644 >--- a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp >+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp >@@ -30,6 +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" >@@ -147,7 +152,8 @@ CoordinatedGraphicsLayer::CoordinatedGraphicsLayer(Type layerType, GraphicsLayer > static CoordinatedLayerID nextLayerID = 1; > m_id = nextLayerID++; > >- m_nicosia.layer = Nicosia::CompositionLayer::create(m_id); >+ m_nicosia.layer = Nicosia::CompositionLayer::create(m_id, >+ Nicosia::CompositionLayerTextureMapperImpl::createFactory()); > } > > CoordinatedGraphicsLayer::~CoordinatedGraphicsLayer() >@@ -158,6 +164,8 @@ CoordinatedGraphicsLayer::~CoordinatedGraphicsLayer() > } > ASSERT(!m_coordinatedImageBacking); > ASSERT(!m_mainBackingStore); >+ ASSERT(!m_nicosia.imageBacking); >+ ASSERT(!m_nicosia.backingStore); > willBeDestroyed(); > } > >@@ -226,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) >@@ -419,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(); >@@ -430,10 +454,20 @@ void CoordinatedGraphicsLayer::setContentsNeedsDisplay() > void CoordinatedGraphicsLayer::setContentsToPlatformLayer(PlatformLayer* platformLayer, ContentsLayerPurpose) > { > #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; > > m_platformLayer = platformLayer; >+#endif > notifyFlushRequired(); > #else > UNUSED_PARAM(platformLayer); >@@ -672,6 +706,7 @@ void CoordinatedGraphicsLayer::syncImageBacking() > m_layerState.imageChanged = true; > } else > releaseImageBackingIfNeeded(); >+ > } > > void CoordinatedGraphicsLayer::syncLayerState() >@@ -740,28 +775,35 @@ void CoordinatedGraphicsLayer::syncAnimations() > > void CoordinatedGraphicsLayer::syncPlatformLayer() > { >-#if USE(COORDINATED_GRAPHICS_THREADED) > if (!m_shouldSyncPlatformLayer) > return; > > m_shouldSyncPlatformLayer = false; >+ >+#if USE(COORDINATED_GRAPHICS_THREADED) >+#if USE(NICOSIA) >+#else > m_layerState.platformLayerChanged = true; > if (m_platformLayer) > m_layerState.platformLayerProxy = m_platformLayer->proxy(); > #endif >+#endif > } > > void CoordinatedGraphicsLayer::updatePlatformLayer() > { >-#if USE(COORDINATED_GRAPHICS_THREADED) > if (!m_shouldUpdatePlatformLayer) > return; > > m_shouldUpdatePlatformLayer = false; >+#if USE(COORDINATED_GRAPHICS_THREADED) >+#if USE(NICOSIA) >+#else > m_layerState.platformLayerUpdated = true; > if (m_platformLayer) > m_platformLayer->swapBuffersIfNeeded(); > #endif >+#endif > } > > void CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly() >@@ -787,6 +829,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) >@@ -843,6 +945,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(); >@@ -912,27 +1021,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(); >@@ -1000,12 +1088,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(); >@@ -1020,14 +1109,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; > } > >@@ -1089,6 +1186,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 >@@ -1096,6 +1286,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(); > >@@ -1314,6 +1512,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 e734509350d..025c1ea42dd 100644 >--- a/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h >+++ b/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsState.h >@@ -38,6 +38,7 @@ > #include "IntSize.h" > #include "NicosiaBuffer.h" > #include "NicosiaPlatformLayer.h" >+#include "NicosiaScene.h" > #include "SurfaceUpdateInfo.h" > #include "TextureMapperAnimation.h" > #include "TransformationMatrix.h" >@@ -170,10 +171,11 @@ struct CoordinatedGraphicsLayerState { > }; > > struct CoordinatedGraphicsState { >+#if USE(NICOSIA) > struct NicosiaState { >- HashSet<RefPtr<Nicosia::CompositionLayer>> layers; >- RefPtr<Nicosia::CompositionLayer> rootLayer; >+ 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..9c0b6307865 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,222 @@ 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) { >+ if (auto proxy = contentLayerImpl(*committed.contentLayer).proxy()) >+ 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) { >+ auto proxy = layerState.contentLayer ? contentLayerImpl(*layerState.contentLayer).proxy() : nullptr; >+ if (proxy) >+ 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); >+ auto proxy = impl.proxy(); >+ if (proxy) >+ commitScope.proxies.add(WTFMove(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 +351,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 d6d56c10d15..9d674855509 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()) > { > } > >@@ -187,8 +187,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 4e04d394dad..2f9ea436be6 100644 >--- a/Source/WebKit/UIProcess/API/wpe/PageClientImpl.h >+++ b/Source/WebKit/UIProcess/API/wpe/PageClientImpl.h >@@ -138,8 +138,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 48d8044135f..94ba2c82b70 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 bf19a319c4b..a1361fd3d92 100644 >--- a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp >+++ b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp >@@ -52,6 +52,8 @@ CompositingCoordinator::CompositingCoordinator(Page* page, CompositingCoordinato > , m_client(client) > , m_paintingEngine(Nicosia::PaintingEngine::create()) > { >+ m_nicosia.scene = Nicosia::Scene::create(); >+ m_state.nicosia.scene = m_nicosia.scene; > } > > CompositingCoordinator::~CompositingCoordinator() >@@ -102,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); >@@ -122,9 +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(); >@@ -172,7 +221,7 @@ void CompositingCoordinator::initializeRootCompositingLayerIfNeeded() > return; > > auto& rootLayer = downcast<CoordinatedGraphicsLayer>(*m_rootLayer); >- m_state.nicosia.rootLayer = rootLayer.compositionLayer(); >+ m_nicosia.state.rootLayer = rootLayer.compositionLayer(); > m_state.rootCompositingLayer = rootLayer.id(); > m_didInitializeRootCompositingLayer = true; > m_shouldSyncFrame = true; >@@ -263,7 +312,7 @@ std::unique_ptr<GraphicsLayer> CompositingCoordinator::createGraphicsLayer(Graph > { > CoordinatedGraphicsLayer* layer = new CoordinatedGraphicsLayer(layerType, client); > layer->setCoordinator(this); >- m_state.nicosia.layers.add(layer->compositionLayer()); >+ m_nicosia.state.layers.add(layer->compositionLayer()); > m_registeredLayers.add(layer->id(), layer); > m_state.layersToCreate.append(layer->id()); > layer->setNeedsVisibleRectAdjustment(); >@@ -304,7 +353,7 @@ void CompositingCoordinator::detachLayer(CoordinatedGraphicsLayer* layer) > if (m_isPurging) > return; > >- m_state.nicosia.layers.remove(layer->compositionLayer()); >+ m_nicosia.state.layers.remove(layer->compositionLayer()); > m_registeredLayers.remove(layer->id()); > > size_t index = m_state.layersToCreate.find(layer->id()); >@@ -320,7 +369,7 @@ void CompositingCoordinator::detachLayer(CoordinatedGraphicsLayer* layer) > void CompositingCoordinator::attachLayer(CoordinatedGraphicsLayer* layer) > { > layer->setCoordinator(this); >- m_state.nicosia.layers.add(layer->compositionLayer()); >+ m_nicosia.state.layers.add(layer->compositionLayer()); > m_registeredLayers.add(layer->id(), layer); > m_state.layersToCreate.append(layer->id()); > layer->setNeedsVisibleRectAdjustment(); >diff --git a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h b/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.h >index 464eb9ee45f..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&); >@@ -128,6 +130,10 @@ private: > WebCore::GraphicsLayer* m_rootCompositingLayer { nullptr }; > WebCore::GraphicsLayer* m_overlayCompositingLayer { nullptr }; > >+ struct { >+ RefPtr<Nicosia::Scene> scene; >+ Nicosia::Scene::State state; >+ } m_nicosia; > WebCore::CoordinatedGraphicsState m_state; > > HashMap<WebCore::CoordinatedLayerID, WebCore::CoordinatedGraphicsLayer*> m_registeredLayers; >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