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