OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/layout/PaintInvalidationState.h" | 5 #include "core/layout/PaintInvalidationState.h" |
6 | 6 |
7 #include "core/layout/LayoutInline.h" | 7 #include "core/layout/LayoutInline.h" |
8 #include "core/layout/LayoutView.h" | 8 #include "core/layout/LayoutView.h" |
9 #include "core/layout/svg/LayoutSVGModelObject.h" | 9 #include "core/layout/svg/LayoutSVGModelObject.h" |
10 #include "core/layout/svg/LayoutSVGRoot.h" | 10 #include "core/layout/svg/LayoutSVGRoot.h" |
11 #include "core/paint/PaintLayer.h" | 11 #include "core/paint/PaintLayer.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 PaintInvalidationState::PaintInvalidationState(const LayoutView& layoutView, Vec
tor<LayoutObject*>& pendingDelayedPaintInvalidations, PaintInvalidationState* ow
nerPaintInvalidationState) | 15 PaintInvalidationState::PaintInvalidationState(const LayoutView& layoutView, Vec
tor<LayoutObject*>& pendingDelayedPaintInvalidations, PaintInvalidationState* ow
nerPaintInvalidationState) |
16 : m_clipped(false) | 16 : m_clipped(false) |
17 , m_cachedOffsetsEnabled(true) | 17 , m_cachedOffsetsEnabled(true) |
18 , m_forcedSubtreeInvalidationWithinContainer(false) | 18 , m_forcedSubtreeInvalidationWithinContainer(false) |
19 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(false) | 19 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(false) |
20 , m_viewClippingAndScrollOffsetDisabled(false) | 20 , m_viewClippingAndScrollOffsetDisabled(false) |
21 , m_paintInvalidationContainer(layoutView.containerForPaintInvalidation()) | 21 , m_paintInvalidationContainer(layoutView.containerForPaintInvalidation()) |
22 , m_pendingDelayedPaintInvalidations(pendingDelayedPaintInvalidations) | 22 , m_pendingDelayedPaintInvalidations(pendingDelayedPaintInvalidations) |
| 23 , m_enclosingLayer(*layoutView.layer()) |
23 { | 24 { |
24 bool establishesPaintInvalidationContainer = layoutView == m_paintInvalidati
onContainer; | 25 bool establishesPaintInvalidationContainer = layoutView == m_paintInvalidati
onContainer; |
25 if (!establishesPaintInvalidationContainer) { | 26 if (!establishesPaintInvalidationContainer) { |
26 if ((ownerPaintInvalidationState && !ownerPaintInvalidationState->m_cach
edOffsetsEnabled) | 27 if ((ownerPaintInvalidationState && !ownerPaintInvalidationState->m_cach
edOffsetsEnabled) |
27 || !layoutView.supportsPaintInvalidationStateCachedOffsets()) { | 28 || !layoutView.supportsPaintInvalidationStateCachedOffsets()) { |
28 m_cachedOffsetsEnabled = false; | 29 m_cachedOffsetsEnabled = false; |
29 return; | 30 return; |
30 } | 31 } |
31 if (ownerPaintInvalidationState && ownerPaintInvalidationState->m_forced
SubtreeInvalidationWithinContainer) | 32 if (ownerPaintInvalidationState && ownerPaintInvalidationState->m_forced
SubtreeInvalidationWithinContainer) |
32 m_forcedSubtreeInvalidationWithinContainer = true; | 33 m_forcedSubtreeInvalidationWithinContainer = true; |
33 FloatPoint point = layoutView.localToAncestorPoint(FloatPoint(), &m_pain
tInvalidationContainer, TraverseDocumentBoundaries); | 34 FloatPoint point = layoutView.localToAncestorPoint(FloatPoint(), &m_pain
tInvalidationContainer, TraverseDocumentBoundaries); |
34 m_paintOffset = LayoutSize(point.x(), point.y()); | 35 m_paintOffset = LayoutSize(point.x(), point.y()); |
35 } | 36 } |
36 m_clipRect = layoutView.viewRect(); | 37 m_clipRect = layoutView.viewRect(); |
37 m_clipRect.move(m_paintOffset); | 38 m_clipRect.move(m_paintOffset); |
38 m_clipped = true; | 39 m_clipped = true; |
39 } | 40 } |
40 | 41 |
41 PaintInvalidationState::PaintInvalidationState(PaintInvalidationState& next, Lay
outBoxModelObject& layoutObject, const LayoutBoxModelObject& paintInvalidationCo
ntainer) | 42 PaintInvalidationState::PaintInvalidationState(PaintInvalidationState& next, Lay
outBoxModelObject& layoutObject, const LayoutBoxModelObject& paintInvalidationCo
ntainer) |
42 : m_clipped(false) | 43 : m_clipped(false) |
43 , m_cachedOffsetsEnabled(true) | 44 , m_cachedOffsetsEnabled(true) |
44 , m_forcedSubtreeInvalidationWithinContainer(next.m_forcedSubtreeInvalidatio
nWithinContainer) | 45 , m_forcedSubtreeInvalidationWithinContainer(next.m_forcedSubtreeInvalidatio
nWithinContainer) |
45 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(next.m_forcedSubtreeI
nvalidationRectUpdateWithinContainer) | 46 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(next.m_forcedSubtreeI
nvalidationRectUpdateWithinContainer) |
46 , m_viewClippingAndScrollOffsetDisabled(false) | 47 , m_viewClippingAndScrollOffsetDisabled(false) |
47 , m_paintInvalidationContainer(paintInvalidationContainer) | 48 , m_paintInvalidationContainer(paintInvalidationContainer) |
48 , m_pendingDelayedPaintInvalidations(next.pendingDelayedPaintInvalidationTar
gets()) | 49 , m_pendingDelayedPaintInvalidations(next.pendingDelayedPaintInvalidationTar
gets()) |
| 50 , m_enclosingLayer(next.enclosingLayer(layoutObject)) |
49 { | 51 { |
50 // FIXME: SVG could probably benefit from a stack-based optimization like ht
ml does. crbug.com/391054 | 52 // FIXME: SVG could probably benefit from a stack-based optimization like ht
ml does. crbug.com/391054 |
51 bool establishesPaintInvalidationContainer = layoutObject == m_paintInvalida
tionContainer; | 53 bool establishesPaintInvalidationContainer = layoutObject == m_paintInvalida
tionContainer; |
52 bool fixed = layoutObject.style()->position() == FixedPosition; | 54 bool fixed = layoutObject.style()->position() == FixedPosition; |
53 | 55 |
54 if (!layoutObject.supportsPaintInvalidationStateCachedOffsets() || !next.m_c
achedOffsetsEnabled) | 56 if (!layoutObject.supportsPaintInvalidationStateCachedOffsets() || !next.m_c
achedOffsetsEnabled) |
55 m_cachedOffsetsEnabled = false; | 57 m_cachedOffsetsEnabled = false; |
56 if (establishesPaintInvalidationContainer) { | 58 if (establishesPaintInvalidationContainer) { |
57 // When we hit a new paint invalidation container, we don't need to | 59 // When we hit a new paint invalidation container, we don't need to |
58 // continue forcing a check for paint invalidation, since we're | 60 // continue forcing a check for paint invalidation, since we're |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 PaintInvalidationState::PaintInvalidationState(PaintInvalidationState& next, con
st LayoutSVGModelObject& layoutObject) | 102 PaintInvalidationState::PaintInvalidationState(PaintInvalidationState& next, con
st LayoutSVGModelObject& layoutObject) |
101 : m_clipped(next.m_clipped) | 103 : m_clipped(next.m_clipped) |
102 , m_cachedOffsetsEnabled(next.m_cachedOffsetsEnabled) | 104 , m_cachedOffsetsEnabled(next.m_cachedOffsetsEnabled) |
103 , m_forcedSubtreeInvalidationWithinContainer(next.m_forcedSubtreeInvalidatio
nWithinContainer) | 105 , m_forcedSubtreeInvalidationWithinContainer(next.m_forcedSubtreeInvalidatio
nWithinContainer) |
104 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(next.m_forcedSubtreeI
nvalidationRectUpdateWithinContainer) | 106 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(next.m_forcedSubtreeI
nvalidationRectUpdateWithinContainer) |
105 , m_viewClippingAndScrollOffsetDisabled(false) | 107 , m_viewClippingAndScrollOffsetDisabled(false) |
106 , m_clipRect(next.m_clipRect) | 108 , m_clipRect(next.m_clipRect) |
107 , m_paintOffset(next.m_paintOffset) | 109 , m_paintOffset(next.m_paintOffset) |
108 , m_paintInvalidationContainer(next.m_paintInvalidationContainer) | 110 , m_paintInvalidationContainer(next.m_paintInvalidationContainer) |
109 , m_pendingDelayedPaintInvalidations(next.pendingDelayedPaintInvalidationTar
gets()) | 111 , m_pendingDelayedPaintInvalidations(next.pendingDelayedPaintInvalidationTar
gets()) |
| 112 , m_enclosingLayer(next.enclosingLayer(layoutObject)) |
110 { | 113 { |
111 ASSERT(layoutObject != m_paintInvalidationContainer); | 114 ASSERT(layoutObject != m_paintInvalidationContainer); |
112 | 115 |
113 if (m_cachedOffsetsEnabled) | 116 if (m_cachedOffsetsEnabled) |
114 m_svgTransform = AffineTransform(next.svgTransform() * layoutObject.loca
lToParentTransform()); | 117 m_svgTransform = AffineTransform(next.svgTransform() * layoutObject.loca
lToParentTransform()); |
115 } | 118 } |
116 | 119 |
117 void PaintInvalidationState::addClipRectRelativeToPaintOffset(const LayoutSize&
clipSize) | 120 void PaintInvalidationState::addClipRectRelativeToPaintOffset(const LayoutSize&
clipSize) |
118 { | 121 { |
119 LayoutRect clipRect(toPoint(m_paintOffset), clipSize); | 122 LayoutRect clipRect(toPoint(m_paintOffset), clipSize); |
(...skipping 15 matching lines...) Expand all Loading... |
135 // Do not clip scroll layer contents because the compositor expects the whol
e layer | 138 // Do not clip scroll layer contents because the compositor expects the whol
e layer |
136 // to be always invalidated in-time. | 139 // to be always invalidated in-time. |
137 if (box.usesCompositedScrolling()) | 140 if (box.usesCompositedScrolling()) |
138 ASSERT(!m_clipped); // The box should establish paint invalidation conta
iner, so no m_clipped inherited. | 141 ASSERT(!m_clipped); // The box should establish paint invalidation conta
iner, so no m_clipped inherited. |
139 else | 142 else |
140 addClipRectRelativeToPaintOffset(LayoutSize(box.layer()->size())); | 143 addClipRectRelativeToPaintOffset(LayoutSize(box.layer()->size())); |
141 | 144 |
142 m_paintOffset -= box.scrolledContentOffset(); | 145 m_paintOffset -= box.scrolledContentOffset(); |
143 } | 146 } |
144 | 147 |
| 148 PaintLayer& PaintInvalidationState::enclosingLayer(const LayoutObject& layoutObj
ect) const |
| 149 { |
| 150 if (layoutObject.hasLayer()) |
| 151 return *toLayoutBoxModelObject(layoutObject).layer(); |
| 152 |
| 153 // During paint invalidation, a multi-column spanner place holder invokes pa
int invalidation of |
| 154 // its layoutObjectInFlowThread (which has a non-null spannerPlaceHolder) di
rectly, skipping the |
| 155 // parent of its layoutObjectInFlowThread which has a PaintLayer. |
| 156 if (layoutObject.spannerPlaceholder()) |
| 157 return *layoutObject.enclosingLayer(); |
| 158 |
| 159 ASSERT(layoutObject.enclosingLayer() == &m_enclosingLayer); |
| 160 return m_enclosingLayer; |
| 161 } |
| 162 |
145 } // namespace blink | 163 } // namespace blink |
OLD | NEW |