QtLottie: Enforce BM nodes parent.

This commit is contained in:
John Preston 2019-05-14 16:37:22 +03:00
parent 67739ae3fd
commit fbc206ebee
27 changed files with 114 additions and 113 deletions

@ -1 +1 @@
Subproject commit 26d3e9ff5f354a20e72b90e2a3d4d57bd73baa8c Subproject commit 2a529ab07bd105e0cac1a58ad5cb77f2fdc8f20d

View File

@ -50,17 +50,17 @@ class LottieRenderer;
class BODYMOVIN_EXPORT BMAsset : public BMBase class BODYMOVIN_EXPORT BMAsset : public BMBase
{ {
public: public:
BMAsset() = default; BMAsset(BMBase *parent);
explicit BMAsset (const BMAsset &other) = default; BMAsset(BMBase *parent, const BMAsset &other);
~BMAsset() = default; ~BMAsset() = default;
BMAsset *clone() const override; BMAsset *clone(BMBase *parent) const override;
static BMAsset *construct(QJsonObject definition); static BMAsset *construct(BMBase *parent, QJsonObject definition);
void parse(const QJsonObject &definition) override; void parse(const QJsonObject &definition) override;
void resolveAssets(const std::function<BMAsset*(QString)> &resolver) override; void resolveAssets(const std::function<BMAsset*(BMBase*, QString)> &resolver) override;
QString id() const; QString id() const;

View File

@ -59,11 +59,12 @@ class BMScene;
class BODYMOVIN_EXPORT BMBase class BODYMOVIN_EXPORT BMBase
{ {
public: public:
BMBase() = default; BMBase(BMBase *parent);
explicit BMBase(const BMBase &other); BMBase(BMBase *parent, const BMBase &other);
BMBase(const BMBase &other) = delete;
virtual ~BMBase(); virtual ~BMBase();
virtual BMBase *clone() const; virtual BMBase *clone(BMBase *parent) const;
virtual bool setProperty(BMLiteral::PropertyType propertyType, QVariant value); virtual bool setProperty(BMLiteral::PropertyType propertyType, QVariant value);
@ -80,7 +81,6 @@ public:
bool hidden() const; bool hidden() const;
inline BMBase *parent() const { return m_parent; } inline BMBase *parent() const { return m_parent; }
void setParent(BMBase *parent);
const QList<BMBase *> &children() const { return m_children; } const QList<BMBase *> &children() const { return m_children; }
void prependChild(BMBase *child); void prependChild(BMBase *child);
@ -91,7 +91,7 @@ public:
virtual void updateProperties(int frame); virtual void updateProperties(int frame);
virtual void render(LottieRenderer &renderer, int frame) const; virtual void render(LottieRenderer &renderer, int frame) const;
virtual void resolveAssets(const std::function<BMAsset*(QString)> &resolver); virtual void resolveAssets(const std::function<BMAsset*(BMBase*, QString)> &resolver);
protected: protected:
virtual BMScene *resolveTopRoot() const; virtual BMScene *resolveTopRoot() const;
@ -110,7 +110,7 @@ protected:
friend class BMRenderer; friend class BMRenderer;
private: private:
BMBase *m_parent = nullptr; BMBase * const m_parent = nullptr;
QList<BMBase *> m_children; QList<BMBase *> m_children;
// Handle to the topmost element on which this element resides // Handle to the topmost element on which this element resides

View File

@ -54,13 +54,13 @@ class QJsonObject;
class BODYMOVIN_EXPORT BMBasicTransform : public BMShape class BODYMOVIN_EXPORT BMBasicTransform : public BMShape
{ {
public: public:
BMBasicTransform() = default; BMBasicTransform(BMBase *parent);
explicit BMBasicTransform(const BMBasicTransform &other); BMBasicTransform(BMBase *parent, const BMBasicTransform &other);
BMBasicTransform(const QJsonObject &definition, BMBase *parent = nullptr); BMBasicTransform(BMBase *parent, const QJsonObject &definition);
BMBase *clone() const override; BMBase *clone(BMBase *parent) const override;
void construct(const QJsonObject &definition); void parse(const QJsonObject &definition);
void updateProperties(int frame) override; void updateProperties(int frame) override;
void render(LottieRenderer &renderer, int frame) const override; void render(LottieRenderer &renderer, int frame) const override;

View File

@ -60,13 +60,13 @@ class QJsonObject;
class BODYMOVIN_EXPORT BMEllipse : public BMShape class BODYMOVIN_EXPORT BMEllipse : public BMShape
{ {
public: public:
BMEllipse() = default; BMEllipse(BMBase *parent);
explicit BMEllipse(const BMEllipse &other); BMEllipse(BMBase *parent, const BMEllipse &other);
BMEllipse(const QJsonObject &definition, BMBase *parent = nullptr); BMEllipse(BMBase *parent, const QJsonObject &definition);
BMBase *clone() const override; BMBase *clone(BMBase *parent) const override;
void construct(const QJsonObject &definition); void parse(const QJsonObject &definition);
void updateProperties(int frame) override; void updateProperties(int frame) override;
void render(LottieRenderer &renderer, int frame) const override; void render(LottieRenderer &renderer, int frame) const override;

View File

@ -52,11 +52,11 @@ QT_BEGIN_NAMESPACE
class BODYMOVIN_EXPORT BMFill : public BMShape class BODYMOVIN_EXPORT BMFill : public BMShape
{ {
public: public:
BMFill() = default; BMFill(BMBase *parent);
explicit BMFill(const BMFill &other); BMFill(BMBase *parent, const BMFill &other);
BMFill(const QJsonObject &definition, BMBase *parent = nullptr); BMFill(BMBase *parent, const QJsonObject &definition);
BMBase *clone() const override; BMBase *clone(BMBase *parent) const override;
void updateProperties(int frame) override; void updateProperties(int frame) override;

View File

@ -54,12 +54,13 @@ class QJsonObject;
class BODYMOVIN_EXPORT BMFillEffect : public BMBase class BODYMOVIN_EXPORT BMFillEffect : public BMBase
{ {
public: public:
BMFillEffect() = default; BMFillEffect(BMBase *parent);
explicit BMFillEffect(const BMFillEffect &other); BMFillEffect(BMBase *parent, const BMFillEffect &other);
BMFillEffect(BMBase *parent, const QJsonObject &definition);
BMBase *clone() const override; BMBase *clone(BMBase *parent) const override;
void construct(const QJsonObject &definition); void parse(const QJsonObject &definition);
void updateProperties(int frame) override; void updateProperties(int frame) override;
void render(LottieRenderer &renderer, int frame) const override; void render(LottieRenderer &renderer, int frame) const override;

View File

@ -56,13 +56,13 @@ class QJsonObject;
class BODYMOVIN_EXPORT BMFreeFormShape : public BMShape class BODYMOVIN_EXPORT BMFreeFormShape : public BMShape
{ {
public: public:
BMFreeFormShape(); BMFreeFormShape(BMBase *parent);
explicit BMFreeFormShape(const BMFreeFormShape &other); BMFreeFormShape(BMBase *parent, const BMFreeFormShape &other);
BMFreeFormShape(const QJsonObject &definition, BMBase *parent = nullptr); BMFreeFormShape(BMBase *parent, const QJsonObject &definition);
BMBase *clone() const override; BMBase *clone(BMBase *parent) const override;
void construct(const QJsonObject &definition); void parse(const QJsonObject &definition);
void updateProperties(int frame) override; void updateProperties(int frame) override;
void render(LottieRenderer &renderer, int frame) const override; void render(LottieRenderer &renderer, int frame) const override;

View File

@ -54,12 +54,12 @@ QT_BEGIN_NAMESPACE
class BODYMOVIN_EXPORT BMGFill : public BMShape class BODYMOVIN_EXPORT BMGFill : public BMShape
{ {
public: public:
BMGFill() = default; BMGFill(BMBase *parent);
explicit BMGFill(const BMGFill &other); BMGFill(BMBase *parent, const BMGFill &other);
BMGFill(const QJsonObject &definition, BMBase *parent = nullptr); BMGFill(BMBase *parent, const QJsonObject &definition);
~BMGFill() override; ~BMGFill() override;
BMBase *clone() const override; BMBase *clone(BMBase *parent) const override;
void updateProperties(int frame) override; void updateProperties(int frame) override;
void render(LottieRenderer &renderer, int frame) const override; void render(LottieRenderer &renderer, int frame) const override;

View File

@ -57,12 +57,13 @@ class BMPathTrimmer;
class BODYMOVIN_EXPORT BMGroup : public BMShape class BODYMOVIN_EXPORT BMGroup : public BMShape
{ {
public: public:
BMGroup() = default; BMGroup(BMBase *parent);
BMGroup(const QJsonObject &definition, BMBase *parent = nullptr); BMGroup(BMBase *parent, const BMGroup &other);
BMGroup(BMBase *parent, const QJsonObject &definition);
BMBase *clone() const override; BMBase *clone(BMBase *parent) const override;
void construct(const QJsonObject& definition); void parse(const QJsonObject& definition);
void updateProperties(int frame) override; void updateProperties(int frame) override;
void render(LottieRenderer &renderer, int frame) const override; void render(LottieRenderer &renderer, int frame) const override;

View File

@ -42,6 +42,7 @@
// //
#include <QtBodymovin/private/bmbase_p.h> #include <QtBodymovin/private/bmbase_p.h>
#include <QtBodymovin/private/bmbasictransform_p.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -53,15 +54,15 @@ class BODYMOVIN_EXPORT BMLayer : public BMBase
public: public:
enum MatteClipMode {NoClip, Alpha, InvertedAlpha, Luminence, InvertedLuminence}; enum MatteClipMode {NoClip, Alpha, InvertedAlpha, Luminence, InvertedLuminence};
BMLayer() = default; BMLayer(BMBase *parent);
explicit BMLayer (const BMLayer &other); BMLayer(BMBase *parent, const BMLayer &other);
~BMLayer() override; ~BMLayer() override;
static BMLayer *construct(QJsonObject definition); static BMLayer *construct(BMBase *parent, QJsonObject definition);
bool active(int frame) const override; bool active(int frame) const override;
void parse(const QJsonObject &definition) override; void parse(const QJsonObject &definition) override;
void updateProperties(int frame) override; void updateProperties(int frame) override;
@ -72,7 +73,6 @@ public:
MatteClipMode clipMode() const; MatteClipMode clipMode() const;
int layerId() const; int layerId() const;
BMBasicTransform *transform() const;
void renderFullTransform(LottieRenderer &renderer, int frame) const; void renderFullTransform(LottieRenderer &renderer, int frame) const;
protected: protected:
@ -89,7 +89,7 @@ protected:
bool m_3dLayer = false; bool m_3dLayer = false;
BMBase *m_effects = nullptr; BMBase *m_effects = nullptr;
qreal m_stretch; qreal m_stretch;
BMBasicTransform *m_layerTransform = nullptr; BMBasicTransform m_layerTransform;
BMMasks *m_masks = nullptr; BMMasks *m_masks = nullptr;
int m_parentLayer = 0; int m_parentLayer = 0;

View File

@ -56,7 +56,9 @@ class QJsonObject;
class BODYMOVIN_EXPORT BMMasks : public BMBase class BODYMOVIN_EXPORT BMMasks : public BMBase
{ {
public: public:
BMBase *clone() const override; BMMasks(BMBase *parent);
BMMasks(BMBase *parent, const BMMasks &other);
BMBase *clone(BMBase *parent) const override;
void render(LottieRenderer &renderer, int frame) const override; void render(LottieRenderer &renderer, int frame) const override;

View File

@ -56,13 +56,13 @@ class QJsonObject;
class BODYMOVIN_EXPORT BMMaskShape : public BMShape class BODYMOVIN_EXPORT BMMaskShape : public BMShape
{ {
public: public:
BMMaskShape(); BMMaskShape(BMBase *parent);
explicit BMMaskShape(const BMMaskShape &other); BMMaskShape(BMBase *parent, const BMMaskShape &other);
BMMaskShape(const QJsonObject &definition, BMBase *parent = nullptr); BMMaskShape(BMBase *parent, const QJsonObject &definition);
BMBase *clone() const override; BMBase *clone(BMBase *parent) const override;
void construct(const QJsonObject &definition); void parse(const QJsonObject &definition);
void updateProperties(int frame) override; void updateProperties(int frame) override;
void render(LottieRenderer &renderer, int frame) const override; void render(LottieRenderer &renderer, int frame) const override;

View File

@ -55,12 +55,12 @@ class BMBasicTransform;
class BODYMOVIN_EXPORT BMNullLayer final : public BMLayer class BODYMOVIN_EXPORT BMNullLayer final : public BMLayer
{ {
public: public:
BMNullLayer() = default; BMNullLayer(BMBase *parent);
explicit BMNullLayer(const BMNullLayer &other); BMNullLayer(BMBase *parent, const BMNullLayer &other);
BMNullLayer(const QJsonObject &definition); BMNullLayer(BMBase *parent, const QJsonObject &definition);
~BMNullLayer() override; ~BMNullLayer() override;
BMBase *clone() const override; BMBase *clone(BMBase *parent) const override;
void render(LottieRenderer &render, int frame) const override; void render(LottieRenderer &render, int frame) const override;

View File

@ -50,12 +50,12 @@ class LottieRenderer;
class BODYMOVIN_EXPORT BMPreCompAsset : public BMAsset class BODYMOVIN_EXPORT BMPreCompAsset : public BMAsset
{ {
public: public:
BMPreCompAsset() = default; BMPreCompAsset(BMBase *parent);
explicit BMPreCompAsset (const BMPreCompAsset &other) = default; BMPreCompAsset(BMBase *parent, const BMPreCompAsset &other);
BMPreCompAsset(const QJsonObject &definition); BMPreCompAsset(BMBase *parent, const QJsonObject &definition);
~BMPreCompAsset() = default; ~BMPreCompAsset() = default;
BMPreCompAsset *clone() const override; BMPreCompAsset *clone(BMBase *parent) const override;
}; };
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -55,16 +55,16 @@ class BMBasicTransform;
class BODYMOVIN_EXPORT BMPreCompLayer final : public BMLayer class BODYMOVIN_EXPORT BMPreCompLayer final : public BMLayer
{ {
public: public:
BMPreCompLayer() = default; BMPreCompLayer(BMBase *parent);
explicit BMPreCompLayer(const BMPreCompLayer &other); BMPreCompLayer(BMBase *parent, const BMPreCompLayer &other);
BMPreCompLayer(const QJsonObject &definition); BMPreCompLayer(BMBase *parent, const QJsonObject &definition);
~BMPreCompLayer() override; ~BMPreCompLayer() override;
BMBase *clone() const override; BMBase *clone(BMBase *parent) const override;
void updateProperties(int frame) override; void updateProperties(int frame) override;
void render(LottieRenderer &renderer, int frame) const override; void render(LottieRenderer &renderer, int frame) const override;
void resolveAssets(const std::function<BMAsset*(QString)> &resolver) override; void resolveAssets(const std::function<BMAsset*(BMBase*, QString)> &resolver) override;
QString refId() const; QString refId() const;

View File

@ -51,7 +51,6 @@
#include <QDebug> #include <QDebug>
#include <QtBodymovin/private/bmconstants_p.h> #include <QtBodymovin/private/bmconstants_p.h>
#include <QtBodymovin/private/bmlayer_p.h>
#include <QtBodymovin/private/beziereasing_p.h> #include <QtBodymovin/private/beziereasing_p.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE

View File

@ -57,13 +57,11 @@ QT_BEGIN_NAMESPACE
class BODYMOVIN_EXPORT BMRect : public BMShape class BODYMOVIN_EXPORT BMRect : public BMShape
{ {
public: public:
BMRect() = default; BMRect(BMBase *parent);
explicit BMRect(const BMRect &other); BMRect(BMBase *parent, const BMRect &other);
BMRect(const QJsonObject &definition, BMBase *parent = nullptr); BMRect(BMBase *parent, const QJsonObject &definition);
BMBase *clone() const override; BMBase *clone(BMBase *parent) const override;
void construct(const QJsonObject &definition);
bool setProperty(BMLiteral::PropertyType propertyType, QVariant value) override; bool setProperty(BMLiteral::PropertyType propertyType, QVariant value) override;

View File

@ -53,13 +53,13 @@ class QJsonObject;
class BODYMOVIN_EXPORT BMRepeater : public BMShape class BODYMOVIN_EXPORT BMRepeater : public BMShape
{ {
public: public:
BMRepeater() = default; BMRepeater(BMBase *parent);
explicit BMRepeater(const BMRepeater &other); BMRepeater(BMBase *parent, const BMRepeater &other);
BMRepeater(const QJsonObject &definition, BMBase *parent = nullptr); BMRepeater(BMBase *parent, const QJsonObject &definition);
BMBase *clone() const override; BMBase *clone(BMBase *parent) const override;
void construct(const QJsonObject& definition); void parse(const QJsonObject& definition);
void updateProperties(int frame) override; void updateProperties(int frame) override;
void render(LottieRenderer &renderer, int frame) const override; void render(LottieRenderer &renderer, int frame) const override;

View File

@ -50,13 +50,13 @@ class QJsonObject;
class BODYMOVIN_EXPORT BMRepeaterTransform : public BMBasicTransform class BODYMOVIN_EXPORT BMRepeaterTransform : public BMBasicTransform
{ {
public: public:
BMRepeaterTransform() = default; BMRepeaterTransform(BMBase *parent);
explicit BMRepeaterTransform(const BMRepeaterTransform &other); BMRepeaterTransform(BMBase *parent, const BMRepeaterTransform &other);
BMRepeaterTransform(const QJsonObject &definition, BMBase *parent); BMRepeaterTransform(BMBase *parent, const QJsonObject &definition);
BMBase *clone() const override; BMBase *clone(BMBase *parent) const override;
void construct(const QJsonObject &definition); void parse(const QJsonObject &definition);
void updateProperties(int frame) override; void updateProperties(int frame) override;
void render(LottieRenderer &renderer, int frame) const override; void render(LottieRenderer &renderer, int frame) const override;

View File

@ -59,13 +59,13 @@ class QJsonObject;
class BODYMOVIN_EXPORT BMRound : public BMShape class BODYMOVIN_EXPORT BMRound : public BMShape
{ {
public: public:
BMRound() = default; BMRound(BMBase *parent);
explicit BMRound(const BMRound &other); BMRound(BMBase *parent, const BMRound &other);
BMRound(const QJsonObject &definition, BMBase *parent = nullptr); BMRound(BMBase *parent, const QJsonObject &definition);
BMBase *clone() const override; BMBase *clone(BMBase *parent) const override;
void construct(const QJsonObject &definition); void parse(const QJsonObject &definition);
void updateProperties(int frame) override; void updateProperties(int frame) override;
void render(LottieRenderer &renderer, int frame) const override; void render(LottieRenderer &renderer, int frame) const override;

View File

@ -56,13 +56,12 @@ class BMAsset;
class BODYMOVIN_EXPORT BMScene : public BMBase class BODYMOVIN_EXPORT BMScene : public BMBase
{ {
public: public:
BMScene();
BMScene(const BMScene &other) = delete; BMScene(const BMScene &other) = delete;
BMScene &operator=(const BMScene &other) = delete; BMScene &operator=(const BMScene &other) = delete;
explicit BMScene(const QJsonObject &definition); explicit BMScene(const QJsonObject &definition);
virtual ~BMScene(); virtual ~BMScene();
BMBase *clone() const override; BMBase *clone(BMBase *parent) const override;
void updateProperties(int frame) override; void updateProperties(int frame) override;
void render(LottieRenderer &renderer, int frame) const override; void render(LottieRenderer &renderer, int frame) const override;

View File

@ -70,12 +70,12 @@ class BMTrimPath;
class BODYMOVIN_EXPORT BMShape : public BMBase class BODYMOVIN_EXPORT BMShape : public BMBase
{ {
public: public:
BMShape() = default; BMShape(BMBase *parent);
explicit BMShape(const BMShape &other); BMShape(BMBase *parent, const BMShape &other);
BMBase *clone() const override; BMBase *clone(BMBase *parent) const override;
static BMShape *construct(QJsonObject definition, BMBase *parent = nullptr); static BMShape *construct(BMBase *parent, QJsonObject definition);
virtual const QPainterPath &path() const; virtual const QPainterPath &path() const;
virtual bool acceptsTrim() const; virtual bool acceptsTrim() const;

View File

@ -55,12 +55,12 @@ class BMBasicTransform;
class BODYMOVIN_EXPORT BMShapeLayer final : public BMLayer class BODYMOVIN_EXPORT BMShapeLayer final : public BMLayer
{ {
public: public:
BMShapeLayer() = default; BMShapeLayer(BMBase *parent);
explicit BMShapeLayer(const BMShapeLayer &other); BMShapeLayer(BMBase *parent, const BMShapeLayer &other);
BMShapeLayer(const QJsonObject &definition); BMShapeLayer(BMBase *parent, const QJsonObject &definition);
~BMShapeLayer() override; ~BMShapeLayer() override;
BMBase *clone() const override; BMBase *clone(BMBase *parent) const override;
void updateProperties(int frame) override; void updateProperties(int frame) override;
void render(LottieRenderer &render, int frame) const override; void render(LottieRenderer &render, int frame) const override;

View File

@ -54,12 +54,13 @@ class QJsonObject;
class BODYMOVIN_EXPORT BMShapeTransform : public BMBasicTransform class BODYMOVIN_EXPORT BMShapeTransform : public BMBasicTransform
{ {
public: public:
explicit BMShapeTransform(const BMShapeTransform &other); BMShapeTransform(BMBase *parent);
BMShapeTransform(const QJsonObject &definition, BMBase *parent); BMShapeTransform(BMBase *parent, const BMShapeTransform &other);
BMShapeTransform(BMBase *parent, const QJsonObject &definition);
BMBase *clone() const override; BMBase *clone(BMBase *parent) const override;
void construct(const QJsonObject &definition); void parse(const QJsonObject &definition);
void updateProperties(int frame) override; void updateProperties(int frame) override;
void render(LottieRenderer &renderer, int frame) const override; void render(LottieRenderer &renderer, int frame) const override;

View File

@ -52,11 +52,11 @@ QT_BEGIN_NAMESPACE
class BODYMOVIN_EXPORT BMStroke : public BMShape class BODYMOVIN_EXPORT BMStroke : public BMShape
{ {
public: public:
BMStroke() = default; BMStroke(BMBase *parent);
explicit BMStroke(const BMStroke &other); BMStroke(BMBase *parent, const BMStroke &other);
BMStroke(const QJsonObject &definition, BMBase *parent = nullptr); BMStroke(BMBase *parent, const QJsonObject &definition);
BMBase *clone() const override; BMBase *clone(BMBase *parent) const override;
void updateProperties(int frame) override; void updateProperties(int frame) override;
void render(LottieRenderer &renderer, int frame) const override; void render(LottieRenderer &renderer, int frame) const override;

View File

@ -52,15 +52,15 @@ QT_BEGIN_NAMESPACE
class BODYMOVIN_EXPORT BMTrimPath : public BMShape class BODYMOVIN_EXPORT BMTrimPath : public BMShape
{ {
public: public:
BMTrimPath(); BMTrimPath(BMBase *parent);
BMTrimPath(const QJsonObject &definition, BMBase *parent = nullptr); BMTrimPath(BMBase *parent, const BMTrimPath &other);
explicit BMTrimPath(const BMTrimPath &other); BMTrimPath(BMBase *parent, const QJsonObject &definition);
void inherit(const BMTrimPath &other); void inherit(const BMTrimPath &other);
BMBase *clone() const override; BMBase *clone(BMBase *parent) const override;
void construct(const QJsonObject &definition); void parse(const QJsonObject &definition);
void updateProperties(int frame) override; void updateProperties(int frame) override;
void render(LottieRenderer &renderer, int frame) const override; void render(LottieRenderer &renderer, int frame) const override;