OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 PaintInvalidator_h | 5 #ifndef PaintInvalidator_h |
6 #define PaintInvalidator_h | 6 #define PaintInvalidator_h |
7 | 7 |
8 #include "core/layout/LayoutObject.h" | |
9 #include "core/paint/PaintPropertyTreeBuilder.h" | |
10 #include "platform/geometry/LayoutRect.h" | 8 #include "platform/geometry/LayoutRect.h" |
11 #include "platform/graphics/paint/GeometryMapper.h" | 9 #include "platform/graphics/paint/GeometryMapper.h" |
12 #include "wtf/Vector.h" | 10 #include "wtf/Vector.h" |
13 | 11 |
14 namespace blink { | 12 namespace blink { |
15 | 13 |
| 14 class FrameView; |
| 15 class LayoutBoxModelObject; |
| 16 class LayoutObject; |
| 17 class PaintLayer; |
| 18 struct PaintPropertyTreeBuilderContext; |
| 19 |
16 struct PaintInvalidatorContext { | 20 struct PaintInvalidatorContext { |
17 PaintInvalidatorContext( | 21 PaintInvalidatorContext( |
18 const PaintPropertyTreeBuilderContext* treeBuilderContext, | 22 const PaintPropertyTreeBuilderContext& treeBuilderContext, |
19 GeometryMapper& geometryMapper) | 23 GeometryMapper& geometryMapper) |
20 : parentContext(nullptr), | 24 : parentContext(nullptr), |
21 m_treeBuilderContext(treeBuilderContext), | 25 m_treeBuilderContext(treeBuilderContext), |
22 m_geometryMapper(geometryMapper) {} | 26 m_geometryMapper(geometryMapper) {} |
23 | 27 |
24 PaintInvalidatorContext( | 28 PaintInvalidatorContext( |
25 const PaintPropertyTreeBuilderContext* treeBuilderContext, | 29 const PaintPropertyTreeBuilderContext& treeBuilderContext, |
26 const PaintInvalidatorContext& parentContext) | 30 const PaintInvalidatorContext& parentContext) |
27 : parentContext(&parentContext), | 31 : parentContext(&parentContext), |
28 forcedSubtreeInvalidationFlags( | 32 forcedSubtreeInvalidationFlags( |
29 parentContext.forcedSubtreeInvalidationFlags), | 33 parentContext.forcedSubtreeInvalidationFlags), |
30 paintInvalidationContainer(parentContext.paintInvalidationContainer), | 34 paintInvalidationContainer(parentContext.paintInvalidationContainer), |
31 paintInvalidationContainerForStackedContents( | 35 paintInvalidationContainerForStackedContents( |
32 parentContext.paintInvalidationContainerForStackedContents), | 36 parentContext.paintInvalidationContainerForStackedContents), |
33 paintingLayer(parentContext.paintingLayer), | 37 paintingLayer(parentContext.paintingLayer), |
34 m_treeBuilderContext(treeBuilderContext), | 38 m_treeBuilderContext(treeBuilderContext), |
35 m_geometryMapper(parentContext.m_geometryMapper) {} | 39 m_geometryMapper(parentContext.m_geometryMapper) {} |
36 | 40 |
37 // This method is virtual temporarily to adapt PaintInvalidatorContext and the | 41 // This method is virtual temporarily to adapt PaintInvalidatorContext and the |
38 // legacy PaintInvalidationState for code shared by old code and new code. | 42 // legacy PaintInvalidationState for code shared by old code and new code. |
39 virtual void mapLocalRectToVisualRectInBacking(const LayoutObject&, | 43 virtual void mapLocalRectToVisualRectInBacking(const LayoutObject&, |
40 LayoutRect&) const; | 44 LayoutRect&) const; |
41 | 45 |
42 bool needsVisualRectUpdate(const LayoutObject& object) const { | |
43 if (!RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) | |
44 return true; | |
45 #if DCHECK_IS_ON() | |
46 if (m_forceVisualRectUpdateForChecking) | |
47 return true; | |
48 #endif | |
49 return object.needsPaintOffsetAndVisualRectUpdate() || | |
50 (forcedSubtreeInvalidationFlags & | |
51 PaintInvalidatorContext::ForcedSubtreeVisualRectUpdate); | |
52 } | |
53 | |
54 const PaintInvalidatorContext* parentContext; | 46 const PaintInvalidatorContext* parentContext; |
55 | 47 |
56 enum ForcedSubtreeInvalidationFlag { | 48 enum ForcedSubtreeInvalidationFlag { |
57 ForcedSubtreeInvalidationChecking = 1 << 0, | 49 ForcedSubtreeInvalidationChecking = 1 << 0, |
58 ForcedSubtreeVisualRectUpdate = 1 << 1, | 50 ForcedSubtreeInvalidationRectUpdate = 1 << 1, |
59 ForcedSubtreeFullInvalidation = 1 << 2, | 51 ForcedSubtreeFullInvalidation = 1 << 2, |
60 ForcedSubtreeFullInvalidationForStackedContents = 1 << 3, | 52 ForcedSubtreeFullInvalidationForStackedContents = 1 << 3, |
61 ForcedSubtreeSVGResourceChange = 1 << 4, | 53 ForcedSubtreeSVGResourceChange = 1 << 4, |
62 | |
63 // TODO(crbug.com/637313): This is temporary before we support filters in | 54 // TODO(crbug.com/637313): This is temporary before we support filters in |
64 // paint property tree. | 55 // paint property tree. |
65 ForcedSubtreeSlowPathRect = 1 << 5, | 56 ForcedSubtreeSlowPathRect = 1 << 5, |
66 | 57 |
67 // The paint invalidation tree walk invalidates paint caches, such as | 58 // The paint invalidation tree walk invalidates paint caches, such as |
68 // DisplayItemClients and subsequence caches, and also the regions | 59 // DisplayItemClients and subsequence caches, and also the regions |
69 // into which objects raster pixels. When this flag is set, raster region | 60 // into which objects raster pixels. When this flag is set, raster region |
70 // invalidations are not issued. | 61 // invalidations are not issued. |
71 // | 62 // |
72 // Context: some objects in this paint walk, for example SVG resource | 63 // Context: some objects in this paint walk, for example SVG resource |
(...skipping 30 matching lines...) Expand all Loading... |
103 // Store the origin of the object's local coordinates in the paint | 94 // Store the origin of the object's local coordinates in the paint |
104 // invalidation backing's coordinates. They are used to detect layoutObject | 95 // invalidation backing's coordinates. They are used to detect layoutObject |
105 // shifts that force a full invalidation and invalidation check in subtree. | 96 // shifts that force a full invalidation and invalidation check in subtree. |
106 // The points do *not* account for composited scrolling. See | 97 // The points do *not* account for composited scrolling. See |
107 // LayoutObject::adjustVisualRectForCompositedScrolling(). | 98 // LayoutObject::adjustVisualRectForCompositedScrolling(). |
108 LayoutPoint oldLocation; | 99 LayoutPoint oldLocation; |
109 LayoutPoint newLocation; | 100 LayoutPoint newLocation; |
110 | 101 |
111 private: | 102 private: |
112 friend class PaintInvalidator; | 103 friend class PaintInvalidator; |
113 const PaintPropertyTreeBuilderContext* m_treeBuilderContext; | 104 const PaintPropertyTreeBuilderContext& m_treeBuilderContext; |
114 GeometryMapper& m_geometryMapper; | 105 GeometryMapper& m_geometryMapper; |
115 | |
116 #if DCHECK_IS_ON() | |
117 friend class FindVisualRectNeedingUpdateScopeBase; | |
118 mutable bool m_forceVisualRectUpdateForChecking = false; | |
119 #endif | |
120 }; | 106 }; |
121 | 107 |
122 class PaintInvalidator { | 108 class PaintInvalidator { |
123 public: | 109 public: |
124 void invalidatePaintIfNeeded(FrameView&, PaintInvalidatorContext&); | 110 void invalidatePaintIfNeeded(FrameView&, PaintInvalidatorContext&); |
125 void invalidatePaintIfNeeded(const LayoutObject&, PaintInvalidatorContext&); | 111 void invalidatePaintIfNeeded(const LayoutObject&, PaintInvalidatorContext&); |
126 | 112 |
127 // Process objects needing paint invalidation on the next frame. | 113 // Process objects needing paint invalidation on the next frame. |
128 // See the definition of PaintInvalidationDelayedFull for more details. | 114 // See the definition of PaintInvalidationDelayedFull for more details. |
129 void processPendingDelayedPaintInvalidations(); | 115 void processPendingDelayedPaintInvalidations(); |
130 | 116 |
131 private: | 117 private: |
132 friend struct PaintInvalidatorContext; | 118 friend struct PaintInvalidatorContext; |
133 template <typename Rect, typename Point> | 119 template <typename Rect, typename Point> |
134 static LayoutRect mapLocalRectToVisualRectInBacking( | 120 static LayoutRect mapLocalRectToVisualRectInBacking( |
135 const LayoutObject&, | 121 const LayoutObject&, |
136 const Rect&, | 122 const Rect&, |
137 const PaintInvalidatorContext&); | 123 const PaintInvalidatorContext&); |
138 | 124 |
139 ALWAYS_INLINE LayoutRect | 125 ALWAYS_INLINE LayoutRect |
140 computeVisualRectInBacking(const LayoutObject&, | 126 computeVisualRectInBacking(const LayoutObject&, |
141 const PaintInvalidatorContext&); | 127 const PaintInvalidatorContext&); |
142 ALWAYS_INLINE LayoutPoint | 128 ALWAYS_INLINE LayoutPoint |
143 computeLocationInBacking(const LayoutObject&, const PaintInvalidatorContext&); | 129 computeLocationInBacking(const LayoutObject&, const PaintInvalidatorContext&); |
144 ALWAYS_INLINE void updatePaintingLayer(const LayoutObject&, | 130 ALWAYS_INLINE void updatePaintingLayer(const LayoutObject&, |
145 PaintInvalidatorContext&); | 131 PaintInvalidatorContext&); |
146 ALWAYS_INLINE void updatePaintInvalidationContainer(const LayoutObject&, | 132 ALWAYS_INLINE void updatePaintInvalidationContainer(const LayoutObject&, |
147 PaintInvalidatorContext&); | 133 PaintInvalidatorContext&); |
148 ALWAYS_INLINE void updateVisualRectIfNeeded(const LayoutObject&, | |
149 PaintInvalidatorContext&); | |
150 ALWAYS_INLINE void updateVisualRect(const LayoutObject&, | 134 ALWAYS_INLINE void updateVisualRect(const LayoutObject&, |
151 PaintInvalidatorContext&); | 135 PaintInvalidatorContext&); |
152 | 136 |
153 Vector<const LayoutObject*> m_pendingDelayedPaintInvalidations; | 137 Vector<const LayoutObject*> m_pendingDelayedPaintInvalidations; |
154 }; | 138 }; |
155 | 139 |
156 } // namespace blink | 140 } // namespace blink |
157 | 141 |
158 #endif // PaintInvalidator_h | 142 #endif // PaintInvalidator_h |
OLD | NEW |