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

Side by Side Diff: cc/transform_operations.h

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

Powered by Google App Engine
This is Rietveld 408576698