OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CC_ANIMATION_TRANSFORM_OPERATIONS_H_ | 5 #ifndef CC_ANIMATION_TRANSFORM_OPERATIONS_H_ |
6 #define CC_ANIMATION_TRANSFORM_OPERATIONS_H_ | 6 #define CC_ANIMATION_TRANSFORM_OPERATIONS_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 // Returns a transformation matrix representing these transform operations. | 37 // Returns a transformation matrix representing these transform operations. |
38 gfx::Transform Apply() const; | 38 gfx::Transform Apply() const; |
39 | 39 |
40 // Given another set of transform operations and a progress in the range | 40 // Given another set of transform operations and a progress in the range |
41 // [0, 1], returns a transformation matrix representing the intermediate | 41 // [0, 1], returns a transformation matrix representing the intermediate |
42 // value. If this->MatchesTypes(from), then each of the operations are | 42 // value. If this->MatchesTypes(from), then each of the operations are |
43 // blended separately and then combined. Otherwise, the two sets of | 43 // blended separately and then combined. Otherwise, the two sets of |
44 // transforms are baked to matrices (using apply), and the matrices are | 44 // transforms are baked to matrices (using apply), and the matrices are |
45 // then decomposed and interpolated. For more information, see | 45 // then decomposed and interpolated. For more information, see |
46 // http://www.w3.org/TR/2011/WD-css3-2d-transforms-20111215/#matrix-decomposit
ion. | 46 // http://www.w3.org/TR/2011/WD-css3-2d-transforms-20111215/#matrix-decomposit
ion. |
47 gfx::Transform Blend(const TransformOperations& from, double progress) const; | 47 gfx::Transform Blend(const TransformOperations& from, |
| 48 SkMScalar progress) const; |
48 | 49 |
49 // Sets |bounds| be the bounding box for the region within which |box| will | 50 // Sets |bounds| be the bounding box for the region within which |box| will |
50 // exist when it is transformed by the result of calling Blend on |from| and | 51 // exist when it is transformed by the result of calling Blend on |from| and |
51 // with progress in the range [min_progress, max_progress]. If this region | 52 // with progress in the range [min_progress, max_progress]. If this region |
52 // cannot be computed, returns false. | 53 // cannot be computed, returns false. |
53 bool BlendedBoundsForBox(const gfx::BoxF& box, | 54 bool BlendedBoundsForBox(const gfx::BoxF& box, |
54 const TransformOperations& from, | 55 const TransformOperations& from, |
55 double min_progress, | 56 SkMScalar min_progress, |
56 double max_progress, | 57 SkMScalar max_progress, |
57 gfx::BoxF* bounds) const; | 58 gfx::BoxF* bounds) const; |
58 | 59 |
59 // Returns true if this operation and its descendants have the same types | 60 // Returns true if this operation and its descendants have the same types |
60 // as other and its descendants. | 61 // as other and its descendants. |
61 bool MatchesTypes(const TransformOperations& other) const; | 62 bool MatchesTypes(const TransformOperations& other) const; |
62 | 63 |
63 // Returns true if these operations can be blended. It will only return | 64 // Returns true if these operations can be blended. It will only return |
64 // false if we must resort to matrix interpolation, and matrix interpolation | 65 // false if we must resort to matrix interpolation, and matrix interpolation |
65 // fails (this can happen if either matrix cannot be decomposed). | 66 // fails (this can happen if either matrix cannot be decomposed). |
66 bool CanBlendWith(const TransformOperations& other) const; | 67 bool CanBlendWith(const TransformOperations& other) const; |
67 | 68 |
68 void AppendTranslate(double x, double y, double z); | 69 void AppendTranslate(SkMScalar x, SkMScalar y, SkMScalar z); |
69 void AppendRotate(double x, double y, double z, double degrees); | 70 void AppendRotate(SkMScalar x, SkMScalar y, SkMScalar z, SkMScalar degrees); |
70 void AppendScale(double x, double y, double z); | 71 void AppendScale(SkMScalar x, SkMScalar y, SkMScalar z); |
71 void AppendSkew(double x, double y); | 72 void AppendSkew(SkMScalar x, SkMScalar y); |
72 void AppendPerspective(double depth); | 73 void AppendPerspective(SkMScalar depth); |
73 void AppendMatrix(const gfx::Transform& matrix); | 74 void AppendMatrix(const gfx::Transform& matrix); |
74 void AppendIdentity(); | 75 void AppendIdentity(); |
75 bool IsIdentity() const; | 76 bool IsIdentity() const; |
76 | 77 |
77 private: | 78 private: |
78 bool BlendInternal(const TransformOperations& from, double progress, | 79 bool BlendInternal(const TransformOperations& from, |
| 80 SkMScalar progress, |
79 gfx::Transform* result) const; | 81 gfx::Transform* result) const; |
80 | 82 |
81 std::vector<TransformOperation> operations_; | 83 std::vector<TransformOperation> operations_; |
82 | 84 |
83 bool ComputeDecomposedTransform() const; | 85 bool ComputeDecomposedTransform() const; |
84 | 86 |
85 // For efficiency, we cache the decomposed transform. | 87 // For efficiency, we cache the decomposed transform. |
86 mutable scoped_ptr<gfx::DecomposedTransform> decomposed_transform_; | 88 mutable scoped_ptr<gfx::DecomposedTransform> decomposed_transform_; |
87 mutable bool decomposed_transform_dirty_; | 89 mutable bool decomposed_transform_dirty_; |
88 | 90 |
89 DISALLOW_ASSIGN(TransformOperations); | 91 DISALLOW_ASSIGN(TransformOperations); |
90 }; | 92 }; |
91 | 93 |
92 } // namespace cc | 94 } // namespace cc |
93 | 95 |
94 #endif // CC_ANIMATION_TRANSFORM_OPERATIONS_H_ | 96 #endif // CC_ANIMATION_TRANSFORM_OPERATIONS_H_ |
OLD | NEW |