| 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 "platform/geometry/LayoutRect.h" | 8 #include "platform/geometry/LayoutRect.h" |
| 9 #include "platform/graphics/paint/GeometryMapper.h" | 9 #include "platform/graphics/paint/GeometryMapper.h" |
| 10 #include "wtf/Vector.h" | 10 #include "wtf/Vector.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 class FrameView; | 14 class FrameView; |
| 15 class LayoutBoxModelObject; | 15 class LayoutBoxModelObject; |
| 16 class LayoutObject; | 16 class LayoutObject; |
| 17 class PaintLayer; | 17 class PaintLayer; |
| 18 struct PaintPropertyTreeBuilderContext; | 18 struct PaintPropertyTreeBuilderContext; |
| 19 | 19 |
| 20 struct PaintInvalidatorContext { | 20 struct PaintInvalidatorContext { |
| 21 PaintInvalidatorContext( | 21 PaintInvalidatorContext( |
| 22 const PaintPropertyTreeBuilderContext& treeBuilderContext, | 22 const PaintPropertyTreeBuilderContext& treeBuilderContext, |
| 23 GeometryMapper& geometryMapper) | 23 GeometryMapper& geometryMapper) |
| 24 : treeBuilderContext(treeBuilderContext), | 24 : parentContext(nullptr), |
| 25 geometryMapper(geometryMapper), | 25 m_treeBuilderContext(treeBuilderContext), |
| 26 parentContext(nullptr) {} | 26 m_geometryMapper(geometryMapper) {} |
| 27 | 27 |
| 28 PaintInvalidatorContext( | 28 PaintInvalidatorContext( |
| 29 const PaintPropertyTreeBuilderContext& treeBuilderContext, | 29 const PaintPropertyTreeBuilderContext& treeBuilderContext, |
| 30 const PaintInvalidatorContext& parentContext) | 30 const PaintInvalidatorContext& parentContext) |
| 31 : treeBuilderContext(treeBuilderContext), | 31 : parentContext(&parentContext), |
| 32 geometryMapper(parentContext.geometryMapper), | |
| 33 parentContext(&parentContext), | |
| 34 forcedSubtreeInvalidationFlags( | 32 forcedSubtreeInvalidationFlags( |
| 35 parentContext.forcedSubtreeInvalidationFlags), | 33 parentContext.forcedSubtreeInvalidationFlags), |
| 36 paintInvalidationContainer(parentContext.paintInvalidationContainer), | 34 paintInvalidationContainer(parentContext.paintInvalidationContainer), |
| 37 paintInvalidationContainerForStackedContents( | 35 paintInvalidationContainerForStackedContents( |
| 38 parentContext.paintInvalidationContainerForStackedContents), | 36 parentContext.paintInvalidationContainerForStackedContents), |
| 39 paintingLayer(parentContext.paintingLayer) {} | 37 paintingLayer(parentContext.paintingLayer), |
| 38 m_treeBuilderContext(treeBuilderContext), |
| 39 m_geometryMapper(parentContext.m_geometryMapper) {} |
| 40 | 40 |
| 41 // This method is virtual temporarily to adapt PaintInvalidatorContext and the | 41 // This method is virtual temporarily to adapt PaintInvalidatorContext and the |
| 42 // legacy PaintInvalidationState for code shared by old code and new code. | 42 // legacy PaintInvalidationState for code shared by old code and new code. |
| 43 virtual void mapLocalRectToVisualRectInBacking(const LayoutObject&, | 43 virtual void mapLocalRectToVisualRectInBacking(const LayoutObject&, |
| 44 LayoutRect&) const; | 44 LayoutRect&) const; |
| 45 | 45 |
| 46 const PaintPropertyTreeBuilderContext& treeBuilderContext; | |
| 47 GeometryMapper& geometryMapper; | |
| 48 const PaintInvalidatorContext* parentContext; | 46 const PaintInvalidatorContext* parentContext; |
| 49 | 47 |
| 50 enum ForcedSubtreeInvalidationFlag { | 48 enum ForcedSubtreeInvalidationFlag { |
| 51 ForcedSubtreeInvalidationChecking = 1 << 0, | 49 ForcedSubtreeInvalidationChecking = 1 << 0, |
| 52 ForcedSubtreeInvalidationRectUpdate = 1 << 1, | 50 ForcedSubtreeInvalidationRectUpdate = 1 << 1, |
| 53 ForcedSubtreeFullInvalidation = 1 << 2, | 51 ForcedSubtreeFullInvalidation = 1 << 2, |
| 54 ForcedSubtreeFullInvalidationForStackedContents = 1 << 3, | 52 ForcedSubtreeFullInvalidationForStackedContents = 1 << 3, |
| 55 ForcedSubtreeSVGResourceChange = 1 << 4, | 53 ForcedSubtreeSVGResourceChange = 1 << 4, |
| 56 // 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 |
| 57 // paint property tree. | 55 // paint property tree. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 82 LayoutRect oldVisualRect; | 80 LayoutRect oldVisualRect; |
| 83 // Use LayoutObject::visualRect() to get the new visual rect. | 81 // Use LayoutObject::visualRect() to get the new visual rect. |
| 84 | 82 |
| 85 // Store the origin of the object's local coordinates in the paint | 83 // Store the origin of the object's local coordinates in the paint |
| 86 // invalidation backing's coordinates. They are used to detect layoutObject | 84 // invalidation backing's coordinates. They are used to detect layoutObject |
| 87 // shifts that force a full invalidation and invalidation check in subtree. | 85 // shifts that force a full invalidation and invalidation check in subtree. |
| 88 // The points do *not* account for composited scrolling. See | 86 // The points do *not* account for composited scrolling. See |
| 89 // LayoutObject::adjustVisualRectForCompositedScrolling(). | 87 // LayoutObject::adjustVisualRectForCompositedScrolling(). |
| 90 LayoutPoint oldLocation; | 88 LayoutPoint oldLocation; |
| 91 LayoutPoint newLocation; | 89 LayoutPoint newLocation; |
| 90 |
| 91 private: |
| 92 friend class PaintInvalidator; |
| 93 const PaintPropertyTreeBuilderContext& m_treeBuilderContext; |
| 94 GeometryMapper& m_geometryMapper; |
| 92 }; | 95 }; |
| 93 | 96 |
| 94 class PaintInvalidator { | 97 class PaintInvalidator { |
| 95 public: | 98 public: |
| 96 void invalidatePaintIfNeeded(FrameView&, PaintInvalidatorContext&); | 99 void invalidatePaintIfNeeded(FrameView&, PaintInvalidatorContext&); |
| 97 void invalidatePaintIfNeeded(const LayoutObject&, PaintInvalidatorContext&); | 100 void invalidatePaintIfNeeded(const LayoutObject&, PaintInvalidatorContext&); |
| 98 | 101 |
| 99 // Process objects needing paint invalidation on the next frame. | 102 // Process objects needing paint invalidation on the next frame. |
| 100 // See the definition of PaintInvalidationDelayedFull for more details. | 103 // See the definition of PaintInvalidationDelayedFull for more details. |
| 101 void processPendingDelayedPaintInvalidations(); | 104 void processPendingDelayedPaintInvalidations(); |
| 102 | 105 |
| 103 private: | 106 private: |
| 107 friend struct PaintInvalidatorContext; |
| 108 template <typename Rect, typename Point> |
| 109 static LayoutRect mapLocalRectToVisualRectInBacking( |
| 110 const LayoutObject&, |
| 111 const Rect&, |
| 112 const PaintInvalidatorContext&); |
| 113 |
| 104 ALWAYS_INLINE LayoutRect | 114 ALWAYS_INLINE LayoutRect |
| 105 computeVisualRectInBacking(const LayoutObject&, | 115 computeVisualRectInBacking(const LayoutObject&, |
| 106 const PaintInvalidatorContext&); | 116 const PaintInvalidatorContext&); |
| 107 ALWAYS_INLINE LayoutPoint | 117 ALWAYS_INLINE LayoutPoint |
| 108 computeLocationInBacking(const LayoutObject&, const PaintInvalidatorContext&); | 118 computeLocationInBacking(const LayoutObject&, const PaintInvalidatorContext&); |
| 109 ALWAYS_INLINE void updatePaintingLayer(const LayoutObject&, | 119 ALWAYS_INLINE void updatePaintingLayer(const LayoutObject&, |
| 110 PaintInvalidatorContext&); | 120 PaintInvalidatorContext&); |
| 111 ALWAYS_INLINE void updatePaintInvalidationContainer(const LayoutObject&, | 121 ALWAYS_INLINE void updatePaintInvalidationContainer(const LayoutObject&, |
| 112 PaintInvalidatorContext&); | 122 PaintInvalidatorContext&); |
| 113 ALWAYS_INLINE void updateVisualRect(const LayoutObject&, | 123 ALWAYS_INLINE void updateVisualRect(const LayoutObject&, |
| 114 PaintInvalidatorContext&); | 124 PaintInvalidatorContext&); |
| 115 | 125 |
| 116 Vector<const LayoutObject*> m_pendingDelayedPaintInvalidations; | 126 Vector<const LayoutObject*> m_pendingDelayedPaintInvalidations; |
| 117 }; | 127 }; |
| 118 | 128 |
| 119 } // namespace blink | 129 } // namespace blink |
| 120 | 130 |
| 121 #endif // PaintInvalidator_h | 131 #endif // PaintInvalidator_h |
| OLD | NEW |