Changeset 215393 in webkit
- Timestamp:
- Apr 15, 2017 6:15:37 AM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r215392 r215393 1 2017-04-14 Antti Koivisto <antti@apple.com> 2 3 GraphicsLayerCA::recursiveCommitChanges should not descend into subtrees without changes 4 https://bugs.webkit.org/show_bug.cgi?id=170851 5 6 Reviewed by Simon Fraser. 7 8 With lots of layers this can be very slow as it always traverses the entire layer tree. 9 For example GIF animations on tumblr.com trigger expensive commits where almost nothing changes. 10 11 This patch adds m_hasDescendantsWithUncommittedChanges bit to GraphicsLayerCA. With this 12 we can avoid descending to branches without changes when committing. 13 14 * platform/graphics/ca/GraphicsLayerCA.cpp: 15 (WebCore::GraphicsLayerCA::setVisibleAndCoverageRects): 16 17 Do all setting of m_uncommittedChanges bits via addUncommittedChanges function. 18 19 (WebCore::GraphicsLayerCA::recursiveCommitChanges): 20 21 Bail out if neither the current layer nor any of its descendants have any uncommited changes 22 and none of the ancestors had changes. 23 24 (WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers): 25 (WebCore::GraphicsLayerCA::ensureStructuralLayer): 26 (WebCore::GraphicsLayerCA::changeLayerTypeTo): 27 (WebCore::GraphicsLayerCA::addUncommittedChanges): 28 29 Set m_hasDescendantsWithUncommittedChanges bit in ancestors when mutating m_uncommittedChanges. 30 31 (WebCore::GraphicsLayerCA::noteLayerPropertyChanged): 32 * platform/graphics/ca/GraphicsLayerCA.h: 33 (WebCore::RenderLayerCompositor::frameViewDidScroll): 34 35 Tell the scrolling layer that it needs to recompute coverage. 36 This also schedules a layer flush so no need to do that separately. 37 1 38 2017-04-15 Wenson Hsieh <wenson_hsieh@apple.com> 2 39 -
trunk/Source/WebCore/platform/graphics/GraphicsLayer.h
r213466 r215393 566 566 virtual bool isCoordinatedGraphicsLayer() const { return false; } 567 567 568 virtual void setScrollPositionChanged() { } 569 568 570 static void traverse(GraphicsLayer&, std::function<void (GraphicsLayer&)>); 569 571 -
trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
r213466 r215393 1242 1242 } 1243 1243 1244 void GraphicsLayerCA::setScrollPositionChanged() 1245 { 1246 // This invalidates the layer so the coverage rects gets updated. 1247 noteLayerPropertyChanged(ScrollPositionChanged); 1248 } 1249 1244 1250 TransformationMatrix GraphicsLayerCA::layerTransform(const FloatPoint& position, const TransformationMatrix* customTransform) const 1245 1251 { … … 1355 1361 bool intersectsCoverageRect = isViewportConstrained || rects.coverageRect.intersects(FloatRect(m_boundsOrigin, size())); 1356 1362 if (intersectsCoverageRect != m_intersectsCoverageRect) { 1357 m_uncommittedChanges |= CoverageRectChanged;1363 addUncommittedChanges(CoverageRectChanged); 1358 1364 m_intersectsCoverageRect = intersectsCoverageRect; 1359 1365 } 1360 1366 1361 1367 if (visibleRectChanged) { 1362 m_uncommittedChanges |= CoverageRectChanged;1368 addUncommittedChanges(CoverageRectChanged); 1363 1369 m_visibleRect = rects.visibleRect; 1364 1370 } 1365 1371 1366 1372 if (coverageRectChanged) { 1367 m_uncommittedChanges |= CoverageRectChanged;1373 addUncommittedChanges(CoverageRectChanged); 1368 1374 m_coverageRect = rects.coverageRect; 1369 1375 } … … 1374 1380 void GraphicsLayerCA::recursiveCommitChanges(const CommitState& commitState, const TransformState& state, float pageScaleFactor, const FloatPoint& positionRelativeToBase, bool affectedByPageScale) 1375 1381 { 1382 if (!commitState.ancestorHadChanges && !m_uncommittedChanges && !hasDescendantsWithUncommittedChanges()) 1383 return; 1384 1376 1385 TransformState localState = state; 1377 1386 CommitState childCommitState = commitState; 1387 1378 1388 bool affectedByTransformAnimation = commitState.ancestorHasTransformAnimation; 1379 1389 … … 1412 1422 1413 1423 bool hadChanges = m_uncommittedChanges; 1414 1424 1425 // FIXME: This could be more fine-grained. Only some types of changes have impact on sublayers. 1426 if (!childCommitState.ancestorHadChanges) 1427 childCommitState.ancestorHadChanges = hadChanges; 1428 1415 1429 if (appliesPageScale()) { 1416 1430 pageScaleFactor = this->pageScaleFactor(); … … 1450 1464 if (GraphicsLayerCA* maskLayer = downcast<GraphicsLayerCA>(m_maskLayer)) 1451 1465 maskLayer->commitLayerChangesAfterSublayers(childCommitState); 1466 1467 setHasDescendantsWithUncommittedChanges(false); 1452 1468 1453 1469 bool hadDirtyRects = m_uncommittedChanges & DirtyRectsChanged; … … 1565 1581 // Ensure that we cap layer depth in commitLayerChangesAfterSublayers(). 1566 1582 if (commitState.treeDepth > cMaxLayerTreeDepth) 1567 m_uncommittedChanges |= ChildrenChanged;1583 addUncommittedChanges(ChildrenChanged); 1568 1584 } 1569 1585 … … 1707 1723 // Ensure that we cap layer depth in commitLayerChangesAfterSublayers(). 1708 1724 if (commitState.treeDepth > cMaxLayerTreeDepth) 1709 m_uncommittedChanges |= ChildrenChanged;1725 addUncommittedChanges(ChildrenChanged); 1710 1726 } 1711 1727 … … 2117 2133 m_structuralLayer = nullptr; 2118 2134 2119 m_uncommittedChanges |= structuralLayerChangeFlags;2135 addUncommittedChanges(structuralLayerChangeFlags); 2120 2136 } 2121 2137 return; … … 2145 2161 return; 2146 2162 2147 m_uncommittedChanges |= structuralLayerChangeFlags;2163 addUncommittedChanges(structuralLayerChangeFlags); 2148 2164 2149 2165 // We've changed the layer that our parent added to its sublayer list, so tell it to update … … 3616 3632 } 3617 3633 3618 m_uncommittedChanges |=ChildrenChanged3634 addUncommittedChanges(ChildrenChanged 3619 3635 | GeometryChanged 3620 3636 | TransformChanged … … 3632 3648 | OpacityChanged 3633 3649 | NameChanged 3634 | DebugIndicatorsChanged ;3650 | DebugIndicatorsChanged); 3635 3651 3636 3652 if (isTiledLayer) 3637 m_uncommittedChanges |= CoverageRectChanged;3653 addUncommittedChanges(CoverageRectChanged); 3638 3654 3639 3655 moveAnimations(oldLayer.get(), m_layer.get()); … … 4009 4025 } 4010 4026 4027 void GraphicsLayerCA::addUncommittedChanges(LayerChangeFlags flags) 4028 { 4029 m_uncommittedChanges |= flags; 4030 4031 if (m_isCommittingChanges) 4032 return; 4033 4034 for (auto* ancestor = parent(); ancestor; ancestor = ancestor->parent()) { 4035 auto& ancestorCA = static_cast<GraphicsLayerCA&>(*ancestor); 4036 ASSERT(!ancestorCA.m_isCommittingChanges); 4037 if (ancestorCA.hasDescendantsWithUncommittedChanges()) 4038 return; 4039 ancestorCA.setHasDescendantsWithUncommittedChanges(true); 4040 } 4041 } 4042 4043 void GraphicsLayerCA::setHasDescendantsWithUncommittedChanges(bool value) 4044 { 4045 m_hasDescendantsWithUncommittedChanges = value; 4046 } 4047 4011 4048 void GraphicsLayerCA::noteLayerPropertyChanged(LayerChangeFlags flags, ScheduleFlushOrNot scheduleFlush) 4012 4049 { … … 4014 4051 bool oldCanThrottleLayerFlush = canThrottleLayerFlush(); 4015 4052 4016 m_uncommittedChanges |= flags;4053 addUncommittedChanges(flags); 4017 4054 4018 4055 if (scheduleFlush == ScheduleFlush) { -
trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h
r212776 r215393 153 153 struct CommitState { 154 154 int treeDepth { 0 }; 155 bool ancestorHadChanges { false }; 155 156 bool ancestorHasTransformAnimation { false }; 156 157 bool ancestorIsViewportConstrained { false }; … … 164 165 165 166 WEBCORE_EXPORT TiledBacking* tiledBacking() const override; 167 168 WEBCORE_EXPORT void setScrollPositionChanged() override; 166 169 167 170 protected: … … 495 498 WindRuleChanged = 1LLU << 37, 496 499 UserInteractionEnabledChanged = 1LLU << 38, 500 ScrollPositionChanged = 1LLU << 39, 497 501 }; 498 502 typedef uint64_t LayerChangeFlags; 503 void addUncommittedChanges(LayerChangeFlags); 504 bool hasDescendantsWithUncommittedChanges() const { return m_hasDescendantsWithUncommittedChanges; } 505 void setHasDescendantsWithUncommittedChanges(bool); 499 506 enum ScheduleFlushOrNot { ScheduleFlush, DontScheduleFlush }; 500 507 void noteLayerPropertyChanged(LayerChangeFlags, ScheduleFlushOrNot = ScheduleFlush); … … 597 604 LayerChangeFlags m_uncommittedChanges { CoverageRectChanged }; 598 605 #endif 606 bool m_hasDescendantsWithUncommittedChanges { false }; 599 607 600 608 bool m_isCommittingChanges { false }; -
trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp
r215347 r215393 1757 1757 // it will also manage updating the scroll layer position. 1758 1758 if (hasCoordinatedScrolling()) { 1759 // We have to schedule a flush in order for the main TiledBacking to update its tile coverage. 1760 scheduleLayerFlushNow(); 1759 m_scrollLayer->setScrollPositionChanged(); 1761 1760 return; 1762 1761 }
Note: See TracChangeset
for help on using the changeset viewer.