| 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" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 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 |
| 88 // The associated scroll node if this transform is the scroll offset for | 125 // The associated scroll node if this transform is the scroll offset for |
| 89 // scrolling, or nullptr otherwise. | 126 // scrolling, or nullptr otherwise. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 107 // Content whose transform nodes have a common rendering context ID are 3D | 144 // Content whose transform nodes have a common rendering context ID are 3D |
| 108 // sorted. If this is 0, content will not be 3D sorted. | 145 // sorted. If this is 0, content will not be 3D sorted. |
| 109 unsigned renderingContextId() const { return m_renderingContextId; } | 146 unsigned renderingContextId() const { return m_renderingContextId; } |
| 110 bool hasRenderingContext() const { return m_renderingContextId; } | 147 bool hasRenderingContext() const { return m_renderingContextId; } |
| 111 | 148 |
| 112 #if DCHECK_IS_ON() | 149 #if DCHECK_IS_ON() |
| 113 // The clone function is used by FindPropertiesNeedingUpdate.h for recording | 150 // The clone function is used by FindPropertiesNeedingUpdate.h for recording |
| 114 // a transform node before it has been updated, to later detect changes. | 151 // a transform node before it has been updated, to later detect changes. |
| 115 PassRefPtr<TransformPaintPropertyNode> clone() const { | 152 PassRefPtr<TransformPaintPropertyNode> clone() const { |
| 116 return adoptRef(new TransformPaintPropertyNode( | 153 return adoptRef(new TransformPaintPropertyNode( |
| 117 m_parent, m_matrix, m_origin, m_scroll, m_flattensInheritedTransform, | 154 m_parent, m_matrix, m_origin, m_flattensInheritedTransform, |
| 118 m_renderingContextId, m_directCompositingReasons, | 155 m_renderingContextId, m_directCompositingReasons, m_compositorElementId, |
| 119 m_compositorElementId)); | 156 m_scroll ? m_scroll->clone() : nullptr)); |
| 120 } | 157 } |
| 121 | 158 |
| 122 // The equality operator is used by FindPropertiesNeedingUpdate.h for checking | 159 // The equality operator is used by FindPropertiesNeedingUpdate.h for checking |
| 123 // if a transform node has changed. | 160 // if a transform node has changed. |
| 124 bool operator==(const TransformPaintPropertyNode& o) const { | 161 bool operator==(const TransformPaintPropertyNode& o) const { |
| 162 if (m_scroll && o.m_scroll && !(*m_scroll == *o.m_scroll)) |
| 163 return false; |
| 125 return m_parent == o.m_parent && m_matrix == o.m_matrix && | 164 return m_parent == o.m_parent && m_matrix == o.m_matrix && |
| 126 m_origin == o.m_origin && m_scroll == o.m_scroll && | 165 m_origin == o.m_origin && |
| 127 m_flattensInheritedTransform == o.m_flattensInheritedTransform && | 166 m_flattensInheritedTransform == o.m_flattensInheritedTransform && |
| 128 m_renderingContextId == o.m_renderingContextId && | 167 m_renderingContextId == o.m_renderingContextId && |
| 129 m_directCompositingReasons == o.m_directCompositingReasons && | 168 m_directCompositingReasons == o.m_directCompositingReasons && |
| 130 m_compositorElementId == o.m_compositorElementId; | 169 m_compositorElementId == o.m_compositorElementId && |
| 170 !!m_scroll == !!o.m_scroll; |
| 131 } | 171 } |
| 132 | 172 |
| 133 String toTreeString() const; | 173 String toTreeString() const; |
| 134 #endif | 174 #endif |
| 135 | 175 |
| 136 String toString() const; | 176 String toString() const; |
| 137 | 177 |
| 138 private: | 178 private: |
| 139 TransformPaintPropertyNode( | 179 TransformPaintPropertyNode( |
| 140 PassRefPtr<const TransformPaintPropertyNode> parent, | 180 PassRefPtr<const TransformPaintPropertyNode> parent, |
| 141 const TransformationMatrix& matrix, | 181 const TransformationMatrix& matrix, |
| 142 const FloatPoint3D& origin, | 182 const FloatPoint3D& origin, |
| 143 PassRefPtr<const ScrollPaintPropertyNode> scroll, | |
| 144 bool flattensInheritedTransform, | 183 bool flattensInheritedTransform, |
| 145 unsigned renderingContextId, | 184 unsigned renderingContextId, |
| 146 CompositingReasons directCompositingReasons, | 185 CompositingReasons directCompositingReasons, |
| 147 CompositorElementId compositorElementId) | 186 CompositorElementId compositorElementId, |
| 187 PassRefPtr<ScrollPaintPropertyNode> scroll = nullptr) |
| 148 : m_parent(parent), | 188 : m_parent(parent), |
| 149 m_matrix(matrix), | 189 m_matrix(matrix), |
| 150 m_origin(origin), | 190 m_origin(origin), |
| 151 m_scroll(scroll), | |
| 152 m_flattensInheritedTransform(flattensInheritedTransform), | 191 m_flattensInheritedTransform(flattensInheritedTransform), |
| 153 m_renderingContextId(renderingContextId), | 192 m_renderingContextId(renderingContextId), |
| 154 m_directCompositingReasons(directCompositingReasons), | 193 m_directCompositingReasons(directCompositingReasons), |
| 155 m_compositorElementId(compositorElementId) {} | 194 m_compositorElementId(compositorElementId), |
| 195 m_scroll(scroll) {} |
| 156 | 196 |
| 157 RefPtr<const TransformPaintPropertyNode> m_parent; | 197 RefPtr<const TransformPaintPropertyNode> m_parent; |
| 158 TransformationMatrix m_matrix; | 198 TransformationMatrix m_matrix; |
| 159 FloatPoint3D m_origin; | 199 FloatPoint3D m_origin; |
| 160 RefPtr<const ScrollPaintPropertyNode> m_scroll; | |
| 161 bool m_flattensInheritedTransform; | 200 bool m_flattensInheritedTransform; |
| 162 unsigned m_renderingContextId; | 201 unsigned m_renderingContextId; |
| 163 CompositingReasons m_directCompositingReasons; | 202 CompositingReasons m_directCompositingReasons; |
| 164 CompositorElementId m_compositorElementId; | 203 CompositorElementId m_compositorElementId; |
| 204 RefPtr<ScrollPaintPropertyNode> m_scroll; |
| 165 }; | 205 }; |
| 166 | 206 |
| 167 // Redeclared here to avoid ODR issues. | 207 // Redeclared here to avoid ODR issues. |
| 168 // See platform/testing/PaintPrinters.h. | 208 // See platform/testing/PaintPrinters.h. |
| 169 void PrintTo(const TransformPaintPropertyNode&, std::ostream*); | 209 void PrintTo(const TransformPaintPropertyNode&, std::ostream*); |
| 170 | 210 |
| 171 } // namespace blink | 211 } // namespace blink |
| 172 | 212 |
| 173 #endif // TransformPaintPropertyNode_h | 213 #endif // TransformPaintPropertyNode_h |
| OLD | NEW |