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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 m_directCompositingReasons == o.m_directCompositingReasons && | 181 m_directCompositingReasons == o.m_directCompositingReasons && |
182 m_compositorElementId == o.m_compositorElementId && | 182 m_compositorElementId == o.m_compositorElementId && |
183 !!m_scroll == !!o.m_scroll; | 183 !!m_scroll == !!o.m_scroll; |
184 } | 184 } |
185 | 185 |
186 String toTreeString() const; | 186 String toTreeString() const; |
187 #endif | 187 #endif |
188 | 188 |
189 String toString() const; | 189 String toString() const; |
190 | 190 |
| 191 // Clears all transform caches (see getTransformCache()). |
| 192 static void clearCache(); |
| 193 |
191 private: | 194 private: |
192 TransformPaintPropertyNode( | 195 TransformPaintPropertyNode( |
193 PassRefPtr<const TransformPaintPropertyNode> parent, | 196 PassRefPtr<const TransformPaintPropertyNode> parent, |
194 const TransformationMatrix& matrix, | 197 const TransformationMatrix& matrix, |
195 const FloatPoint3D& origin, | 198 const FloatPoint3D& origin, |
196 bool flattensInheritedTransform, | 199 bool flattensInheritedTransform, |
197 unsigned renderingContextId, | 200 unsigned renderingContextId, |
198 CompositingReasons directCompositingReasons, | 201 CompositingReasons directCompositingReasons, |
199 CompositorElementId compositorElementId, | 202 CompositorElementId compositorElementId, |
200 PassRefPtr<ScrollPaintPropertyNode> scroll = nullptr) | 203 PassRefPtr<ScrollPaintPropertyNode> scroll = nullptr) |
201 : m_parent(parent), | 204 : m_parent(parent), |
202 m_matrix(matrix), | 205 m_matrix(matrix), |
203 m_origin(origin), | 206 m_origin(origin), |
204 m_flattensInheritedTransform(flattensInheritedTransform), | 207 m_flattensInheritedTransform(flattensInheritedTransform), |
205 m_renderingContextId(renderingContextId), | 208 m_renderingContextId(renderingContextId), |
206 m_directCompositingReasons(directCompositingReasons), | 209 m_directCompositingReasons(directCompositingReasons), |
207 m_compositorElementId(compositorElementId), | 210 m_compositorElementId(compositorElementId), |
208 m_scroll(scroll) {} | 211 m_scroll(scroll) {} |
209 | 212 |
| 213 struct TransformCacheEntry { |
| 214 const TransformPaintPropertyNode* ancestorNode; |
| 215 TransformationMatrix toAncestor; |
| 216 TransformCacheEntry(const TransformPaintPropertyNode* ancestorNodeArg, |
| 217 const TransformationMatrix& toAncestorArg) |
| 218 : ancestorNode(ancestorNodeArg), toAncestor(toAncestorArg) {} |
| 219 }; |
| 220 |
| 221 // For access to getCachedTransform() and setCachedTransform. |
| 222 friend class GeometryMapper; |
| 223 friend class GeometryMapperTest; |
| 224 |
| 225 Vector<TransformCacheEntry>* getTransformCacheEntries(); |
| 226 |
| 227 // Returns the "transformed rect" (see GeometryMapper.h) of |this| in the |
| 228 // space of |ancestorTransform|, if there is one cached. Otherwise returns |
| 229 // null. |
| 230 const TransformationMatrix* getCachedTransform( |
| 231 const TransformPaintPropertyNode* ancestorTransform) const; |
| 232 |
| 233 // Stores the "transformed rect" of |this| in the space of |ancestors|, |
| 234 // into a local cache. |
| 235 void setCachedTransform(const TransformPaintPropertyNode* ancestorTransform, |
| 236 const TransformationMatrix& toAncestor) const; |
| 237 |
210 RefPtr<const TransformPaintPropertyNode> m_parent; | 238 RefPtr<const TransformPaintPropertyNode> m_parent; |
211 TransformationMatrix m_matrix; | 239 TransformationMatrix m_matrix; |
212 FloatPoint3D m_origin; | 240 FloatPoint3D m_origin; |
213 bool m_flattensInheritedTransform; | 241 bool m_flattensInheritedTransform; |
214 unsigned m_renderingContextId; | 242 unsigned m_renderingContextId; |
215 CompositingReasons m_directCompositingReasons; | 243 CompositingReasons m_directCompositingReasons; |
216 CompositorElementId m_compositorElementId; | 244 CompositorElementId m_compositorElementId; |
217 RefPtr<ScrollPaintPropertyNode> m_scroll; | 245 RefPtr<ScrollPaintPropertyNode> m_scroll; |
| 246 |
| 247 std::unique_ptr<Vector<TransformCacheEntry>> m_transformCache; |
| 248 unsigned m_cacheGeneration; |
218 }; | 249 }; |
219 | 250 |
220 // Redeclared here to avoid ODR issues. | 251 // Redeclared here to avoid ODR issues. |
221 // See platform/testing/PaintPrinters.h. | 252 // See platform/testing/PaintPrinters.h. |
222 void PrintTo(const TransformPaintPropertyNode&, std::ostream*); | 253 void PrintTo(const TransformPaintPropertyNode&, std::ostream*); |
223 | 254 |
224 } // namespace blink | 255 } // namespace blink |
225 | 256 |
226 #endif // TransformPaintPropertyNode_h | 257 #endif // TransformPaintPropertyNode_h |
OLD | NEW |