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

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

Issue 2651093003: Make scroll translation transform nodes reference scroll nodes (Closed)
Patch Set: Add note about scroll tree differences 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 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"
11 #include "platform/graphics/CompositorElementId.h" 11 #include "platform/graphics/CompositorElementId.h"
12 #include "platform/graphics/paint/ScrollPaintPropertyNode.h"
12 #include "platform/transforms/TransformationMatrix.h" 13 #include "platform/transforms/TransformationMatrix.h"
13 #include "wtf/PassRefPtr.h" 14 #include "wtf/PassRefPtr.h"
14 #include "wtf/RefCounted.h" 15 #include "wtf/RefCounted.h"
15 #include "wtf/RefPtr.h" 16 #include "wtf/RefPtr.h"
16 #include "wtf/text/WTFString.h" 17 #include "wtf/text/WTFString.h"
17 18
18 #include <iosfwd> 19 #include <iosfwd>
19 20
20 namespace blink { 21 namespace blink {
21 22
22 // A transform created by a css property such as "transform" or "perspective" 23 // A transform (e.g., created by css "transform" or "perspective", or for
23 // along with a reference to the parent TransformPaintPropertyNode. 24 // internal positioning such as paint offset or scrolling) along with a
25 // reference to the parent TransformPaintPropertyNode. The scroll tree is owned
26 // by transform nodes and a transform node for scrolling will have a 2d
27 // translation for the scroll offset and an associated ScrollPaintPropertyNode.
24 // 28 //
25 // The transform tree is rooted at a node with no parent. This root node should 29 // The transform tree is rooted at a node with no parent. This root node should
26 // not be modified. 30 // not be modified.
27 class PLATFORM_EXPORT TransformPaintPropertyNode 31 class PLATFORM_EXPORT TransformPaintPropertyNode
28 : public RefCounted<TransformPaintPropertyNode> { 32 : public RefCounted<TransformPaintPropertyNode> {
29 public: 33 public:
30 // 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
31 // space. 35 // space.
32 static TransformPaintPropertyNode* root(); 36 static TransformPaintPropertyNode* root();
33 37
34 static PassRefPtr<TransformPaintPropertyNode> create( 38 static PassRefPtr<TransformPaintPropertyNode> create(
35 PassRefPtr<const TransformPaintPropertyNode> parent, 39 PassRefPtr<const TransformPaintPropertyNode> parent,
36 const TransformationMatrix& matrix, 40 const TransformationMatrix& matrix,
37 const FloatPoint3D& origin, 41 const FloatPoint3D& origin,
42 PassRefPtr<const ScrollPaintPropertyNode> scroll = nullptr,
38 bool flattensInheritedTransform = false, 43 bool flattensInheritedTransform = false,
39 unsigned renderingContextId = 0, 44 unsigned renderingContextId = 0,
40 CompositingReasons directCompositingReasons = CompositingReasonNone, 45 CompositingReasons directCompositingReasons = CompositingReasonNone,
41 const CompositorElementId& compositorElementId = CompositorElementId()) { 46 const CompositorElementId& compositorElementId = CompositorElementId()) {
47 // If this transform is for scroll offset, it should be a 2d translation.
48 if (scroll)
49 DCHECK(matrix.isIdentityOr2DTranslation());
42 return adoptRef(new TransformPaintPropertyNode( 50 return adoptRef(new TransformPaintPropertyNode(
43 std::move(parent), matrix, origin, flattensInheritedTransform, 51 std::move(parent), matrix, origin, std::move(scroll),
44 renderingContextId, directCompositingReasons, compositorElementId)); 52 flattensInheritedTransform, renderingContextId,
53 directCompositingReasons, compositorElementId));
45 } 54 }
46 55
47 void update( 56 void update(
48 PassRefPtr<const TransformPaintPropertyNode> parent, 57 PassRefPtr<const TransformPaintPropertyNode> parent,
49 const TransformationMatrix& matrix, 58 const TransformationMatrix& matrix,
50 const FloatPoint3D& origin, 59 const FloatPoint3D& origin,
60 PassRefPtr<const ScrollPaintPropertyNode> scroll = nullptr,
51 bool flattensInheritedTransform = false, 61 bool flattensInheritedTransform = false,
52 unsigned renderingContextId = 0, 62 unsigned renderingContextId = 0,
53 CompositingReasons directCompositingReasons = CompositingReasonNone, 63 CompositingReasons directCompositingReasons = CompositingReasonNone,
54 CompositorElementId compositorElementId = CompositorElementId()) { 64 CompositorElementId compositorElementId = CompositorElementId()) {
55 DCHECK(!isRoot()); 65 DCHECK(!isRoot());
56 DCHECK(parent != this); 66 DCHECK(parent != this);
57 m_parent = parent; 67 m_parent = parent;
58 m_matrix = matrix; 68 m_matrix = matrix;
59 m_origin = origin; 69 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;
60 m_flattensInheritedTransform = flattensInheritedTransform; 74 m_flattensInheritedTransform = flattensInheritedTransform;
61 m_renderingContextId = renderingContextId; 75 m_renderingContextId = renderingContextId;
62 m_directCompositingReasons = directCompositingReasons; 76 m_directCompositingReasons = directCompositingReasons;
63 m_compositorElementId = compositorElementId; 77 m_compositorElementId = compositorElementId;
64 } 78 }
65 79
66 const TransformationMatrix& matrix() const { return m_matrix; } 80 const TransformationMatrix& matrix() const { return m_matrix; }
67 const FloatPoint3D& origin() const { return m_origin; } 81 const FloatPoint3D& origin() const { return m_origin; }
68 82
69 // Parent transform that this transform is relative to, or nullptr if this 83 // Parent transform that this transform is relative to, or nullptr if this
70 // is the root transform. 84 // is the root transform.
71 const TransformPaintPropertyNode* parent() const { return m_parent.get(); } 85 const TransformPaintPropertyNode* parent() const { return m_parent.get(); }
72 bool isRoot() const { return !m_parent; } 86 bool isRoot() const { return !m_parent; }
73 87
88 // The associated scroll node if this transform is the scroll offset for
89 // scrolling, or nullptr otherwise.
90 const ScrollPaintPropertyNode* scrollNode() const { return m_scroll.get(); }
91
74 // If true, content with this transform node (or its descendant) appears in 92 // If true, content with this transform node (or its descendant) appears in
75 // the plane of its parent. This is implemented by flattening the total 93 // the plane of its parent. This is implemented by flattening the total
76 // accumulated transform from its ancestors. 94 // accumulated transform from its ancestors.
77 bool flattensInheritedTransform() const { 95 bool flattensInheritedTransform() const {
78 return m_flattensInheritedTransform; 96 return m_flattensInheritedTransform;
79 } 97 }
80 98
81 bool hasDirectCompositingReasons() const { 99 bool hasDirectCompositingReasons() const {
82 return m_directCompositingReasons != CompositingReasonNone; 100 return m_directCompositingReasons != CompositingReasonNone;
83 } 101 }
84 102
85 const CompositorElementId& compositorElementId() const { 103 const CompositorElementId& compositorElementId() const {
86 return m_compositorElementId; 104 return m_compositorElementId;
87 } 105 }
88 106
89 // Content whose transform nodes have a common rendering context ID are 3D 107 // Content whose transform nodes have a common rendering context ID are 3D
90 // sorted. If this is 0, content will not be 3D sorted. 108 // sorted. If this is 0, content will not be 3D sorted.
91 unsigned renderingContextId() const { return m_renderingContextId; } 109 unsigned renderingContextId() const { return m_renderingContextId; }
92 bool hasRenderingContext() const { return m_renderingContextId; } 110 bool hasRenderingContext() const { return m_renderingContextId; }
93 111
94 #if DCHECK_IS_ON() 112 #if DCHECK_IS_ON()
95 // The clone function is used by FindPropertiesNeedingUpdate.h for recording 113 // The clone function is used by FindPropertiesNeedingUpdate.h for recording
96 // a transform node before it has been updated, to later detect changes. 114 // a transform node before it has been updated, to later detect changes.
97 PassRefPtr<TransformPaintPropertyNode> clone() const { 115 PassRefPtr<TransformPaintPropertyNode> clone() const {
98 return adoptRef(new TransformPaintPropertyNode( 116 return adoptRef(new TransformPaintPropertyNode(
99 m_parent, m_matrix, m_origin, m_flattensInheritedTransform, 117 m_parent, m_matrix, m_origin, m_scroll, m_flattensInheritedTransform,
100 m_renderingContextId, m_directCompositingReasons, 118 m_renderingContextId, m_directCompositingReasons,
101 m_compositorElementId)); 119 m_compositorElementId));
102 } 120 }
103 121
104 // The equality operator is used by FindPropertiesNeedingUpdate.h for checking 122 // The equality operator is used by FindPropertiesNeedingUpdate.h for checking
105 // if a transform node has changed. 123 // if a transform node has changed.
106 bool operator==(const TransformPaintPropertyNode& o) const { 124 bool operator==(const TransformPaintPropertyNode& o) const {
107 return m_parent == o.m_parent && m_matrix == o.m_matrix && 125 return m_parent == o.m_parent && m_matrix == o.m_matrix &&
108 m_origin == o.m_origin && 126 m_origin == o.m_origin && m_scroll == o.m_scroll &&
109 m_flattensInheritedTransform == o.m_flattensInheritedTransform && 127 m_flattensInheritedTransform == o.m_flattensInheritedTransform &&
110 m_renderingContextId == o.m_renderingContextId && 128 m_renderingContextId == o.m_renderingContextId &&
111 m_directCompositingReasons == o.m_directCompositingReasons && 129 m_directCompositingReasons == o.m_directCompositingReasons &&
112 m_compositorElementId == o.m_compositorElementId; 130 m_compositorElementId == o.m_compositorElementId;
113 } 131 }
114 132
115 String toTreeString() const; 133 String toTreeString() const;
116 #endif 134 #endif
117 135
118 String toString() const; 136 String toString() const;
119 137
120 private: 138 private:
121 TransformPaintPropertyNode( 139 TransformPaintPropertyNode(
122 PassRefPtr<const TransformPaintPropertyNode> parent, 140 PassRefPtr<const TransformPaintPropertyNode> parent,
123 const TransformationMatrix& matrix, 141 const TransformationMatrix& matrix,
124 const FloatPoint3D& origin, 142 const FloatPoint3D& origin,
143 PassRefPtr<const ScrollPaintPropertyNode> scroll,
125 bool flattensInheritedTransform, 144 bool flattensInheritedTransform,
126 unsigned renderingContextId, 145 unsigned renderingContextId,
127 CompositingReasons directCompositingReasons, 146 CompositingReasons directCompositingReasons,
128 CompositorElementId compositorElementId) 147 CompositorElementId compositorElementId)
129 : m_parent(parent), 148 : m_parent(parent),
130 m_matrix(matrix), 149 m_matrix(matrix),
131 m_origin(origin), 150 m_origin(origin),
151 m_scroll(scroll),
132 m_flattensInheritedTransform(flattensInheritedTransform), 152 m_flattensInheritedTransform(flattensInheritedTransform),
133 m_renderingContextId(renderingContextId), 153 m_renderingContextId(renderingContextId),
134 m_directCompositingReasons(directCompositingReasons), 154 m_directCompositingReasons(directCompositingReasons),
135 m_compositorElementId(compositorElementId) {} 155 m_compositorElementId(compositorElementId) {}
136 156
137 RefPtr<const TransformPaintPropertyNode> m_parent; 157 RefPtr<const TransformPaintPropertyNode> m_parent;
138 TransformationMatrix m_matrix; 158 TransformationMatrix m_matrix;
139 FloatPoint3D m_origin; 159 FloatPoint3D m_origin;
160 RefPtr<const ScrollPaintPropertyNode> m_scroll;
140 bool m_flattensInheritedTransform; 161 bool m_flattensInheritedTransform;
141 unsigned m_renderingContextId; 162 unsigned m_renderingContextId;
142 CompositingReasons m_directCompositingReasons; 163 CompositingReasons m_directCompositingReasons;
143 CompositorElementId m_compositorElementId; 164 CompositorElementId m_compositorElementId;
144 }; 165 };
145 166
146 // Redeclared here to avoid ODR issues. 167 // Redeclared here to avoid ODR issues.
147 // See platform/testing/PaintPrinters.h. 168 // See platform/testing/PaintPrinters.h.
148 void PrintTo(const TransformPaintPropertyNode&, std::ostream*); 169 void PrintTo(const TransformPaintPropertyNode&, std::ostream*);
149 170
150 } // namespace blink 171 } // namespace blink
151 172
152 #endif // TransformPaintPropertyNode_h 173 #endif // TransformPaintPropertyNode_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698