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