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

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

Issue 2651093003: Make scroll translation transform nodes reference scroll nodes (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"
11 #include "platform/graphics/paint/TransformPaintPropertyNode.h"
12 #include "platform/scroll/MainThreadScrollingReason.h" 10 #include "platform/scroll/MainThreadScrollingReason.h"
13 #include "wtf/PassRefPtr.h" 11 #include "wtf/PassRefPtr.h"
14 #include "wtf/RefCounted.h" 12 #include "wtf/RefCounted.h"
15 #include "wtf/RefPtr.h" 13 #include "wtf/RefPtr.h"
16 #include "wtf/text/WTFString.h" 14 #include "wtf/text/WTFString.h"
17 15
18 #include <iosfwd> 16 #include <iosfwd>
19 17
20 namespace blink { 18 namespace blink {
21 19
22 using MainThreadScrollingReasons = uint32_t; 20 using MainThreadScrollingReasons = uint32_t;
23 21
24 // A scroll node contains auxiliary scrolling information for threaded scrolling 22 // A scroll node contains auxiliary scrolling information which includes how far
25 // which includes how far an area can be scrolled, which transform node contains 23 // an area can be scrolled, main thread scrolling reasons, etc. Scroll nodes
26 // the scroll offset, etc. 24 // are owned by TransformPaintPropertyNodes that are used for the scroll offset
25 // translation.
pdr. 2017/01/25 19:51:09 Walter pointed out that we should put a comment he
27 // 26 //
28 // Main thread scrolling reasons force scroll updates to go to the main thread 27 // Main thread scrolling reasons force scroll updates to go to the main thread
29 // and can have dependencies on other nodes. For example, all parents of a 28 // and can have dependencies on other nodes. For example, all parents of a
30 // scroll node with background attachment fixed set should also have it set. 29 // scroll node with background attachment fixed set should also have it set.
31 class PLATFORM_EXPORT ScrollPaintPropertyNode 30 class PLATFORM_EXPORT ScrollPaintPropertyNode
32 : public RefCounted<ScrollPaintPropertyNode> { 31 : public RefCounted<ScrollPaintPropertyNode> {
33 public: 32 public:
34 // This node is really a sentinel, and does not represent a real scroll. 33 // This node is really a sentinel, and does not represent a real scroll.
35 static ScrollPaintPropertyNode* root(); 34 static ScrollPaintPropertyNode* root();
36 35
37 static PassRefPtr<ScrollPaintPropertyNode> create( 36 static PassRefPtr<ScrollPaintPropertyNode> create(
38 PassRefPtr<const ScrollPaintPropertyNode> parent, 37 PassRefPtr<const ScrollPaintPropertyNode> parent,
39 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation,
40 const IntSize& clip, 38 const IntSize& clip,
41 const IntSize& bounds, 39 const IntSize& bounds,
42 bool userScrollableHorizontal, 40 bool userScrollableHorizontal,
43 bool userScrollableVertical, 41 bool userScrollableVertical,
44 MainThreadScrollingReasons mainThreadScrollingReasons, 42 MainThreadScrollingReasons mainThreadScrollingReasons) {
45 const CompositorElementId& compositorElementId = CompositorElementId()) {
46 return adoptRef(new ScrollPaintPropertyNode( 43 return adoptRef(new ScrollPaintPropertyNode(
47 std::move(parent), std::move(scrollOffsetTranslation), clip, bounds, 44 std::move(parent), clip, bounds, userScrollableHorizontal,
48 userScrollableHorizontal, userScrollableVertical, 45 userScrollableVertical, mainThreadScrollingReasons));
49 mainThreadScrollingReasons, compositorElementId));
50 } 46 }
51 47
52 void update( 48 void update(PassRefPtr<const ScrollPaintPropertyNode> parent,
53 PassRefPtr<const ScrollPaintPropertyNode> parent, 49 const IntSize& clip,
54 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation, 50 const IntSize& bounds,
55 const IntSize& clip, 51 bool userScrollableHorizontal,
56 const IntSize& bounds, 52 bool userScrollableVertical,
57 bool userScrollableHorizontal, 53 MainThreadScrollingReasons mainThreadScrollingReasons) {
58 bool userScrollableVertical,
59 MainThreadScrollingReasons mainThreadScrollingReasons,
60 CompositorElementId compositorElementId = CompositorElementId()) {
61 DCHECK(!isRoot()); 54 DCHECK(!isRoot());
62 DCHECK(parent != this); 55 DCHECK(parent != this);
63 m_parent = parent; 56 m_parent = parent;
64 DCHECK(scrollOffsetTranslation->matrix().isIdentityOr2DTranslation());
65 m_scrollOffsetTranslation = scrollOffsetTranslation;
66 m_clip = clip; 57 m_clip = clip;
67 m_bounds = bounds; 58 m_bounds = bounds;
68 m_userScrollableHorizontal = userScrollableHorizontal; 59 m_userScrollableHorizontal = userScrollableHorizontal;
69 m_userScrollableVertical = userScrollableVertical; 60 m_userScrollableVertical = userScrollableVertical;
70 m_mainThreadScrollingReasons = mainThreadScrollingReasons; 61 m_mainThreadScrollingReasons = mainThreadScrollingReasons;
71 m_compositorElementId = compositorElementId;
72 } 62 }
73 63
74 const ScrollPaintPropertyNode* parent() const { return m_parent.get(); } 64 const ScrollPaintPropertyNode* parent() const { return m_parent.get(); }
75 bool isRoot() const { return !m_parent; } 65 bool isRoot() const { return !m_parent; }
76 66
77 // Transform that the scroll is relative to.
78 const TransformPaintPropertyNode* scrollOffsetTranslation() const {
79 return m_scrollOffsetTranslation.get();
80 }
81
82 // The clipped area that contains the scrolled content. 67 // The clipped area that contains the scrolled content.
83 const IntSize& clip() const { return m_clip; } 68 const IntSize& clip() const { return m_clip; }
84 69
85 // The bounds of the content that is scrolled within |clip|. 70 // The bounds of the content that is scrolled within |clip|.
86 const IntSize& bounds() const { return m_bounds; } 71 const IntSize& bounds() const { return m_bounds; }
87 72
88 bool userScrollableHorizontal() const { return m_userScrollableHorizontal; } 73 bool userScrollableHorizontal() const { return m_userScrollableHorizontal; }
89 bool userScrollableVertical() const { return m_userScrollableVertical; } 74 bool userScrollableVertical() const { return m_userScrollableVertical; }
90 75
91 // Return reason bitfield with values from cc::MainThreadScrollingReason. 76 // Return reason bitfield with values from cc::MainThreadScrollingReason.
92 MainThreadScrollingReasons mainThreadScrollingReasons() const { 77 MainThreadScrollingReasons mainThreadScrollingReasons() const {
93 return m_mainThreadScrollingReasons; 78 return m_mainThreadScrollingReasons;
94 } 79 }
95 80
96 const CompositorElementId& compositorElementId() const {
97 return m_compositorElementId;
98 }
99
100 // Main thread scrolling reason for the threaded scrolling disabled setting. 81 // Main thread scrolling reason for the threaded scrolling disabled setting.
101 bool threadedScrollingDisabled() const { 82 bool threadedScrollingDisabled() const {
102 return m_mainThreadScrollingReasons & 83 return m_mainThreadScrollingReasons &
103 MainThreadScrollingReason::kThreadedScrollingDisabled; 84 MainThreadScrollingReason::kThreadedScrollingDisabled;
104 } 85 }
105 86
106 // Main thread scrolling reason for background attachment fixed descendants. 87 // Main thread scrolling reason for background attachment fixed descendants.
107 bool hasBackgroundAttachmentFixedDescendants() const { 88 bool hasBackgroundAttachmentFixedDescendants() const {
108 return m_mainThreadScrollingReasons & 89 return m_mainThreadScrollingReasons &
109 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects; 90 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects;
110 } 91 }
111 92
112 #if DCHECK_IS_ON() 93 #if DCHECK_IS_ON()
113 // The clone function is used by FindPropertiesNeedingUpdate.h for recording 94 // The clone function is used by FindPropertiesNeedingUpdate.h for recording
114 // a scroll node before it has been updated, to later detect changes. 95 // a scroll node before it has been updated, to later detect changes.
115 PassRefPtr<ScrollPaintPropertyNode> clone() const { 96 PassRefPtr<ScrollPaintPropertyNode> clone() const {
116 RefPtr<ScrollPaintPropertyNode> cloned = 97 RefPtr<ScrollPaintPropertyNode> cloned =
117 adoptRef(new ScrollPaintPropertyNode( 98 adoptRef(new ScrollPaintPropertyNode(
118 m_parent, m_scrollOffsetTranslation, m_clip, m_bounds, 99 m_parent, m_clip, m_bounds, m_userScrollableHorizontal,
119 m_userScrollableHorizontal, m_userScrollableVertical, 100 m_userScrollableVertical, m_mainThreadScrollingReasons));
120 m_mainThreadScrollingReasons, m_compositorElementId));
121 return cloned; 101 return cloned;
122 } 102 }
123 103
124 // The equality operator is used by FindPropertiesNeedingUpdate.h for checking 104 // The equality operator is used by FindPropertiesNeedingUpdate.h for checking
125 // if a scroll node has changed. 105 // if a scroll node has changed.
126 bool operator==(const ScrollPaintPropertyNode& o) const { 106 bool operator==(const ScrollPaintPropertyNode& o) const {
127 return m_parent == o.m_parent && 107 return m_parent == o.m_parent && m_clip == o.m_clip &&
128 m_scrollOffsetTranslation == o.m_scrollOffsetTranslation && 108 m_bounds == o.m_bounds &&
129 m_clip == o.m_clip && m_bounds == o.m_bounds &&
130 m_userScrollableHorizontal == o.m_userScrollableHorizontal && 109 m_userScrollableHorizontal == o.m_userScrollableHorizontal &&
131 m_userScrollableVertical == o.m_userScrollableVertical && 110 m_userScrollableVertical == o.m_userScrollableVertical &&
132 m_mainThreadScrollingReasons == o.m_mainThreadScrollingReasons && 111 m_mainThreadScrollingReasons == o.m_mainThreadScrollingReasons;
133 m_compositorElementId == o.m_compositorElementId;
134 } 112 }
135 113
136 String toTreeString() const; 114 String toTreeString() const;
137 #endif 115 #endif
138 116
139 String toString() const; 117 String toString() const;
140 118
141 private: 119 private:
142 ScrollPaintPropertyNode( 120 ScrollPaintPropertyNode(PassRefPtr<const ScrollPaintPropertyNode> parent,
143 PassRefPtr<const ScrollPaintPropertyNode> parent, 121 IntSize clip,
144 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation, 122 IntSize bounds,
145 IntSize clip, 123 bool userScrollableHorizontal,
146 IntSize bounds, 124 bool userScrollableVertical,
147 bool userScrollableHorizontal, 125 MainThreadScrollingReasons mainThreadScrollingReasons)
148 bool userScrollableVertical,
149 MainThreadScrollingReasons mainThreadScrollingReasons,
150 CompositorElementId compositorElementId)
151 : m_parent(parent), 126 : m_parent(parent),
152 m_scrollOffsetTranslation(scrollOffsetTranslation),
153 m_clip(clip), 127 m_clip(clip),
154 m_bounds(bounds), 128 m_bounds(bounds),
155 m_userScrollableHorizontal(userScrollableHorizontal), 129 m_userScrollableHorizontal(userScrollableHorizontal),
156 m_userScrollableVertical(userScrollableVertical), 130 m_userScrollableVertical(userScrollableVertical),
157 m_mainThreadScrollingReasons(mainThreadScrollingReasons), 131 m_mainThreadScrollingReasons(mainThreadScrollingReasons) {}
158 m_compositorElementId(compositorElementId) {
159 DCHECK(m_scrollOffsetTranslation->matrix().isIdentityOr2DTranslation());
160 }
161 132
162 RefPtr<const ScrollPaintPropertyNode> m_parent; 133 RefPtr<const ScrollPaintPropertyNode> m_parent;
163 RefPtr<const TransformPaintPropertyNode> m_scrollOffsetTranslation;
164 IntSize m_clip; 134 IntSize m_clip;
165 IntSize m_bounds; 135 IntSize m_bounds;
166 bool m_userScrollableHorizontal : 1; 136 bool m_userScrollableHorizontal : 1;
167 bool m_userScrollableVertical : 1; 137 bool m_userScrollableVertical : 1;
168 MainThreadScrollingReasons m_mainThreadScrollingReasons; 138 MainThreadScrollingReasons m_mainThreadScrollingReasons;
169 CompositorElementId m_compositorElementId;
170 }; 139 };
171 140
172 // Redeclared here to avoid ODR issues. 141 // Redeclared here to avoid ODR issues.
173 // See platform/testing/PaintPrinters.h. 142 // See platform/testing/PaintPrinters.h.
174 void PrintTo(const ScrollPaintPropertyNode&, std::ostream*); 143 void PrintTo(const ScrollPaintPropertyNode&, std::ostream*);
175 144
176 } // namespace blink 145 } // namespace blink
177 146
178 #endif // ScrollPaintPropertyNode_h 147 #endif // ScrollPaintPropertyNode_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698