Changeset 220479 in webkit
- Timestamp:
- Aug 9, 2017 2:03:03 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r220478 r220479 1 2017-08-09 Dave Hyatt <hyatt@apple.com> 2 3 [Repaint from Layout Removal] Move layer repaint rects into a map 4 https://bugs.webkit.org/show_bug.cgi?id=175393 5 6 Reviewed by Zalan Bujtas. 7 8 Move the two repaint rects held by RenderLayer into a RenderLayerModelObject -> RepaintLayoutRects hash map. 9 RepaintLayoutRects is a new struct that holds both rects. 10 11 Eventually more objects than just self painting layers will be caching repaint rects, so this takes a first 12 step towards having a common cache for these repaint rects. In addition this change saves memory, since 13 layers that aren't self-painting no longer have empty repaint rects taking up space in RenderLayer. 14 15 * rendering/RenderBlockLineLayout.cpp: 16 (WebCore::RenderBlockFlow::layoutRunsAndFloats): 17 * rendering/RenderLayer.cpp: 18 (WebCore::RenderLayer::RenderLayer): 19 (WebCore::RenderLayer::updateLayerPositions): 20 (WebCore::RenderLayer::repaintRectIncludingNonCompositingDescendants): 21 (WebCore::RenderLayer::computeRepaintRects): 22 (WebCore::RenderLayer::clearRepaintRects): 23 (WebCore::RenderLayer::updateLayerPositionsAfterScroll): 24 (WebCore::RenderLayer::scrollTo): 25 * rendering/RenderLayer.h: 26 * rendering/RenderLayerModelObject.cpp: 27 (WebCore::RepaintLayoutRects::RepaintLayoutRects): 28 (WebCore::RenderLayerModelObject::willBeDestroyed): 29 (WebCore::RenderLayerModelObject::destroyLayer): 30 (WebCore::RenderLayerModelObject::styleDidChange): 31 (WebCore::RenderLayerModelObject::hasRepaintLayoutRects): 32 (WebCore::RenderLayerModelObject::setRepaintLayoutRects): 33 (WebCore::RenderLayerModelObject::clearRepaintLayoutRects): 34 (WebCore::RenderLayerModelObject::repaintLayoutRects): 35 (WebCore::RenderLayerModelObject::computeRepaintLayoutRects): 36 * rendering/RenderLayerModelObject.h: 37 (WebCore::RepaintLayoutRects::RepaintLayoutRects): 38 1 39 2017-08-09 Sam Weinig <sam@webkit.org> 2 40 -
trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp
r219190 r220479 1282 1282 if (layoutState.isFullLayout() && hasInlineChild && !selfNeedsLayout()) { 1283 1283 setNeedsLayout(MarkOnlyThis); // Mark as needing a full layout to force us to repaint. 1284 if (!view().doingFullRepaint() && hasSelfPaintingLayer() && layer()->hasComputedRepaintRect()) {1284 if (!view().doingFullRepaint() && hasSelfPaintingLayer() && hasRepaintLayoutRects()) { 1285 1285 // Because we waited until we were already inside layout to discover 1286 1286 // that the block really needed a full layout, we missed our chance to repaint the layer 1287 1287 // before layout started. Luckily the layer has cached the repaint rect for its original 1288 1288 // position and size, and so we can use that to make a repaint happen now. 1289 repaintUsingContainer(containerForRepaint(), layer()->repaintRect());1289 repaintUsingContainer(containerForRepaint(), repaintLayoutRects().m_repaintRect); 1290 1290 } 1291 1291 } -
trunk/Source/WebCore/rendering/RenderLayer.cpp
r219961 r220479 311 311 #endif 312 312 , m_hasFilterInfo(false) 313 , m_hasComputedRepaintRect(false)314 313 #if ENABLE(CSS_COMPOSITING) 315 314 , m_blendMode(BlendModeNormal) … … 517 516 518 517 RenderLayerModelObject* repaintContainer = renderer().containerForRepaint(); 519 LayoutRect oldRepaintRect = m_repaintRect; 520 LayoutRect oldOutlineBox = m_outlineBox; 518 519 auto hadRepaintLayoutRects = renderer().hasRepaintLayoutRects(); 520 RepaintLayoutRects oldRects = hadRepaintLayoutRects ? renderer().repaintLayoutRects() : RepaintLayoutRects(); 521 521 computeRepaintRects(repaintContainer, geometryMap); 522 522 523 auto hasRepaintLayoutRects = renderer().hasRepaintLayoutRects(); 524 RepaintLayoutRects newRects = hasRepaintLayoutRects ? renderer().repaintLayoutRects() : RepaintLayoutRects(); 523 525 // FIXME: Should ASSERT that value calculated for m_outlineBox using the cached offset is the same 524 526 // as the value not using the cached offset, but we can't due to https://bugs.webkit.org/show_bug.cgi?id=37048 525 if ((flags & CheckForRepaint) && m_hasComputedRepaintRect) {527 if ((flags & CheckForRepaint) && hasRepaintLayoutRects) { 526 528 if (!renderer().view().printing()) { 527 529 bool didRepaint = false; 528 530 if (m_repaintStatus & NeedsFullRepaint) { 529 renderer().repaintUsingContainer(repaintContainer, oldRepaintRect); 530 if (m_repaintRect != oldRepaintRect) { 531 renderer().repaintUsingContainer(repaintContainer, m_repaintRect); 531 if (hadRepaintLayoutRects) 532 renderer().repaintUsingContainer(repaintContainer, oldRects.m_repaintRect); 533 if (!hadRepaintLayoutRects || newRects.m_repaintRect != oldRects.m_repaintRect) { 534 renderer().repaintUsingContainer(repaintContainer, newRects.m_repaintRect); 532 535 didRepaint = true; 533 536 } 534 537 } else if (shouldRepaintAfterLayout()) { 535 renderer().repaintAfterLayoutIfNeeded(repaintContainer, oldRepaintRect, oldOutlineBox, &m_repaintRect, &m_outlineBox); 538 // FIXME: We will convert this to just take the old and new RepaintLayoutRects once 539 // we change other callers to use RepaintLayoutRects. 540 renderer().repaintAfterLayoutIfNeeded(repaintContainer, oldRects.m_repaintRect, oldRects.m_outlineBox, &newRects.m_repaintRect, &newRects.m_outlineBox); 536 541 didRepaint = true; 537 542 } … … 602 607 LayoutRect RenderLayer::repaintRectIncludingNonCompositingDescendants() const 603 608 { 604 LayoutRect repaintRect = m_repaintRect;609 LayoutRect repaintRect = renderer().repaintLayoutRects().m_repaintRect; 605 610 for (RenderLayer* child = firstChild(); child; child = child->nextSibling()) { 606 611 // Don't include repaint rects for composited child layers; they will paint themselves and have a different origin. … … 798 803 { 799 804 ASSERT(!m_visibleContentStatusDirty); 800 801 if (!isSelfPaintingLayer()) { 802 clearRepaintRects(); 803 return; 804 } 805 806 m_hasComputedRepaintRect = true; 807 m_repaintRect = renderer().clippedOverflowRectForRepaint(repaintContainer); 808 m_outlineBox = renderer().outlineBoundsForRepaint(repaintContainer, geometryMap); 809 } 810 805 renderer().computeRepaintLayoutRects(repaintContainer, geometryMap); 806 } 811 807 812 808 void RenderLayer::computeRepaintRectsIncludingDescendants() … … 825 821 ASSERT(!m_visibleContentStatusDirty); 826 822 827 m_hasComputedRepaintRect = false; 828 m_repaintRect = LayoutRect(); 829 m_outlineBox = LayoutRect(); 823 renderer().clearRepaintLayoutRects(); 830 824 } 831 825 … … 890 884 } else { 891 885 // Check that our cached rects are correct. 892 ASSERT(! m_hasComputedRepaintRect || (m_repaintRect == renderer().clippedOverflowRectForRepaint(renderer().containerForRepaint())));893 ASSERT(! m_hasComputedRepaintRect ||m_outlineBox == renderer().outlineBoundsForRepaint(renderer().containerForRepaint()));886 ASSERT(!renderer().hasRepaintLayoutRects() || renderer().repaintLayoutRects().m_repaintRect == renderer().clippedOverflowRectForRepaint(renderer().containerForRepaint())); 887 ASSERT(!renderer().hasRepaintLayoutRects() || renderer().repaintLayoutRects().m_outlineBox == renderer().outlineBoundsForRepaint(renderer().containerForRepaint())); 894 888 } 895 889 … … 2441 2435 frame.selection().setCaretRectNeedsUpdate(); 2442 2436 2443 LayoutRect rectForRepaint = m_hasComputedRepaintRect ?m_repaintRect : renderer().clippedOverflowRectForRepaint(repaintContainer);2437 LayoutRect rectForRepaint = renderer().hasRepaintLayoutRects() ? renderer().repaintLayoutRects().m_repaintRect : renderer().clippedOverflowRectForRepaint(repaintContainer); 2444 2438 2445 2439 FloatQuad quadForFakeMouseMoveEvent = FloatQuad(rectForRepaint); -
trunk/Source/WebCore/rendering/RenderLayer.h
r218396 r220479 582 582 583 583 // Return a cached repaint rect, computed relative to the layer renderer's containerForRepaint. 584 bool hasComputedRepaintRect() const { return m_hasComputedRepaintRect; } 585 LayoutRect repaintRect() const { ASSERT(hasComputedRepaintRect()); return m_repaintRect; } 584 bool hasComputedRepaintRects() const { return renderer().hasRepaintLayoutRects(); } 586 585 LayoutRect repaintRectIncludingNonCompositingDescendants() const; 587 586 … … 1116 1115 1117 1116 bool m_hasFilterInfo : 1; 1118 1119 bool m_hasComputedRepaintRect : 1;1120 1117 1121 1118 #if ENABLE(CSS_COMPOSITING) … … 1133 1130 RenderLayer* m_first; 1134 1131 RenderLayer* m_last; 1135 1136 LayoutRect m_repaintRect; // Cached repaint rects. Used by layout.1137 LayoutRect m_outlineBox;1138 1132 1139 1133 // Our current relative position offset. -
trunk/Source/WebCore/rendering/RenderLayerModelObject.cpp
r214173 r220479 39 39 bool RenderLayerModelObject::s_layerWasSelfPainting = false; 40 40 41 typedef WTF::HashMap<const RenderLayerModelObject*, RepaintLayoutRects> RepaintLayoutRectsMap; 42 static RepaintLayoutRectsMap* gRepaintLayoutRectsMap = nullptr; 43 44 RepaintLayoutRects::RepaintLayoutRects(const RenderLayerModelObject& renderer, const RenderLayerModelObject* repaintContainer, const RenderGeometryMap* geometryMap) 45 : m_repaintRect(renderer.clippedOverflowRectForRepaint(repaintContainer)) 46 , m_outlineBox(renderer.outlineBoundsForRepaint(repaintContainer, geometryMap)) 47 { 48 } 49 41 50 RenderLayerModelObject::RenderLayerModelObject(Element& element, RenderStyle&& style, BaseTypeFlags baseTypeFlags) 42 51 : RenderElement(element, WTFMove(style), baseTypeFlags | RenderLayerModelObjectFlag) … … 62 71 63 72 RenderElement::willBeDestroyed(); 64 73 74 clearRepaintLayoutRects(); 75 65 76 // Our layer should have been destroyed and cleared by now 66 77 ASSERT(!hasLayer()); … … 72 83 ASSERT(!hasLayer()); // Callers should have already called setHasLayer(false) 73 84 ASSERT(m_layer); 85 if (m_layer->isSelfPaintingLayer()) 86 clearRepaintLayoutRects(); 74 87 m_layer = nullptr; 75 88 } … … 167 180 setHasReflection(false); 168 181 // Repaint the about to be destroyed self-painting layer when style change also triggers repaint. 169 if (layer()->isSelfPaintingLayer() && layer()->repaintStatus() == NeedsFullRepaint && layer()->hasComputedRepaintRect())170 repaintUsingContainer(containerForRepaint(), layer()->repaintRect());182 if (layer()->isSelfPaintingLayer() && layer()->repaintStatus() == NeedsFullRepaint && hasRepaintLayoutRects()) 183 repaintUsingContainer(containerForRepaint(), repaintLayoutRects().m_repaintRect); 171 184 layer()->removeOnlyThisLayer(); // calls destroyLayer() which clears m_layer 172 185 if (s_wasFloating && isFloating()) … … 236 249 } 237 250 251 bool RenderLayerModelObject::hasRepaintLayoutRects() const 252 { 253 return gRepaintLayoutRectsMap && gRepaintLayoutRectsMap->contains(this); 254 } 255 256 void RenderLayerModelObject::setRepaintLayoutRects(const RepaintLayoutRects& rects) 257 { 258 if (!gRepaintLayoutRectsMap) 259 gRepaintLayoutRectsMap = new RepaintLayoutRectsMap(); 260 gRepaintLayoutRectsMap->set(this, rects); 261 } 262 263 void RenderLayerModelObject::clearRepaintLayoutRects() 264 { 265 if (gRepaintLayoutRectsMap) 266 gRepaintLayoutRectsMap->remove(this); 267 } 268 269 RepaintLayoutRects RenderLayerModelObject::repaintLayoutRects() const 270 { 271 if (!hasRepaintLayoutRects()) 272 return RepaintLayoutRects(); 273 return gRepaintLayoutRectsMap->get(this); 274 } 275 276 void RenderLayerModelObject::computeRepaintLayoutRects(const RenderLayerModelObject* repaintContainer, const RenderGeometryMap* geometryMap) 277 { 278 if (!m_layer || !m_layer->isSelfPaintingLayer()) 279 clearRepaintLayoutRects(); 280 else 281 setRepaintLayoutRects(RepaintLayoutRects(*this, repaintContainer, geometryMap)); 282 } 283 238 284 } // namespace WebCore 239 285 -
trunk/Source/WebCore/rendering/RenderLayerModelObject.h
r214173 r220479 29 29 class RenderLayer; 30 30 31 struct RepaintLayoutRects { 32 LayoutRect m_repaintRect; // This rect is clipped by enclosing objects (e.g., overflow:hidden). 33 LayoutRect m_outlineBox; // This rect is unclipped. 34 35 RepaintLayoutRects(const RenderLayerModelObject& renderer, const RenderLayerModelObject* repaintContainer, const RenderGeometryMap* = nullptr); 36 RepaintLayoutRects() { }; 37 }; 38 31 39 class RenderLayerModelObject : public RenderElement { 32 40 public: … … 52 60 53 61 bool shouldPlaceBlockDirectionScrollbarOnLeft() const; 62 63 void computeRepaintLayoutRects(const RenderLayerModelObject* repaintContainer, const RenderGeometryMap* = nullptr); 64 65 RepaintLayoutRects repaintLayoutRects() const; 66 67 bool hasRepaintLayoutRects() const; 68 void setRepaintLayoutRects(const RepaintLayoutRects&); 69 void clearRepaintLayoutRects(); 54 70 55 71 protected:
Note: See TracChangeset
for help on using the changeset viewer.