Title: [203157] trunk/Source
Revision
203157
Author
[email protected]
Date
2016-07-13 04:00:43 -0700 (Wed, 13 Jul 2016)

Log Message

[Coordinated Graphics] Remove toCoordinatedGraphicsLayer and use downcast instead
https://bugs.webkit.org/show_bug.cgi?id=159469

Reviewed by Michael Catanzaro.

Source/WebCore:

* page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp:
(WebCore::ScrollingCoordinatorCoordinatedGraphics::detachFromStateTree):
(WebCore::ScrollingCoordinatorCoordinatedGraphics::updateViewportConstrainedNode):
(WebCore::ScrollingCoordinatorCoordinatedGraphics::scrollableAreaScrollLayerDidChange):
(WebCore::ScrollingCoordinatorCoordinatedGraphics::willDestroyScrollableArea):
* platform/graphics/GraphicsLayer.h:
(WebCore::GraphicsLayer::isCoordinatedGraphicsLayer):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::toCoordinatedLayerID):
(WebCore::CoordinatedGraphicsLayer::setShouldUpdateVisibleRect):
(WebCore::CoordinatedGraphicsLayer::removeFromParent):
(WebCore::CoordinatedGraphicsLayer::setMaskLayer):
(WebCore::CoordinatedGraphicsLayer::flushCompositingState):
(WebCore::CoordinatedGraphicsLayer::syncPendingStateChangesIncludingSubLayers):
(WebCore::CoordinatedGraphicsLayer::findFirstDescendantWithContentsRecursively):
(WebCore::CoordinatedGraphicsLayer::updateContentBuffersIncludingSubLayers):
(WebCore::CoordinatedGraphicsLayer::computeTransformedVisibleRect):
(WebCore::CoordinatedGraphicsLayer::selfOrAncestorHasActiveTransformAnimation):
(WebCore::CoordinatedGraphicsLayer::selfOrAncestorHaveNonAffineTransforms):
(WebCore::toCoordinatedGraphicsLayer): Deleted.
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:

Source/WebKit2:

* WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp:
(WebKit::CompositingCoordinator::flushPendingLayerChanges):
(WebKit::CompositingCoordinator::initializeRootCompositingLayerIfNeeded):
(WebKit::CompositingCoordinator::mainContentsLayer):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (203156 => 203157)


--- trunk/Source/WebCore/ChangeLog	2016-07-13 10:22:33 UTC (rev 203156)
+++ trunk/Source/WebCore/ChangeLog	2016-07-13 11:00:43 UTC (rev 203157)
@@ -1,3 +1,32 @@
+2016-07-13  Carlos Garcia Campos  <[email protected]>
+
+        [Coordinated Graphics] Remove toCoordinatedGraphicsLayer and use downcast instead
+        https://bugs.webkit.org/show_bug.cgi?id=159469
+
+        Reviewed by Michael Catanzaro.
+
+        * page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp:
+        (WebCore::ScrollingCoordinatorCoordinatedGraphics::detachFromStateTree):
+        (WebCore::ScrollingCoordinatorCoordinatedGraphics::updateViewportConstrainedNode):
+        (WebCore::ScrollingCoordinatorCoordinatedGraphics::scrollableAreaScrollLayerDidChange):
+        (WebCore::ScrollingCoordinatorCoordinatedGraphics::willDestroyScrollableArea):
+        * platform/graphics/GraphicsLayer.h:
+        (WebCore::GraphicsLayer::isCoordinatedGraphicsLayer):
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
+        (WebCore::toCoordinatedLayerID):
+        (WebCore::CoordinatedGraphicsLayer::setShouldUpdateVisibleRect):
+        (WebCore::CoordinatedGraphicsLayer::removeFromParent):
+        (WebCore::CoordinatedGraphicsLayer::setMaskLayer):
+        (WebCore::CoordinatedGraphicsLayer::flushCompositingState):
+        (WebCore::CoordinatedGraphicsLayer::syncPendingStateChangesIncludingSubLayers):
+        (WebCore::CoordinatedGraphicsLayer::findFirstDescendantWithContentsRecursively):
+        (WebCore::CoordinatedGraphicsLayer::updateContentBuffersIncludingSubLayers):
+        (WebCore::CoordinatedGraphicsLayer::computeTransformedVisibleRect):
+        (WebCore::CoordinatedGraphicsLayer::selfOrAncestorHasActiveTransformAnimation):
+        (WebCore::CoordinatedGraphicsLayer::selfOrAncestorHaveNonAffineTransforms):
+        (WebCore::toCoordinatedGraphicsLayer): Deleted.
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
+
 2016-07-12  Youenn Fablet  <[email protected]>
 
         [Fetch API] isRedirected should be conveyed in workers

