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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/ScrollPaintPropertyNode.h

Issue 2638333007: Add compositor element id for scroll nodes in SPv2. (Closed)
Patch Set: Sync to head. Created 3 years, 11 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 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 ScrollPaintPropertyNode_h 5 #ifndef ScrollPaintPropertyNode_h
6 #define ScrollPaintPropertyNode_h 6 #define ScrollPaintPropertyNode_h
7 7
8 #include "platform/PlatformExport.h" 8 #include "platform/PlatformExport.h"
9 #include "platform/geometry/FloatSize.h" 9 #include "platform/geometry/FloatSize.h"
10 #include "platform/graphics/CompositorElementId.h"
10 #include "platform/graphics/paint/TransformPaintPropertyNode.h" 11 #include "platform/graphics/paint/TransformPaintPropertyNode.h"
11 #include "platform/scroll/MainThreadScrollingReason.h" 12 #include "platform/scroll/MainThreadScrollingReason.h"
12 #include "wtf/PassRefPtr.h" 13 #include "wtf/PassRefPtr.h"
13 #include "wtf/RefCounted.h" 14 #include "wtf/RefCounted.h"
14 #include "wtf/RefPtr.h" 15 #include "wtf/RefPtr.h"
15 #include "wtf/text/WTFString.h" 16 #include "wtf/text/WTFString.h"
16 17
17 #include <iosfwd> 18 #include <iosfwd>
18 19
19 namespace blink { 20 namespace blink {
(...skipping 13 matching lines...) Expand all
33 // This node is really a sentinel, and does not represent a real scroll. 34 // This node is really a sentinel, and does not represent a real scroll.
34 static ScrollPaintPropertyNode* root(); 35 static ScrollPaintPropertyNode* root();
35 36
36 static PassRefPtr<ScrollPaintPropertyNode> create( 37 static PassRefPtr<ScrollPaintPropertyNode> create(
37 PassRefPtr<const ScrollPaintPropertyNode> parent, 38 PassRefPtr<const ScrollPaintPropertyNode> parent,
38 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation, 39 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation,
39 const IntSize& clip, 40 const IntSize& clip,
40 const IntSize& bounds, 41 const IntSize& bounds,
41 bool userScrollableHorizontal, 42 bool userScrollableHorizontal,
42 bool userScrollableVertical, 43 bool userScrollableVertical,
43 MainThreadScrollingReasons mainThreadScrollingReasons) { 44 MainThreadScrollingReasons mainThreadScrollingReasons,
45 const CompositorElementId& compositorElementId = CompositorElementId()) {
44 return adoptRef(new ScrollPaintPropertyNode( 46 return adoptRef(new ScrollPaintPropertyNode(
45 std::move(parent), std::move(scrollOffsetTranslation), clip, bounds, 47 std::move(parent), std::move(scrollOffsetTranslation), clip, bounds,
46 userScrollableHorizontal, userScrollableVertical, 48 userScrollableHorizontal, userScrollableVertical,
47 mainThreadScrollingReasons)); 49 mainThreadScrollingReasons, compositorElementId));
48 } 50 }
49 51
50 void update( 52 void update(
51 PassRefPtr<const ScrollPaintPropertyNode> parent, 53 PassRefPtr<const ScrollPaintPropertyNode> parent,
52 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation, 54 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation,
53 const IntSize& clip, 55 const IntSize& clip,
54 const IntSize& bounds, 56 const IntSize& bounds,
55 bool userScrollableHorizontal, 57 bool userScrollableHorizontal,
56 bool userScrollableVertical, 58 bool userScrollableVertical,
57 MainThreadScrollingReasons mainThreadScrollingReasons) { 59 MainThreadScrollingReasons mainThreadScrollingReasons,
60 CompositorElementId compositorElementId = CompositorElementId()) {
58 DCHECK(!isRoot()); 61 DCHECK(!isRoot());
59 DCHECK(parent != this); 62 DCHECK(parent != this);
60 m_parent = parent; 63 m_parent = parent;
61 DCHECK(scrollOffsetTranslation->matrix().isIdentityOr2DTranslation()); 64 DCHECK(scrollOffsetTranslation->matrix().isIdentityOr2DTranslation());
62 m_scrollOffsetTranslation = scrollOffsetTranslation; 65 m_scrollOffsetTranslation = scrollOffsetTranslation;
63 m_clip = clip; 66 m_clip = clip;
64 m_bounds = bounds; 67 m_bounds = bounds;
65 m_userScrollableHorizontal = userScrollableHorizontal; 68 m_userScrollableHorizontal = userScrollableHorizontal;
66 m_userScrollableVertical = userScrollableVertical; 69 m_userScrollableVertical = userScrollableVertical;
67 m_mainThreadScrollingReasons = mainThreadScrollingReasons; 70 m_mainThreadScrollingReasons = mainThreadScrollingReasons;
71 m_compositorElementId = compositorElementId;
68 } 72 }
69 73
70 const ScrollPaintPropertyNode* parent() const { return m_parent.get(); } 74 const ScrollPaintPropertyNode* parent() const { return m_parent.get(); }
71 bool isRoot() const { return !m_parent; } 75 bool isRoot() const { return !m_parent; }
72 76
73 // Transform that the scroll is relative to. 77 // Transform that the scroll is relative to.
74 const TransformPaintPropertyNode* scrollOffsetTranslation() const { 78 const TransformPaintPropertyNode* scrollOffsetTranslation() const {
75 return m_scrollOffsetTranslation.get(); 79 return m_scrollOffsetTranslation.get();
76 } 80 }
77 81
78 // The clipped area that contains the scrolled content. 82 // The clipped area that contains the scrolled content.
79 const IntSize& clip() const { return m_clip; } 83 const IntSize& clip() const { return m_clip; }
80 84
81 // The bounds of the content that is scrolled within |clip|. 85 // The bounds of the content that is scrolled within |clip|.
82 const IntSize& bounds() const { return m_bounds; } 86 const IntSize& bounds() const { return m_bounds; }
83 87
84 bool userScrollableHorizontal() const { return m_userScrollableHorizontal; } 88 bool userScrollableHorizontal() const { return m_userScrollableHorizontal; }
85 bool userScrollableVertical() const { return m_userScrollableVertical; } 89 bool userScrollableVertical() const { return m_userScrollableVertical; }
86 90
87 // Return reason bitfield with values from cc::MainThreadScrollingReason. 91 // Return reason bitfield with values from cc::MainThreadScrollingReason.
88 MainThreadScrollingReasons mainThreadScrollingReasons() const { 92 MainThreadScrollingReasons mainThreadScrollingReasons() const {
89 return m_mainThreadScrollingReasons; 93 return m_mainThreadScrollingReasons;
90 } 94 }
91 95
96 const CompositorElementId& compositorElementId() const {
97 return m_compositorElementId;
98 }
99
92 // Main thread scrolling reason for the threaded scrolling disabled setting. 100 // Main thread scrolling reason for the threaded scrolling disabled setting.
93 bool threadedScrollingDisabled() const { 101 bool threadedScrollingDisabled() const {
94 return m_mainThreadScrollingReasons & 102 return m_mainThreadScrollingReasons &
95 MainThreadScrollingReason::kThreadedScrollingDisabled; 103 MainThreadScrollingReason::kThreadedScrollingDisabled;
96 } 104 }
97 105
98 // Main thread scrolling reason for background attachment fixed descendants. 106 // Main thread scrolling reason for background attachment fixed descendants.
99 bool hasBackgroundAttachmentFixedDescendants() const { 107 bool hasBackgroundAttachmentFixedDescendants() const {
100 return m_mainThreadScrollingReasons & 108 return m_mainThreadScrollingReasons &
101 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects; 109 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects;
102 } 110 }
103 111
104 #if DCHECK_IS_ON() 112 #if DCHECK_IS_ON()
105 // The clone function is used by FindPropertiesNeedingUpdate.h for recording 113 // The clone function is used by FindPropertiesNeedingUpdate.h for recording
106 // a scroll node before it has been updated, to later detect changes. 114 // a scroll node before it has been updated, to later detect changes.
107 PassRefPtr<ScrollPaintPropertyNode> clone() const { 115 PassRefPtr<ScrollPaintPropertyNode> clone() const {
108 RefPtr<ScrollPaintPropertyNode> cloned = 116 RefPtr<ScrollPaintPropertyNode> cloned =
109 adoptRef(new ScrollPaintPropertyNode( 117 adoptRef(new ScrollPaintPropertyNode(
110 m_parent, m_scrollOffsetTranslation, m_clip, m_bounds, 118 m_parent, m_scrollOffsetTranslation, m_clip, m_bounds,
111 m_userScrollableHorizontal, m_userScrollableVertical, 119 m_userScrollableHorizontal, m_userScrollableVertical,
112 m_mainThreadScrollingReasons)); 120 m_mainThreadScrollingReasons, m_compositorElementId));
113 return cloned; 121 return cloned;
114 } 122 }
115 123
116 // The equality operator is used by FindPropertiesNeedingUpdate.h for checking 124 // The equality operator is used by FindPropertiesNeedingUpdate.h for checking
117 // if a scroll node has changed. 125 // if a scroll node has changed.
118 bool operator==(const ScrollPaintPropertyNode& o) const { 126 bool operator==(const ScrollPaintPropertyNode& o) const {
119 return m_parent == o.m_parent && 127 return m_parent == o.m_parent &&
120 m_scrollOffsetTranslation == o.m_scrollOffsetTranslation && 128 m_scrollOffsetTranslation == o.m_scrollOffsetTranslation &&
121 m_clip == o.m_clip && m_bounds == o.m_bounds && 129 m_clip == o.m_clip && m_bounds == o.m_bounds &&
122 m_userScrollableHorizontal == o.m_userScrollableHorizontal && 130 m_userScrollableHorizontal == o.m_userScrollableHorizontal &&
123 m_userScrollableVertical == o.m_userScrollableVertical && 131 m_userScrollableVertical == o.m_userScrollableVertical &&
124 m_mainThreadScrollingReasons == o.m_mainThreadScrollingReasons; 132 m_mainThreadScrollingReasons == o.m_mainThreadScrollingReasons &&
133 m_compositorElementId == o.m_compositorElementId;
125 } 134 }
126 135
127 String toTreeString() const; 136 String toTreeString() const;
128 #endif 137 #endif
129 138
130 String toString() const; 139 String toString() const;
131 140
132 private: 141 private:
133 ScrollPaintPropertyNode( 142 ScrollPaintPropertyNode(
134 PassRefPtr<const ScrollPaintPropertyNode> parent, 143 PassRefPtr<const ScrollPaintPropertyNode> parent,
135 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation, 144 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation,
136 IntSize clip, 145 IntSize clip,
137 IntSize bounds, 146 IntSize bounds,
138 bool userScrollableHorizontal, 147 bool userScrollableHorizontal,
139 bool userScrollableVertical, 148 bool userScrollableVertical,
140 MainThreadScrollingReasons mainThreadScrollingReasons) 149 MainThreadScrollingReasons mainThreadScrollingReasons,
150 CompositorElementId compositorElementId)
141 : m_parent(parent), 151 : m_parent(parent),
142 m_scrollOffsetTranslation(scrollOffsetTranslation), 152 m_scrollOffsetTranslation(scrollOffsetTranslation),
143 m_clip(clip), 153 m_clip(clip),
144 m_bounds(bounds), 154 m_bounds(bounds),
145 m_userScrollableHorizontal(userScrollableHorizontal), 155 m_userScrollableHorizontal(userScrollableHorizontal),
146 m_userScrollableVertical(userScrollableVertical), 156 m_userScrollableVertical(userScrollableVertical),
147 m_mainThreadScrollingReasons(mainThreadScrollingReasons) { 157 m_mainThreadScrollingReasons(mainThreadScrollingReasons),
158 m_compositorElementId(compositorElementId) {
148 DCHECK(m_scrollOffsetTranslation->matrix().isIdentityOr2DTranslation()); 159 DCHECK(m_scrollOffsetTranslation->matrix().isIdentityOr2DTranslation());
149 } 160 }
150 161
151 RefPtr<const ScrollPaintPropertyNode> m_parent; 162 RefPtr<const ScrollPaintPropertyNode> m_parent;
152 RefPtr<const TransformPaintPropertyNode> m_scrollOffsetTranslation; 163 RefPtr<const TransformPaintPropertyNode> m_scrollOffsetTranslation;
153 IntSize m_clip; 164 IntSize m_clip;
154 IntSize m_bounds; 165 IntSize m_bounds;
155 bool m_userScrollableHorizontal : 1; 166 bool m_userScrollableHorizontal : 1;
156 bool m_userScrollableVertical : 1; 167 bool m_userScrollableVertical : 1;
157 MainThreadScrollingReasons m_mainThreadScrollingReasons; 168 MainThreadScrollingReasons m_mainThreadScrollingReasons;
169 CompositorElementId m_compositorElementId;
158 }; 170 };
159 171
160 // Redeclared here to avoid ODR issues. 172 // Redeclared here to avoid ODR issues.
161 // See platform/testing/PaintPrinters.h. 173 // See platform/testing/PaintPrinters.h.
162 void PrintTo(const ScrollPaintPropertyNode&, std::ostream*); 174 void PrintTo(const ScrollPaintPropertyNode&, std::ostream*);
163 175
164 } // namespace blink 176 } // namespace blink
165 177
166 #endif // ScrollPaintPropertyNode_h 178 #endif // ScrollPaintPropertyNode_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698