| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 SkMScalar min_progress, | 56 SkMScalar min_progress, |
| 57 SkMScalar max_progress, | 57 SkMScalar max_progress, |
| 58 gfx::BoxF* bounds) const; | 58 gfx::BoxF* bounds) const; |
| 59 | 59 |
| 60 // Returns true if these operations affect scale. | 60 // Returns true if these operations affect scale. |
| 61 bool AffectsScale() const; | 61 bool AffectsScale() const; |
| 62 | 62 |
| 63 // Returns true if these operations are only translations. | 63 // Returns true if these operations are only translations. |
| 64 bool IsTranslation() const; | 64 bool IsTranslation() const; |
| 65 | 65 |
| 66 // Sets |max_scale| to be the maximum scale in any dimension when calling | |
| 67 // Blend on |from| with progress in the range [min_progress, max_progress]. If | |
| 68 // this maximum scale cannot be computed, returns false. | |
| 69 bool MaximumScale(const TransformOperations& from, | |
| 70 SkMScalar min_progress, | |
| 71 SkMScalar max_progress, | |
| 72 float* max_scale) const; | |
| 73 | |
| 74 // Returns true if this operation and its descendants have the same types | 66 // Returns true if this operation and its descendants have the same types |
| 75 // as other and its descendants. | 67 // as other and its descendants. |
| 76 bool MatchesTypes(const TransformOperations& other) const; | 68 bool MatchesTypes(const TransformOperations& other) const; |
| 77 | 69 |
| 78 // Returns true if these operations can be blended. It will only return | 70 // Returns true if these operations can be blended. It will only return |
| 79 // false if we must resort to matrix interpolation, and matrix interpolation | 71 // false if we must resort to matrix interpolation, and matrix interpolation |
| 80 // fails (this can happen if either matrix cannot be decomposed). | 72 // fails (this can happen if either matrix cannot be decomposed). |
| 81 bool CanBlendWith(const TransformOperations& other) const; | 73 bool CanBlendWith(const TransformOperations& other) const; |
| 82 | 74 |
| 75 // If these operations have no more than one scale operation, and if the only |
| 76 // other operations are translations, sets |scale| to the scale component |
| 77 // of these operations. Otherwise, returns false. |
| 78 bool ScaleComponent(gfx::Vector3dF* scale) const; |
| 79 |
| 83 void AppendTranslate(SkMScalar x, SkMScalar y, SkMScalar z); | 80 void AppendTranslate(SkMScalar x, SkMScalar y, SkMScalar z); |
| 84 void AppendRotate(SkMScalar x, SkMScalar y, SkMScalar z, SkMScalar degrees); | 81 void AppendRotate(SkMScalar x, SkMScalar y, SkMScalar z, SkMScalar degrees); |
| 85 void AppendScale(SkMScalar x, SkMScalar y, SkMScalar z); | 82 void AppendScale(SkMScalar x, SkMScalar y, SkMScalar z); |
| 86 void AppendSkew(SkMScalar x, SkMScalar y); | 83 void AppendSkew(SkMScalar x, SkMScalar y); |
| 87 void AppendPerspective(SkMScalar depth); | 84 void AppendPerspective(SkMScalar depth); |
| 88 void AppendMatrix(const gfx::Transform& matrix); | 85 void AppendMatrix(const gfx::Transform& matrix); |
| 89 void AppendIdentity(); | 86 void AppendIdentity(); |
| 90 bool IsIdentity() const; | 87 bool IsIdentity() const; |
| 91 | 88 |
| 92 private: | 89 private: |
| 93 bool BlendInternal(const TransformOperations& from, | 90 bool BlendInternal(const TransformOperations& from, |
| 94 SkMScalar progress, | 91 SkMScalar progress, |
| 95 gfx::Transform* result) const; | 92 gfx::Transform* result) const; |
| 96 | 93 |
| 97 std::vector<TransformOperation> operations_; | 94 std::vector<TransformOperation> operations_; |
| 98 | 95 |
| 99 bool ComputeDecomposedTransform() const; | 96 bool ComputeDecomposedTransform() const; |
| 100 | 97 |
| 101 // If these operations have no more than one scale operation, and if the only | |
| 102 // other operations are translations, sets |scale| to the scale component | |
| 103 // of these operations. Otherwise, returns false. | |
| 104 bool ScaleComponent(gfx::Vector3dF* scale) const; | |
| 105 | |
| 106 // For efficiency, we cache the decomposed transform. | 98 // For efficiency, we cache the decomposed transform. |
| 107 mutable scoped_ptr<gfx::DecomposedTransform> decomposed_transform_; | 99 mutable scoped_ptr<gfx::DecomposedTransform> decomposed_transform_; |
| 108 mutable bool decomposed_transform_dirty_; | 100 mutable bool decomposed_transform_dirty_; |
| 109 | 101 |
| 110 DISALLOW_ASSIGN(TransformOperations); | 102 DISALLOW_ASSIGN(TransformOperations); |
| 111 }; | 103 }; |
| 112 | 104 |
| 113 } // namespace cc | 105 } // namespace cc |
| 114 | 106 |
| 115 #endif // CC_ANIMATION_TRANSFORM_OPERATIONS_H_ | 107 #endif // CC_ANIMATION_TRANSFORM_OPERATIONS_H_ |
| OLD | NEW |