| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 PaintInvalidationState_h | 5 #ifndef PaintInvalidationState_h |
| 6 #define PaintInvalidationState_h | 6 #define PaintInvalidationState_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "core/paint/PaintInvalidator.h" | 9 #include "core/paint/PaintInvalidator.h" |
| 10 #include "platform/geometry/LayoutRect.h" | 10 #include "platform/geometry/LayoutRect.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 // See Source/core/paint/README.md#Paint-invalidation for more details. | 36 // See Source/core/paint/README.md#Paint-invalidation for more details. |
| 37 | 37 |
| 38 class CORE_EXPORT PaintInvalidationState { | 38 class CORE_EXPORT PaintInvalidationState { |
| 39 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 39 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 40 WTF_MAKE_NONCOPYABLE(PaintInvalidationState); | 40 WTF_MAKE_NONCOPYABLE(PaintInvalidationState); |
| 41 | 41 |
| 42 public: | 42 public: |
| 43 PaintInvalidationState(const PaintInvalidationState& parentState, | 43 PaintInvalidationState(const PaintInvalidationState& parentState, |
| 44 const LayoutObject&); | 44 const LayoutObject&); |
| 45 | 45 |
| 46 // For root LayoutView, or when sub-frame LayoutView's invalidateTreeIfNeeded(
) is called directly from | 46 // For root LayoutView, or when sub-frame LayoutView's |
| 47 // FrameView::invalidateTreeIfNeededRecursive() instead of the owner LayoutPar
t. | 47 // invalidateTreeIfNeeded() is called directly from |
| 48 // FrameView::invalidateTreeIfNeededRecursive() instead of the owner |
| 49 // LayoutPart. |
| 48 // TODO(wangxianzhu): Eliminate the latter case. | 50 // TODO(wangxianzhu): Eliminate the latter case. |
| 49 PaintInvalidationState( | 51 PaintInvalidationState( |
| 50 const LayoutView&, | 52 const LayoutView&, |
| 51 Vector<const LayoutObject*>& pendingDelayedPaintInvalidations); | 53 Vector<const LayoutObject*>& pendingDelayedPaintInvalidations); |
| 52 | 54 |
| 53 // When a PaintInvalidationState is constructed, it can be used to map points/
rects in the object's | 55 // When a PaintInvalidationState is constructed, it can be used to map |
| 54 // local space (border box space for LayoutBoxes). After invalidation of the c
urrent object, | 56 // points/rects in the object's local space (border box space for |
| 55 // before invalidation of the subtrees, this method must be called to apply cl
ip and scroll offset | 57 // LayoutBoxes). After invalidation of the current object, before invalidation |
| 58 // of the subtrees, this method must be called to apply clip and scroll offset |
| 56 // etc. for creating child PaintInvalidationStates. | 59 // etc. for creating child PaintInvalidationStates. |
| 57 void updateForChildren(PaintInvalidationReason); | 60 void updateForChildren(PaintInvalidationReason); |
| 58 | 61 |
| 59 bool hasForcedSubtreeInvalidationFlags() const { | 62 bool hasForcedSubtreeInvalidationFlags() const { |
| 60 return m_forcedSubtreeInvalidationFlags; | 63 return m_forcedSubtreeInvalidationFlags; |
| 61 } | 64 } |
| 62 | 65 |
| 63 bool forcedSubtreeInvalidationCheckingWithinContainer() const { | 66 bool forcedSubtreeInvalidationCheckingWithinContainer() const { |
| 64 return m_forcedSubtreeInvalidationFlags & | 67 return m_forcedSubtreeInvalidationFlags & |
| 65 PaintInvalidatorContext::ForcedSubtreeInvalidationChecking; | 68 PaintInvalidatorContext::ForcedSubtreeInvalidationChecking; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 80 } | 83 } |
| 81 void setForceSubtreeInvalidationRectUpdateWithinContainer() { | 84 void setForceSubtreeInvalidationRectUpdateWithinContainer() { |
| 82 m_forcedSubtreeInvalidationFlags |= | 85 m_forcedSubtreeInvalidationFlags |= |
| 83 PaintInvalidatorContext::ForcedSubtreeInvalidationRectUpdate; | 86 PaintInvalidatorContext::ForcedSubtreeInvalidationRectUpdate; |
| 84 } | 87 } |
| 85 | 88 |
| 86 const LayoutBoxModelObject& paintInvalidationContainer() const { | 89 const LayoutBoxModelObject& paintInvalidationContainer() const { |
| 87 return *m_paintInvalidationContainer; | 90 return *m_paintInvalidationContainer; |
| 88 } | 91 } |
| 89 | 92 |
| 90 // Computes the position of the current object ((0,0) in the space of the obje
ct) | 93 // Computes the position of the current object ((0,0) in the space of the |
| 91 // in the space of paint invalidation backing. | 94 // object) in the space of paint invalidation backing. |
| 92 LayoutPoint computePositionFromPaintInvalidationBacking() const; | 95 LayoutPoint computePositionFromPaintInvalidationBacking() const; |
| 93 | 96 |
| 94 // Returns the rect bounds needed to invalidate paint of this object, | 97 // Returns the rect bounds needed to invalidate paint of this object, |
| 95 // in the space of paint invalidation backing. | 98 // in the space of paint invalidation backing. |
| 96 LayoutRect computePaintInvalidationRectInBacking() const; | 99 LayoutRect computePaintInvalidationRectInBacking() const; |
| 97 | 100 |
| 98 void mapLocalRectToPaintInvalidationBacking(LayoutRect&) const; | 101 void mapLocalRectToPaintInvalidationBacking(LayoutRect&) const; |
| 99 | 102 |
| 100 PaintLayer& paintingLayer() const; | 103 PaintLayer& paintingLayer() const; |
| 101 | 104 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 114 | 117 |
| 115 void addClipRectRelativeToPaintOffset(const LayoutRect& localClipRect); | 118 void addClipRectRelativeToPaintOffset(const LayoutRect& localClipRect); |
| 116 | 119 |
| 117 const LayoutObject& m_currentObject; | 120 const LayoutObject& m_currentObject; |
| 118 | 121 |
| 119 unsigned m_forcedSubtreeInvalidationFlags; | 122 unsigned m_forcedSubtreeInvalidationFlags; |
| 120 | 123 |
| 121 bool m_clipped; | 124 bool m_clipped; |
| 122 bool m_clippedForAbsolutePosition; | 125 bool m_clippedForAbsolutePosition; |
| 123 | 126 |
| 124 // Clip rect from paintInvalidationContainer if m_cachedOffsetsEnabled is true
. | 127 // Clip rect from paintInvalidationContainer if m_cachedOffsetsEnabled is |
| 128 // true. |
| 125 LayoutRect m_clipRect; | 129 LayoutRect m_clipRect; |
| 126 LayoutRect m_clipRectForAbsolutePosition; | 130 LayoutRect m_clipRectForAbsolutePosition; |
| 127 | 131 |
| 128 // x/y offset from the paintInvalidationContainer if m_cachedOffsetsEnabled is
true. | 132 // x/y offset from the paintInvalidationContainer if m_cachedOffsetsEnabled is |
| 133 // true. |
| 129 // It includes relative positioning and scroll offsets. | 134 // It includes relative positioning and scroll offsets. |
| 130 LayoutSize m_paintOffset; | 135 LayoutSize m_paintOffset; |
| 131 LayoutSize m_paintOffsetForAbsolutePosition; | 136 LayoutSize m_paintOffsetForAbsolutePosition; |
| 132 | 137 |
| 133 // Whether m_paintOffset[XXX] and m_clipRect[XXX] are valid and can be used | 138 // Whether m_paintOffset[XXX] and m_clipRect[XXX] are valid and can be used |
| 134 // to map a rect from space of the current object to space of paintInvalidatio
nContainer. | 139 // to map a rect from space of the current object to space of |
| 140 // paintInvalidationContainer. |
| 135 bool m_cachedOffsetsEnabled; | 141 bool m_cachedOffsetsEnabled; |
| 136 bool m_cachedOffsetsForAbsolutePositionEnabled; | 142 bool m_cachedOffsetsForAbsolutePositionEnabled; |
| 137 | 143 |
| 138 // The following two fields are never null. Declare them as pointers because w
e need some | 144 // The following two fields are never null. Declare them as pointers because |
| 139 // logic to initialize them in the body of the constructor. | 145 // we need some logic to initialize them in the body of the constructor. |
| 140 | 146 |
| 141 // The current paint invalidation container for normal flow objects. | 147 // The current paint invalidation container for normal flow objects. |
| 142 // It is the enclosing composited object. | 148 // It is the enclosing composited object. |
| 143 const LayoutBoxModelObject* m_paintInvalidationContainer; | 149 const LayoutBoxModelObject* m_paintInvalidationContainer; |
| 144 | 150 |
| 145 // The current paint invalidation container for stacked contents (stacking con
texts or positioned objects). | 151 // The current paint invalidation container for stacked contents (stacking |
| 146 // It is the nearest ancestor composited object which establishes a stacking c
ontext. | 152 // contexts or positioned objects). It is the nearest ancestor composited |
| 147 // See Source/core/paint/README.md ### PaintInvalidationState for details on h
ow stacked contents' | 153 // object which establishes a stacking context. See |
| 148 // paint invalidation containers differ. | 154 // Source/core/paint/README.md ### PaintInvalidationState for details on how |
| 155 // stacked contents' paint invalidation containers differ. |
| 149 const LayoutBoxModelObject* m_paintInvalidationContainerForStackedContents; | 156 const LayoutBoxModelObject* m_paintInvalidationContainerForStackedContents; |
| 150 | 157 |
| 151 const LayoutObject& m_containerForAbsolutePosition; | 158 const LayoutObject& m_containerForAbsolutePosition; |
| 152 | 159 |
| 153 // Transform from the initial viewport coordinate system of an outermost | 160 // Transform from the initial viewport coordinate system of an outermost |
| 154 // SVG root to the userspace _before_ the relevant element. Combining this | 161 // SVG root to the userspace _before_ the relevant element. Combining this |
| 155 // with |m_paintOffset| yields the "final" offset. | 162 // with |m_paintOffset| yields the "final" offset. |
| 156 AffineTransform m_svgTransform; | 163 AffineTransform m_svgTransform; |
| 157 | 164 |
| 158 // Records objects needing paint invalidation on the next frame. See the defin
ition of PaintInvalidationDelayedFull for more details. | 165 // Records objects needing paint invalidation on the next frame. See the |
| 166 // definition of PaintInvalidationDelayedFull for more details. |
| 159 Vector<const LayoutObject*>& m_pendingDelayedPaintInvalidations; | 167 Vector<const LayoutObject*>& m_pendingDelayedPaintInvalidations; |
| 160 | 168 |
| 161 PaintLayer& m_paintingLayer; | 169 PaintLayer& m_paintingLayer; |
| 162 | 170 |
| 163 #if ENABLE(ASSERT) | 171 #if ENABLE(ASSERT) |
| 164 bool m_didUpdateForChildren; | 172 bool m_didUpdateForChildren; |
| 165 #endif | 173 #endif |
| 166 | 174 |
| 167 #if ENABLE(ASSERT) && !defined(NDEBUG) | 175 #if ENABLE(ASSERT) && !defined(NDEBUG) |
| 168 // #define CHECK_FAST_PATH_SLOW_PATH_EQUALITY | 176 // #define CHECK_FAST_PATH_SLOW_PATH_EQUALITY |
| 169 #endif | 177 #endif |
| 170 | 178 |
| 171 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY | 179 #ifdef CHECK_FAST_PATH_SLOW_PATH_EQUALITY |
| 172 void assertFastPathAndSlowPathRectsEqual( | 180 void assertFastPathAndSlowPathRectsEqual( |
| 173 const LayoutRect& fastPathRect, | 181 const LayoutRect& fastPathRect, |
| 174 const LayoutRect& slowPathRect) const; | 182 const LayoutRect& slowPathRect) const; |
| 175 bool m_canCheckFastPathSlowPathEquality; | 183 bool m_canCheckFastPathSlowPathEquality; |
| 176 #endif | 184 #endif |
| 177 }; | 185 }; |
| 178 | 186 |
| 179 // This is temporary to adapt legacy PaintInvalidationState to PaintInvalidatorC
ontext | 187 // This is temporary to adapt legacy PaintInvalidationState to |
| 188 // PaintInvalidatorContext |
| 180 class PaintInvalidatorContextAdapter : public PaintInvalidatorContext { | 189 class PaintInvalidatorContextAdapter : public PaintInvalidatorContext { |
| 181 public: | 190 public: |
| 182 PaintInvalidatorContextAdapter(const PaintInvalidationState&); | 191 PaintInvalidatorContextAdapter(const PaintInvalidationState&); |
| 183 void mapLocalRectToPaintInvalidationBacking(const LayoutObject&, | 192 void mapLocalRectToPaintInvalidationBacking(const LayoutObject&, |
| 184 LayoutRect&) const override; | 193 LayoutRect&) const override; |
| 185 | 194 |
| 186 private: | 195 private: |
| 187 const PaintInvalidationState& m_paintInvalidationState; | 196 const PaintInvalidationState& m_paintInvalidationState; |
| 188 }; | 197 }; |
| 189 | 198 |
| 190 } // namespace blink | 199 } // namespace blink |
| 191 | 200 |
| 192 #endif // PaintInvalidationState_h | 201 #endif // PaintInvalidationState_h |
| OLD | NEW |