Modified: trunk/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp (203156 => 203157)


--- trunk/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp	2016-07-13 10:22:33 UTC (rev 203156)
+++ trunk/Source/WebCore/page/scrolling/coordinatedgraphics/ScrollingCoordinatorCoordinatedGraphics.cpp	2016-07-13 11:00:43 UTC (rev 203157)
@@ -63,7 +63,7 @@
 {
     ScrollingStateNode* node = m_scrollingStateTree->stateNodeForID(nodeID);
     if (node && node->nodeType() == FixedNode)
-        toCoordinatedGraphicsLayer(node->layer())->setFixedToViewport(false);
+        downcast<CoordinatedGraphicsLayer>(*static_cast<GraphicsLayer*>(node->layer())).setFixedToViewport(false);
 
     m_scrollingStateTree->detachNode(nodeID);
 }
@@ -83,7 +83,7 @@
 
     switch (constraints.constraintType()) {
     case ViewportConstraints::FixedPositionConstraint: {
-        toCoordinatedGraphicsLayer(graphicsLayer)->setFixedToViewport(true); // FIXME : Use constraints!
+        downcast<CoordinatedGraphicsLayer>(*graphicsLayer).setFixedToViewport(true);
         downcast<ScrollingStateFixedNode>(*node).setLayer(graphicsLayer);
         break;
     }
@@ -96,7 +96,7 @@
 
 void ScrollingCoordinatorCoordinatedGraphics::scrollableAreaScrollLayerDidChange(ScrollableArea& scrollableArea)
 {
-    CoordinatedGraphicsLayer* layer = toCoordinatedGraphicsLayer(scrollLayerForScrollableArea(scrollableArea));
+    CoordinatedGraphicsLayer* layer = downcast<CoordinatedGraphicsLayer>(scrollLayerForScrollableArea(scrollableArea));
     if (!layer)
         return;
 
@@ -105,7 +105,7 @@
 
 void ScrollingCoordinatorCoordinatedGraphics::willDestroyScrollableArea(ScrollableArea& scrollableArea)
 {
-    CoordinatedGraphicsLayer* layer = toCoordinatedGraphicsLayer(scrollLayerForScrollableArea(scrollableArea));
+    CoordinatedGraphicsLayer* layer = downcast<CoordinatedGraphicsLayer>(scrollLayerForScrollableArea(scrollableArea));
     if (!layer)
         return;
 

Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.h (203156 => 203157)


--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.h	2016-07-13 10:22:33 UTC (rev 203156)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.h	2016-07-13 11:00:43 UTC (rev 203157)
@@ -551,6 +551,7 @@
     virtual bool isGraphicsLayerCA() const { return false; }
     virtual bool isGraphicsLayerCARemote() const { return false; }
     virtual bool isGraphicsLayerTextureMapper() const { return false; }
+    virtual bool isCoordinatedGraphicsLayer() const { return false; }
 
 protected:
     WEBCORE_EXPORT explicit GraphicsLayer(Type, GraphicsLayerClient&);

Modified: trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp (203156 => 203157)


--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp	2016-07-13 10:22:33 UTC (rev 203156)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp	2016-07-13 11:00:43 UTC (rev 203157)
@@ -52,7 +52,7 @@
 
 static CoordinatedLayerID toCoordinatedLayerID(GraphicsLayer* layer)
 {
-    return layer ? toCoordinatedGraphicsLayer(layer)->id() : 0;
+    return is<CoordinatedGraphicsLayer>(layer) ? downcast<CoordinatedGraphicsLayer>(*layer).id() : 0;
 }
 
 bool CoordinatedGraphicsLayer::notifyFlushRequired()
@@ -99,9 +99,9 @@
 {
     m_shouldUpdateVisibleRect = true;
     for (auto& child : children())
-        toCoordinatedGraphicsLayer(child)->setShouldUpdateVisibleRect();
+        downcast<CoordinatedGraphicsLayer>(*child).setShouldUpdateVisibleRect();
     if (replicaLayer())
-        toCoordinatedGraphicsLayer(replicaLayer())->setShouldUpdateVisibleRect();
+        downcast<CoordinatedGraphicsLayer>(*replicaLayer()).setShouldUpdateVisibleRect();
 }
 
 void CoordinatedGraphicsLayer::didChangeGeometry()
@@ -197,7 +197,7 @@
 
 void CoordinatedGraphicsLayer::removeFromParent()
 {
-    if (CoordinatedGraphicsLayer* parentLayer = toCoordinatedGraphicsLayer(parent()))
+    if (CoordinatedGraphicsLayer* parentLayer = downcast<CoordinatedGraphicsLayer>(parent()))
         parentLayer->didChangeChildren();
     GraphicsLayer::removeFromParent();
 }
@@ -503,10 +503,10 @@
 
     layer->setSize(size());
     layer->setContentsVisible(contentsAreVisible());
-    CoordinatedGraphicsLayer* coordinatedLayer = toCoordinatedGraphicsLayer(layer);
-    coordinatedLayer->didChangeLayerState();
+    auto& coordinatedLayer = downcast<CoordinatedGraphicsLayer>(*layer);
+    coordinatedLayer.didChangeLayerState();
 
-    m_layerState.mask = coordinatedLayer->id();
+    m_layerState.mask = coordinatedLayer.id();
     m_layerState.maskChanged = true;
 
     didChangeLayerState();
@@ -590,10 +590,10 @@
     if (notifyFlushRequired())
         return;
 
-    if (CoordinatedGraphicsLayer* mask = toCoordinatedGraphicsLayer(maskLayer()))
+    if (CoordinatedGraphicsLayer* mask = downcast<CoordinatedGraphicsLayer>(maskLayer()))
         mask->flushCompositingStateForThisLayerOnly(viewportIsStable);
 
-    if (CoordinatedGraphicsLayer* replica = toCoordinatedGraphicsLayer(replicaLayer()))
+    if (CoordinatedGraphicsLayer* replica = downcast<CoordinatedGraphicsLayer>(replicaLayer()))
         replica->flushCompositingStateForThisLayerOnly(viewportIsStable);
 
     flushCompositingStateForThisLayerOnly(viewportIsStable);
@@ -602,11 +602,6 @@
         child->flushCompositingState(rect, viewportIsStable);
 }
 
-CoordinatedGraphicsLayer* toCoordinatedGraphicsLayer(GraphicsLayer* layer)
-{
-    return static_cast<CoordinatedGraphicsLayer*>(layer);
-}
-
 void CoordinatedGraphicsLayer::syncChildren()
 {
     if (!m_shouldSyncChildren)
@@ -811,10 +806,10 @@
     }
 
     if (maskLayer())
-        toCoordinatedGraphicsLayer(maskLayer())->syncPendingStateChangesIncludingSubLayers();
+        downcast<CoordinatedGraphicsLayer>(*maskLayer()).syncPendingStateChangesIncludingSubLayers();
 
     for (auto& child : children())
-        toCoordinatedGraphicsLayer(child)->syncPendingStateChangesIncludingSubLayers();
+        downcast<CoordinatedGraphicsLayer>(*child).syncPendingStateChangesIncludingSubLayers();
 }
 
 void CoordinatedGraphicsLayer::resetLayerState()
@@ -850,12 +845,11 @@
         return this;
 
     for (auto& child : children()) {
-        CoordinatedGraphicsLayer* layer = toCoordinatedGraphicsLayer(child)->findFirstDescendantWithContentsRecursively();
-        if (layer)
+        if (CoordinatedGraphicsLayer* layer = downcast<CoordinatedGraphicsLayer>(*child).findFirstDescendantWithContentsRecursively())
             return layer;
     }
 
-    return 0;
+    return nullptr;
 }
 
 void CoordinatedGraphicsLayer::setVisibleContentRectTrajectoryVector(const FloatPoint& trajectoryVector)
