summaryrefslogtreecommitdiffstats
path: root/cc/animation/transform_operation.h
blob: 3ea5fc20210a230a1014915a16fdaaf2bf07a8d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CC_ANIMATION_TRANSFORM_OPERATION_H_
#define CC_ANIMATION_TRANSFORM_OPERATION_H_

#include "ui/gfx/transform.h"

namespace gfx {
class BoxF;
}

namespace cc {

struct TransformOperation {
  enum Type {
    TRANSFORM_OPERATION_TRANSLATE,
    TRANSFORM_OPERATION_ROTATE,
    TRANSFORM_OPERATION_SCALE,
    TRANSFORM_OPERATION_SKEW,
    TRANSFORM_OPERATION_PERSPECTIVE,
    TRANSFORM_OPERATION_MATRIX,
    TRANSFORM_OPERATION_IDENTITY
  };

  TransformOperation() : type(TRANSFORM_OPERATION_IDENTITY) {}

  Type type;
  gfx::Transform matrix;

  union {
    SkMScalar perspective_depth;

    struct {
      SkMScalar x, y;
    } skew;

    struct {
      SkMScalar x, y, z;
    } scale;

    struct {
      SkMScalar x, y, z;
    } translate;

    struct {
      struct {
        SkMScalar x, y, z;
      } axis;

      SkMScalar angle;
    } rotate;
  };

  bool IsIdentity() const;
  static bool BlendTransformOperations(const TransformOperation* from,
                                       const TransformOperation* to,
                                       SkMScalar progress,
                                       gfx::Transform* result);

  static bool BlendedBoundsForBox(const gfx::BoxF& box,
                                  const TransformOperation* from,
                                  const TransformOperation* to,
                                  SkMScalar min_progress,
                                  SkMScalar max_progress,
                                  gfx::BoxF* bounds);
};

}  // namespace cc

#endif  // CC_ANIMATION_TRANSFORM_OPERATION_H_