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 "core/paint/PaintInvalidator.h" | |
9 #include "platform/geometry/LayoutRect.h" | 10 #include "platform/geometry/LayoutRect.h" |
10 #include "platform/graphics/PaintInvalidationReason.h" | 11 #include "platform/graphics/PaintInvalidationReason.h" |
11 #include "platform/transforms/AffineTransform.h" | 12 #include "platform/transforms/AffineTransform.h" |
12 #include "wtf/Allocator.h" | 13 #include "wtf/Allocator.h" |
13 #include "wtf/Noncopyable.h" | 14 #include "wtf/Noncopyable.h" |
14 | 15 |
15 namespace blink { | 16 namespace blink { |
16 | 17 |
17 class LayoutBoxModelObject; | 18 class LayoutBoxModelObject; |
18 class LayoutObject; | 19 class LayoutObject; |
(...skipping 30 matching lines...) Expand all Loading... | |
49 PaintInvalidationState(const LayoutView&, Vector<const LayoutObject*>& pendi ngDelayedPaintInvalidations); | 50 PaintInvalidationState(const LayoutView&, Vector<const LayoutObject*>& pendi ngDelayedPaintInvalidations); |
50 | 51 |
51 // When a PaintInvalidationState is constructed, it can be used to map point s/rects in the object's | 52 // 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, | 53 // 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 | 54 // before invalidation of the subtrees, this method must be called to apply clip and scroll offset |
54 // etc. for creating child PaintInvalidationStates. | 55 // etc. for creating child PaintInvalidationStates. |
55 void updateForChildren(PaintInvalidationReason); | 56 void updateForChildren(PaintInvalidationReason); |
56 | 57 |
57 bool hasForcedSubtreeInvalidationFlags() const { return m_forcedSubtreeInval idationFlags; } | 58 bool hasForcedSubtreeInvalidationFlags() const { return m_forcedSubtreeInval idationFlags; } |
58 | 59 |
59 bool forcedSubtreeInvalidationCheckingWithinContainer() const { return m_for cedSubtreeInvalidationFlags & InvalidationChecking; } | 60 bool forcedSubtreeInvalidationCheckingWithinContainer() const { return m_for cedSubtreeInvalidationFlags & PaintInvalidatorContext::ForcedSubtreeInvalidation Checking; } |
60 void setForceSubtreeInvalidationCheckingWithinContainer() { m_forcedSubtreeI nvalidationFlags |= InvalidationChecking; } | 61 void setForceSubtreeInvalidationCheckingWithinContainer() { m_forcedSubtreeI nvalidationFlags |= PaintInvalidatorContext::ForcedSubtreeInvalidationChecking; } |
61 | 62 |
62 bool forcedSubtreeFullInvalidationWithinContainer() const { return m_forcedS ubtreeInvalidationFlags & FullInvalidation; } | 63 bool forcedSubtreeFullInvalidationWithinContainer() const { return m_forcedS ubtreeInvalidationFlags & PaintInvalidatorContext::ForcedSubtreeFullInvalidation ; } |
63 | 64 |
64 bool forcedSubtreeInvalidationRectUpdateWithinContainerOnly() const { return m_forcedSubtreeInvalidationFlags == InvalidationRectUpdate; } | 65 bool forcedSubtreeInvalidationRectUpdateWithinContainerOnly() const { return m_forcedSubtreeInvalidationFlags == PaintInvalidatorContext::ForcedSubtreeInval idationRectUpdate; } |
65 void setForceSubtreeInvalidationRectUpdateWithinContainer() { m_forcedSubtre eInvalidationFlags |= InvalidationRectUpdate; } | 66 void setForceSubtreeInvalidationRectUpdateWithinContainer() { m_forcedSubtre eInvalidationFlags |= PaintInvalidatorContext::ForcedSubtreeInvalidationRectUpda te; } |
66 | 67 |
67 const LayoutBoxModelObject& paintInvalidationContainer() const { return *m_p aintInvalidationContainer; } | 68 const LayoutBoxModelObject& paintInvalidationContainer() const { return *m_p aintInvalidationContainer; } |
68 | 69 |
69 // Computes the position of the current object ((0,0) in the space of the ob ject) | 70 // Computes the position of the current object ((0,0) in the space of the ob ject) |
70 // in the space of paint invalidation backing. | 71 // in the space of paint invalidation backing. |
71 LayoutPoint computePositionFromPaintInvalidationBacking() const; | 72 LayoutPoint computePositionFromPaintInvalidationBacking() const; |
72 | 73 |
73 // Returns the rect bounds needed to invalidate paint of this object, | 74 // Returns the rect bounds needed to invalidate paint of this object, |
74 // in the space of paint invalidation backing. | 75 // in the space of paint invalidation backing. |
75 LayoutRect computePaintInvalidationRectInBacking() const; | 76 LayoutRect computePaintInvalidationRectInBacking() const; |
76 | 77 |
77 void mapLocalRectToPaintInvalidationBacking(LayoutRect&) const; | 78 void mapLocalRectToPaintInvalidationBacking(LayoutRect&) const; |
78 | 79 |
79 PaintLayer& paintingLayer() const; | 80 PaintLayer& paintingLayer() const; |
80 | 81 |
81 #if ENABLE(ASSERT) | 82 #if ENABLE(ASSERT) |
82 const LayoutObject& currentObject() const { return m_currentObject; } | 83 const LayoutObject& currentObject() const { return m_currentObject; } |
83 #endif | 84 #endif |
84 | 85 |
85 private: | 86 private: |
86 friend class VisualRectMappingTest; | 87 friend class VisualRectMappingTest; |
88 friend class PaintInvalidatorContextAdapter; | |
87 | 89 |
88 void mapLocalRectToPaintInvalidationContainer(LayoutRect&) const; | 90 void mapLocalRectToPaintInvalidationContainer(LayoutRect&) const; |
89 | 91 |
90 void updateForCurrentObject(const PaintInvalidationState& parentState); | 92 void updateForCurrentObject(const PaintInvalidationState& parentState); |
91 void updateForNormalChildren(); | 93 void updateForNormalChildren(); |
92 | 94 |
93 LayoutRect computePaintInvalidationRectInBackingForSVG() const; | 95 LayoutRect computePaintInvalidationRectInBackingForSVG() const; |
94 | 96 |
95 void addClipRectRelativeToPaintOffset(const LayoutRect& localClipRect); | 97 void addClipRectRelativeToPaintOffset(const LayoutRect& localClipRect); |
96 | 98 |
97 const LayoutObject& m_currentObject; | 99 const LayoutObject& m_currentObject; |
98 | 100 |
99 enum ForcedSubtreeInvalidationFlag { | |
100 InvalidationChecking = 1 << 0, | |
101 InvalidationRectUpdate = 1 << 1, | |
102 FullInvalidation = 1 << 2, | |
103 FullInvalidationForStackedContents = 1 << 3, | |
104 }; | |
105 unsigned m_forcedSubtreeInvalidationFlags; | 101 unsigned m_forcedSubtreeInvalidationFlags; |
106 | 102 |
107 bool m_clipped; | 103 bool m_clipped; |
108 bool m_clippedForAbsolutePosition; | 104 bool m_clippedForAbsolutePosition; |
109 | 105 |
110 // Clip rect from paintInvalidationContainer if m_cachedOffsetsEnabled is tr ue. | 106 // Clip rect from paintInvalidationContainer if m_cachedOffsetsEnabled is tr ue. |
111 LayoutRect m_clipRect; | 107 LayoutRect m_clipRect; |
112 LayoutRect m_clipRectForAbsolutePosition; | 108 LayoutRect m_clipRectForAbsolutePosition; |
113 | 109 |
114 // x/y offset from the paintInvalidationContainer if m_cachedOffsetsEnabled is true. | 110 // x/y offset from the paintInvalidationContainer if m_cachedOffsetsEnabled is true. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 #if ENABLE(ASSERT) && !defined(NDEBUG) | 149 #if ENABLE(ASSERT) && !defined(NDEBUG) |
154 // #define CHECK_FAST_PATH_SLOW_PATH_EQUALITY | 150 // #define CHECK_FAST_PATH_SLOW_PATH_EQUALITY |
155 #endif | 151 #endif |
156 | 152 |
157 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY | 153 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY |
158 void assertFastPathAndSlowPathRectsEqual(const LayoutRect& fastPathRect, con st LayoutRect& slowPathRect) const; | 154 void assertFastPathAndSlowPathRectsEqual(const LayoutRect& fastPathRect, con st LayoutRect& slowPathRect) const; |
159 bool m_canCheckFastPathSlowPathEquality; | 155 bool m_canCheckFastPathSlowPathEquality; |
160 #endif | 156 #endif |
161 }; | 157 }; |
162 | 158 |
159 // This is temporary to adapt legacy PaintInvalidationState to PaintInvalidatorC ontext | |
160 class PaintInvalidatorContextAdapter : public PaintInvalidatorContext { | |
161 public: | |
162 PaintInvalidatorContextAdapter(const PaintInvalidationState&); | |
163 void mapLocalRectToPaintInvalidationBacking(const LayoutObject& object, Layo utRect& rect) const override | |
chrishtr
2016/08/09 23:47:31
Doesn't need to be inline.
Xianzhu
2016/08/10 16:25:01
Done.
| |
164 { | |
165 DCHECK(&object == &m_paintInvalidationState.currentObject()); | |
166 m_paintInvalidationState.mapLocalRectToPaintInvalidationBacking(rect); | |
167 } | |
168 private: | |
169 const PaintInvalidationState& m_paintInvalidationState; | |
170 }; | |
171 | |
163 } // namespace blink | 172 } // namespace blink |
164 | 173 |
165 #endif // PaintInvalidationState_h | 174 #endif // PaintInvalidationState_h |
OLD | NEW |