@@ -989,16 +983,16 @@
 
 void CoordinatedGraphicsLayer::updateContentBuffersIncludingSubLayers()
 {
-    if (CoordinatedGraphicsLayer* mask = toCoordinatedGraphicsLayer(maskLayer()))
+    if (CoordinatedGraphicsLayer* mask = downcast<CoordinatedGraphicsLayer>(maskLayer()))
         mask->updateContentBuffers();
 
-    if (CoordinatedGraphicsLayer* replica = toCoordinatedGraphicsLayer(replicaLayer()))
+    if (CoordinatedGraphicsLayer* replica = downcast<CoordinatedGraphicsLayer>(replicaLayer()))
         replica->updateContentBuffers();
 
     updateContentBuffers();
 
     for (auto& child : children())
-        toCoordinatedGraphicsLayer(child)->updateContentBuffersIncludingSubLayers();
+        downcast<CoordinatedGraphicsLayer>(*child).updateContentBuffersIncludingSubLayers();
 }
 
 void CoordinatedGraphicsLayer::updateContentBuffers()
@@ -1134,7 +1128,7 @@
 
     m_layerTransform.setFlattening(!preserves3D());
     m_layerTransform.setChildrenTransform(childrenTransform());
-    m_layerTransform.combineTransforms(parent() ? toCoordinatedGraphicsLayer(parent())->m_layerTransform.combinedForChildren() : TransformationMatrix());
+    m_layerTransform.combineTransforms(parent() ? downcast<CoordinatedGraphicsLayer>(*parent()).m_layerTransform.combinedForChildren() : TransformationMatrix());
 
     m_cachedInverseTransform = m_layerTransform.combined().inverse().valueOr(TransformationMatrix());
 
