Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Transform.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkottieTransform_DEFINED
9#define SkottieTransform_DEFINED
10
11#include "include/core/SkM44.h"
17
18#include <utility>
19
20namespace skjson {
21class ObjectValue;
22
23} // namespace skjson
24
25namespace skottie {
26namespace internal {
27class AnimationBuilder;
28
29class TransformAdapter2D final : public DiscardableAdapterBase<TransformAdapter2D,
30 sksg::Matrix<SkMatrix>> {
31public:
33 const skjson::ObjectValue* janchor_point,
34 const skjson::ObjectValue* jposition,
35 const skjson::ObjectValue* jscale,
36 const skjson::ObjectValue* jrotation,
37 const skjson::ObjectValue* jskew,
38 const skjson::ObjectValue* jskew_axis,
39 bool auto_orient = false);
40 ~TransformAdapter2D() override;
41
42 // Accessors needed for public property APIs.
43 // TODO: introduce a separate public type.
44 SkPoint getAnchorPoint() const;
45 void setAnchorPoint(const SkPoint&);
46
47 SkPoint getPosition() const;
48 void setPosition(const SkPoint&);
49
50 SkVector getScale() const;
51 void setScale(const SkVector&);
52
53 float getRotation() const { return fRotation; }
54 void setRotation(float r);
55
56 float getSkew() const { return fSkew; }
57 void setSkew(float sk);
58
59 float getSkewAxis() const { return fSkewAxis; }
60 void setSkewAxis(float sa );
61
62 SkMatrix totalMatrix() const;
63
64private:
65 void onSync() override;
66
67 Vec2Value fAnchorPoint = { 0, 0 },
68 fPosition = { 0, 0 },
69 fScale = { 100, 100 };
70 ScalarValue fRotation = 0,
71 fSkew = 0,
72 fSkewAxis = 0,
73 fOrientation = 0; // additional rotation component controlled by auto-orient
74
75 using INHERITED = DiscardableAdapterBase<TransformAdapter2D, sksg::Matrix<SkMatrix>>;
76};
77
78class TransformAdapter3D : public DiscardableAdapterBase<TransformAdapter3D, sksg::Matrix<SkM44>> {
79public:
82
83 virtual SkM44 totalMatrix() const;
84
85protected:
86 SkV3 anchor_point() const;
87 SkV3 position() const;
88 SkV3 rotation() const;
89
90private:
91 void onSync() final;
92
93 VectorValue fAnchorPoint,
94 fPosition,
95 fOrientation,
96 fScale = { 100, 100, 100 };
97 ScalarValue fRx = 0,
98 fRy = 0,
99 fRz = 0;
100
102};
103
104} // namespace internal
105} // namespace skottie
106
107#endif // SkottieTransform_DEFINED
Definition SkM44.h:150
void setAnchorPoint(const SkPoint &)
Definition Transform.cpp:76
void setPosition(const SkPoint &)
Definition Transform.cpp:85
void setScale(const SkVector &)
Definition Transform.cpp:94
SkScalar ScalarValue
Definition SkM44.h:19
Definition SkM44.h:56