Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(543)

Side by Side Diff: cc/animation/transform_operations.h

Issue 2971503002: Transform animations should not collapse by default when interpolating (Closed)
Patch Set: . Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/animation/transform_operation.cc ('k') | cc/animation/transform_operations.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 18 matching lines...) Expand all
29 // transform made up of a rotation followed by a skew. Blending is possible if 29 // transform made up of a rotation followed by a skew. Blending is possible if
30 // we have two dissimilar sets of transform operations, but the effect may not 30 // we have two dissimilar sets of transform operations, but the effect may not
31 // be what was intended. For more information, see the comments for the blend 31 // be what was intended. For more information, see the comments for the blend
32 // function below. 32 // function below.
33 class CC_ANIMATION_EXPORT TransformOperations { 33 class CC_ANIMATION_EXPORT TransformOperations {
34 public: 34 public:
35 TransformOperations(); 35 TransformOperations();
36 TransformOperations(const TransformOperations& other); 36 TransformOperations(const TransformOperations& other);
37 ~TransformOperations(); 37 ~TransformOperations();
38 38
39 TransformOperations& operator=(const TransformOperations& other);
40
39 // Returns a transformation matrix representing these transform operations. 41 // Returns a transformation matrix representing these transform operations.
40 gfx::Transform Apply() const; 42 gfx::Transform Apply() const;
41 43
42 // Given another set of transform operations and a progress in the range 44 // Given another set of transform operations and a progress in the range
43 // [0, 1], returns a transformation matrix representing the intermediate 45 // [0, 1], returns a transformation matrix representing the intermediate
44 // value. If this->MatchesTypes(from), then each of the operations are 46 // value. If this->MatchesTypes(from), then each of the operations are
45 // blended separately and then combined. Otherwise, the two sets of 47 // blended separately and then combined. Otherwise, the two sets of
46 // transforms are baked to matrices (using apply), and the matrices are 48 // transforms are baked to matrices (using apply), and the matrices are
47 // then decomposed and interpolated. For more information, see 49 // then decomposed and interpolated. For more information, see
48 // http://www.w3.org/TR/2011/WD-css3-2d-transforms-20111215/#matrix-decomposit ion. 50 // http://www.w3.org/TR/2011/WD-css3-2d-transforms-20111215/#matrix-decomposit ion.
49 gfx::Transform Blend(const TransformOperations& from, 51 TransformOperations Blend(const TransformOperations& from,
50 SkMScalar progress) const; 52 SkMScalar progress) const;
51 53
52 // Sets |bounds| be the bounding box for the region within which |box| will 54 // Sets |bounds| be the bounding box for the region within which |box| will
53 // exist when it is transformed by the result of calling Blend on |from| and 55 // exist when it is transformed by the result of calling Blend on |from| and
54 // with progress in the range [min_progress, max_progress]. If this region 56 // with progress in the range [min_progress, max_progress]. If this region
55 // cannot be computed, returns false. 57 // cannot be computed, returns false.
56 bool BlendedBoundsForBox(const gfx::BoxF& box, 58 bool BlendedBoundsForBox(const gfx::BoxF& box,
57 const TransformOperations& from, 59 const TransformOperations& from,
58 SkMScalar min_progress, 60 SkMScalar min_progress,
59 SkMScalar max_progress, 61 SkMScalar max_progress,
60 gfx::BoxF* bounds) const; 62 gfx::BoxF* bounds) const;
(...skipping 18 matching lines...) Expand all
79 // returns false. 81 // returns false.
80 bool ScaleComponent(SkMScalar* scale) const; 82 bool ScaleComponent(SkMScalar* scale) const;
81 83
82 void AppendTranslate(SkMScalar x, SkMScalar y, SkMScalar z); 84 void AppendTranslate(SkMScalar x, SkMScalar y, SkMScalar z);
83 void AppendRotate(SkMScalar x, SkMScalar y, SkMScalar z, SkMScalar degrees); 85 void AppendRotate(SkMScalar x, SkMScalar y, SkMScalar z, SkMScalar degrees);
84 void AppendScale(SkMScalar x, SkMScalar y, SkMScalar z); 86 void AppendScale(SkMScalar x, SkMScalar y, SkMScalar z);
85 void AppendSkew(SkMScalar x, SkMScalar y); 87 void AppendSkew(SkMScalar x, SkMScalar y);
86 void AppendPerspective(SkMScalar depth); 88 void AppendPerspective(SkMScalar depth);
87 void AppendMatrix(const gfx::Transform& matrix); 89 void AppendMatrix(const gfx::Transform& matrix);
88 void AppendIdentity(); 90 void AppendIdentity();
91 void Append(const TransformOperation& operation);
89 bool IsIdentity() const; 92 bool IsIdentity() const;
90 93
91 size_t size() const { return operations_.size(); } 94 size_t size() const { return operations_.size(); }
92 95
93 const TransformOperation& at(size_t index) const { 96 const TransformOperation& at(size_t index) const {
94 DCHECK_LT(index, size()); 97 DCHECK_LT(index, size());
95 return operations_[index]; 98 return operations_[index];
96 } 99 }
97 100
98 private: 101 private:
99 bool BlendInternal(const TransformOperations& from, 102 bool BlendInternal(const TransformOperations& from,
100 SkMScalar progress, 103 SkMScalar progress,
101 gfx::Transform* result) const; 104 TransformOperations* result) const;
102 105
103 std::vector<TransformOperation> operations_; 106 std::vector<TransformOperation> operations_;
104 107
105 bool ComputeDecomposedTransform() const; 108 bool ComputeDecomposedTransform() const;
106 109
107 // For efficiency, we cache the decomposed transform. 110 // For efficiency, we cache the decomposed transform.
108 mutable std::unique_ptr<gfx::DecomposedTransform> decomposed_transform_; 111 mutable std::unique_ptr<gfx::DecomposedTransform> decomposed_transform_;
109 mutable bool decomposed_transform_dirty_; 112 mutable bool decomposed_transform_dirty_;
110
111 DISALLOW_ASSIGN(TransformOperations);
112 }; 113 };
113 114
114 } // namespace cc 115 } // namespace cc
115 116
116 #endif // CC_ANIMATION_TRANSFORM_OPERATIONS_H_ 117 #endif // CC_ANIMATION_TRANSFORM_OPERATIONS_H_
OLDNEW
« no previous file with comments | « cc/animation/transform_operation.cc ('k') | cc/animation/transform_operations.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698