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

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

Issue 2657863004: Move scroll paint property nodes to be owned by the transform tree (Closed)
Patch Set: Rebase & remove parens Created 3 years, 10 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 TransformPaintPropertyNode_h 5 #ifndef TransformPaintPropertyNode_h
6 #define TransformPaintPropertyNode_h 6 #define TransformPaintPropertyNode_h
7 7
8 #include "platform/PlatformExport.h" 8 #include "platform/PlatformExport.h"
9 #include "platform/geometry/FloatPoint3D.h" 9 #include "platform/geometry/FloatPoint3D.h"
10 #include "platform/graphics/CompositingReasons.h" 10 #include "platform/graphics/CompositingReasons.h"
(...skipping 21 matching lines...) Expand all
32 : public RefCounted<TransformPaintPropertyNode> { 32 : public RefCounted<TransformPaintPropertyNode> {
33 public: 33 public:
34 // This node is really a sentinel, and does not represent a real transform 34 // This node is really a sentinel, and does not represent a real transform
35 // space. 35 // space.
36 static TransformPaintPropertyNode* root(); 36 static TransformPaintPropertyNode* root();
37 37
38 static PassRefPtr<TransformPaintPropertyNode> create( 38 static PassRefPtr<TransformPaintPropertyNode> create(
39 PassRefPtr<const TransformPaintPropertyNode> parent, 39 PassRefPtr<const TransformPaintPropertyNode> parent,
40 const TransformationMatrix& matrix, 40 const TransformationMatrix& matrix,
41 const FloatPoint3D& origin, 41 const FloatPoint3D& origin,
42 PassRefPtr<const ScrollPaintPropertyNode> scroll = nullptr,
43 bool flattensInheritedTransform = false, 42 bool flattensInheritedTransform = false,
44 unsigned renderingContextId = 0, 43 unsigned renderingContextId = 0,
45 CompositingReasons directCompositingReasons = CompositingReasonNone, 44 CompositingReasons directCompositingReasons = CompositingReasonNone,
46 const CompositorElementId& compositorElementId = CompositorElementId()) { 45 const CompositorElementId& compositorElementId = CompositorElementId()) {
46 return adoptRef(new TransformPaintPropertyNode(
47 std::move(parent), matrix, origin, flattensInheritedTransform,
48 renderingContextId, directCompositingReasons, compositorElementId));
49 }
50
51 static PassRefPtr<TransformPaintPropertyNode> createScrollTranslation(
52 PassRefPtr<const TransformPaintPropertyNode> parent,
53 const TransformationMatrix& matrix,
54 const FloatPoint3D& origin,
55 bool flattensInheritedTransform,
56 unsigned renderingContextId,
57 CompositingReasons directCompositingReasons,
58 const CompositorElementId& compositorElementId,
59 PassRefPtr<const ScrollPaintPropertyNode> parentScroll,
60 const IntSize& clip,
61 const IntSize& bounds,
62 bool userScrollableHorizontal,
63 bool userScrollableVertical,
64 MainThreadScrollingReasons mainThreadScrollingReasons) {
47 // If this transform is for scroll offset, it should be a 2d translation. 65 // If this transform is for scroll offset, it should be a 2d translation.
48 if (scroll) 66 DCHECK(matrix.isIdentityOr2DTranslation());
49 DCHECK(matrix.isIdentityOr2DTranslation());
50 return adoptRef(new TransformPaintPropertyNode( 67 return adoptRef(new TransformPaintPropertyNode(
51 std::move(parent), matrix, origin, std::move(scroll), 68 std::move(parent), matrix, origin, flattensInheritedTransform,
52 flattensInheritedTransform, renderingContextId, 69 renderingContextId, directCompositingReasons, compositorElementId,
53 directCompositingReasons, compositorElementId)); 70 ScrollPaintPropertyNode::create(
71 std::move(parentScroll), clip, bounds, userScrollableHorizontal,
72 userScrollableVertical, mainThreadScrollingReasons)));
54 } 73 }
55 74
56 void update( 75 void update(
57 PassRefPtr<const TransformPaintPropertyNode> parent, 76 PassRefPtr<const TransformPaintPropertyNode> parent,
58 const TransformationMatrix& matrix, 77 const TransformationMatrix& matrix,
59 const FloatPoint3D& origin, 78 const FloatPoint3D& origin,
60 PassRefPtr<const ScrollPaintPropertyNode> scroll = nullptr,
61 bool flattensInheritedTransform = false, 79 bool flattensInheritedTransform = false,
62 unsigned renderingContextId = 0, 80 unsigned renderingContextId = 0,
63 CompositingReasons directCompositingReasons = CompositingReasonNone, 81 CompositingReasons directCompositingReasons = CompositingReasonNone,
64 CompositorElementId compositorElementId = CompositorElementId()) { 82 CompositorElementId compositorElementId = CompositorElementId()) {
65 DCHECK(!isRoot()); 83 DCHECK(!isRoot());
66 DCHECK(parent != this); 84 DCHECK(parent != this);
67 m_parent = parent; 85 m_parent = parent;
68 m_matrix = matrix; 86 m_matrix = matrix;
69 m_origin = origin; 87 m_origin = origin;
70 // If this transform is for scroll offset, it should be a 2d translation.
71 if (scroll)
72 DCHECK(matrix.isIdentityOr2DTranslation());
73 m_scroll = scroll;
74 m_flattensInheritedTransform = flattensInheritedTransform; 88 m_flattensInheritedTransform = flattensInheritedTransform;
75 m_renderingContextId = renderingContextId; 89 m_renderingContextId = renderingContextId;
76 m_directCompositingReasons = directCompositingReasons; 90 m_directCompositingReasons = directCompositingReasons;
77 m_compositorElementId = compositorElementId; 91 m_compositorElementId = compositorElementId;
78 } 92 }
79 93
94 void updateScrollTranslation(
95 PassRefPtr<const TransformPaintPropertyNode> parent,
96 const TransformationMatrix& matrix,
97 const FloatPoint3D& origin,
98 bool flattensInheritedTransform,
99 unsigned renderingContextId,
100 CompositingReasons directCompositingReasons,
101 CompositorElementId compositorElementId,
102 PassRefPtr<const ScrollPaintPropertyNode> parentScroll,
103 const IntSize& clip,
104 const IntSize& bounds,
105 bool userScrollableHorizontal,
106 bool userScrollableVertical,
107 MainThreadScrollingReasons mainThreadScrollingReasons) {
108 update(std::move(parent), matrix, origin, flattensInheritedTransform,
109 renderingContextId, directCompositingReasons, compositorElementId);
110 DCHECK(m_scroll);
111 DCHECK(matrix.isIdentityOr2DTranslation());
112 m_scroll->update(std::move(parentScroll), clip, bounds,
113 userScrollableHorizontal, userScrollableVertical,
114 mainThreadScrollingReasons);
115 }
116
80 const TransformationMatrix& matrix() const { return m_matrix; } 117 const TransformationMatrix& matrix() const { return m_matrix; }
81 const FloatPoint3D& origin() const { return m_origin; } 118 const FloatPoint3D& origin() const { return m_origin; }
82 119
83 // Parent transform that this transform is relative to, or nullptr if this 120 // Parent transform that this transform is relative to, or nullptr if this
84 // is the root transform. 121 // is the root transform.
85 const TransformPaintPropertyNode* parent() const { return m_parent.get(); } 122 const TransformPaintPropertyNode* parent() const { return m_parent.get(); }
86 bool isRoot() const { return !m_parent; } 123 bool isRoot() const { return !m_parent; }
87 124
125 // True if this transform is for the scroll offset translation.
126 bool isScrollTranslation() const { return !!m_scroll; }
88 // The associated scroll node if this transform is the scroll offset for 127 // The associated scroll node if this transform is the scroll offset for
89 // scrolling, or nullptr otherwise. 128 // scrolling, or nullptr otherwise.
90 const ScrollPaintPropertyNode* scrollNode() const { return m_scroll.get(); } 129 const ScrollPaintPropertyNode* scrollNode() const { return m_scroll.get(); }
91 130
92 // If true, content with this transform node (or its descendant) appears in 131 // If true, content with this transform node (or its descendant) appears in
93 // the plane of its parent. This is implemented by flattening the total 132 // the plane of its parent. This is implemented by flattening the total
94 // accumulated transform from its ancestors. 133 // accumulated transform from its ancestors.
95 bool flattensInheritedTransform() const { 134 bool flattensInheritedTransform() const {
96 return m_flattensInheritedTransform; 135 return m_flattensInheritedTransform;
97 } 136 }
(...skipping 13 matching lines...) Expand all
111 // Content whose transform nodes have a common rendering context ID are 3D 150 // Content whose transform nodes have a common rendering context ID are 3D
112 // sorted. If this is 0, content will not be 3D sorted. 151 // sorted. If this is 0, content will not be 3D sorted.
113 unsigned renderingContextId() const { return m_renderingContextId; } 152 unsigned renderingContextId() const { return m_renderingContextId; }
114 bool hasRenderingContext() const { return m_renderingContextId; } 153 bool hasRenderingContext() const { return m_renderingContextId; }
115 154
116 #if DCHECK_IS_ON() 155 #if DCHECK_IS_ON()
117 // The clone function is used by FindPropertiesNeedingUpdate.h for recording 156 // The clone function is used by FindPropertiesNeedingUpdate.h for recording
118 // a transform node before it has been updated, to later detect changes. 157 // a transform node before it has been updated, to later detect changes.
119 PassRefPtr<TransformPaintPropertyNode> clone() const { 158 PassRefPtr<TransformPaintPropertyNode> clone() const {
120 return adoptRef(new TransformPaintPropertyNode( 159 return adoptRef(new TransformPaintPropertyNode(
121 m_parent, m_matrix, m_origin, m_scroll, m_flattensInheritedTransform, 160 m_parent, m_matrix, m_origin, m_flattensInheritedTransform,
122 m_renderingContextId, m_directCompositingReasons, 161 m_renderingContextId, m_directCompositingReasons, m_compositorElementId,
123 m_compositorElementId)); 162 m_scroll ? m_scroll->clone() : nullptr));
124 } 163 }
125 164
126 // The equality operator is used by FindPropertiesNeedingUpdate.h for checking 165 // The equality operator is used by FindPropertiesNeedingUpdate.h for checking
127 // if a transform node has changed. 166 // if a transform node has changed.
128 bool operator==(const TransformPaintPropertyNode& o) const { 167 bool operator==(const TransformPaintPropertyNode& o) const {
168 if (m_scroll && o.m_scroll && !(*m_scroll == *o.m_scroll))
169 return false;
129 return m_parent == o.m_parent && m_matrix == o.m_matrix && 170 return m_parent == o.m_parent && m_matrix == o.m_matrix &&
130 m_origin == o.m_origin && m_scroll == o.m_scroll && 171 m_origin == o.m_origin &&
131 m_flattensInheritedTransform == o.m_flattensInheritedTransform && 172 m_flattensInheritedTransform == o.m_flattensInheritedTransform &&
132 m_renderingContextId == o.m_renderingContextId && 173 m_renderingContextId == o.m_renderingContextId &&
133 m_directCompositingReasons == o.m_directCompositingReasons && 174 m_directCompositingReasons == o.m_directCompositingReasons &&
134 m_compositorElementId == o.m_compositorElementId; 175 m_compositorElementId == o.m_compositorElementId &&
176 !!m_scroll == !!o.m_scroll;
135 } 177 }
136 178
137 String toTreeString() const; 179 String toTreeString() const;
138 #endif 180 #endif
139 181
140 String toString() const; 182 String toString() const;
141 183
142 private: 184 private:
143 TransformPaintPropertyNode( 185 TransformPaintPropertyNode(
144 PassRefPtr<const TransformPaintPropertyNode> parent, 186 PassRefPtr<const TransformPaintPropertyNode> parent,
145 const TransformationMatrix& matrix, 187 const TransformationMatrix& matrix,
146 const FloatPoint3D& origin, 188 const FloatPoint3D& origin,
147 PassRefPtr<const ScrollPaintPropertyNode> scroll,
148 bool flattensInheritedTransform, 189 bool flattensInheritedTransform,
149 unsigned renderingContextId, 190 unsigned renderingContextId,
150 CompositingReasons directCompositingReasons, 191 CompositingReasons directCompositingReasons,
151 CompositorElementId compositorElementId) 192 CompositorElementId compositorElementId,
193 PassRefPtr<ScrollPaintPropertyNode> scroll = nullptr)
152 : m_parent(parent), 194 : m_parent(parent),
153 m_matrix(matrix), 195 m_matrix(matrix),
154 m_origin(origin), 196 m_origin(origin),
155 m_scroll(scroll),
156 m_flattensInheritedTransform(flattensInheritedTransform), 197 m_flattensInheritedTransform(flattensInheritedTransform),
157 m_renderingContextId(renderingContextId), 198 m_renderingContextId(renderingContextId),
158 m_directCompositingReasons(directCompositingReasons), 199 m_directCompositingReasons(directCompositingReasons),
159 m_compositorElementId(compositorElementId) {} 200 m_compositorElementId(compositorElementId),
201 m_scroll(scroll) {}
160 202
161 RefPtr<const TransformPaintPropertyNode> m_parent; 203 RefPtr<const TransformPaintPropertyNode> m_parent;
162 TransformationMatrix m_matrix; 204 TransformationMatrix m_matrix;
163 FloatPoint3D m_origin; 205 FloatPoint3D m_origin;
164 RefPtr<const ScrollPaintPropertyNode> m_scroll;
165 bool m_flattensInheritedTransform; 206 bool m_flattensInheritedTransform;
166 unsigned m_renderingContextId; 207 unsigned m_renderingContextId;
167 CompositingReasons m_directCompositingReasons; 208 CompositingReasons m_directCompositingReasons;
168 CompositorElementId m_compositorElementId; 209 CompositorElementId m_compositorElementId;
210 RefPtr<ScrollPaintPropertyNode> m_scroll;
169 }; 211 };
170 212
171 // Redeclared here to avoid ODR issues. 213 // Redeclared here to avoid ODR issues.
172 // See platform/testing/PaintPrinters.h. 214 // See platform/testing/PaintPrinters.h.
173 void PrintTo(const TransformPaintPropertyNode&, std::ostream*); 215 void PrintTo(const TransformPaintPropertyNode&, std::ostream*);
174 216
175 } // namespace blink 217 } // namespace blink
176 218
177 #endif // TransformPaintPropertyNode_h 219 #endif // TransformPaintPropertyNode_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698