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