1 | // Copyright (C) 2018 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef BMFEEFORMSHAPE_P_H |
5 | #define BMFEEFORMSHAPE_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QPainterPath> |
19 | #include <QJsonArray> |
20 | #include <QMap> |
21 | #include <QHash> |
22 | #include <QList> |
23 | |
24 | #include <QtBodymovin/bmglobal.h> |
25 | #include <QtBodymovin/private/bmshape_p.h> |
26 | #include <QtBodymovin/private/bmtrimpath_p.h> |
27 | #include <QtBodymovin/private/lottierenderer_p.h> |
28 | |
29 | QT_BEGIN_NAMESPACE |
30 | |
31 | class QJsonObject; |
32 | |
33 | class BODYMOVIN_EXPORT BMFreeFormShape : public BMShape |
34 | { |
35 | public: |
36 | BMFreeFormShape(); |
37 | explicit BMFreeFormShape(const BMFreeFormShape &other); |
38 | BMFreeFormShape(const QJsonObject &definition, const QVersionNumber &version, |
39 | BMBase *parent = nullptr); |
40 | |
41 | BMBase *clone() const override; |
42 | |
43 | void construct(const QJsonObject &definition, const QVersionNumber &version); |
44 | |
45 | void updateProperties(int frame) override; |
46 | void render(LottieRenderer &renderer) const override; |
47 | |
48 | bool acceptsTrim() const override; |
49 | |
50 | protected: |
51 | struct VertexInfo { |
52 | BMProperty2D<QPointF> pos; |
53 | BMProperty2D<QPointF> ci; |
54 | BMProperty2D<QPointF> co; |
55 | }; |
56 | |
57 | void parseShapeKeyframes(QJsonObject &keyframes); |
58 | void buildShape(const QJsonObject &keyframe); |
59 | void buildShape(int frame); |
60 | void parseEasedVertices(const QJsonObject &keyframe, int startFrame); |
61 | |
62 | QHash<int, QJsonObject> m_vertexMap; |
63 | QList<VertexInfo> m_vertexList; |
64 | QMap<int, bool> m_closedShape; |
65 | |
66 | private: |
67 | struct VertexBuildInfo |
68 | { |
69 | QJsonArray posKeyframes; |
70 | QJsonArray ciKeyframes; |
71 | QJsonArray coKeyframes; |
72 | }; |
73 | |
74 | void finalizeVertices(); |
75 | |
76 | QMap<int, VertexBuildInfo*> m_vertexInfos; |
77 | |
78 | QJsonObject createKeyframe(QJsonArray startValue, QJsonArray endValue, |
79 | int startFrame, QJsonObject easingIn, |
80 | QJsonObject easingOut); |
81 | }; |
82 | |
83 | QT_END_NAMESPACE |
84 | |
85 | #endif // BMFEEFORMSHAPE_P_H |
86 | |