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_TRANSFORM_OPERATIONS_H_ | 5 #ifndef CC_TRANSFORM_OPERATIONS_H_ |
6 #define CC_TRANSFORM_OPERATIONS_H_ | 6 #define CC_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" |
11 #include "cc/cc_export.h" | 11 #include "cc/cc_export.h" |
12 #include "cc/transform_operation.h" | 12 #include "cc/transform_operation.h" |
13 #include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMa trix.h" | 13 #include "ui/gfx/transform.h" |
14 | 14 |
15 namespace cc { | 15 namespace cc { |
16 | 16 |
17 // Transform operations are a decomposed transformation matrix. It can be | 17 // Transform operations are a decomposed transformation matrix. It can be |
18 // applied to obtain a WebTransformationMatrix at any time, and can be blended | 18 // applied to obtain a gfx::Transform at any time, and can be blended |
19 // intelligently with other transform operations, so long as they represent the | 19 // intelligently with other transform operations, so long as they represent the |
20 // same decomposition. For example, if we have a transform that is made up of | 20 // same decomposition. For example, if we have a transform that is made up of |
21 // a rotation followed by skew, it can be blended intelligently with another | 21 // a rotation followed by skew, it can be blended intelligently with another |
22 // transform made up of a rotation followed by a skew. Blending is possible if | 22 // transform made up of a rotation followed by a skew. Blending is possible if |
23 // we have two dissimilar sets of transform operations, but the effect may not | 23 // we have two dissimilar sets of transform operations, but the effect may not |
24 // be what was intended. For more information, see the comments for the blend | 24 // be what was intended. For more information, see the comments for the blend |
25 // function below. | 25 // function below. |
26 class CC_EXPORT TransformOperations { | 26 class CC_EXPORT TransformOperations { |
27 public: | 27 public: |
28 TransformOperations(); | 28 TransformOperations(); |
29 TransformOperations(const TransformOperations& other); | 29 TransformOperations(const TransformOperations& other); |
30 ~TransformOperations(); | 30 ~TransformOperations(); |
31 | 31 |
32 // Returns a transformation matrix representing these transform operations. | 32 // Returns a transformation matrix representing these transform operations. |
33 WebKit::WebTransformationMatrix Apply() const; | 33 gfx::Transform Apply() const; |
34 | 34 |
35 // Given another set of transform operations and a progress in the range | 35 // Given another set of transform operations and a progress in the range |
36 // [0, 1], returns a transformation matrix representing the intermediate | 36 // [0, 1], returns a transformation matrix representing the intermediate |
37 // value. If this->MatchesTypes(from), then each of the operations are | 37 // value. If this->MatchesTypes(from), then each of the operations are |
38 // blended separately and then combined. Otherwise, the two sets of | 38 // blended separately and then combined. Otherwise, the two sets of |
39 // transforms are baked to matrices (using apply), and the matrices are | 39 // transforms are baked to matrices (using apply), and the matrices are |
40 // then decomposed and interpolated. For more information, see | 40 // then decomposed and interpolated. For more information, see |
41 // http://www.w3.org/TR/2011/WD-css3-2d-transforms-20111215/#matrix-decomposit ion. | 41 // http://www.w3.org/TR/2011/WD-css3-2d-transforms-20111215/#matrix-decomposit ion. |
42 WebKit::WebTransformationMatrix Blend( | 42 gfx::Transform Blend(const TransformOperations& from, double progress) const; |
43 const TransformOperations& from, double progress) const; | |
44 | 43 |
45 // Returns true if this operation and its descendants have the same types | 44 // Returns true if this operation and its descendants have the same types |
46 // as other and its descendants. | 45 // as other and its descendants. |
47 bool MatchesTypes(const TransformOperations& other) const; | 46 bool MatchesTypes(const TransformOperations& other) const; |
48 | 47 |
49 // Returns true if these operations can be blended. It will only return | 48 // Returns true if these operations can be blended. It will only return |
50 // false if we must resort to matrix interpolation, and matrix interpolation | 49 // false if we must resort to matrix interpolation, and matrix interpolation |
51 // fails (this can happen if either matrix cannot be decomposed). | 50 // fails (this can happen if either matrix cannot be decomposed). |
52 bool CanBlendWith(const TransformOperations& other) const; | 51 bool CanBlendWith(const TransformOperations& other) const; |
53 | 52 |
54 void AppendTranslate(double x, double y, double z); | 53 void AppendTranslate(double x, double y, double z); |
55 void AppendRotate(double x, double y, double z, double degrees); | 54 void AppendRotate(double x, double y, double z, double degrees); |
56 void AppendScale(double x, double y, double z); | 55 void AppendScale(double x, double y, double z); |
57 void AppendSkew(double x, double y); | 56 void AppendSkew(double x, double y); |
58 void AppendPerspective(double depth); | 57 void AppendPerspective(double depth); |
59 void AppendMatrix(const WebKit::WebTransformationMatrix& matrix); | 58 void AppendMatrix(const gfx::Transform& matrix); |
60 void AppendIdentity(); | 59 void AppendIdentity(); |
61 bool IsIdentity() const; | 60 bool IsIdentity() const; |
62 | 61 |
63 private: | 62 private: |
64 bool BlendInternal(const TransformOperations& from, double progress, | 63 bool BlendInternal(const TransformOperations& from, double progress, |
65 WebKit::WebTransformationMatrix& result) const; | 64 gfx::Transform& result) const; |
danakj
2013/01/25 18:04:03
Can you make this into a * instead of a &. Chromiu
ajuma
2013/01/25 19:28:26
Done.
| |
66 | 65 |
67 std::vector<TransformOperation> operations_; | 66 std::vector<TransformOperation> operations_; |
68 }; | 67 }; |
69 | 68 |
70 } // namespace cc | 69 } // namespace cc |
71 | 70 |
72 #endif // CC_TRANSFORM_OPERATIONS_H_ | 71 #endif // CC_TRANSFORM_OPERATIONS_H_ |
OLD | NEW |