2 * Copyright 2020 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef SkottieTransform_DEFINED
9 #define SkottieTransform_DEFINED
11 #include "include/core/SkM44.h"
12 #include "include/core/SkMatrix.h"
13 #include "include/core/SkPoint.h"
14 #include "modules/skottie/src/Adapter.h"
15 #include "modules/skottie/src/SkottieValue.h"
16 #include "modules/sksg/include/SkSGTransform.h"
27 class TransformAdapter2D final : public DiscardableAdapterBase<TransformAdapter2D,
28 sksg::Matrix<SkMatrix>> {
30 TransformAdapter2D(const AnimationBuilder&,
31 const skjson::ObjectValue* janchor_point,
32 const skjson::ObjectValue* jposition,
33 const skjson::ObjectValue* jscale,
34 const skjson::ObjectValue* jrotation,
35 const skjson::ObjectValue* jskew,
36 const skjson::ObjectValue* jskew_axis,
37 bool auto_orient = false);
38 ~TransformAdapter2D() override;
40 // Accessors needed for public property APIs.
41 // TODO: introduce a separate public type.
42 SkPoint getAnchorPoint() const;
43 void setAnchorPoint(const SkPoint&);
45 SkPoint getPosition() const;
46 void setPosition(const SkPoint&);
48 SkVector getScale() const;
49 void setScale(const SkVector&);
51 float getRotation() const { return fRotation; }
52 void setRotation(float r);
54 float getSkew() const { return fSkew; }
55 void setSkew(float sk);
57 float getSkewAxis() const { return fSkewAxis; }
58 void setSkewAxis(float sa );
60 SkMatrix totalMatrix() const;
63 void onSync() override;
65 Vec2Value fAnchorPoint = { 0, 0 },
67 fScale = { 100, 100 };
68 ScalarValue fRotation = 0,
71 fOrientation = 0; // additional rotation component controlled by auto-orient
73 using INHERITED = DiscardableAdapterBase<TransformAdapter2D, sksg::Matrix<SkMatrix>>;
76 class TransformAdapter3D : public DiscardableAdapterBase<TransformAdapter3D, sksg::Matrix<SkM44>> {
78 TransformAdapter3D(const skjson::ObjectValue&, const AnimationBuilder&);
79 ~TransformAdapter3D() override;
81 virtual SkM44 totalMatrix() const;
84 SkV3 anchor_point() const;
85 SkV3 position() const;
86 SkV3 rotation() const;
91 VectorValue fAnchorPoint,
94 fScale = { 100, 100, 100 };
99 using INHERITED = DiscardableAdapterBase<TransformAdapter3D, sksg::Matrix<SkM44>>;
102 } // namespace internal
103 } // namespace skottie
105 #endif // SkottieTransform_DEFINED