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 #ifndef PaintInvalidationState_h | 5 #ifndef PaintInvalidationState_h |
6 #define PaintInvalidationState_h | 6 #define PaintInvalidationState_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "platform/geometry/LayoutRect.h" | 9 #include "platform/geometry/LayoutRect.h" |
10 #include "platform/graphics/PaintInvalidationReason.h" | 10 #include "platform/graphics/PaintInvalidationReason.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 // PaintInvalidationState is an optimization used during the paint | 28 // PaintInvalidationState is an optimization used during the paint |
29 // invalidation phase. | 29 // invalidation phase. |
30 // | 30 // |
31 // This class is extremely close to LayoutState so see the documentation | 31 // This class is extremely close to LayoutState so see the documentation |
32 // of LayoutState for the class existence and performance benefits. | 32 // of LayoutState for the class existence and performance benefits. |
33 // | 33 // |
34 // The main difference with LayoutState is that it was customized for the | 34 // The main difference with LayoutState is that it was customized for the |
35 // needs of the paint invalidation systems (keeping visual rectangles | 35 // needs of the paint invalidation systems (keeping visual rectangles |
36 // instead of layout specific information). | 36 // instead of layout specific information). |
37 // | 37 // |
38 // See Source/core/paint/README.md ### PaintInvalidationState for more details. | 38 // See Source/core/paint/README.md#Paint-invalidation for more details. |
39 | 39 |
40 class CORE_EXPORT PaintInvalidationState { | 40 class CORE_EXPORT PaintInvalidationState { |
41 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 41 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
42 WTF_MAKE_NONCOPYABLE(PaintInvalidationState); | 42 WTF_MAKE_NONCOPYABLE(PaintInvalidationState); |
43 public: | 43 public: |
44 PaintInvalidationState(const PaintInvalidationState& parentState, const Layo
utObject&); | 44 PaintInvalidationState(const PaintInvalidationState& parentState, const Layo
utObject&); |
45 | 45 |
46 // For root LayoutView, or when sub-frame LayoutView's invalidateTreeIfNeede
d() is called directly from | 46 // For root LayoutView, or when sub-frame LayoutView's invalidateTreeIfNeede
d() is called directly from |
47 // FrameView::invalidateTreeIfNeededRecursive() instead of the owner LayoutP
art. | 47 // FrameView::invalidateTreeIfNeededRecursive() instead of the owner LayoutP
art. |
48 // TODO(wangxianzhu): Eliminate the latter case. | 48 // TODO(wangxianzhu): Eliminate the latter case. |
49 PaintInvalidationState(const LayoutView&, Vector<LayoutObject*>& pendingDela
yedPaintInvalidations); | 49 PaintInvalidationState(const LayoutView&, Vector<const LayoutObject*>& pendi
ngDelayedPaintInvalidations); |
50 | 50 |
51 // When a PaintInvalidationState is constructed, it can be used to map point
s/rects in the object's | 51 // When a PaintInvalidationState is constructed, it can be used to map point
s/rects in the object's |
52 // local space (border box space for LayoutBoxes). After invalidation of the
current object, | 52 // local space (border box space for LayoutBoxes). After invalidation of the
current object, |
53 // before invalidation of the subtrees, this method must be called to apply
clip and scroll offset | 53 // before invalidation of the subtrees, this method must be called to apply
clip and scroll offset |
54 // etc. for creating child PaintInvalidationStates. | 54 // etc. for creating child PaintInvalidationStates. |
55 void updateForChildren(PaintInvalidationReason); | 55 void updateForChildren(PaintInvalidationReason); |
56 | 56 |
57 bool hasForcedSubtreeInvalidationFlags() const { return m_forcedSubtreeInval
idationFlags; } | 57 bool hasForcedSubtreeInvalidationFlags() const { return m_forcedSubtreeInval
idationFlags; } |
58 | 58 |
59 bool forcedSubtreeInvalidationCheckingWithinContainer() const { return m_for
cedSubtreeInvalidationFlags & InvalidationChecking; } | 59 bool forcedSubtreeInvalidationCheckingWithinContainer() const { return m_for
cedSubtreeInvalidationFlags & InvalidationChecking; } |
60 void setForceSubtreeInvalidationCheckingWithinContainer() { m_forcedSubtreeI
nvalidationFlags |= InvalidationChecking; } | 60 void setForceSubtreeInvalidationCheckingWithinContainer() { m_forcedSubtreeI
nvalidationFlags |= InvalidationChecking; } |
61 | 61 |
62 bool forcedSubtreeFullInvalidationWithinContainer() const { return m_forcedS
ubtreeInvalidationFlags & FullInvalidation; } | 62 bool forcedSubtreeFullInvalidationWithinContainer() const { return m_forcedS
ubtreeInvalidationFlags & FullInvalidation; } |
63 | 63 |
64 bool forcedSubtreeInvalidationRectUpdateWithinContainerOnly() const { return
m_forcedSubtreeInvalidationFlags == InvalidationRectUpdate; } | 64 bool forcedSubtreeInvalidationRectUpdateWithinContainerOnly() const { return
m_forcedSubtreeInvalidationFlags == InvalidationRectUpdate; } |
65 void setForceSubtreeInvalidationRectUpdateWithinContainer() { m_forcedSubtre
eInvalidationFlags |= InvalidationRectUpdate; } | 65 void setForceSubtreeInvalidationRectUpdateWithinContainer() { m_forcedSubtre
eInvalidationFlags |= InvalidationRectUpdate; } |
66 | 66 |
67 const LayoutBoxModelObject& paintInvalidationContainer() const { return *m_p
aintInvalidationContainer; } | 67 const LayoutBoxModelObject& paintInvalidationContainer() const { return *m_p
aintInvalidationContainer; } |
68 | 68 |
69 // Computes the position of the current object ((0,0) in the space of the ob
ject) | 69 // Computes the position of the current object ((0,0) in the space of the ob
ject) |
70 // in the space of paint invalidation backing. | 70 // in the space of paint invalidation backing. |
71 LayoutPoint computePositionFromPaintInvalidationBacking() const; | 71 LayoutPoint computePositionFromPaintInvalidationBacking() const; |
72 | 72 |
73 // Returns the rect bounds needed to invalidate paint of this object, | 73 // Returns the rect bounds needed to invalidate paint of this object, |
74 // in the space of paint invalidation backing. | 74 // in the space of paint invalidation backing. |
75 LayoutRect computePaintInvalidationRectInBacking() const; | 75 LayoutRect computePaintInvalidationRectInBacking() const; |
76 | 76 |
77 void mapLocalRectToPaintInvalidationBacking(LayoutRect&) const; | 77 void mapLocalRectToPaintInvalidationBacking(LayoutRect&) const; |
78 | 78 |
79 // Records |obj| as needing paint invalidation on the next frame. See the de
finition of PaintInvalidationDelayedFull for more details. | |
80 void pushDelayedPaintInvalidationTarget(LayoutObject& obj) const { m_pending
DelayedPaintInvalidations.append(&obj); } | |
81 Vector<LayoutObject*>& pendingDelayedPaintInvalidationTargets() const { retu
rn m_pendingDelayedPaintInvalidations; } | |
82 | |
83 PaintLayer& paintingLayer() const; | 79 PaintLayer& paintingLayer() const; |
84 | 80 |
85 #if ENABLE(ASSERT) | 81 #if ENABLE(ASSERT) |
86 const LayoutObject& currentObject() const { return m_currentObject; } | 82 const LayoutObject& currentObject() const { return m_currentObject; } |
87 #endif | 83 #endif |
88 | 84 |
89 private: | 85 private: |
90 friend class VisualRectMappingTest; | 86 friend class VisualRectMappingTest; |
91 | 87 |
92 void mapLocalRectToPaintInvalidationContainer(LayoutRect&) const; | 88 void mapLocalRectToPaintInvalidationContainer(LayoutRect&) const; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 // paint invalidation containers differ. | 134 // paint invalidation containers differ. |
139 const LayoutBoxModelObject* m_paintInvalidationContainerForStackedContents; | 135 const LayoutBoxModelObject* m_paintInvalidationContainerForStackedContents; |
140 | 136 |
141 const LayoutObject& m_containerForAbsolutePosition; | 137 const LayoutObject& m_containerForAbsolutePosition; |
142 | 138 |
143 // Transform from the initial viewport coordinate system of an outermost | 139 // Transform from the initial viewport coordinate system of an outermost |
144 // SVG root to the userspace _before_ the relevant element. Combining this | 140 // SVG root to the userspace _before_ the relevant element. Combining this |
145 // with |m_paintOffset| yields the "final" offset. | 141 // with |m_paintOffset| yields the "final" offset. |
146 AffineTransform m_svgTransform; | 142 AffineTransform m_svgTransform; |
147 | 143 |
148 Vector<LayoutObject*>& m_pendingDelayedPaintInvalidations; | 144 // Records objects needing paint invalidation on the next frame. See the def
inition of PaintInvalidationDelayedFull for more details. |
| 145 Vector<const LayoutObject*>& m_pendingDelayedPaintInvalidations; |
149 | 146 |
150 PaintLayer& m_paintingLayer; | 147 PaintLayer& m_paintingLayer; |
151 | 148 |
152 #if ENABLE(ASSERT) | 149 #if ENABLE(ASSERT) |
153 bool m_didUpdateForChildren; | 150 bool m_didUpdateForChildren; |
154 #endif | 151 #endif |
155 | 152 |
156 #if ENABLE(ASSERT) && !defined(NDEBUG) | 153 #if ENABLE(ASSERT) && !defined(NDEBUG) |
157 // #define CHECK_FAST_PATH_SLOW_PATH_EQUALITY | 154 // #define CHECK_FAST_PATH_SLOW_PATH_EQUALITY |
158 #endif | 155 #endif |
159 | 156 |
160 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY | 157 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY |
161 void assertFastPathAndSlowPathRectsEqual(const LayoutRect& fastPathRect, con
st LayoutRect& slowPathRect) const; | 158 void assertFastPathAndSlowPathRectsEqual(const LayoutRect& fastPathRect, con
st LayoutRect& slowPathRect) const; |
162 bool m_canCheckFastPathSlowPathEquality; | 159 bool m_canCheckFastPathSlowPathEquality; |
163 #endif | 160 #endif |
164 }; | 161 }; |
165 | 162 |
166 } // namespace blink | 163 } // namespace blink |
167 | 164 |
168 #endif // PaintInvalidationState_h | 165 #endif // PaintInvalidationState_h |
OLD | NEW |