@@ -1155,7 +1149,7 @@
     if (!parent())
         return false;
 
-    return toCoordinatedGraphicsLayer(parent())->selfOrAncestorHasActiveTransformAnimation();
+    return downcast<CoordinatedGraphicsLayer>(*parent()).selfOrAncestorHasActiveTransformAnimation();
 }
 
 bool CoordinatedGraphicsLayer::selfOrAncestorHaveNonAffineTransforms()
@@ -1169,7 +1163,7 @@
     if (!parent())
         return false;
 
-    return toCoordinatedGraphicsLayer(parent())->selfOrAncestorHaveNonAffineTransforms();
+    return downcast<CoordinatedGraphicsLayer>(*parent()).selfOrAncestorHaveNonAffineTransforms();
 }
 
 bool CoordinatedGraphicsLayer::addAnimation(const KeyframeValueList& valueList, const FloatSize& boxSize, const Animation* anim, const String& keyframesName, double delayAsNegativeTimeOffset)

Modified: trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h (203156 => 203157)


--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h	2016-07-13 10:22:33 UTC (rev 203156)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h	2016-07-13 11:00:43 UTC (rev 203157)
@@ -149,6 +149,8 @@
     CoordinatedGraphicsLayer* findFirstDescendantWithContentsRecursively();
 
 private:
+    bool isCoordinatedGraphicsLayer() const override { return true; }
+
 #if USE(GRAPHICS_SURFACE)
     enum PendingPlatformLayerOperation {
         None = 0x00,
@@ -255,9 +257,10 @@
     ScrollableArea* m_scrollableArea;
 };
 
-CoordinatedGraphicsLayer* toCoordinatedGraphicsLayer(GraphicsLayer*);
+} // namespace WebCore
 
