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

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: Disable fast-path/slow-path comparison because of saturated operations of LayoutUnit Created 4 years, 8 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 24 matching lines...) Expand all
35 class PaintInvalidationState { 35 class PaintInvalidationState {
36 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); 36 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
37 WTF_MAKE_NONCOPYABLE(PaintInvalidationState); 37 WTF_MAKE_NONCOPYABLE(PaintInvalidationState);
38 public: 38 public:
39 PaintInvalidationState(const PaintInvalidationState& parentState, const Layo utObject&); 39 PaintInvalidationState(const PaintInvalidationState& parentState, const Layo utObject&);
40 40
41 // TODO(wangxianzhu): This is temporary for positioned object whose paintInv alidationContainer is different from 41 // TODO(wangxianzhu): This is temporary for positioned object whose paintInv alidationContainer is different from
42 // the one we find during tree walk. Remove this after we fix the issue with tree walk in DOM-order. 42 // the one we find during tree walk. Remove this after we fix the issue with tree walk in DOM-order.
43 PaintInvalidationState(const PaintInvalidationState& parentState, const Layo utBoxModelObject&, const LayoutBoxModelObject& paintInvalidationContainer); 43 PaintInvalidationState(const PaintInvalidationState& parentState, const Layo utBoxModelObject&, const LayoutBoxModelObject& paintInvalidationContainer);
44 44
45 // For root LayoutView. 45 // For root LayoutView, or when sub-frame LayoutView's invalidateTreeIfNeede d() is called directly from
46 PaintInvalidationState(const LayoutView& layoutView, Vector<LayoutObject*>& pendingDelayedPaintInvalidations) 46 // FrameView::invalidateTreeIfNeededRecursive() instead of the owner LayoutP art.
47 : PaintInvalidationState(layoutView, pendingDelayedPaintInvalidations, n ullptr) { } 47 // TODO(wangxianzhu): Eliminate the latter case.
48 // For LayoutView in a sub-frame. 48 PaintInvalidationState(const LayoutView&, Vector<LayoutObject*>& pendingDela yedPaintInvalidations);
49 PaintInvalidationState(const LayoutView& layoutView, const PaintInvalidation State& ownerPaintInvalidationState)
50 : PaintInvalidationState(layoutView, ownerPaintInvalidationState.m_pendi ngDelayedPaintInvalidations, &ownerPaintInvalidationState) { }
51 49
52 // When a PaintInvalidationState is constructed, it just updates paintInvali dationContainer and 50 // When a PaintInvalidationState is constructed, it can be used to map point s/rects in the object's
53 // copy cached paintOffset and clip from the parent PaintInvalidationContain er. 51 // local space (border box space for LayoutBoxes). After invalidation of the current object,
54 // This PaintInvalidationContainer can be used to invalidate the current obj ect. 52 // before invalidation of the subtrees, this method must be called to apply clip and scroll offset
55 // 53 // etc. for creating child PaintInvalidationStates.
56 // After invalidation of the current object, before invalidation of the subt rees, 54 void updateForChildren();
57 // this method must be called to make this PaintInvalidationState suitable f or
58 // paint invalidation of children.
59 void updatePaintOffsetAndClipForChildren();
60
61 const LayoutRect& clipRect() const { return m_clipRect; }
62 const LayoutSize& paintOffset() const { return m_paintOffset; }
63 const AffineTransform& svgTransform() const { return m_svgTransform; }
64
65 bool cachedOffsetsEnabled() const { return m_cachedOffsetsEnabled; }
66 bool isClipped() const { return m_clipped; }
67 55
68 bool forcedSubtreeInvalidationWithinContainer() const { return m_forcedSubtr eeInvalidationWithinContainer; } 56 bool forcedSubtreeInvalidationWithinContainer() const { return m_forcedSubtr eeInvalidationWithinContainer; }
69 void setForceSubtreeInvalidationWithinContainer() { m_forcedSubtreeInvalidat ionWithinContainer = true; } 57 void setForceSubtreeInvalidationWithinContainer() { m_forcedSubtreeInvalidat ionWithinContainer = true; }
70 58
71 bool forcedSubtreeInvalidationRectUpdateWithinContainer() const { return m_f orcedSubtreeInvalidationRectUpdateWithinContainer; } 59 bool forcedSubtreeInvalidationRectUpdateWithinContainer() const { return m_f orcedSubtreeInvalidationRectUpdateWithinContainer; }
72 void setForceSubtreeInvalidationRectUpdateWithinContainer() { m_forcedSubtre eInvalidationRectUpdateWithinContainer = true; } 60 void setForceSubtreeInvalidationRectUpdateWithinContainer() { m_forcedSubtre eInvalidationRectUpdateWithinContainer = true; }
73 61
74 const LayoutBoxModelObject& paintInvalidationContainer() const { return m_pa intInvalidationContainer; } 62 const LayoutBoxModelObject& paintInvalidationContainer() const { return m_pa intInvalidationContainer; }
75 63
76 bool canMapToAncestor(const LayoutBoxModelObject* ancestor) const 64 // Computes the position of the current object ((0,0) in the space of the ob ject)
77 { 65 // in the space of paint invalidation backing.
78 return m_cachedOffsetsEnabled && ancestor == &m_paintInvalidationContain er; 66 LayoutPoint computePositionFromPaintInvalidationBacking() const;
79 } 67
80 bool mapObjectRectToAncestor(const LayoutObject&, const LayoutBoxModelObject * ancestor, LayoutRect&, VisibleRectFlags = DefaultVisibleRectFlags) const; 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;
81 73
82 // 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.
83 void pushDelayedPaintInvalidationTarget(LayoutObject& obj) const { m_pending DelayedPaintInvalidations.append(&obj); } 75 void pushDelayedPaintInvalidationTarget(LayoutObject& obj) const { m_pending DelayedPaintInvalidations.append(&obj); }
84 Vector<LayoutObject*>& pendingDelayedPaintInvalidationTargets() const { retu rn m_pendingDelayedPaintInvalidations; } 76 Vector<LayoutObject*>& pendingDelayedPaintInvalidationTargets() const { retu rn m_pendingDelayedPaintInvalidations; }
85 77
86 // Disable view clipping and scroll offset adjustment for paint invalidation of FrameView scrollbars.
87 // TODO(wangxianzhu): Remove this when root-layer-scrolls launches.
88 bool viewClippingAndScrollOffsetDisabled() const { return m_viewClippingAndS crollOffsetDisabled; }
89 void setViewClippingAndScrollOffsetDisabled(bool b) { m_viewClippingAndScrol lOffsetDisabled = b; }
90
91 PaintLayer& enclosingSelfPaintingLayer(const LayoutObject&) const; 78 PaintLayer& enclosingSelfPaintingLayer(const LayoutObject&) const;
92 79
80 #if ENABLE(ASSERT)
81 const LayoutObject& currentObject() const { return m_currentObject; }
82 #endif
83
93 private: 84 private:
94 PaintInvalidationState(const LayoutView&, Vector<LayoutObject*>& pendingDela yedPaintInvalidations, const PaintInvalidationState* ownerPaintInvalidationState ); 85 LayoutRect computePaintInvalidationRectInBackingForSVG() const;
95 86
96 void applyClipIfNeeded(); 87 void addClipRectRelativeToPaintOffset(const LayoutRect& localClipRect);
97 void addClipRectRelativeToPaintOffset(const LayoutSize& clipSize);
98 88
99 friend class ForceHorriblySlowRectMapping; 89 friend class ForceHorriblySlowRectMapping;
100 90
101 const LayoutObject& m_currentObject; 91 const LayoutObject& m_currentObject;
102 92
103 bool m_clipped; 93 bool m_clipped;
104 mutable bool m_cachedOffsetsEnabled; 94 mutable bool m_cachedOffsetsEnabled;
105 bool m_forcedSubtreeInvalidationWithinContainer; 95 bool m_forcedSubtreeInvalidationWithinContainer;
106 bool m_forcedSubtreeInvalidationRectUpdateWithinContainer; 96 bool m_forcedSubtreeInvalidationRectUpdateWithinContainer;
107 bool m_viewClippingAndScrollOffsetDisabled;
108 97
109 LayoutRect m_clipRect; 98 LayoutRect m_clipRect;
110 99
111 // 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.
112 LayoutSize m_paintOffset; 101 LayoutSize m_paintOffset;
113 102
114 // The current paint invalidation container. 103 // The current paint invalidation container.
115 // 104 //
116 // It is the enclosing composited object. 105 // It is the enclosing composited object.
117 const LayoutBoxModelObject& m_paintInvalidationContainer; 106 const LayoutBoxModelObject& m_paintInvalidationContainer;
118 107
119 // Transform from the initial viewport coordinate system of an outermost 108 // Transform from the initial viewport coordinate system of an outermost
120 // SVG root to the userspace _before_ the relevant element. Combining this 109 // SVG root to the userspace _before_ the relevant element. Combining this
121 // with |m_paintOffset| yields the "final" offset. 110 // with |m_paintOffset| yields the "final" offset.
122 AffineTransform m_svgTransform; 111 AffineTransform m_svgTransform;
123 112
124 Vector<LayoutObject*>& m_pendingDelayedPaintInvalidations; 113 Vector<LayoutObject*>& m_pendingDelayedPaintInvalidations;
125 114
126 PaintLayer& m_enclosingSelfPaintingLayer; 115 PaintLayer& m_enclosingSelfPaintingLayer;
127 116
128 #if ENABLE(ASSERT) 117 #if ENABLE(ASSERT)
129 bool m_didUpdatePaintOffsetAndClipForChildren; 118 bool m_didUpdateForChildren;
130 #endif 119 #endif
131 }; 120 };
132 121
133 // Suspends the PaintInvalidationState cached offset and clipRect optimization. Used under transforms 122 // Suspends the PaintInvalidationState cached offset and clipRect optimization. Used under transforms
134 // 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
135 // 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
136 // is nested under a relatively positioned inline-block child). 125 // is nested under a relatively positioned inline-block child).
137 class ForceHorriblySlowRectMapping { 126 class ForceHorriblySlowRectMapping {
138 STACK_ALLOCATED(); 127 STACK_ALLOCATED();
139 WTF_MAKE_NONCOPYABLE(ForceHorriblySlowRectMapping); 128 WTF_MAKE_NONCOPYABLE(ForceHorriblySlowRectMapping);
140 public: 129 public:
141 ForceHorriblySlowRectMapping(const PaintInvalidationState* paintInvalidation State) 130 ForceHorriblySlowRectMapping(const PaintInvalidationState* paintInvalidation State)
142 : m_paintInvalidationState(paintInvalidationState) 131 : m_paintInvalidationState(paintInvalidationState)
143 , m_didDisable(m_paintInvalidationState && m_paintInvalidationState->cac hedOffsetsEnabled()) 132 , m_didDisable(m_paintInvalidationState && m_paintInvalidationState->m_c achedOffsetsEnabled)
144 { 133 {
145 if (m_paintInvalidationState) 134 if (m_paintInvalidationState)
146 m_paintInvalidationState->m_cachedOffsetsEnabled = false; 135 m_paintInvalidationState->m_cachedOffsetsEnabled = false;
147 } 136 }
148 137
149 ~ForceHorriblySlowRectMapping() 138 ~ForceHorriblySlowRectMapping()
150 { 139 {
151 if (m_didDisable) 140 if (m_didDisable)
152 m_paintInvalidationState->m_cachedOffsetsEnabled = true; 141 m_paintInvalidationState->m_cachedOffsetsEnabled = true;
153 } 142 }
154 private: 143 private:
155 const PaintInvalidationState* m_paintInvalidationState; 144 const PaintInvalidationState* m_paintInvalidationState;
156 bool m_didDisable; 145 bool m_didDisable;
157 }; 146 };
158 147
159 } // namespace blink 148 } // namespace blink
160 149
161 #endif // PaintInvalidationState_h 150 #endif // PaintInvalidationState_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutView.cpp ('k') | third_party/WebKit/Source/core/layout/PaintInvalidationState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698