| 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 "platform/geometry/LayoutRect.h" | 8 #include "platform/geometry/LayoutRect.h" |
| 9 #include "platform/transforms/AffineTransform.h" | 9 #include "platform/transforms/AffineTransform.h" |
| 10 #include "wtf/Allocator.h" | 10 #include "wtf/Allocator.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 class PaintInvalidationState { | 30 class PaintInvalidationState { |
| 31 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 31 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 32 WTF_MAKE_NONCOPYABLE(PaintInvalidationState); | 32 WTF_MAKE_NONCOPYABLE(PaintInvalidationState); |
| 33 public: | 33 public: |
| 34 PaintInvalidationState(const PaintInvalidationState& parentState, const Layo
utObject&); | 34 PaintInvalidationState(const PaintInvalidationState& parentState, const Layo
utObject&); |
| 35 | 35 |
| 36 // TODO(wangxianzhu): This is temporary for positioned object whose paintInv
alidationContainer is different from | 36 // TODO(wangxianzhu): This is temporary for positioned object whose paintInv
alidationContainer is different from |
| 37 // the one we find during tree walk. Remove this after we fix the issue with
tree walk in DOM-order. | 37 // the one we find during tree walk. Remove this after we fix the issue with
tree walk in DOM-order. |
| 38 PaintInvalidationState(const PaintInvalidationState& parentState, const Layo
utBoxModelObject&, const LayoutBoxModelObject& paintInvalidationContainer); | 38 PaintInvalidationState(const PaintInvalidationState& parentState, const Layo
utBoxModelObject&, const LayoutBoxModelObject& paintInvalidationContainer); |
| 39 | 39 |
| 40 // For root LayoutView. | 40 // For root LayoutView, or when sub-frame LayoutView's invalidateTreeIfNeede
d() is called directly from |
| 41 PaintInvalidationState(const LayoutView& layoutView, Vector<LayoutObject*>&
pendingDelayedPaintInvalidations) | 41 // FrameView::invalidateTreeIfNeededRecursive() instead of the owner LayoutP
art. |
| 42 : PaintInvalidationState(layoutView, pendingDelayedPaintInvalidations, n
ullptr) { } | 42 // TODO(wangxianzhu): Eliminate the latter case. |
| 43 // For LayoutView in a sub-frame. | 43 PaintInvalidationState(const LayoutView&, Vector<LayoutObject*>& pendingDela
yedPaintInvalidations); |
| 44 PaintInvalidationState(const LayoutView& layoutView, const PaintInvalidation
State& ownerPaintInvalidationState) | |
| 45 : PaintInvalidationState(layoutView, ownerPaintInvalidationState.m_pendi
ngDelayedPaintInvalidations, &ownerPaintInvalidationState) { } | |
| 46 | 44 |
| 47 // When a PaintInvalidationState is constructed, it just updates paintInvali
dationContainer and | 45 // When a PaintInvalidationState is constructed, it just updates paintInvali
dationContainer and |
| 48 // copy cached paintOffset and clip from the parent PaintInvalidationContain
er. | 46 // copy cached paintOffset and clip from the parent PaintInvalidationContain
er. |
| 49 // This PaintInvalidationContainer can be used to invalidate the current obj
ect. | 47 // This PaintInvalidationContainer can be used to invalidate the current obj
ect. |
| 50 // | 48 // |
| 51 // After invalidation of the current object, before invalidation of the subt
rees, | 49 // After invalidation of the current object, before invalidation of the subt
rees, |
| 52 // this method must be called to make this PaintInvalidationState suitable f
or | 50 // this method must be called to make this PaintInvalidationState suitable f
or |
| 53 // paint invalidation of children. | 51 // paint invalidation of children. |
| 54 void updatePaintOffsetAndClipForChildren(); | 52 void updateForChildren(); |
| 55 | |
| 56 const LayoutRect& clipRect() const { return m_clipRect; } | |
| 57 const LayoutSize& paintOffset() const { return m_paintOffset; } | |
| 58 const AffineTransform& svgTransform() const { return m_svgTransform; } | |
| 59 | |
| 60 bool cachedOffsetsEnabled() const { return m_cachedOffsetsEnabled; } | |
| 61 bool isClipped() const { return m_clipped; } | |
| 62 | 53 |
| 63 bool forcedSubtreeInvalidationWithinContainer() const { return m_forcedSubtr
eeInvalidationWithinContainer; } | 54 bool forcedSubtreeInvalidationWithinContainer() const { return m_forcedSubtr
eeInvalidationWithinContainer; } |
| 64 void setForceSubtreeInvalidationWithinContainer() { m_forcedSubtreeInvalidat
ionWithinContainer = true; } | 55 void setForceSubtreeInvalidationWithinContainer() { m_forcedSubtreeInvalidat
ionWithinContainer = true; } |
| 65 | 56 |
| 66 bool forcedSubtreeInvalidationRectUpdateWithinContainer() const { return m_f
orcedSubtreeInvalidationRectUpdateWithinContainer; } | 57 bool forcedSubtreeInvalidationRectUpdateWithinContainer() const { return m_f
orcedSubtreeInvalidationRectUpdateWithinContainer; } |
| 67 void setForceSubtreeInvalidationRectUpdateWithinContainer() { m_forcedSubtre
eInvalidationRectUpdateWithinContainer = true; } | 58 void setForceSubtreeInvalidationRectUpdateWithinContainer() { m_forcedSubtre
eInvalidationRectUpdateWithinContainer = true; } |
| 68 | 59 |
| 69 const LayoutBoxModelObject& paintInvalidationContainer() const { return m_pa
intInvalidationContainer; } | 60 const LayoutBoxModelObject& paintInvalidationContainer() const { return m_pa
intInvalidationContainer; } |
| 70 | 61 |
| 71 bool canMapToAncestor(const LayoutBoxModelObject* ancestor) const | 62 // Computes the position of the current object ((0,0) in the space of the ob
ject) |
| 72 { | 63 // in the space of paint invalidation backing. |
| 73 return m_cachedOffsetsEnabled && ancestor == &m_paintInvalidationContain
er; | 64 // The result will be the same as the location of computePaintInvalidaitonRe
ctInBacking() |
| 74 } | 65 // if the object doesn't have overflow at top/left or transformation. |
| 75 void mapObjectRectToAncestor(const LayoutObject&, const LayoutBoxModelObject
* ancestor, LayoutRect&) const; | 66 LayoutPoint computePositionFromPaintInvalidationBacking() const; |
| 67 |
| 68 // Returns the rect bounds needed to invalidate paint of this object, |
| 69 // in the space of paint invalidation backing. |
| 70 LayoutRect computePaintInvalidationRectInBacking() const; |
| 71 |
| 72 void mapLocalRectToPaintInvalidationBacking(LayoutRect&) const; |
| 76 | 73 |
| 77 // Records |obj| as needing paint invalidation on the next frame. See the de
finition of PaintInvalidationDelayedFull for more details. | 74 // Records |obj| as needing paint invalidation on the next frame. See the de
finition of PaintInvalidationDelayedFull for more details. |
| 78 void pushDelayedPaintInvalidationTarget(LayoutObject& obj) const { m_pending
DelayedPaintInvalidations.append(&obj); } | 75 void pushDelayedPaintInvalidationTarget(LayoutObject& obj) const { m_pending
DelayedPaintInvalidations.append(&obj); } |
| 79 Vector<LayoutObject*>& pendingDelayedPaintInvalidationTargets() const { retu
rn m_pendingDelayedPaintInvalidations; } | 76 Vector<LayoutObject*>& pendingDelayedPaintInvalidationTargets() const { retu
rn m_pendingDelayedPaintInvalidations; } |
| 80 | 77 |
| 81 // Disable view clipping and scroll offset adjustment for paint invalidation
of FrameView scrollbars. | |
| 82 // TODO(wangxianzhu): Remove this when root-layer-scrolls launches. | |
| 83 bool viewClippingAndScrollOffsetDisabled() const { return m_viewClippingAndS
crollOffsetDisabled; } | |
| 84 void setViewClippingAndScrollOffsetDisabled(bool b) { m_viewClippingAndScrol
lOffsetDisabled = b; } | |
| 85 | |
| 86 PaintLayer& enclosingSelfPaintingLayer(const LayoutObject&) const; | 78 PaintLayer& enclosingSelfPaintingLayer(const LayoutObject&) const; |
| 87 | 79 |
| 80 #if ENABLE(ASSERT) |
| 81 const LayoutObject& currentObject() const { return m_currentObject; } |
| 82 #endif |
| 83 |
| 88 private: | 84 private: |
| 89 PaintInvalidationState(const LayoutView&, Vector<LayoutObject*>& pendingDela
yedPaintInvalidations, const PaintInvalidationState* ownerPaintInvalidationState
); | 85 LayoutRect computePaintInvalidationRectInBackingForSVG() const; |
| 90 | 86 |
| 91 void applyClipIfNeeded(); | |
| 92 void addClipRectRelativeToPaintOffset(const LayoutSize& clipSize); | 87 void addClipRectRelativeToPaintOffset(const LayoutSize& clipSize); |
| 93 | 88 |
| 94 friend class ForceHorriblySlowRectMapping; | 89 friend class ForceHorriblySlowRectMapping; |
| 95 | 90 |
| 96 const LayoutObject& m_currentObject; | 91 const LayoutObject& m_currentObject; |
| 97 | 92 |
| 98 bool m_clipped; | 93 bool m_clipped; |
| 99 mutable bool m_cachedOffsetsEnabled; | 94 mutable bool m_cachedOffsetsEnabled; |
| 100 bool m_forcedSubtreeInvalidationWithinContainer; | 95 bool m_forcedSubtreeInvalidationWithinContainer; |
| 101 bool m_forcedSubtreeInvalidationRectUpdateWithinContainer; | 96 bool m_forcedSubtreeInvalidationRectUpdateWithinContainer; |
| 102 bool m_viewClippingAndScrollOffsetDisabled; | |
| 103 | 97 |
| 104 LayoutRect m_clipRect; | 98 LayoutRect m_clipRect; |
| 105 | 99 |
| 106 // x/y offset from paint invalidation container. Includes relative positioni
ng and scroll offsets. | 100 // x/y offset from paint invalidation container. Includes relative positioni
ng and scroll offsets. |
| 107 LayoutSize m_paintOffset; | 101 LayoutSize m_paintOffset; |
| 108 | 102 |
| 109 // The current paint invalidation container. | 103 // The current paint invalidation container. |
| 110 // | 104 // |
| 111 // It is the enclosing composited object. | 105 // It is the enclosing composited object. |
| 112 const LayoutBoxModelObject& m_paintInvalidationContainer; | 106 const LayoutBoxModelObject& m_paintInvalidationContainer; |
| 113 | 107 |
| 114 // Transform from the initial viewport coordinate system of an outermost | 108 // Transform from the initial viewport coordinate system of an outermost |
| 115 // SVG root to the userspace _before_ the relevant element. Combining this | 109 // SVG root to the userspace _before_ the relevant element. Combining this |
| 116 // with |m_paintOffset| yields the "final" offset. | 110 // with |m_paintOffset| yields the "final" offset. |
| 117 AffineTransform m_svgTransform; | 111 AffineTransform m_svgTransform; |
| 118 | 112 |
| 119 Vector<LayoutObject*>& m_pendingDelayedPaintInvalidations; | 113 Vector<LayoutObject*>& m_pendingDelayedPaintInvalidations; |
| 120 | 114 |
| 121 PaintLayer& m_enclosingSelfPaintingLayer; | 115 PaintLayer& m_enclosingSelfPaintingLayer; |
| 122 | 116 |
| 123 #if ENABLE(ASSERT) | 117 #if ENABLE(ASSERT) |
| 124 bool m_didUpdatePaintOffsetAndClipForChildren; | 118 bool m_didUpdateForChildren; |
| 125 #endif | 119 #endif |
| 126 }; | 120 }; |
| 127 | 121 |
| 128 // Suspends the PaintInvalidationState cached offset and clipRect optimization.
Used under transforms | 122 // Suspends the PaintInvalidationState cached offset and clipRect optimization.
Used under transforms |
| 129 // that cannot be represented by PaintInvalidationState (common in SVG) and when
paint invalidation | 123 // that cannot be represented by PaintInvalidationState (common in SVG) and when
paint invalidation |
| 130 // containers don't follow the common tree-walk algorithm (e.g. when an absolute
positioned descendant | 124 // containers don't follow the common tree-walk algorithm (e.g. when an absolute
positioned descendant |
| 131 // is nested under a relatively positioned inline-block child). | 125 // is nested under a relatively positioned inline-block child). |
| 132 class ForceHorriblySlowRectMapping { | 126 class ForceHorriblySlowRectMapping { |
| 133 STACK_ALLOCATED(); | 127 STACK_ALLOCATED(); |
| 134 WTF_MAKE_NONCOPYABLE(ForceHorriblySlowRectMapping); | 128 WTF_MAKE_NONCOPYABLE(ForceHorriblySlowRectMapping); |
| 135 public: | 129 public: |
| 136 ForceHorriblySlowRectMapping(const PaintInvalidationState* paintInvalidation
State) | 130 ForceHorriblySlowRectMapping(const PaintInvalidationState* paintInvalidation
State) |
| 137 : m_paintInvalidationState(paintInvalidationState) | 131 : m_paintInvalidationState(paintInvalidationState) |
| 138 , m_didDisable(m_paintInvalidationState && m_paintInvalidationState->cac
hedOffsetsEnabled()) | 132 , m_didDisable(m_paintInvalidationState && m_paintInvalidationState->m_c
achedOffsetsEnabled) |
| 139 { | 133 { |
| 140 if (m_paintInvalidationState) | 134 if (m_paintInvalidationState) |
| 141 m_paintInvalidationState->m_cachedOffsetsEnabled = false; | 135 m_paintInvalidationState->m_cachedOffsetsEnabled = false; |
| 142 } | 136 } |
| 143 | 137 |
| 144 ~ForceHorriblySlowRectMapping() | 138 ~ForceHorriblySlowRectMapping() |
| 145 { | 139 { |
| 146 if (m_didDisable) | 140 if (m_didDisable) |
| 147 m_paintInvalidationState->m_cachedOffsetsEnabled = true; | 141 m_paintInvalidationState->m_cachedOffsetsEnabled = true; |
| 148 } | 142 } |
| 149 private: | 143 private: |
| 150 const PaintInvalidationState* m_paintInvalidationState; | 144 const PaintInvalidationState* m_paintInvalidationState; |
| 151 bool m_didDisable; | 145 bool m_didDisable; |
| 152 }; | 146 }; |
| 153 | 147 |
| 154 } // namespace blink | 148 } // namespace blink |
| 155 | 149 |
| 156 #endif // PaintInvalidationState_h | 150 #endif // PaintInvalidationState_h |
| OLD | NEW |