• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_ANIMATION_TRANSFORM_OPERATION_H_
6 #define CC_ANIMATION_TRANSFORM_OPERATION_H_
7 
8 #include "ui/gfx/transform.h"
9 
10 namespace gfx {
11 class BoxF;
12 }
13 
14 namespace cc {
15 
16 struct TransformOperation {
17   enum Type {
18     TransformOperationTranslate,
19     TransformOperationRotate,
20     TransformOperationScale,
21     TransformOperationSkew,
22     TransformOperationPerspective,
23     TransformOperationMatrix,
24     TransformOperationIdentity
25   };
26 
TransformOperationTransformOperation27   TransformOperation()
28       : type(TransformOperationIdentity) {
29   }
30 
31   Type type;
32   gfx::Transform matrix;
33 
34   union {
35     SkMScalar perspective_depth;
36 
37     struct {
38       SkMScalar x, y;
39     } skew;
40 
41     struct {
42       SkMScalar x, y, z;
43     } scale;
44 
45     struct {
46       SkMScalar x, y, z;
47     } translate;
48 
49     struct {
50       struct {
51         SkMScalar x, y, z;
52       } axis;
53 
54       SkMScalar angle;
55     } rotate;
56   };
57 
58   bool IsIdentity() const;
59   static bool BlendTransformOperations(const TransformOperation* from,
60                                        const TransformOperation* to,
61                                        SkMScalar progress,
62                                        gfx::Transform* result);
63 
64   static bool BlendedBoundsForBox(const gfx::BoxF& box,
65                                   const TransformOperation* from,
66                                   const TransformOperation* to,
67                                   SkMScalar min_progress,
68                                   SkMScalar max_progress,
69                                   gfx::BoxF* bounds);
70 };
71 
72 }  // namespace cc
73 
74 #endif  // CC_ANIMATION_TRANSFORM_OPERATION_H_
75