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

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: 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 #endif 135 #endif
127 136
128 String toString() const; 137 String toString() const;
129 138
130 private: 139 private:
131 ScrollPaintPropertyNode( 140 ScrollPaintPropertyNode(
132 PassRefPtr<const ScrollPaintPropertyNode> parent, 141 PassRefPtr<const ScrollPaintPropertyNode> parent,
133 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation, 142 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation,
134 IntSize clip, 143 IntSize clip,
135 IntSize bounds, 144 IntSize bounds,
136 bool userScrollableHorizontal, 145 bool userScrollableHorizontal,
137 bool userScrollableVertical, 146 bool userScrollableVertical,
138 MainThreadScrollingReasons mainThreadScrollingReasons) 147 MainThreadScrollingReasons mainThreadScrollingReasons,
148 CompositorElementId compositorElementId)
139 : m_parent(parent), 149 : m_parent(parent),
140 m_scrollOffsetTranslation(scrollOffsetTranslation), 150 m_scrollOffsetTranslation(scrollOffsetTranslation),
141 m_clip(clip), 151 m_clip(clip),
142 m_bounds(bounds), 152 m_bounds(bounds),
143 m_userScrollableHorizontal(userScrollableHorizontal), 153 m_userScrollableHorizontal(userScrollableHorizontal),
144 m_userScrollableVertical(userScrollableVertical), 154 m_userScrollableVertical(userScrollableVertical),
145 m_mainThreadScrollingReasons(mainThreadScrollingReasons) { 155 m_mainThreadScrollingReasons(mainThreadScrollingReasons),
156 m_compositorElementId(compositorElementId) {
146 DCHECK(m_scrollOffsetTranslation->matrix().isIdentityOr2DTranslation()); 157 DCHECK(m_scrollOffsetTranslation->matrix().isIdentityOr2DTranslation());
147 } 158 }
148 159
149 RefPtr<const ScrollPaintPropertyNode> m_parent; 160 RefPtr<const ScrollPaintPropertyNode> m_parent;
150 RefPtr<const TransformPaintPropertyNode> m_scrollOffsetTranslation; 161 RefPtr<const TransformPaintPropertyNode> m_scrollOffsetTranslation;
151 IntSize m_clip; 162 IntSize m_clip;
152 IntSize m_bounds; 163 IntSize m_bounds;
153 bool m_userScrollableHorizontal : 1; 164 bool m_userScrollableHorizontal : 1;
154 bool m_userScrollableVertical : 1; 165 bool m_userScrollableVertical : 1;
155 MainThreadScrollingReasons m_mainThreadScrollingReasons; 166 MainThreadScrollingReasons m_mainThreadScrollingReasons;
167 CompositorElementId m_compositorElementId;
156 }; 168 };
157 169
158 // Redeclared here to avoid ODR issues. 170 // Redeclared here to avoid ODR issues.
159 // See platform/testing/PaintPrinters.h. 171 // See platform/testing/PaintPrinters.h.
160 void PrintTo(const ScrollPaintPropertyNode&, std::ostream*); 172 void PrintTo(const ScrollPaintPropertyNode&, std::ostream*);
161 173
162 } // namespace blink 174 } // namespace blink
163 175
164 #endif // ScrollPaintPropertyNode_h 176 #endif // ScrollPaintPropertyNode_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698