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