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