Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(475)

Side by Side Diff: third_party/WebKit/Source/core/layout/PaintInvalidationState.h

Issue 1813383002: Move all fast-path paint invalidation mapping into PaintInvalidationState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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's for paint invalidation of the current object.
48 // copy cached paintOffset and clip from the parent PaintInvalidationContain er. 46 // After invalidation of the current object, before invalidation of the subt rees, this method must
49 // This PaintInvalidationContainer can be used to invalidate the current obj ect. 47 // be called to make this PaintInvalidationState suitable for paint invalida tion of children.
50 // 48 void updateForChildren();
51 // 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
53 // paint invalidation of children.
54 void updatePaintOffsetAndClipForChildren();
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 49
63 bool forcedSubtreeInvalidationWithinContainer() const { return m_forcedSubtr eeInvalidationWithinContainer; } 50 bool forcedSubtreeInvalidationWithinContainer() const { return m_forcedSubtr eeInvalidationWithinContainer; }
64 void setForceSubtreeInvalidationWithinContainer() { m_forcedSubtreeInvalidat ionWithinContainer = true; } 51 void setForceSubtreeInvalidationWithinContainer() { m_forcedSubtreeInvalidat ionWithinContainer = true; }
65 52
66 bool forcedSubtreeInvalidationRectUpdateWithinContainer() const { return m_f orcedSubtreeInvalidationRectUpdateWithinContainer; } 53 bool forcedSubtreeInvalidationRectUpdateWithinContainer() const { return m_f orcedSubtreeInvalidationRectUpdateWithinContainer; }
67 void setForceSubtreeInvalidationRectUpdateWithinContainer() { m_forcedSubtre eInvalidationRectUpdateWithinContainer = true; } 54 void setForceSubtreeInvalidationRectUpdateWithinContainer() { m_forcedSubtre eInvalidationRectUpdateWithinContainer = true; }
68 55
69 const LayoutBoxModelObject& paintInvalidationContainer() const { return m_pa intInvalidationContainer; } 56 const LayoutBoxModelObject& paintInvalidationContainer() const { return m_pa intInvalidationContainer; }
70 57
71 bool canMapToAncestor(const LayoutBoxModelObject* ancestor) const 58 // Computes the position of the current object ((0,0) in the space of the ob ject)
72 { 59 // in the space of paint invalidation backing.
73 return m_cachedOffsetsEnabled && ancestor == &m_paintInvalidationContain er; 60 LayoutPoint computePositionFromPaintInvalidationBacking() const;
74 } 61
75 void mapObjectRectToAncestor(const LayoutObject&, const LayoutBoxModelObject * ancestor, LayoutRect&) const; 62 // Returns the rect bounds needed to invalidate paint of this object,
63 // in the space of paint invalidation backing.
64 LayoutRect computePaintInvalidationRectInBacking() const;
65
66 void mapLocalRectToPaintInvalidationBacking(LayoutRect&) const;
76 67
77 // Records |obj| as needing paint invalidation on the next frame. See the de finition of PaintInvalidationDelayedFull for more details. 68 // 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); } 69 void pushDelayedPaintInvalidationTarget(LayoutObject& obj) const { m_pending DelayedPaintInvalidations.append(&obj); }
79 Vector<LayoutObject*>& pendingDelayedPaintInvalidationTargets() const { retu rn m_pendingDelayedPaintInvalidations; } 70 Vector<LayoutObject*>& pendingDelayedPaintInvalidationTargets() const { retu rn m_pendingDelayedPaintInvalidations; }
80 71
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; 72 PaintLayer& enclosingSelfPaintingLayer(const LayoutObject&) const;
87 73
74 #if ENABLE(ASSERT)
75 const LayoutObject& currentObject() const { return m_currentObject; }
76 #endif
77
88 private: 78 private:
89 PaintInvalidationState(const LayoutView&, Vector<LayoutObject*>& pendingDela yedPaintInvalidations, const PaintInvalidationState* ownerPaintInvalidationState ); 79 LayoutRect computePaintInvalidationRectInBackingForSVG() const;
90 80
91 void applyClipIfNeeded(); 81 void addClipRectRelativeToPaintOffset(const LayoutRect& localClipRect);
92 void addClipRectRelativeToPaintOffset(const LayoutSize& clipSize);
93 82
94 friend class ForceHorriblySlowRectMapping; 83 friend class ForceHorriblySlowRectMapping;
95 84
96 const LayoutObject& m_currentObject; 85 const LayoutObject& m_currentObject;
97 86
98 bool m_clipped; 87 bool m_clipped;
99 mutable bool m_cachedOffsetsEnabled; 88 mutable bool m_cachedOffsetsEnabled;
100 bool m_forcedSubtreeInvalidationWithinContainer; 89 bool m_forcedSubtreeInvalidationWithinContainer;
101 bool m_forcedSubtreeInvalidationRectUpdateWithinContainer; 90 bool m_forcedSubtreeInvalidationRectUpdateWithinContainer;
102 bool m_viewClippingAndScrollOffsetDisabled;
103 91
104 LayoutRect m_clipRect; 92 LayoutRect m_clipRect;
105 93
106 // x/y offset from paint invalidation container. Includes relative positioni ng and scroll offsets. 94 // x/y offset from paint invalidation container. Includes relative positioni ng and scroll offsets.
107 LayoutSize m_paintOffset; 95 LayoutSize m_paintOffset;
108 96
109 // The current paint invalidation container. 97 // The current paint invalidation container.
110 // 98 //
111 // It is the enclosing composited object. 99 // It is the enclosing composited object.
112 const LayoutBoxModelObject& m_paintInvalidationContainer; 100 const LayoutBoxModelObject& m_paintInvalidationContainer;
113 101
114 // Transform from the initial viewport coordinate system of an outermost 102 // Transform from the initial viewport coordinate system of an outermost
115 // SVG root to the userspace _before_ the relevant element. Combining this 103 // SVG root to the userspace _before_ the relevant element. Combining this
116 // with |m_paintOffset| yields the "final" offset. 104 // with |m_paintOffset| yields the "final" offset.
117 AffineTransform m_svgTransform; 105 AffineTransform m_svgTransform;
118 106
119 Vector<LayoutObject*>& m_pendingDelayedPaintInvalidations; 107 Vector<LayoutObject*>& m_pendingDelayedPaintInvalidations;
120 108
121 PaintLayer& m_enclosingSelfPaintingLayer; 109 PaintLayer& m_enclosingSelfPaintingLayer;
122 110
123 #if ENABLE(ASSERT) 111 #if ENABLE(ASSERT)
124 bool m_didUpdatePaintOffsetAndClipForChildren; 112 bool m_didUpdateForChildren;
125 #endif 113 #endif
126 }; 114 };
127 115
128 // Suspends the PaintInvalidationState cached offset and clipRect optimization. Used under transforms 116 // 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 117 // 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 118 // 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). 119 // is nested under a relatively positioned inline-block child).
132 class ForceHorriblySlowRectMapping { 120 class ForceHorriblySlowRectMapping {
133 STACK_ALLOCATED(); 121 STACK_ALLOCATED();
134 WTF_MAKE_NONCOPYABLE(ForceHorriblySlowRectMapping); 122 WTF_MAKE_NONCOPYABLE(ForceHorriblySlowRectMapping);
135 public: 123 public:
136 ForceHorriblySlowRectMapping(const PaintInvalidationState* paintInvalidation State) 124 ForceHorriblySlowRectMapping(const PaintInvalidationState* paintInvalidation State)
137 : m_paintInvalidationState(paintInvalidationState) 125 : m_paintInvalidationState(paintInvalidationState)
138 , m_didDisable(m_paintInvalidationState && m_paintInvalidationState->cac hedOffsetsEnabled()) 126 , m_didDisable(m_paintInvalidationState && m_paintInvalidationState->m_c achedOffsetsEnabled)
139 { 127 {
140 if (m_paintInvalidationState) 128 if (m_paintInvalidationState)
141 m_paintInvalidationState->m_cachedOffsetsEnabled = false; 129 m_paintInvalidationState->m_cachedOffsetsEnabled = false;
142 } 130 }
143 131
144 ~ForceHorriblySlowRectMapping() 132 ~ForceHorriblySlowRectMapping()
145 { 133 {
146 if (m_didDisable) 134 if (m_didDisable)
147 m_paintInvalidationState->m_cachedOffsetsEnabled = true; 135 m_paintInvalidationState->m_cachedOffsetsEnabled = true;
148 } 136 }
149 private: 137 private:
150 const PaintInvalidationState* m_paintInvalidationState; 138 const PaintInvalidationState* m_paintInvalidationState;
151 bool m_didDisable; 139 bool m_didDisable;
152 }; 140 };
153 141
154 } // namespace blink 142 } // namespace blink
155 143
156 #endif // PaintInvalidationState_h 144 #endif // PaintInvalidationState_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698