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