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

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

Issue 2506353002: Incrementally build main thread scrolling reasons [spv2] (Closed)
Patch Set: Cleanup comments Created 4 years, 1 month 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/paint/TransformPaintPropertyNode.h" 10 #include "platform/graphics/paint/TransformPaintPropertyNode.h"
(...skipping 14 matching lines...) Expand all
25 // 25 //
26 // Main thread scrolling reasons force scroll updates to go to the main thread 26 // Main thread scrolling reasons force scroll updates to go to the main thread
27 // and can have dependencies on other nodes. For example, all parents of a 27 // and can have dependencies on other nodes. For example, all parents of a
28 // scroll node with background attachment fixed set should also have it set. 28 // scroll node with background attachment fixed set should also have it set.
29 class PLATFORM_EXPORT ScrollPaintPropertyNode 29 class PLATFORM_EXPORT ScrollPaintPropertyNode
30 : public RefCounted<ScrollPaintPropertyNode> { 30 : public RefCounted<ScrollPaintPropertyNode> {
31 public: 31 public:
32 static ScrollPaintPropertyNode* root(); 32 static ScrollPaintPropertyNode* root();
33 33
34 static PassRefPtr<ScrollPaintPropertyNode> create( 34 static PassRefPtr<ScrollPaintPropertyNode> create(
35 PassRefPtr<ScrollPaintPropertyNode> parent, 35 PassRefPtr<const ScrollPaintPropertyNode> parent,
36 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation, 36 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation,
37 const IntSize& clip, 37 const IntSize& clip,
38 const IntSize& bounds, 38 const IntSize& bounds,
39 bool userScrollableHorizontal, 39 bool userScrollableHorizontal,
40 bool userScrollableVertical) { 40 bool userScrollableVertical,
41 bool threadedScrollingDisabled,
42 bool hasBackgroundAttachmentFixedDescendants) {
41 return adoptRef(new ScrollPaintPropertyNode( 43 return adoptRef(new ScrollPaintPropertyNode(
42 std::move(parent), std::move(scrollOffsetTranslation), clip, bounds, 44 std::move(parent), std::move(scrollOffsetTranslation), clip, bounds,
43 userScrollableHorizontal, userScrollableVertical)); 45 userScrollableHorizontal, userScrollableVertical,
46 threadedScrollingDisabled, hasBackgroundAttachmentFixedDescendants));
44 } 47 }
45 48
46 void update( 49 void update(
47 PassRefPtr<ScrollPaintPropertyNode> parent, 50 PassRefPtr<const ScrollPaintPropertyNode> parent,
48 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation, 51 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation,
49 const IntSize& clip, 52 const IntSize& clip,
50 const IntSize& bounds, 53 const IntSize& bounds,
51 bool userScrollableHorizontal, 54 bool userScrollableHorizontal,
52 bool userScrollableVertical) { 55 bool userScrollableVertical,
56 bool threadedScrollingDisabled,
57 bool hasBackgroundAttachmentFixedDescendants) {
53 DCHECK(!isRoot()); 58 DCHECK(!isRoot());
54 DCHECK(parent != this); 59 DCHECK(parent != this);
55 m_parent = parent; 60 m_parent = parent;
56 DCHECK(scrollOffsetTranslation->matrix().isIdentityOr2DTranslation()); 61 DCHECK(scrollOffsetTranslation->matrix().isIdentityOr2DTranslation());
57 m_scrollOffsetTranslation = scrollOffsetTranslation; 62 m_scrollOffsetTranslation = scrollOffsetTranslation;
58 m_clip = clip; 63 m_clip = clip;
59 m_bounds = bounds; 64 m_bounds = bounds;
60 m_userScrollableHorizontal = userScrollableHorizontal; 65 m_userScrollableHorizontal = userScrollableHorizontal;
61 m_userScrollableVertical = userScrollableVertical; 66 m_userScrollableVertical = userScrollableVertical;
62 m_mainThreadScrollingReasons = 0; 67 m_threadedScrollingDisabled = threadedScrollingDisabled;
68 m_hasBackgroundAttachmentFixedDescendants =
69 hasBackgroundAttachmentFixedDescendants;
63 } 70 }
64 71
65 ScrollPaintPropertyNode* parent() const { return m_parent.get(); } 72 const ScrollPaintPropertyNode* parent() const { return m_parent.get(); }
66 bool isRoot() const { return !m_parent; } 73 bool isRoot() const { return !m_parent; }
67 74
68 // Transform that the scroll is relative to. 75 // Transform that the scroll is relative to.
69 const TransformPaintPropertyNode* scrollOffsetTranslation() const { 76 const TransformPaintPropertyNode* scrollOffsetTranslation() const {
70 return m_scrollOffsetTranslation.get(); 77 return m_scrollOffsetTranslation.get();
71 } 78 }
72 79
73 // The clipped area that contains the scrolled content. 80 // The clipped area that contains the scrolled content.
74 const IntSize& clip() const { return m_clip; } 81 const IntSize& clip() const { return m_clip; }
75 82
76 // The bounds of the content that is scrolled within |clip|. 83 // The bounds of the content that is scrolled within |clip|.
77 const IntSize& bounds() const { return m_bounds; } 84 const IntSize& bounds() const { return m_bounds; }
78 85
79 bool userScrollableHorizontal() const { return m_userScrollableHorizontal; } 86 bool userScrollableHorizontal() const { return m_userScrollableHorizontal; }
80 bool userScrollableVertical() const { return m_userScrollableVertical; } 87 bool userScrollableVertical() const { return m_userScrollableVertical; }
81 88
82 // Return reason bitfield with values from cc::MainThreadScrollingReason. 89 // Return reason bitfield with values from cc::MainThreadScrollingReason.
83 MainThreadScrollingReasons mainThreadScrollingReasons() const { 90 MainThreadScrollingReasons mainThreadScrollingReasons() const {
84 return m_mainThreadScrollingReasons; 91 MainThreadScrollingReasons reasons = 0;
92 if (threadedScrollingDisabled())
93 reasons |= MainThreadScrollingReason::kThreadedScrollingDisabled;
94 if (hasBackgroundAttachmentFixedDescendants()) {
95 reasons |=
96 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects;
97 }
98 return reasons;
85 } 99 }
86 bool hasMainThreadScrollingReasons(MainThreadScrollingReasons reasons) const { 100
87 return m_mainThreadScrollingReasons & reasons; 101 // Main thread scrolling reason for the threaded scrolling disabled setting.
102 bool threadedScrollingDisabled() const { return m_threadedScrollingDisabled; }
103
104 // Main thread scrolling reason for background attachment fixed descendants.
105 bool hasBackgroundAttachmentFixedDescendants() const {
106 return m_hasBackgroundAttachmentFixedDescendants;
88 } 107 }
89 void addMainThreadScrollingReasons(MainThreadScrollingReasons reasons) {
90 m_mainThreadScrollingReasons |= reasons;
91 }
92 void clearMainThreadScrollingReasons() { m_mainThreadScrollingReasons = 0; }
93 108
94 #if DCHECK_IS_ON() 109 #if DCHECK_IS_ON()
95 // The clone function is used by FindPropertiesNeedingUpdate.h for recording 110 // The clone function is used by FindPropertiesNeedingUpdate.h for recording
96 // a scroll node before it has been updated, to later detect changes. 111 // a scroll node before it has been updated, to later detect changes.
97 PassRefPtr<ScrollPaintPropertyNode> clone() const { 112 PassRefPtr<ScrollPaintPropertyNode> clone() const {
98 RefPtr<ScrollPaintPropertyNode> cloned = 113 RefPtr<ScrollPaintPropertyNode> cloned =
99 adoptRef(new ScrollPaintPropertyNode( 114 adoptRef(new ScrollPaintPropertyNode(
100 m_parent, m_scrollOffsetTranslation, m_clip, m_bounds, 115 m_parent, m_scrollOffsetTranslation, m_clip, m_bounds,
101 m_userScrollableHorizontal, m_userScrollableVertical)); 116 m_userScrollableHorizontal, m_userScrollableVertical,
102 cloned->addMainThreadScrollingReasons(m_mainThreadScrollingReasons); 117 m_threadedScrollingDisabled,
118 m_hasBackgroundAttachmentFixedDescendants));
103 return cloned; 119 return cloned;
104 } 120 }
105 121
106 // The equality operator is used by FindPropertiesNeedingUpdate.h for checking 122 // The equality operator is used by FindPropertiesNeedingUpdate.h for checking
107 // if a scroll node has changed. 123 // if a scroll node has changed.
108 bool operator==(const ScrollPaintPropertyNode& o) const { 124 bool operator==(const ScrollPaintPropertyNode& o) const {
109 // TODO(pdr): Check main thread scrolling reason equality as well. We do
110 // not yet mark nodes as needing a paint property update on main thread
111 // scrolling reason changes. See: See: https://crbug.com/664672.
112 return m_parent == o.m_parent && 125 return m_parent == o.m_parent &&
113 m_scrollOffsetTranslation == o.m_scrollOffsetTranslation && 126 m_scrollOffsetTranslation == o.m_scrollOffsetTranslation &&
114 m_clip == o.m_clip && m_bounds == o.m_bounds && 127 m_clip == o.m_clip && m_bounds == o.m_bounds &&
115 m_userScrollableHorizontal == o.m_userScrollableHorizontal && 128 m_userScrollableHorizontal == o.m_userScrollableHorizontal &&
116 m_userScrollableVertical == o.m_userScrollableVertical; 129 m_userScrollableVertical == o.m_userScrollableVertical &&
130 m_threadedScrollingDisabled == o.m_threadedScrollingDisabled &&
131 m_hasBackgroundAttachmentFixedDescendants ==
132 o.m_hasBackgroundAttachmentFixedDescendants;
117 } 133 }
118 #endif 134 #endif
119 135
120 private: 136 private:
121 ScrollPaintPropertyNode( 137 ScrollPaintPropertyNode(
122 PassRefPtr<ScrollPaintPropertyNode> parent, 138 PassRefPtr<const ScrollPaintPropertyNode> parent,
123 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation, 139 PassRefPtr<const TransformPaintPropertyNode> scrollOffsetTranslation,
124 IntSize clip, 140 IntSize clip,
125 IntSize bounds, 141 IntSize bounds,
126 bool userScrollableHorizontal, 142 bool userScrollableHorizontal,
127 bool userScrollableVertical) 143 bool userScrollableVertical,
144 bool threadedScrollingDisabled,
145 bool hasBackgroundAttachmentFixedDescendants)
Xianzhu 2016/11/17 19:03:04 Can we use named bit flags to replace the multiple
pdr. 2016/11/17 21:01:36 +1, this looks much better. Done.
128 : m_parent(parent), 146 : m_parent(parent),
129 m_scrollOffsetTranslation(scrollOffsetTranslation), 147 m_scrollOffsetTranslation(scrollOffsetTranslation),
130 m_clip(clip), 148 m_clip(clip),
131 m_bounds(bounds), 149 m_bounds(bounds),
132 m_userScrollableHorizontal(userScrollableHorizontal), 150 m_userScrollableHorizontal(userScrollableHorizontal),
133 m_userScrollableVertical(userScrollableVertical), 151 m_userScrollableVertical(userScrollableVertical),
134 m_mainThreadScrollingReasons(0) { 152 m_threadedScrollingDisabled(threadedScrollingDisabled),
153 m_hasBackgroundAttachmentFixedDescendants(
154 hasBackgroundAttachmentFixedDescendants) {
135 DCHECK(m_scrollOffsetTranslation->matrix().isIdentityOr2DTranslation()); 155 DCHECK(m_scrollOffsetTranslation->matrix().isIdentityOr2DTranslation());
136 } 156 }
137 157
138 RefPtr<ScrollPaintPropertyNode> m_parent; 158 RefPtr<const ScrollPaintPropertyNode> m_parent;
139 RefPtr<const TransformPaintPropertyNode> m_scrollOffsetTranslation; 159 RefPtr<const TransformPaintPropertyNode> m_scrollOffsetTranslation;
140 IntSize m_clip; 160 IntSize m_clip;
141 IntSize m_bounds; 161 IntSize m_bounds;
142 bool m_userScrollableHorizontal; 162 bool m_userScrollableHorizontal : 1;
143 bool m_userScrollableVertical; 163 bool m_userScrollableVertical : 1;
144 MainThreadScrollingReasons m_mainThreadScrollingReasons; 164 // The following bools are for main thread scrolling reasons.
165 bool m_threadedScrollingDisabled : 1;
166 bool m_hasBackgroundAttachmentFixedDescendants : 1;
145 // TODO(pdr): Add an offset for the clip and bounds to the transform. 167 // TODO(pdr): Add an offset for the clip and bounds to the transform.
146 // TODO(pdr): Add 2 bits for whether this is a viewport scroll node. 168 // TODO(pdr): Add 2 bits for whether this is a viewport scroll node.
147 // TODO(pdr): Add a bit for whether this is affected by page scale. 169 // TODO(pdr): Add a bit for whether this is affected by page scale.
148 }; 170 };
149 171
150 // Redeclared here to avoid ODR issues. 172 // Redeclared here to avoid ODR issues.
151 // See platform/testing/PaintPrinters.h. 173 // See platform/testing/PaintPrinters.h.
152 void PrintTo(const ScrollPaintPropertyNode&, std::ostream*); 174 void PrintTo(const ScrollPaintPropertyNode&, std::ostream*);
153 175
154 } // namespace blink 176 } // namespace blink
155 177
156 #endif // ScrollPaintPropertyNode_h 178 #endif // ScrollPaintPropertyNode_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698