| 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" | 8 #include "core/layout/LayoutObject.h" |
| 9 #include "core/paint/PaintPropertyTreeBuilder.h" | 9 #include "core/paint/PaintPropertyTreeBuilder.h" |
| 10 #include "platform/geometry/LayoutRect.h" | 10 #include "platform/geometry/LayoutRect.h" |
| 11 #include "platform/wtf/Vector.h" | 11 #include "platform/wtf/Vector.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 struct PaintInvalidatorContext { | 15 struct PaintInvalidatorContext { |
| 16 PaintInvalidatorContext( | 16 PaintInvalidatorContext() : parent_context(nullptr) {} |
| 17 const PaintPropertyTreeBuilderContext* tree_builder_context) | |
| 18 : parent_context(nullptr), tree_builder_context_(tree_builder_context) {} | |
| 19 | 17 |
| 20 PaintInvalidatorContext( | 18 PaintInvalidatorContext(const PaintInvalidatorContext& parent_context) |
| 21 const PaintPropertyTreeBuilderContext* tree_builder_context, | |
| 22 const PaintInvalidatorContext& parent_context) | |
| 23 : parent_context(&parent_context), | 19 : parent_context(&parent_context), |
| 24 forced_subtree_invalidation_flags( | 20 forced_subtree_invalidation_flags( |
| 25 parent_context.forced_subtree_invalidation_flags), | 21 parent_context.forced_subtree_invalidation_flags), |
| 26 paint_invalidation_container( | 22 paint_invalidation_container( |
| 27 parent_context.paint_invalidation_container), | 23 parent_context.paint_invalidation_container), |
| 28 paint_invalidation_container_for_stacked_contents( | 24 paint_invalidation_container_for_stacked_contents( |
| 29 parent_context.paint_invalidation_container_for_stacked_contents), | 25 parent_context.paint_invalidation_container_for_stacked_contents), |
| 30 painting_layer(parent_context.painting_layer), | 26 painting_layer(parent_context.painting_layer) {} |
| 31 tree_builder_context_(tree_builder_context) {} | |
| 32 | 27 |
| 33 // This method is virtual temporarily to adapt PaintInvalidatorContext and the | 28 // This method is virtual temporarily to adapt PaintInvalidatorContext and the |
| 34 // legacy PaintInvalidationState for code shared by old code and new code. | 29 // legacy PaintInvalidationState for code shared by old code and new code. |
| 35 virtual void MapLocalRectToVisualRectInBacking(const LayoutObject&, | 30 virtual void MapLocalRectToVisualRectInBacking(const LayoutObject&, |
| 36 LayoutRect&) const; | 31 LayoutRect&) const; |
| 37 | 32 |
| 38 bool NeedsVisualRectUpdate(const LayoutObject& object) const { | 33 bool NeedsVisualRectUpdate(const LayoutObject& object) const { |
| 39 if (!RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) | 34 if (!RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) |
| 40 return true; | 35 return true; |
| 41 #if DCHECK_IS_ON() | 36 #if DCHECK_IS_ON() |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // 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 |
| 100 // invalidation backing's coordinates. They are used to detect layoutObject | 95 // invalidation backing's coordinates. They are used to detect layoutObject |
| 101 // shifts that force a full invalidation and invalidation check in subtree. | 96 // shifts that force a full invalidation and invalidation check in subtree. |
| 102 // The points do *not* account for composited scrolling. See | 97 // The points do *not* account for composited scrolling. See |
| 103 // LayoutObject::adjustVisualRectForCompositedScrolling(). | 98 // LayoutObject::adjustVisualRectForCompositedScrolling(). |
| 104 LayoutPoint old_location; | 99 LayoutPoint old_location; |
| 105 LayoutPoint new_location; | 100 LayoutPoint new_location; |
| 106 | 101 |
| 107 private: | 102 private: |
| 108 friend class PaintInvalidator; | 103 friend class PaintInvalidator; |
| 109 const PaintPropertyTreeBuilderContext* tree_builder_context_; | 104 const PaintPropertyTreeBuilderFragmentContext* tree_builder_context_ = |
| 105 nullptr; |
| 110 | 106 |
| 111 #if DCHECK_IS_ON() | 107 #if DCHECK_IS_ON() |
| 108 bool tree_builder_context_actually_needed_ = false; |
| 109 friend class FindVisualRectNeedingUpdateScope; |
| 112 friend class FindVisualRectNeedingUpdateScopeBase; | 110 friend class FindVisualRectNeedingUpdateScopeBase; |
| 113 mutable bool force_visual_rect_update_for_checking_ = false; | 111 mutable bool force_visual_rect_update_for_checking_ = false; |
| 114 #endif | 112 #endif |
| 115 }; | 113 }; |
| 116 | 114 |
| 117 class PaintInvalidator { | 115 class PaintInvalidator { |
| 118 public: | 116 public: |
| 119 void InvalidatePaint(FrameView&, PaintInvalidatorContext&); | 117 void InvalidatePaint(FrameView&, |
| 120 void InvalidatePaint(const LayoutObject&, PaintInvalidatorContext&); | 118 const PaintPropertyTreeBuilderContext*, |
| 119 PaintInvalidatorContext&); |
| 120 void InvalidatePaint(const LayoutObject&, |
| 121 const PaintPropertyTreeBuilderContext*, |
| 122 PaintInvalidatorContext&); |
| 121 | 123 |
| 122 // Process objects needing paint invalidation on the next frame. | 124 // Process objects needing paint invalidation on the next frame. |
| 123 // See the definition of PaintInvalidationDelayedFull for more details. | 125 // See the definition of PaintInvalidationDelayedFull for more details. |
| 124 void ProcessPendingDelayedPaintInvalidations(); | 126 void ProcessPendingDelayedPaintInvalidations(); |
| 125 | 127 |
| 126 private: | 128 private: |
| 127 friend struct PaintInvalidatorContext; | 129 friend struct PaintInvalidatorContext; |
| 128 template <typename Rect, typename Point> | 130 template <typename Rect, typename Point> |
| 129 static LayoutRect MapLocalRectToVisualRectInBacking( | 131 static LayoutRect MapLocalRectToVisualRectInBacking( |
| 130 const LayoutObject&, | 132 const LayoutObject&, |
| 131 const Rect&, | 133 const Rect&, |
| 132 const PaintInvalidatorContext&); | 134 const PaintInvalidatorContext&); |
| 133 | 135 |
| 134 ALWAYS_INLINE LayoutRect | 136 ALWAYS_INLINE LayoutRect |
| 135 ComputeVisualRectInBacking(const LayoutObject&, | 137 ComputeVisualRectInBacking(const LayoutObject&, |
| 136 const PaintInvalidatorContext&); | 138 const PaintInvalidatorContext&); |
| 137 ALWAYS_INLINE LayoutPoint | 139 ALWAYS_INLINE LayoutPoint |
| 138 ComputeLocationInBacking(const LayoutObject&, const PaintInvalidatorContext&); | 140 ComputeLocationInBacking(const LayoutObject&, const PaintInvalidatorContext&); |
| 139 ALWAYS_INLINE void UpdatePaintingLayer(const LayoutObject&, | 141 ALWAYS_INLINE void UpdatePaintingLayer(const LayoutObject&, |
| 140 PaintInvalidatorContext&); | 142 PaintInvalidatorContext&); |
| 141 ALWAYS_INLINE void UpdatePaintInvalidationContainer(const LayoutObject&, | 143 ALWAYS_INLINE void UpdatePaintInvalidationContainer(const LayoutObject&, |
| 142 PaintInvalidatorContext&); | 144 PaintInvalidatorContext&); |
| 143 ALWAYS_INLINE void UpdateVisualRectIfNeeded(const LayoutObject&, | 145 ALWAYS_INLINE void UpdateVisualRectIfNeeded( |
| 144 PaintInvalidatorContext&); | 146 const LayoutObject&, |
| 147 const PaintPropertyTreeBuilderContext*, |
| 148 PaintInvalidatorContext&); |
| 145 ALWAYS_INLINE void UpdateVisualRect(const LayoutObject&, | 149 ALWAYS_INLINE void UpdateVisualRect(const LayoutObject&, |
| 146 PaintInvalidatorContext&); | 150 PaintInvalidatorContext&); |
| 147 | 151 |
| 148 Vector<const LayoutObject*> pending_delayed_paint_invalidations_; | 152 Vector<const LayoutObject*> pending_delayed_paint_invalidations_; |
| 149 }; | 153 }; |
| 150 | 154 |
| 151 } // namespace blink | 155 } // namespace blink |
| 152 | 156 |
| 153 #endif // PaintInvalidator_h | 157 #endif // PaintInvalidator_h |
| OLD | NEW |