| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 GeometryMapper_h | 5 #ifndef GeometryMapper_h |
| 6 #define GeometryMapper_h | 6 #define GeometryMapper_h |
| 7 | 7 |
| 8 #include "platform/graphics/paint/FloatClipRect.h" | 8 #include "platform/graphics/paint/FloatClipRect.h" |
| 9 #include "platform/graphics/paint/PropertyTreeState.h" | 9 #include "platform/graphics/paint/PropertyTreeState.h" |
| 10 #include "platform/transforms/TransformationMatrix.h" | 10 #include "platform/transforms/TransformationMatrix.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // | 46 // |
| 47 // NOTE: A GeometryMapper object is only valid for property trees that do not | 47 // NOTE: A GeometryMapper object is only valid for property trees that do not |
| 48 // change. If any mutation occurs, a new GeometryMapper object must be allocated | 48 // change. If any mutation occurs, a new GeometryMapper object must be allocated |
| 49 // corresponding to the new state. | 49 // corresponding to the new state. |
| 50 // | 50 // |
| 51 // Design document: http://bit.ly/28P4FDA | 51 // Design document: http://bit.ly/28P4FDA |
| 52 // | 52 // |
| 53 // TODO(chrishtr): take effect tree into account. | 53 // TODO(chrishtr): take effect tree into account. |
| 54 class PLATFORM_EXPORT GeometryMapper { | 54 class PLATFORM_EXPORT GeometryMapper { |
| 55 public: | 55 public: |
| 56 GeometryMapper() {} | 56 static std::unique_ptr<GeometryMapper> create() { |
| 57 return WTF::wrapUnique(new GeometryMapper()); |
| 58 } |
| 59 |
| 57 // The runtime of m calls among localToAncestorVisualRect, localToAncestorRect | 60 // The runtime of m calls among localToAncestorVisualRect, localToAncestorRect |
| 58 // or ancestorToLocalRect with the same |ancestorState| parameter is | 61 // or ancestorToLocalRect with the same |ancestorState| parameter is |
| 59 // guaranteed to be O(n + m), where n is the number of transform and clip | 62 // guaranteed to be O(n + m), where n is the number of transform and clip |
| 60 // nodes in their respective property trees. | 63 // nodes in their respective property trees. |
| 61 | 64 |
| 62 // If the clips and transforms of |sourceState| are equal to or descendants of | 65 // If the clips and transforms of |sourceState| are equal to or descendants of |
| 63 // those of |destinationState|, returns the same value as | 66 // those of |destinationState|, returns the same value as |
| 64 // localToAncestorVisualRect. Otherwise, maps the input rect to the | 67 // localToAncestorVisualRect. Otherwise, maps the input rect to the |
| 65 // transform state which is the lowest common ancestor of | 68 // transform state which is the lowest common ancestor of |
| 66 // |sourceState.transform| and |destinationState.transform|, then multiplies | 69 // |sourceState.transform| and |destinationState.transform|, then multiplies |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 const PropertyTreeState& localTransformState, | 139 const PropertyTreeState& localTransformState, |
| 137 const PropertyTreeState& ancestorState); | 140 const PropertyTreeState& ancestorState); |
| 138 | 141 |
| 139 // Returns the lowest common ancestor in the paint property tree. | 142 // Returns the lowest common ancestor in the paint property tree. |
| 140 template <typename NodeType> | 143 template <typename NodeType> |
| 141 static PLATFORM_EXPORT const NodeType* lowestCommonAncestor(const NodeType*, | 144 static PLATFORM_EXPORT const NodeType* lowestCommonAncestor(const NodeType*, |
| 142 const NodeType*); | 145 const NodeType*); |
| 143 | 146 |
| 144 void clearCache(); | 147 void clearCache(); |
| 145 | 148 |
| 149 protected: |
| 150 GeometryMapper() {} |
| 151 |
| 146 private: | 152 private: |
| 147 // The internal methods do the same things as their public counterparts, but | 153 // The internal methods do the same things as their public counterparts, but |
| 148 // take an extra |success| parameter which indicates if the function is | 154 // take an extra |success| parameter which indicates if the function is |
| 149 // successful on return. See comments of the public functions for failure | 155 // successful on return. See comments of the public functions for failure |
| 150 // conditions. | 156 // conditions. |
| 151 | 157 |
| 152 FloatClipRect sourceToDestinationVisualRectInternal( | 158 FloatClipRect sourceToDestinationVisualRectInternal( |
| 153 const FloatRect&, | 159 const FloatRect&, |
| 154 const PropertyTreeState& sourceState, | 160 const PropertyTreeState& sourceState, |
| 155 const PropertyTreeState& destinationState, | 161 const PropertyTreeState& destinationState, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 m_data; | 209 m_data; |
| 204 | 210 |
| 205 const TransformationMatrix m_identity; | 211 const TransformationMatrix m_identity; |
| 206 | 212 |
| 207 DISALLOW_COPY_AND_ASSIGN(GeometryMapper); | 213 DISALLOW_COPY_AND_ASSIGN(GeometryMapper); |
| 208 }; | 214 }; |
| 209 | 215 |
| 210 } // namespace blink | 216 } // namespace blink |
| 211 | 217 |
| 212 #endif // GeometryMapper_h | 218 #endif // GeometryMapper_h |
| OLD | NEW |