-} // namespace WebCore
+SPECIALIZE_TYPE_TRAITS_GRAPHICSLAYER(WebCore::CoordinatedGraphicsLayer, isCoordinatedGraphicsLayer())
+
 #endif // USE(COORDINATED_GRAPHICS)
 
 #endif // CoordinatedGraphicsLayer_h

Modified: trunk/Source/WebKit2/ChangeLog (203156 => 203157)


--- trunk/Source/WebKit2/ChangeLog	2016-07-13 10:22:33 UTC (rev 203156)
+++ trunk/Source/WebKit2/ChangeLog	2016-07-13 11:00:43 UTC (rev 203157)
@@ -1,5 +1,17 @@
 2016-07-13  Carlos Garcia Campos  <[email protected]>
 
+        [Coordinated Graphics] Remove toCoordinatedGraphicsLayer and use downcast instead
+        https://bugs.webkit.org/show_bug.cgi?id=159469
+
+        Reviewed by Michael Catanzaro.
+
+        * WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp:
+        (WebKit::CompositingCoordinator::flushPendingLayerChanges):
+        (WebKit::CompositingCoordinator::initializeRootCompositingLayerIfNeeded):
+        (WebKit::CompositingCoordinator::mainContentsLayer):
+
+2016-07-13  Carlos Garcia Campos  <[email protected]>
+
         [GTK] WebKitGtk+ uses too many file descriptors
         https://bugs.webkit.org/show_bug.cgi?id=152316
 

Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp (203156 => 203157)


--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp	2016-07-13 10:22:33 UTC (rev 203156)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp	2016-07-13 11:00:43 UTC (rev 203157)
@@ -106,8 +106,9 @@
 
     bool didSync = m_page->mainFrame().view()->flushCompositingStateIncludingSubframes();
 
-    toCoordinatedGraphicsLayer(m_rootLayer.get())->updateContentBuffersIncludingSubLayers();
-    toCoordinatedGraphicsLayer(m_rootLayer.get())->syncPendingStateChangesIncludingSubLayers();
+    auto& coordinatedLayer = downcast<CoordinatedGraphicsLayer>(*m_rootLayer);
+    coordinatedLayer.updateContentBuffersIncludingSubLayers();
+    coordinatedLayer.syncPendingStateChangesIncludingSubLayers();
 
     flushPendingImageBackingChanges();
 
@@ -177,7 +178,7 @@
     if (m_didInitializeRootCompositingLayer)
         return;
 
-    m_state.rootCompositingLayer = toCoordinatedGraphicsLayer(m_rootLayer.get())->id();
+    m_state.rootCompositingLayer = downcast<CoordinatedGraphicsLayer>(*m_rootLayer).id();
     m_didInitializeRootCompositingLayer = true;
     m_shouldSyncFrame = true;
 }
@@ -302,10 +303,10 @@
 
 CoordinatedGraphicsLayer* CompositingCoordinator::mainContentsLayer()
 {
-    if (!m_rootCompositingLayer)
-        return 0;
+    if (!is<CoordinatedGraphicsLayer>(m_rootCompositingLayer))
+        return nullptr;
 
-    return toCoordinatedGraphicsLayer(m_rootCompositingLayer)->findFirstDescendantWithContentsRecursively();
+    return downcast<CoordinatedGraphicsLayer>(*m_rootCompositingLayer).findFirstDescendantWithContentsRecursively();
 }
 
 void CompositingCoordinator::setVisibleContentsRect(const FloatRect& rect, const FloatPoint& trajectoryVector)

Modified: trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp (203156 => 203157)


--- trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp	2016-07-13 10:22:33 UTC (rev 203156)
+++ trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp	2016-07-13 11:00:43 UTC (rev 203157)
@@ -66,7 +66,7 @@
 {
     m_coordinator.createRootLayer(m_webPage.size());
 #if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
-    m_layerTreeContext.contextID = toCoordinatedGraphicsLayer(m_coordinator.rootLayer())->id();
+    m_layerTreeContext.contextID = downcast<CoordinatedGraphicsLayer>(*m_coordinator.rootLayer()).id();
 #endif
 
     CoordinatedSurface::setFactory(createCoordinatedSurface);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to