Changeset 261592 in webkit
- Timestamp:
- May 12, 2020 5:17:40 PM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r261588 r261592 1 2020-05-12 Simon Fraser <simon.fraser@apple.com> 2 3 Move perspective-setting code into its own function 4 https://bugs.webkit.org/show_bug.cgi?id=211812 5 6 Reviewed by Zalan Bujtas. 7 8 Move the code that updates anchor point and children transform (for perspective) 9 into its own function. 10 11 No behavior change. 12 13 * rendering/RenderLayerBacking.cpp: 14 (WebCore::RenderLayerBacking::updateChildrenTransformAndAnchorPoint): 15 (WebCore::computeOffsetFromAncestorGraphicsLayer): 16 (WebCore::RenderLayerBacking::updateGeometry): 17 * rendering/RenderLayerBacking.h: 18 1 19 2020-05-12 Jiewen Tan <jiewen_tan@apple.com> 2 20 -
trunk/Source/WebCore/rendering/RenderLayerBacking.cpp
r261585 r261592 618 618 } 619 619 620 void RenderLayerBacking::updateChildrenTransformAndAnchorPoint(const LayoutRect& primaryGraphicsLayerRect, LayoutSize offsetFromParentGraphicsLayer) 621 { 622 if (!renderer().hasTransformRelatedProperty()) { 623 auto defaultAnchorPoint = FloatPoint3D { 0.5, 0.5, 0 }; 624 m_graphicsLayer->setAnchorPoint(defaultAnchorPoint); 625 if (m_contentsContainmentLayer) 626 m_contentsContainmentLayer->setAnchorPoint(defaultAnchorPoint); 627 return; 628 } 629 630 const auto deviceScaleFactor = this->deviceScaleFactor(); 631 auto borderBoxRect = downcast<RenderBox>(renderer()).borderBoxRect(); 632 auto transformOrigin = computeTransformOriginForPainting(borderBoxRect); 633 auto layerOffset = roundPointToDevicePixels(toLayoutPoint(offsetFromParentGraphicsLayer), deviceScaleFactor); 634 auto anchor = FloatPoint3D { 635 primaryGraphicsLayerRect.width() ? ((layerOffset.x() - primaryGraphicsLayerRect.x()) + transformOrigin.x()) / primaryGraphicsLayerRect.width() : 0.5f, 636 primaryGraphicsLayerRect.height() ? ((layerOffset.y() - primaryGraphicsLayerRect.y())+ transformOrigin.y()) / primaryGraphicsLayerRect.height() : 0.5f, 637 transformOrigin.z() 638 }; 639 640 if (m_contentsContainmentLayer) 641 m_contentsContainmentLayer->setAnchorPoint(anchor); 642 else 643 m_graphicsLayer->setAnchorPoint(anchor); 644 645 auto* clipLayer = clippingLayer(); 646 if (!renderer().style().hasPerspective()) { 647 if (clipLayer) 648 clipLayer->setChildrenTransform({ }); 649 else 650 m_graphicsLayer->setChildrenTransform({ }); 651 return; 652 } 653 654 // FIXME: borderBoxRect isn't quite right here. This needs work: webkit.org/b/211787. 655 auto perspectiveTransform = owningLayer().perspectiveTransform(borderBoxRect); 656 if (clipLayer) { 657 clipLayer->setChildrenTransform(perspectiveTransform); 658 m_graphicsLayer->setChildrenTransform({ }); 659 } else 660 m_graphicsLayer->setChildrenTransform(perspectiveTransform); 661 } 662 620 663 void RenderLayerBacking::updateFilters(const RenderStyle& style) 621 664 { … … 1041 1084 return toLayoutSize(location); 1042 1085 1043 // FIXME: This is a workaround until after webkit.org/ 162634 gets fixed. ancestorSubpixelOffsetFromRenderer1086 // FIXME: This is a workaround until after webkit.org/b/162634 gets fixed. ancestorSubpixelOffsetFromRenderer 1044 1087 // could be stale when a dynamic composited state change triggers a pre-order updateGeometry() traversal. 1045 1088 LayoutSize ancestorSubpixelOffsetFromRenderer = compositedAncestor->backing()->subpixelOffsetFromRenderer(); … … 1294 1337 updateMaskingLayerGeometry(); 1295 1338 1296 if (renderer().hasTransformRelatedProperty()) { 1297 // Update properties that depend on layer dimensions. 1298 auto borderBoxRect = downcast<RenderBox>(renderer()).borderBoxRect(); 1299 FloatPoint3D transformOrigin = computeTransformOriginForPainting(borderBoxRect); 1300 FloatPoint layerOffset = roundPointToDevicePixels(toLayoutPoint(rendererOffset.fromParentGraphicsLayer()), deviceScaleFactor); 1301 // Compute the anchor point, which is in the center of the renderer box unless transform-origin is set. 1302 FloatPoint3D anchor( 1303 primaryGraphicsLayerRect.width() ? ((layerOffset.x() - primaryGraphicsLayerRect.x()) + transformOrigin.x()) / primaryGraphicsLayerRect.width() : 0.5, 1304 primaryGraphicsLayerRect.height() ? ((layerOffset.y() - primaryGraphicsLayerRect.y())+ transformOrigin.y()) / primaryGraphicsLayerRect.height() : 0.5, 1305 transformOrigin.z()); 1306 1307 if (m_contentsContainmentLayer) 1308 m_contentsContainmentLayer->setAnchorPoint(anchor); 1309 else 1310 m_graphicsLayer->setAnchorPoint(anchor); 1311 1312 auto* clipLayer = clippingLayer(); 1313 if (style.hasPerspective()) { 1314 // FIXME: borderBoxRect isn't quite right here. This needs work: webkit.org/b/211787. 1315 TransformationMatrix t = owningLayer().perspectiveTransform(borderBoxRect); 1316 1317 if (clipLayer) { 1318 clipLayer->setChildrenTransform(t); 1319 m_graphicsLayer->setChildrenTransform(TransformationMatrix()); 1320 } 1321 else 1322 m_graphicsLayer->setChildrenTransform(t); 1323 } else { 1324 if (clipLayer) 1325 clipLayer->setChildrenTransform(TransformationMatrix()); 1326 else 1327 m_graphicsLayer->setChildrenTransform(TransformationMatrix()); 1328 } 1329 } else { 1330 m_graphicsLayer->setAnchorPoint(FloatPoint3D(0.5, 0.5, 0)); 1331 if (m_contentsContainmentLayer) 1332 m_contentsContainmentLayer->setAnchorPoint(FloatPoint3D(0.5, 0.5, 0)); 1333 } 1339 updateChildrenTransformAndAnchorPoint(primaryGraphicsLayerRect, rendererOffset.fromParentGraphicsLayer()); 1334 1340 1335 1341 if (m_owningLayer.reflectionLayer() && m_owningLayer.reflectionLayer()->isComposited()) { -
trunk/Source/WebCore/rendering/RenderLayerBacking.h
r260808 r261592 330 330 void updateOpacity(const RenderStyle&); 331 331 void updateTransform(const RenderStyle&); 332 void updateChildrenTransformAndAnchorPoint(const LayoutRect& primaryGraphicsLayerRect, LayoutSize offsetFromParentGraphicsLayer); 332 333 void updateFilters(const RenderStyle&); 333 334 #if ENABLE(FILTERS_LEVEL_2)
Note: See TracChangeset
for help on using the changeset viewer.