diff options
author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2024-01-22 22:42:23 +0200 |
---|---|---|
committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2024-02-20 15:17:31 +0000 |
commit | 1b0fd864e4d16fa977e73d668e8c66242507d6d7 (patch) | |
tree | c47dba4b730fb7fdd5ce43861418ef1f5bdec15b | |
parent | a26e9841a45a564da8bd89c33030658f99a5487d (diff) | |
parent | 73ce0c571a0ad11fdffe76a464fc25a90b67acc1 (diff) |
Merge remote-tracking branch 'origin/tqtc/lts-6.2.8' into tqtc/lts-6.2-opensource
Conflicts solved in a file:
dependencies.yaml
Change-Id: I0929147f52102f0beb38dcf7424ceea225ced769
60 files changed, 447 insertions, 173 deletions
diff --git a/.cmake.conf b/.cmake.conf index 07d90b8..e62fae5 100644 --- a/.cmake.conf +++ b/.cmake.conf @@ -1,2 +1,2 @@ -set(QT_REPO_MODULE_VERSION "6.2.7") +set(QT_REPO_MODULE_VERSION "6.2.8") set(QT_REPO_MODULE_PRERELEASE_VERSION_SEGMENT "") diff --git a/.qmake.conf b/.qmake.conf index 0f7f82c..a33722e 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -3,4 +3,4 @@ CONFIG += warning_clean DEFINES += QT_NO_FOREACH QT_NO_JAVA_STYLE_ITERATORS -MODULE_VERSION = 6.2.7 +MODULE_VERSION = 6.2.8 diff --git a/dependencies.yaml b/dependencies.yaml index 0cc657f..31b554e 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -1,7 +1,7 @@ dependencies: ../tqtc-qtbase: - ref: 694575a59b5370afc494fbf700eee8db1d1ec091 + ref: 67934c103800bae50c2ec1977758d40fa8e4e507 required: true ../tqtc-qtdeclarative: - ref: 02277e3753613d9e19bbb36367c7d2b1d13d7545 + ref: 302ab20d46280e11042f3896460c55d8b8146e41 required: true diff --git a/src/bodymovin/bmbase_p.h b/src/bodymovin/bmbase_p.h index 90818dc..04458f6 100644 --- a/src/bodymovin/bmbase_p.h +++ b/src/bodymovin/bmbase_p.h @@ -43,6 +43,7 @@ #include <QJsonObject> #include <QList> +#include <QVersionNumber> #include <QtBodymovin/bmglobal.h> #include <QtBodymovin/private/bmconstants_p.h> @@ -50,7 +51,6 @@ #include <QtBodymovin/private/lottierenderer_p.h> QT_BEGIN_NAMESPACE - class BODYMOVIN_EXPORT BMBase { public: @@ -95,6 +95,7 @@ protected: QJsonObject m_definition; int m_type; bool m_hidden = false; + QVersionNumber m_version; QString m_name; QString m_matchName; bool m_autoOrient = false; diff --git a/src/bodymovin/bmbasictransform.cpp b/src/bodymovin/bmbasictransform.cpp index 1f30b0a..3c0bf49 100644 --- a/src/bodymovin/bmbasictransform.cpp +++ b/src/bodymovin/bmbasictransform.cpp @@ -49,10 +49,11 @@ BMBasicTransform::BMBasicTransform(const BMBasicTransform &other) m_opacity = other.m_opacity; } -BMBasicTransform::BMBasicTransform(const QJsonObject &definition, BMBase *parent) +BMBasicTransform::BMBasicTransform(const QJsonObject &definition, const QVersionNumber &version, + BMBase *parent) { setParent(parent); - construct(definition); + construct(definition, version); } BMBase *BMBasicTransform::clone() const @@ -60,7 +61,7 @@ BMBase *BMBasicTransform::clone() const return new BMBasicTransform(*this); } -void BMBasicTransform::construct(const QJsonObject &definition) +void BMBasicTransform::construct(const QJsonObject &definition, const QVersionNumber &version) { BMBase::parse(definition); @@ -69,38 +70,38 @@ void BMBasicTransform::construct(const QJsonObject &definition) QJsonObject anchors = definition.value(QLatin1String("a")).toObject(); anchors = resolveExpression(anchors); - m_anchorPoint.construct(anchors); + m_anchorPoint.construct(anchors, version); if (definition.value(QLatin1String("p")).toObject().contains(QLatin1String("s"))) { QJsonObject posX = definition.value(QLatin1String("p")).toObject().value(QLatin1String("x")).toObject(); posX = resolveExpression(posX); - m_xPos.construct(posX); + m_xPos.construct(posX, version); QJsonObject posY = definition.value(QLatin1String("p")).toObject().value(QLatin1String("y")).toObject(); posY = resolveExpression(posY); - m_yPos.construct(posY); + m_yPos.construct(posY, version); m_splitPosition = true; } else { QJsonObject position = definition.value(QLatin1String("p")).toObject(); position = resolveExpression(position); - m_position.construct(position); + m_position.construct(position, version); } QJsonObject scale = definition.value(QLatin1String("s")).toObject(); scale = resolveExpression(scale); - m_scale.construct(scale); + m_scale.construct(scale, version); QJsonObject rotation = definition.value(QLatin1String("r")).toObject(); rotation = resolveExpression(rotation); - m_rotation.construct(rotation); + m_rotation.construct(rotation, version); // If this is the base class for BMRepeaterTransform, // opacity is not present if (definition.contains(QLatin1String("o"))) { QJsonObject opacity = definition.value(QLatin1String("o")).toObject(); opacity = resolveExpression(opacity); - m_opacity.construct(opacity); + m_opacity.construct(opacity, version); } } diff --git a/src/bodymovin/bmbasictransform_p.h b/src/bodymovin/bmbasictransform_p.h index a42e646..53818a3 100644 --- a/src/bodymovin/bmbasictransform_p.h +++ b/src/bodymovin/bmbasictransform_p.h @@ -56,11 +56,12 @@ class BODYMOVIN_EXPORT BMBasicTransform : public BMShape public: BMBasicTransform() = default; explicit BMBasicTransform(const BMBasicTransform &other); - BMBasicTransform(const QJsonObject &definition, BMBase *parent = nullptr); + BMBasicTransform(const QJsonObject &definition, const QVersionNumber &version, + BMBase *parent = nullptr); BMBase *clone() const override; - void construct(const QJsonObject &definition); + void construct(const QJsonObject &definition, const QVersionNumber &version); void updateProperties(int frame) override; void render(LottieRenderer &renderer) const override; diff --git a/src/bodymovin/bmellipse.cpp b/src/bodymovin/bmellipse.cpp index f550f43..ef39f8b 100644 --- a/src/bodymovin/bmellipse.cpp +++ b/src/bodymovin/bmellipse.cpp @@ -43,10 +43,10 @@ BMEllipse::BMEllipse(const BMEllipse &other) m_size = other.m_size; } -BMEllipse::BMEllipse(const QJsonObject &definition, BMBase *parent) +BMEllipse::BMEllipse(const QJsonObject &definition, const QVersionNumber &version, BMBase *parent) { setParent(parent); - construct(definition); + construct(definition, version); } BMBase *BMEllipse::clone() const @@ -54,8 +54,7 @@ BMBase *BMEllipse::clone() const return new BMEllipse(*this); } - -void BMEllipse::construct(const QJsonObject &definition) +void BMEllipse::construct(const QJsonObject &definition, const QVersionNumber &version) { BMBase::parse(definition); if (m_hidden) @@ -65,11 +64,11 @@ void BMEllipse::construct(const QJsonObject &definition) QJsonObject position = definition.value(QLatin1String("p")).toObject(); position = resolveExpression(position); - m_position.construct(position); + m_position.construct(position, version); QJsonObject size = definition.value(QLatin1String("s")).toObject(); size = resolveExpression(size); - m_size.construct(size); + m_size.construct(size, version); m_direction = definition.value(QLatin1String("d")).toInt(); } @@ -91,7 +90,7 @@ void BMEllipse::updateProperties(int frame) m_path = QPainterPath(); m_path.arcMoveTo(QRectF(pos, m_size.value()), 90); - m_path.arcTo(QRectF(pos, m_size.value()), 90, -360); + m_path.arcTo(QRectF(pos, m_size.value()), 90, 360); if (m_direction) m_path = m_path.toReversed(); diff --git a/src/bodymovin/bmellipse_p.h b/src/bodymovin/bmellipse_p.h index a3d8809..17b4ecc 100644 --- a/src/bodymovin/bmellipse_p.h +++ b/src/bodymovin/bmellipse_p.h @@ -62,11 +62,12 @@ class BODYMOVIN_EXPORT BMEllipse : public BMShape public: BMEllipse() = default; explicit BMEllipse(const BMEllipse &other); - BMEllipse(const QJsonObject &definition, BMBase *parent = nullptr); + BMEllipse(const QJsonObject &definition, const QVersionNumber &version, + BMBase *parent = nullptr); BMBase *clone() const override; - void construct(const QJsonObject &definition); + void construct(const QJsonObject &definition, const QVersionNumber &version); void updateProperties(int frame) override; void render(LottieRenderer &renderer) const override; diff --git a/src/bodymovin/bmfill.cpp b/src/bodymovin/bmfill.cpp index 76012b3..ad24fff 100644 --- a/src/bodymovin/bmfill.cpp +++ b/src/bodymovin/bmfill.cpp @@ -38,7 +38,7 @@ BMFill::BMFill(const BMFill &other) m_opacity = other.m_opacity; } -BMFill::BMFill(const QJsonObject &definition, BMBase *parent) +BMFill::BMFill(const QJsonObject &definition, const QVersionNumber &version, BMBase *parent) { setParent(parent); BMBase::parse(definition); @@ -48,11 +48,11 @@ BMFill::BMFill(const QJsonObject &definition, BMBase *parent) qCDebug(lcLottieQtBodymovinParser) << "BMFill::construct():" << m_name; QJsonObject color = definition.value(QLatin1String("c")).toObject(); - m_color.construct(color); + m_color.construct(color, version); QJsonObject opacity = definition.value(QLatin1String("o")).toObject(); opacity = resolveExpression(opacity); - m_opacity.construct(opacity); + m_opacity.construct(opacity, version); } BMBase *BMFill::clone() const diff --git a/src/bodymovin/bmfill_p.h b/src/bodymovin/bmfill_p.h index 060a2f0..0f0642f 100644 --- a/src/bodymovin/bmfill_p.h +++ b/src/bodymovin/bmfill_p.h @@ -54,7 +54,7 @@ class BODYMOVIN_EXPORT BMFill : public BMShape public: BMFill() = default; explicit BMFill(const BMFill &other); - BMFill(const QJsonObject &definition, BMBase *parent = nullptr); + BMFill(const QJsonObject &definition, const QVersionNumber &version, BMBase *parent = nullptr); BMBase *clone() const override; diff --git a/src/bodymovin/bmfilleffect.cpp b/src/bodymovin/bmfilleffect.cpp index 34e0e63..2d7ff86 100644 --- a/src/bodymovin/bmfilleffect.cpp +++ b/src/bodymovin/bmfilleffect.cpp @@ -48,7 +48,7 @@ BMBase *BMFillEffect::clone() const return new BMFillEffect(*this); } -void BMFillEffect::construct(const QJsonObject &definition) +void BMFillEffect::construct(const QJsonObject &definition, const QVersionNumber &version) { m_type = BM_EFFECT_FILL; @@ -59,8 +59,8 @@ void BMFillEffect::construct(const QJsonObject &definition) // TODO: Check are property positions really fixed in the effect? - m_color.construct(properties.at(2).toObject().value(QLatin1String("v")).toObject()); - m_opacity.construct(properties.at(6).toObject().value(QLatin1String("v")).toObject()); + m_color.construct(properties.at(2).toObject().value(QLatin1String("v")).toObject(), version); + m_opacity.construct(properties.at(6).toObject().value(QLatin1String("v")).toObject(), version); if (!qFuzzyCompare(properties.at(0).toObject().value(QLatin1String("v")).toObject().value(QLatin1String("k")).toDouble(), 0.0)) qCWarning(lcLottieQtBodymovinParser)<< "BMFillEffect: Property 'Fill mask' not supported"; @@ -75,8 +75,8 @@ void BMFillEffect::construct(const QJsonObject &definition) qCWarning(lcLottieQtBodymovinParser) << "BMFillEffect: Property 'Horizontal feather' not supported"; if (!qFuzzyCompare(properties.at(5).toObject().value(QLatin1String("v")).toObject().value(QLatin1String("k")).toDouble(), 0.0)) - qCWarning(lcLottieQtBodymovinParser) << "BMFillEffect: Property 'Vertical feather' not supported"; - + qCWarning(lcLottieQtBodymovinParser) + << "BMFillEffect: Property 'Vertical feather' not supported"; } void BMFillEffect::updateProperties(int frame) diff --git a/src/bodymovin/bmfilleffect_p.h b/src/bodymovin/bmfilleffect_p.h index 43888bb..e7cab8e 100644 --- a/src/bodymovin/bmfilleffect_p.h +++ b/src/bodymovin/bmfilleffect_p.h @@ -59,7 +59,7 @@ public: BMBase *clone() const override; - void construct(const QJsonObject &definition); + void construct(const QJsonObject &definition, const QVersionNumber &version); void updateProperties(int frame) override; void render(LottieRenderer &renderer) const override; diff --git a/src/bodymovin/bmfreeformshape.cpp b/src/bodymovin/bmfreeformshape.cpp index 07133e0..e51c47b 100644 --- a/src/bodymovin/bmfreeformshape.cpp +++ b/src/bodymovin/bmfreeformshape.cpp @@ -45,10 +45,11 @@ BMFreeFormShape::BMFreeFormShape(const BMFreeFormShape &other) m_vertexMap = other.m_vertexMap; } -BMFreeFormShape::BMFreeFormShape(const QJsonObject &definition, BMBase *parent) +BMFreeFormShape::BMFreeFormShape(const QJsonObject &definition, const QVersionNumber &version, + BMBase *parent) { setParent(parent); - construct(definition); + construct(definition, version); } BMBase *BMFreeFormShape::clone() const @@ -56,9 +57,10 @@ BMBase *BMFreeFormShape::clone() const return new BMFreeFormShape(*this); } -void BMFreeFormShape::construct(const QJsonObject &definition) +void BMFreeFormShape::construct(const QJsonObject &definition, const QVersionNumber &version) { BMBase::parse(definition); + m_version = version; if (m_hidden) return; @@ -315,9 +317,9 @@ void BMFreeFormShape::finalizeVertices() coObj.insert(QLatin1String("k"), m_vertexInfos.value(i)->coKeyframes); VertexInfo vertexInfo; - vertexInfo.pos.construct(posObj); - vertexInfo.ci.construct(ciObj); - vertexInfo.co.construct(coObj); + vertexInfo.pos.construct(posObj, m_version); + vertexInfo.ci.construct(ciObj, m_version); + vertexInfo.co.construct(coObj, m_version); m_vertexList.push_back(vertexInfo); } qDeleteAll(m_vertexInfos); diff --git a/src/bodymovin/bmfreeformshape_p.h b/src/bodymovin/bmfreeformshape_p.h index c27e0c6..400f802 100644 --- a/src/bodymovin/bmfreeformshape_p.h +++ b/src/bodymovin/bmfreeformshape_p.h @@ -58,11 +58,12 @@ class BODYMOVIN_EXPORT BMFreeFormShape : public BMShape public: BMFreeFormShape(); explicit BMFreeFormShape(const BMFreeFormShape &other); - BMFreeFormShape(const QJsonObject &definition, BMBase *parent = nullptr); + BMFreeFormShape(const QJsonObject &definition, const QVersionNumber &version, + BMBase *parent = nullptr); BMBase *clone() const override; - void construct(const QJsonObject &definition); + void construct(const QJsonObject &definition, const QVersionNumber &version); void updateProperties(int frame) override; void render(LottieRenderer &renderer) const override; diff --git a/src/bodymovin/bmgfill.cpp b/src/bodymovin/bmgfill.cpp index 569b204..7f2b272 100644 --- a/src/bodymovin/bmgfill.cpp +++ b/src/bodymovin/bmgfill.cpp @@ -68,7 +68,7 @@ BMBase *BMGFill::clone() const return new BMGFill(*this); } -BMGFill::BMGFill(const QJsonObject &definition, BMBase *parent) +BMGFill::BMGFill(const QJsonObject &definition, const QVersionNumber &version, BMBase *parent) { setParent(parent); @@ -108,22 +108,22 @@ BMGFill::BMGFill(const QJsonObject &definition, BMBase *parent) QJsonObject opacity = definition.value(QLatin1String("o")).toObject(); opacity = resolveExpression(opacity); - m_opacity.construct(opacity); + m_opacity.construct(opacity, version); QJsonObject startPoint = definition.value(QLatin1String("s")).toObject(); startPoint = resolveExpression(startPoint); - m_startPoint.construct(startPoint); + m_startPoint.construct(startPoint, version); QJsonObject endPoint = definition.value(QLatin1String("e")).toObject(); endPoint = resolveExpression(endPoint); - m_endPoint.construct(endPoint); + m_endPoint.construct(endPoint, version); QJsonObject highlight = definition.value(QLatin1String("h")).toObject(); - m_highlightLength.construct(highlight); + m_highlightLength.construct(highlight, version); QJsonObject angle = definition.value(QLatin1String("a")).toObject(); angle = resolveExpression(angle); - m_highlightAngle.construct(angle); + m_highlightAngle.construct(angle, version); m_highlightAngle.setValue(0.0); } diff --git a/src/bodymovin/bmgfill_p.h b/src/bodymovin/bmgfill_p.h index 87fa0f5..86ba007 100644 --- a/src/bodymovin/bmgfill_p.h +++ b/src/bodymovin/bmgfill_p.h @@ -56,7 +56,7 @@ class BODYMOVIN_EXPORT BMGFill : public BMShape public: BMGFill() = default; explicit BMGFill(const BMGFill &other); - BMGFill(const QJsonObject &definition, BMBase *parent = nullptr); + BMGFill(const QJsonObject &definition, const QVersionNumber &version, BMBase *parent = nullptr); ~BMGFill() override; BMBase *clone() const override; diff --git a/src/bodymovin/bmgroup.cpp b/src/bodymovin/bmgroup.cpp index ed13f8c..e1fc587 100644 --- a/src/bodymovin/bmgroup.cpp +++ b/src/bodymovin/bmgroup.cpp @@ -39,10 +39,10 @@ QT_BEGIN_NAMESPACE -BMGroup::BMGroup(const QJsonObject &definition, BMBase *parent) +BMGroup::BMGroup(const QJsonObject &definition, const QVersionNumber &version, BMBase *parent) { setParent(parent); - construct(definition); + construct(definition, version); } BMBase *BMGroup::clone() const @@ -50,7 +50,7 @@ BMBase *BMGroup::clone() const return new BMGroup(*this); } -void BMGroup::construct(const QJsonObject &definition) +void BMGroup::construct(const QJsonObject &definition, const QVersionNumber &version) { BMBase::parse(definition); if (m_hidden) @@ -63,7 +63,7 @@ void BMGroup::construct(const QJsonObject &definition) QJsonArray::const_iterator itemIt = groupItems.constEnd(); while (itemIt != groupItems.constBegin()) { itemIt--; - BMShape *shape = BMShape::construct((*itemIt).toObject(), this); + BMShape *shape = BMShape::construct((*itemIt).toObject(), version, this); if (shape) { // Transform affects how group contents are drawn. // It must be traversed first when drawing diff --git a/src/bodymovin/bmgroup_p.h b/src/bodymovin/bmgroup_p.h index 1683a1d..fe8a2b3 100644 --- a/src/bodymovin/bmgroup_p.h +++ b/src/bodymovin/bmgroup_p.h @@ -58,11 +58,11 @@ class BODYMOVIN_EXPORT BMGroup : public BMShape { public: BMGroup() = default; - BMGroup(const QJsonObject &definition, BMBase *parent = nullptr); + BMGroup(const QJsonObject &definition, const QVersionNumber &version, BMBase *parent = nullptr); BMBase *clone() const override; - void construct(const QJsonObject& definition); + void construct(const QJsonObject &definition, const QVersionNumber &version); void updateProperties(int frame) override; void render(LottieRenderer &renderer) const override; diff --git a/src/bodymovin/bmimage.cpp b/src/bodymovin/bmimage.cpp index 8035edf..1a9259e 100644 --- a/src/bodymovin/bmimage.cpp +++ b/src/bodymovin/bmimage.cpp @@ -45,10 +45,10 @@ BMImage::BMImage(const BMImage &other) m_image = other.m_image; } -BMImage::BMImage(const QJsonObject &definition, BMBase *parent) +BMImage::BMImage(const QJsonObject &definition, const QVersionNumber &version, BMBase *parent) { setParent(parent); - construct(definition); + construct(definition, version); } BMBase *BMImage::clone() const @@ -56,7 +56,7 @@ BMBase *BMImage::clone() const return new BMImage(*this); } -void BMImage::construct(const QJsonObject &definition) +void BMImage::construct(const QJsonObject &definition, const QVersionNumber &version) { BMBase::parse(definition); if (m_hidden) @@ -86,11 +86,11 @@ void BMImage::construct(const QJsonObject &definition) QJsonObject position = definition.value(QLatin1String("p")).toObject(); position = resolveExpression(position); - m_position.construct(position); + m_position.construct(position, version); QJsonObject radius = definition.value(QLatin1String("r")).toObject(); radius = resolveExpression(radius); - m_radius.construct(radius); + m_radius.construct(radius, version); } void BMImage::updateProperties(int frame) diff --git a/src/bodymovin/bmimage_p.h b/src/bodymovin/bmimage_p.h index 2b988df..94fdead 100644 --- a/src/bodymovin/bmimage_p.h +++ b/src/bodymovin/bmimage_p.h @@ -56,11 +56,11 @@ class BODYMOVIN_EXPORT BMImage : public BMBase public: BMImage() = default; explicit BMImage(const BMImage &other); - BMImage(const QJsonObject &definition, BMBase *parent = nullptr); + BMImage(const QJsonObject &definition, const QVersionNumber &version, BMBase *parent = nullptr); BMBase *clone() const override; - void construct(const QJsonObject &definition); + void construct(const QJsonObject &definition, const QVersionNumber &version); void updateProperties(int frame) override; void render(LottieRenderer &renderer) const override; diff --git a/src/bodymovin/bmimagelayer.cpp b/src/bodymovin/bmimagelayer.cpp index f228d1c..7ddf5ea 100644 --- a/src/bodymovin/bmimagelayer.cpp +++ b/src/bodymovin/bmimagelayer.cpp @@ -50,13 +50,14 @@ BMImageLayer::BMImageLayer(const BMImageLayer &other) m_appliedTrim = other.m_appliedTrim; } -BMImageLayer::BMImageLayer(const QJsonObject &definition) +BMImageLayer::BMImageLayer(const QJsonObject &definition, const QVersionNumber &version) { m_type = BM_LAYER_IMAGE_IX; + m_version = version; BMLayer::parse(definition); - BMImage *image = new BMImage(definition, this); + BMImage *image = new BMImage(definition, version, this); appendChild(image); if (m_hidden) @@ -73,13 +74,13 @@ BMImageLayer::BMImageLayer(const QJsonObject &definition) } QJsonObject trans = definition.value(QLatin1String("ks")).toObject(); - m_layerTransform = new BMBasicTransform(trans, this); + m_layerTransform = new BMBasicTransform(trans, version, this); QJsonArray items = definition.value(QLatin1String("shapes")).toArray(); QJsonArray::const_iterator itemIt = items.constEnd(); while (itemIt != items.constBegin()) { itemIt--; - BMShape *shape = BMShape::construct((*itemIt).toObject(), this); + BMShape *shape = BMShape::construct((*itemIt).toObject(), version, this); if (shape) appendChild(shape); } diff --git a/src/bodymovin/bmimagelayer_p.h b/src/bodymovin/bmimagelayer_p.h index f7a4fd5..11380d0 100644 --- a/src/bodymovin/bmimagelayer_p.h +++ b/src/bodymovin/bmimagelayer_p.h @@ -57,7 +57,7 @@ class BODYMOVIN_EXPORT BMImageLayer : public BMLayer public: BMImageLayer() = default; explicit BMImageLayer(const BMImageLayer &other); - BMImageLayer(const QJsonObject &definition); + BMImageLayer(const QJsonObject &definition, const QVersionNumber &version); ~BMImageLayer() override; BMBase *clone() const override; diff --git a/src/bodymovin/bmlayer.cpp b/src/bodymovin/bmlayer.cpp index 12878b0..0238e66 100644 --- a/src/bodymovin/bmlayer.cpp +++ b/src/bodymovin/bmlayer.cpp @@ -73,7 +73,7 @@ BMBase *BMLayer::clone() const return new BMLayer(*this); } -BMLayer *BMLayer::construct(QJsonObject definition) +BMLayer *BMLayer::construct(QJsonObject definition, const QVersionNumber &version) { qCDebug(lcLottieQtBodymovinParser) << "BMLayer::construct()"; @@ -82,11 +82,11 @@ BMLayer *BMLayer::construct(QJsonObject definition) switch (type) { case 2: qCDebug(lcLottieQtBodymovinParser) << "Parse image layer"; - layer = new BMImageLayer(definition); + layer = new BMImageLayer(definition, version); break; case 4: qCDebug(lcLottieQtBodymovinParser) << "Parse shape layer"; - layer = new BMShapeLayer(definition); + layer = new BMShapeLayer(definition, version); break; default: qCWarning(lcLottieQtBodymovinParser) << "Unsupported layer type:" << type; @@ -270,7 +270,7 @@ void BMLayer::parseEffects(const QJsonArray &definition, BMBase *effectRoot) case 21: { BMFillEffect *fill = new BMFillEffect; - fill->construct(effect); + fill->construct(effect, m_version); effectRoot->appendChild(fill); break; } diff --git a/src/bodymovin/bmlayer_p.h b/src/bodymovin/bmlayer_p.h index 6f6515f..7ed8620 100644 --- a/src/bodymovin/bmlayer_p.h +++ b/src/bodymovin/bmlayer_p.h @@ -58,11 +58,11 @@ public: BMBase *clone() const override; - static BMLayer *construct(QJsonObject definition); + static BMLayer *construct(QJsonObject definition, const QVersionNumber &version); bool active(int frame) const override; - void parse(const QJsonObject &definition) override; + void parse(const QJsonObject &definition) override; void updateProperties(int frame) override; void render(LottieRenderer &renderer) const override; diff --git a/src/bodymovin/bmproperty_p.h b/src/bodymovin/bmproperty_p.h index 106fe4f..d1f3127 100644 --- a/src/bodymovin/bmproperty_p.h +++ b/src/bodymovin/bmproperty_p.h @@ -75,7 +75,7 @@ class BODYMOVIN_EXPORT BMProperty public: virtual ~BMProperty() = default; - virtual void construct(const QJsonObject &definition) + virtual void construct(const QJsonObject &definition, const QVersionNumber &version) { if (definition.value(QLatin1String("s")).toVariant().toInt()) qCWarning(lcLottieQtBodymovinParser) @@ -86,11 +86,25 @@ public: if (m_animated) { QJsonArray keyframes = definition.value(QLatin1String("k")).toArray(); QJsonArray::const_iterator it = keyframes.constBegin(); - while (it != keyframes.constEnd()) { - EasingSegment<T> easing = parseKeyframe((*it).toObject(), - fromExpression); - addEasing(easing); - ++it; + + bool schemaChanged = (version >= QVersionNumber(5, 5, 0)); + + if (!schemaChanged) { + while (it != keyframes.constEnd()) { + EasingSegment<T> easing = parseKeyframe((*it).toObject(), fromExpression); + addEasing(easing); + ++it; + } + } else { + while (it != (keyframes.constEnd() - 1)) { + EasingSegment<T> easing = + parseKeyframe((*it).toObject(), (*(it + 1)).toObject(), fromExpression); + addEasing(easing); + ++it; + } + int lastFrame = (*it).toObject().value(QLatin1String("t")).toVariant().toInt(); + m_easingCurves.last().endFrame = lastFrame; + this->m_endFrame = lastFrame; } m_value = T(); } else @@ -164,8 +178,7 @@ protected: return m_currentEasing; } - virtual EasingSegment<T> parseKeyframe(const QJsonObject keyframe, - bool fromExpression) + virtual EasingSegment<T> parseKeyframe(const QJsonObject keyframe, bool fromExpression) { Q_UNUSED(fromExpression); @@ -214,6 +227,41 @@ protected: return easing; } + virtual EasingSegment<T> parseKeyframe(const QJsonObject keyframe, + const QJsonObject nextKeyframe, bool fromExpression) + { + Q_UNUSED(fromExpression); + + EasingSegment<T> easing; + + int startTime = keyframe.value(QLatin1String("t")).toVariant().toInt(); + + if (m_startFrame > startTime) + m_startFrame = startTime; + + easing.startValue = getValue(keyframe.value(QLatin1String("s")).toArray()); + easing.endValue = getValue(nextKeyframe.value(QLatin1String("s")).toArray()); + easing.startFrame = startTime; + + QJsonObject easingIn = keyframe.value(QLatin1String("i")).toObject(); + QJsonObject easingOut = keyframe.value(QLatin1String("o")).toObject(); + + qreal eix = easingIn.value(QLatin1String("x")).toArray().at(0).toDouble(); + qreal eiy = easingIn.value(QLatin1String("y")).toArray().at(0).toDouble(); + + qreal eox = easingOut.value(QLatin1String("x")).toArray().at(0).toDouble(); + qreal eoy = easingOut.value(QLatin1String("y")).toArray().at(0).toDouble(); + + QPointF c1 = QPointF(eox, eoy); + QPointF c2 = QPointF(eix, eiy); + + easing.easing.addCubicBezierSegment(c1, c2, QPointF(1.0, 1.0)); + + easing.complete = true; + + return easing; + } + virtual T getValue(const QJsonValue &value) { if (value.isArray()) @@ -263,8 +311,7 @@ protected: return T(); } - EasingSegment<T> parseKeyframe(const QJsonObject keyframe, - bool fromExpression) override + EasingSegment<T> parseKeyframe(const QJsonObject keyframe, bool fromExpression) override { QJsonArray startValues = keyframe.value(QLatin1String("s")).toArray(); QJsonArray endValues = keyframe.value(QLatin1String("e")).toArray(); @@ -326,6 +373,79 @@ protected: qreal eix = eixArr.takeAt(0).toDouble(); qreal eiy = eiyArr.takeAt(0).toDouble(); + qreal eox = eoxArr.takeAt(0).toDouble(); + qreal eoy = eoyArr.takeAt(0).toDouble(); + + QPointF c1 = QPointF(eox, eoy); + QPointF c2 = QPointF(eix, eiy); + + easingCurve.easing.addCubicBezierSegment(c1, c2, QPointF(1.0, 1.0)); + } + } else { + qreal eix = easingIn.value(QLatin1String("x")).toDouble(); + qreal eiy = easingIn.value(QLatin1String("y")).toDouble(); + + qreal eox = easingOut.value(QLatin1String("x")).toDouble(); + qreal eoy = easingOut.value(QLatin1String("y")).toDouble(); + + QPointF c1 = QPointF(eox, eoy); + QPointF c2 = QPointF(eix, eiy); + + easingCurve.easing.addCubicBezierSegment(c1, c2, QPointF(1.0, 1.0)); + } + + easingCurve.complete = true; + return easingCurve; + } + + EasingSegment<T> parseKeyframe(const QJsonObject keyframe, const QJsonObject nextKeyframe, + bool fromExpression) override + { + QJsonArray startValues = keyframe.value(QLatin1String("s")).toArray(); + QJsonArray endValues = nextKeyframe.value(QLatin1String("s")).toArray(); + int startTime = keyframe.value(QLatin1String("t")).toVariant().toInt(); + + EasingSegment<T> easingCurve; + easingCurve.startFrame = startTime; + + if (this->m_startFrame > startTime) + this->m_startFrame = startTime; + + qreal xs, ys, xe, ye; + // Keyframes originating from an expression use only scalar values. + // They must be expanded for both x and y coordinates + if (fromExpression) { + xs = startValues.at(0).toDouble(); + ys = startValues.at(0).toDouble(); + xe = endValues.at(0).toDouble(); + ye = endValues.at(0).toDouble(); + } else { + xs = startValues.at(0).toDouble(); + ys = startValues.at(1).toDouble(); + xe = endValues.at(0).toDouble(); + ye = endValues.at(1).toDouble(); + } + T s(xs, ys); + T e(xe, ye); + + QJsonObject easingIn = keyframe.value(QLatin1String("i")).toObject(); + QJsonObject easingOut = keyframe.value(QLatin1String("o")).toObject(); + + easingCurve.startFrame = startTime; + easingCurve.startValue = s; + easingCurve.endValue = e; + + if (easingIn.value(QLatin1String("x")).isArray()) { + QJsonArray eixArr = easingIn.value(QLatin1String("x")).toArray(); + QJsonArray eiyArr = easingIn.value(QLatin1String("y")).toArray(); + + QJsonArray eoxArr = easingOut.value(QLatin1String("x")).toArray(); + QJsonArray eoyArr = easingOut.value(QLatin1String("y")).toArray(); + + while (!eixArr.isEmpty() && !eiyArr.isEmpty()) { + qreal eix = eixArr.takeAt(0).toDouble(); + qreal eiy = eiyArr.takeAt(0).toDouble(); + qreal eox =eoxArr.takeAt(0).toDouble(); qreal eoy = eoyArr.takeAt(0).toDouble(); diff --git a/src/bodymovin/bmrect.cpp b/src/bodymovin/bmrect.cpp index 88909e1..a7d3c0d 100644 --- a/src/bodymovin/bmrect.cpp +++ b/src/bodymovin/bmrect.cpp @@ -47,7 +47,7 @@ BMRect::BMRect(const BMRect &other) m_roundness = other.m_roundness; } -BMRect::BMRect(const QJsonObject &definition, BMBase *parent) +BMRect::BMRect(const QJsonObject &definition, const QVersionNumber &version, BMBase *parent) { setParent(parent); BMBase::parse(definition); @@ -58,15 +58,15 @@ BMRect::BMRect(const QJsonObject &definition, BMBase *parent) QJsonObject position = definition.value(QLatin1String("p")).toObject(); position = resolveExpression(position); - m_position.construct(position); + m_position.construct(position, version); QJsonObject size = definition.value(QLatin1String("s")).toObject(); size = resolveExpression(size); - m_size.construct(size); + m_size.construct(size, version); QJsonObject roundness = definition.value(QLatin1String("r")).toObject(); roundness = resolveExpression(roundness); - m_roundness.construct(roundness); + m_roundness.construct(roundness, version); m_direction = definition.value(QLatin1String("d")).toInt(); } diff --git a/src/bodymovin/bmrect_p.h b/src/bodymovin/bmrect_p.h index 924d82f..27a9f97 100644 --- a/src/bodymovin/bmrect_p.h +++ b/src/bodymovin/bmrect_p.h @@ -59,11 +59,11 @@ class BODYMOVIN_EXPORT BMRect : public BMShape public: BMRect() = default; explicit BMRect(const BMRect &other); - BMRect(const QJsonObject &definition, BMBase *parent = nullptr); + BMRect(const QJsonObject &definition, const QVersionNumber &version, BMBase *parent = nullptr); BMBase *clone() const override; - void construct(const QJsonObject &definition); + void construct(const QJsonObject &definition, const QVersionNumber &version); bool setProperty(BMLiteral::PropertyType propertyType, QVariant value) override; diff --git a/src/bodymovin/bmrepeater.cpp b/src/bodymovin/bmrepeater.cpp index 53d1d3a..e5d552d 100644 --- a/src/bodymovin/bmrepeater.cpp +++ b/src/bodymovin/bmrepeater.cpp @@ -29,11 +29,11 @@ #include "bmrepeater_p.h" -BMRepeater::BMRepeater(const QJsonObject &definition, BMBase *parent) +BMRepeater::BMRepeater(const QJsonObject &definition, const QVersionNumber &version, BMBase *parent) { setParent(parent); m_transform.setParent(this); - construct(definition); + construct(definition, version); } BMBase *BMRepeater::clone() const @@ -41,7 +41,7 @@ BMBase *BMRepeater::clone() const return new BMRepeater(*this); } -void BMRepeater::construct(const QJsonObject &definition) +void BMRepeater::construct(const QJsonObject &definition, const QVersionNumber &version) { qCDebug(lcLottieQtBodymovinParser) << "BMRepeater::construct():" << m_name; @@ -51,13 +51,13 @@ void BMRepeater::construct(const QJsonObject &definition) QJsonObject copies = definition.value(QLatin1String("c")).toObject(); copies = resolveExpression(copies); - m_copies.construct(copies); + m_copies.construct(copies, version); QJsonObject offset = definition.value(QLatin1String("o")).toObject(); offset = resolveExpression(offset); - m_offset.construct(offset); + m_offset.construct(offset, version); - m_transform.construct(definition.value(QLatin1String("tr")).toObject()); + m_transform.construct(definition.value(QLatin1String("tr")).toObject(), version); } void BMRepeater::updateProperties(int frame) diff --git a/src/bodymovin/bmrepeater_p.h b/src/bodymovin/bmrepeater_p.h index 5657f6c..d9b81f0 100644 --- a/src/bodymovin/bmrepeater_p.h +++ b/src/bodymovin/bmrepeater_p.h @@ -55,11 +55,12 @@ class BODYMOVIN_EXPORT BMRepeater : public BMShape public: BMRepeater() = default; explicit BMRepeater(const BMRepeater &other) = default; - BMRepeater(const QJsonObject &definition, BMBase *parent = nullptr); + BMRepeater(const QJsonObject &definition, const QVersionNumber &version, + BMBase *parent = nullptr); BMBase *clone() const override; - void construct(const QJsonObject& definition); + void construct(const QJsonObject &definition, const QVersionNumber &version); void updateProperties(int frame) override; void render(LottieRenderer &renderer) const override; diff --git a/src/bodymovin/bmrepeatertransform.cpp b/src/bodymovin/bmrepeatertransform.cpp index 1631a3c..0a7be08 100644 --- a/src/bodymovin/bmrepeatertransform.cpp +++ b/src/bodymovin/bmrepeatertransform.cpp @@ -39,10 +39,11 @@ BMRepeaterTransform::BMRepeaterTransform(const BMRepeaterTransform &other) m_opacities = other.m_opacities; } -BMRepeaterTransform::BMRepeaterTransform(const QJsonObject &definition, BMBase *parent) +BMRepeaterTransform::BMRepeaterTransform(const QJsonObject &definition, + const QVersionNumber &version, BMBase *parent) { setParent(parent); - construct(definition); + construct(definition, version); } BMBase *BMRepeaterTransform::clone() const @@ -50,21 +51,21 @@ BMBase *BMRepeaterTransform::clone() const return new BMRepeaterTransform(*this); } -void BMRepeaterTransform::construct(const QJsonObject &definition) +void BMRepeaterTransform::construct(const QJsonObject &definition, const QVersionNumber &version) { qCDebug(lcLottieQtBodymovinParser) << "BMRepeaterTransform::construct():" << name(); - BMBasicTransform::construct(definition); + BMBasicTransform::construct(definition, version); if (m_hidden) return; QJsonObject startOpacity = definition.value(QLatin1String("so")).toObject(); startOpacity = resolveExpression(startOpacity); - m_startOpacity.construct(startOpacity); + m_startOpacity.construct(startOpacity, version); QJsonObject endOpacity = definition.value(QLatin1String("eo")).toObject(); endOpacity = resolveExpression(endOpacity); - m_endOpacity.construct(endOpacity); + m_endOpacity.construct(endOpacity, version); } void BMRepeaterTransform::updateProperties(int frame) diff --git a/src/bodymovin/bmrepeatertransform_p.h b/src/bodymovin/bmrepeatertransform_p.h index 259b051..a68f4d9 100644 --- a/src/bodymovin/bmrepeatertransform_p.h +++ b/src/bodymovin/bmrepeatertransform_p.h @@ -52,11 +52,12 @@ class BODYMOVIN_EXPORT BMRepeaterTransform : public BMBasicTransform public: BMRepeaterTransform() = default; explicit BMRepeaterTransform(const BMRepeaterTransform &other); - BMRepeaterTransform(const QJsonObject &definition, BMBase *parent); + BMRepeaterTransform(const QJsonObject &definition, const QVersionNumber &version, + BMBase *parent); BMBase *clone() const override; - void construct(const QJsonObject &definition); + void construct(const QJsonObject &definition, const QVersionNumber &version); void updateProperties(int frame) override; void render(LottieRenderer &renderer) const override; diff --git a/src/bodymovin/bmround.cpp b/src/bodymovin/bmround.cpp index 4f02163..ac49023 100644 --- a/src/bodymovin/bmround.cpp +++ b/src/bodymovin/bmround.cpp @@ -42,10 +42,10 @@ BMRound::BMRound(const BMRound &other) m_radius = other.m_radius; } -BMRound::BMRound(const QJsonObject &definition, BMBase *parent) +BMRound::BMRound(const QJsonObject &definition, const QVersionNumber &version, BMBase *parent) { setParent(parent); - construct(definition); + construct(definition, version); } BMBase *BMRound::clone() const @@ -53,7 +53,7 @@ BMBase *BMRound::clone() const return new BMRound(*this); } -void BMRound::construct(const QJsonObject &definition) +void BMRound::construct(const QJsonObject &definition, const QVersionNumber &version) { BMBase::parse(definition); if (m_hidden) @@ -63,11 +63,11 @@ void BMRound::construct(const QJsonObject &definition) QJsonObject position = definition.value(QLatin1String("p")).toObject(); position = resolveExpression(position); - m_position.construct(position); + m_position.construct(position, version); QJsonObject radius = definition.value(QLatin1String("r")).toObject(); radius = resolveExpression(radius); - m_radius.construct(radius); + m_radius.construct(radius, version); } void BMRound::updateProperties(int frame) diff --git a/src/bodymovin/bmround_p.h b/src/bodymovin/bmround_p.h index 9a66b35..c960a86 100644 --- a/src/bodymovin/bmround_p.h +++ b/src/bodymovin/bmround_p.h @@ -61,11 +61,11 @@ class BODYMOVIN_EXPORT BMRound : public BMShape public: BMRound() = default; explicit BMRound(const BMRound &other); - BMRound(const QJsonObject &definition, BMBase *parent = nullptr); + BMRound(const QJsonObject &definition, const QVersionNumber &version, BMBase *parent = nullptr); BMBase *clone() const override; - void construct(const QJsonObject &definition); + void construct(const QJsonObject &definition, const QVersionNumber &version); void updateProperties(int frame) override; void render(LottieRenderer &renderer) const override; diff --git a/src/bodymovin/bmshape.cpp b/src/bodymovin/bmshape.cpp index dd80b45..16df745 100644 --- a/src/bodymovin/bmshape.cpp +++ b/src/bodymovin/bmshape.cpp @@ -61,7 +61,7 @@ BMBase *BMShape::clone() const return new BMShape(*this); } -BMShape *BMShape::construct(QJsonObject definition, BMBase *parent) +BMShape *BMShape::construct(QJsonObject definition, const QVersionNumber &version, BMBase *parent) { qCDebug(lcLottieQtBodymovinParser) << "BMShape::construct()"; @@ -82,77 +82,77 @@ BMShape *BMShape::construct(QJsonObject definition, BMBase *parent) case BM_SHAPE_TAG('g', 'r'): { qCDebug(lcLottieQtBodymovinParser) << "Parse group"; - shape = new BMGroup(definition, parent); + shape = new BMGroup(definition, version, parent); shape->setType(BM_SHAPE_GROUP_IX); break; } case BM_SHAPE_TAG('r', 'c'): { qCDebug(lcLottieQtBodymovinParser) << "Parse m_rect"; - shape = new BMRect(definition, parent); + shape = new BMRect(definition, version, parent); shape->setType(BM_SHAPE_RECT_IX); break; } case BM_SHAPE_TAG('f', 'l'): { qCDebug(lcLottieQtBodymovinParser) << "Parse fill"; - shape = new BMFill(definition, parent); + shape = new BMFill(definition, version, parent); shape->setType(BM_SHAPE_FILL_IX); break; } case BM_SHAPE_TAG('g', 'f'): { qCDebug(lcLottieQtBodymovinParser) << "Parse group fill"; - shape = new BMGFill(definition, parent); + shape = new BMGFill(definition, version, parent); shape->setType(BM_SHAPE_GFILL_IX); break; } case BM_SHAPE_TAG('s', 't'): { qCDebug(lcLottieQtBodymovinParser) << "Parse stroke"; - shape = new BMStroke(definition, parent); + shape = new BMStroke(definition, version, parent); shape->setType(BM_SHAPE_STROKE_IX); break; } case BM_SHAPE_TAG('t', 'r'): { qCDebug(lcLottieQtBodymovinParser) << "Parse shape transform"; - shape = new BMShapeTransform(definition, parent); + shape = new BMShapeTransform(definition, version, parent); shape->setType(BM_SHAPE_TRANS_IX); break; } case BM_SHAPE_TAG('e', 'l'): { qCDebug(lcLottieQtBodymovinParser) << "Parse ellipse"; - shape = new BMEllipse(definition, parent); + shape = new BMEllipse(definition, version, parent); shape->setType(BM_SHAPE_ELLIPSE_IX); break; } case BM_SHAPE_TAG('r', 'd'): { qCDebug(lcLottieQtBodymovinParser) << "Parse round"; - shape = new BMRound(definition, parent); + shape = new BMRound(definition, version, parent); shape->setType(BM_SHAPE_ROUND_IX); break; } case BM_SHAPE_TAG('s', 'h'): { qCDebug(lcLottieQtBodymovinParser) << "Parse shape"; - shape = new BMFreeFormShape(definition, parent); + shape = new BMFreeFormShape(definition, version, parent); shape->setType(BM_SHAPE_SHAPE_IX); break; } case BM_SHAPE_TAG('t', 'm'): { qCDebug(lcLottieQtBodymovinParser) << "Parse trim path"; - shape = new BMTrimPath(definition, parent); + shape = new BMTrimPath(definition, version, parent); shape->setType(BM_SHAPE_TRIM_IX); break; } case BM_SHAPE_TAG('r', 'p'): { qCDebug(lcLottieQtBodymovinParser) << "Parse trim path"; - shape = new BMRepeater(definition, parent); + shape = new BMRepeater(definition, version, parent); shape->setType(BM_SHAPE_REPEATER_IX); break; } diff --git a/src/bodymovin/bmshape_p.h b/src/bodymovin/bmshape_p.h index 97caad6..e747144 100644 --- a/src/bodymovin/bmshape_p.h +++ b/src/bodymovin/bmshape_p.h @@ -75,7 +75,8 @@ public: BMBase *clone() const override; - static BMShape *construct(QJsonObject definition, BMBase *parent = nullptr); + static BMShape *construct(QJsonObject definition, const QVersionNumber &version, + BMBase *parent = nullptr); virtual const QPainterPath &path() const; virtual bool acceptsTrim() const; diff --git a/src/bodymovin/bmshapelayer.cpp b/src/bodymovin/bmshapelayer.cpp index 164f100..fbd0b0a 100644 --- a/src/bodymovin/bmshapelayer.cpp +++ b/src/bodymovin/bmshapelayer.cpp @@ -51,9 +51,10 @@ BMShapeLayer::BMShapeLayer(const BMShapeLayer &other) m_appliedTrim = other.m_appliedTrim; } -BMShapeLayer::BMShapeLayer(const QJsonObject &definition) +BMShapeLayer::BMShapeLayer(const QJsonObject &definition, const QVersionNumber &version) { m_type = BM_LAYER_SHAPE_IX; + m_version = version; BMLayer::parse(definition); if (m_hidden) @@ -70,13 +71,13 @@ BMShapeLayer::BMShapeLayer(const QJsonObject &definition) } QJsonObject trans = definition.value(QLatin1String("ks")).toObject(); - m_layerTransform = new BMBasicTransform(trans, this); + m_layerTransform = new BMBasicTransform(trans, version, this); QJsonArray items = definition.value(QLatin1String("shapes")).toArray(); QJsonArray::const_iterator itemIt = items.constEnd(); while (itemIt != items.constBegin()) { itemIt--; - BMShape *shape = BMShape::construct((*itemIt).toObject(), this); + BMShape *shape = BMShape::construct((*itemIt).toObject(), version, this); if (shape) appendChild(shape); } diff --git a/src/bodymovin/bmshapelayer_p.h b/src/bodymovin/bmshapelayer_p.h index babd782..9dcf4b9 100644 --- a/src/bodymovin/bmshapelayer_p.h +++ b/src/bodymovin/bmshapelayer_p.h @@ -57,7 +57,7 @@ class BODYMOVIN_EXPORT BMShapeLayer : public BMLayer public: BMShapeLayer() = default; explicit BMShapeLayer(const BMShapeLayer &other); - BMShapeLayer(const QJsonObject &definition); + BMShapeLayer(const QJsonObject &definition, const QVersionNumber &version); ~BMShapeLayer() override; BMBase *clone() const override; diff --git a/src/bodymovin/bmshapetransform.cpp b/src/bodymovin/bmshapetransform.cpp index d9cc24b..9c10efc 100644 --- a/src/bodymovin/bmshapetransform.cpp +++ b/src/bodymovin/bmshapetransform.cpp @@ -45,10 +45,11 @@ BMShapeTransform::BMShapeTransform(const BMShapeTransform &other) m_shearAngle = other.m_shearAngle; } -BMShapeTransform::BMShapeTransform(const QJsonObject &definition, BMBase *parent) +BMShapeTransform::BMShapeTransform(const QJsonObject &definition, const QVersionNumber &version, + BMBase *parent) { setParent(parent); - construct(definition); + construct(definition, version); } BMBase *BMShapeTransform::clone() const @@ -56,19 +57,19 @@ BMBase *BMShapeTransform::clone() const return new BMShapeTransform(*this); } -void BMShapeTransform::construct(const QJsonObject &definition) +void BMShapeTransform::construct(const QJsonObject &definition, const QVersionNumber &version) { - BMBasicTransform::construct(definition); + BMBasicTransform::construct(definition, version); qCDebug(lcLottieQtBodymovinParser) << "BMShapeTransform::construct():" << BMShape::name(); QJsonObject skew = definition.value(QLatin1String("sk")).toObject(); skew = resolveExpression(skew); - m_skew.construct(skew); + m_skew.construct(skew, version); QJsonObject skewAxis = definition.value(QLatin1String("sa")).toObject(); skewAxis = resolveExpression(skewAxis); - m_skewAxis.construct(skewAxis); + m_skewAxis.construct(skewAxis, version); } void BMShapeTransform::updateProperties(int frame) diff --git a/src/bodymovin/bmshapetransform_p.h b/src/bodymovin/bmshapetransform_p.h index f73f639..de5966d 100644 --- a/src/bodymovin/bmshapetransform_p.h +++ b/src/bodymovin/bmshapetransform_p.h @@ -55,11 +55,11 @@ class BODYMOVIN_EXPORT BMShapeTransform : public BMBasicTransform { public: explicit BMShapeTransform(const BMShapeTransform &other); - BMShapeTransform(const QJsonObject &definition, BMBase *parent); + BMShapeTransform(const QJsonObject &definition, const QVersionNumber &version, BMBase *parent); BMBase *clone() const override; - void construct(const QJsonObject &definition); + void construct(const QJsonObject &definition, const QVersionNumber &version); void updateProperties(int frame) override; void render(LottieRenderer &renderer) const override; diff --git a/src/bodymovin/bmspatialproperty_p.h b/src/bodymovin/bmspatialproperty_p.h index 09e27a8..22e428c 100644 --- a/src/bodymovin/bmspatialproperty_p.h +++ b/src/bodymovin/bmspatialproperty_p.h @@ -51,15 +51,68 @@ QT_BEGIN_NAMESPACE class BMSpatialProperty : public BMProperty2D<QPointF> { public: - virtual void construct(const QJsonObject &definition) override + virtual void construct(const QJsonObject &definition, const QVersionNumber &version) override { qCDebug(lcLottieQtBodymovinParser) << "BMSpatialProperty::construct()"; - BMProperty2D<QPointF>::construct(definition); + BMProperty2D<QPointF>::construct(definition, version); } - virtual EasingSegment<QPointF> parseKeyframe(const QJsonObject keyframe, bool fromExpression) override + virtual EasingSegment<QPointF> parseKeyframe(const QJsonObject keyframe, + bool fromExpression) override { - EasingSegment<QPointF> easing = BMProperty2D<QPointF>::parseKeyframe(keyframe, fromExpression); + EasingSegment<QPointF> easing = + BMProperty2D<QPointF>::parseKeyframe(keyframe, fromExpression); + + // No need to parse further incomplete keyframes (i.e. last keyframes) + if (!easing.complete) { + return easing; + } + + qreal tix = 0, tiy = 0, tox = 0, toy = 0; + if (fromExpression) { + // If spatial property definition originates from + // an expression (specifically Slider), it contains scalar + // property. It must be expanded to both x and y coordinates + QJsonArray iArr = keyframe.value(QLatin1String("i")).toArray(); + QJsonArray oArr = keyframe.value(QLatin1String("o")).toArray(); + + if (iArr.count() && oArr.count()) { + tix = iArr.at(0).toDouble(); + tiy = tix; + tox = oArr.at(0).toDouble(); + toy = tox; + } + } else { + QJsonArray tiArr = keyframe.value(QLatin1String("ti")).toArray(); + QJsonArray toArr = keyframe.value(QLatin1String("to")).toArray(); + + if (tiArr.count() && toArr.count()) { + tix = tiArr.at(0).toDouble(); + tiy = tiArr.at(1).toDouble(); + tox = toArr.at(0).toDouble(); + toy = toArr.at(1).toDouble(); + } + } + QPointF s(easing.startValue); + QPointF e(easing.endValue); + QPointF c1(tox, toy); + QPointF c2(tix, tiy); + + c1 += s; + c2 += e; + + m_bezierPath.moveTo(s); + m_bezierPath.cubicTo(c1, c2, e); + + return easing; + } + + virtual EasingSegment<QPointF> parseKeyframe(const QJsonObject keyframe, + const QJsonObject nextKeyframe, + bool fromExpression) override + { + EasingSegment<QPointF> easing = + BMProperty2D<QPointF>::parseKeyframe(keyframe, nextKeyframe, fromExpression); // No need to parse further incomplete keyframes (i.e. last keyframes) if (!easing.complete) { diff --git a/src/bodymovin/bmstroke.cpp b/src/bodymovin/bmstroke.cpp index 1d9f16f..c850039 100644 --- a/src/bodymovin/bmstroke.cpp +++ b/src/bodymovin/bmstroke.cpp @@ -46,7 +46,7 @@ BMStroke::BMStroke(const BMStroke &other) m_miterLimit = other.m_miterLimit; } -BMStroke::BMStroke(const QJsonObject &definition, BMBase *parent) +BMStroke::BMStroke(const QJsonObject &definition, const QVersionNumber &version, BMBase *parent) { setParent(parent); @@ -89,15 +89,15 @@ BMStroke::BMStroke(const QJsonObject &definition, BMBase *parent) QJsonObject opacity = definition.value(QLatin1String("o")).toObject(); opacity = resolveExpression(opacity); - m_opacity.construct(opacity); + m_opacity.construct(opacity, version); QJsonObject width = definition.value(QLatin1String("w")).toObject(); width = resolveExpression(width); - m_width.construct(width); + m_width.construct(width, version); QJsonObject color = definition.value(QLatin1String("c")).toObject(); color = resolveExpression(color); - m_color.construct(color); + m_color.construct(color, version); } BMBase *BMStroke::clone() const diff --git a/src/bodymovin/bmstroke_p.h b/src/bodymovin/bmstroke_p.h index 135d5e5..8dcf0a0 100644 --- a/src/bodymovin/bmstroke_p.h +++ b/src/bodymovin/bmstroke_p.h @@ -54,7 +54,8 @@ class BODYMOVIN_EXPORT BMStroke : public BMShape public: BMStroke() = default; explicit BMStroke(const BMStroke &other); - BMStroke(const QJsonObject &definition, BMBase *parent = nullptr); + BMStroke(const QJsonObject &definition, const QVersionNumber &version, + BMBase *parent = nullptr); BMBase *clone() const override; diff --git a/src/bodymovin/bmtrimpath.cpp b/src/bodymovin/bmtrimpath.cpp index c5457e9..13ccbdc 100644 --- a/src/bodymovin/bmtrimpath.cpp +++ b/src/bodymovin/bmtrimpath.cpp @@ -41,12 +41,12 @@ BMTrimPath::BMTrimPath() m_appliedTrim = this; } -BMTrimPath::BMTrimPath(const QJsonObject &definition, BMBase *parent) +BMTrimPath::BMTrimPath(const QJsonObject &definition, const QVersionNumber &version, BMBase *parent) { m_appliedTrim = this; setParent(parent); - construct(definition); + construct(definition, version); } BMTrimPath::BMTrimPath(const BMTrimPath &other) @@ -63,7 +63,7 @@ BMBase *BMTrimPath::clone() const return new BMTrimPath(*this); } -void BMTrimPath::construct(const QJsonObject &definition) +void BMTrimPath::construct(const QJsonObject &definition, const QVersionNumber &version) { BMBase::parse(definition); if (m_hidden) @@ -73,15 +73,15 @@ void BMTrimPath::construct(const QJsonObject &definition) QJsonObject start = definition.value(QLatin1String("s")).toObject(); start = resolveExpression(start); - m_start.construct(start); + m_start.construct(start, version); QJsonObject end = definition.value(QLatin1String("e")).toObject(); end = resolveExpression(end); - m_end.construct(end); + m_end.construct(end, version); QJsonObject offset = definition.value(QLatin1String("o")).toObject(); offset = resolveExpression(offset); - m_offset.construct(offset); + m_offset.construct(offset, version); int simultaneous = true; if (definition.contains(QLatin1String("m"))) { diff --git a/src/bodymovin/bmtrimpath_p.h b/src/bodymovin/bmtrimpath_p.h index 4f4ff42..9a6680c 100644 --- a/src/bodymovin/bmtrimpath_p.h +++ b/src/bodymovin/bmtrimpath_p.h @@ -53,14 +53,15 @@ class BODYMOVIN_EXPORT BMTrimPath : public BMShape { public: BMTrimPath(); - BMTrimPath(const QJsonObject &definition, BMBase *parent = nullptr); + BMTrimPath(const QJsonObject &definition, const QVersionNumber &version, + BMBase *parent = nullptr); explicit BMTrimPath(const BMTrimPath &other); void inherit(const BMTrimPath &other); BMBase *clone() const override; - void construct(const QJsonObject &definition); + void construct(const QJsonObject &definition, const QVersionNumber &version); void updateProperties(int frame) override; void render(LottieRenderer &renderer) const override; diff --git a/src/imports/lottieanimation.cpp b/src/imports/lottieanimation.cpp index 05f5c57..bcee25d 100644 --- a/src/imports/lottieanimation.cpp +++ b/src/imports/lottieanimation.cpp @@ -341,6 +341,11 @@ int LottieAnimation::currentFrame() const return m_currentFrame; } +QVersionNumber LottieAnimation::version() const +{ + return m_version; +} + /*! \qmlproperty int LottieAnimation::frameRate @@ -681,6 +686,12 @@ int LottieAnimation::parse(QByteArray jsonSource) if (Q_UNLIKELY(rootObj.empty())) return -1; + QStringList versionString = rootObj.value(QLatin1String("v")).toString().split(u'.'); + QList<int> version; + foreach (QString v, versionString) + version.append(v.toInt()); + m_version = QVersionNumber(version); + int startFrame = rootObj.value(QLatin1String("ip")).toVariant().toInt(); int endFrame = rootObj.value(QLatin1String("op")).toVariant().toInt(); m_animFrameRate = rootObj.value(QLatin1String("fr")).toVariant().toInt(); diff --git a/src/imports/lottieanimation.h b/src/imports/lottieanimation.h index 79f9064..3f6bb2d 100644 --- a/src/imports/lottieanimation.h +++ b/src/imports/lottieanimation.h @@ -97,6 +97,8 @@ public: int endFrame() const; int currentFrame() const; + QVersionNumber version() const; + Q_INVOKABLE void start(); Q_INVOKABLE void play(); @@ -145,6 +147,7 @@ protected: QMetaObject::Connection m_waitForFrameConn; Status m_status = Null; + QVersionNumber m_version = QVersionNumber(); int m_startFrame = 0; int m_endFrame = 0; int m_currentFrame = 0; diff --git a/src/imports/rasterrenderer/batchrenderer.cpp b/src/imports/rasterrenderer/batchrenderer.cpp index 7600b95..a4aaf85 100644 --- a/src/imports/rasterrenderer/batchrenderer.cpp +++ b/src/imports/rasterrenderer/batchrenderer.cpp @@ -112,7 +112,7 @@ void BatchRenderer::registerAnimator(LottieAnimation *animator) entry->currentFrame = animator->startFrame(); entry->animDir = animator->direction(); entry->bmTreeBlueprint = new BMBase; - parse(entry->bmTreeBlueprint, animator->jsonSource()); + parse(entry->bmTreeBlueprint, animator->jsonSource(), animator->version()); m_waitCondition.wakeAll(); } @@ -236,7 +236,8 @@ void BatchRenderer::run() } } -int BatchRenderer::parse(BMBase *rootElement, const QByteArray &jsonSource) const +int BatchRenderer::parse(BMBase *rootElement, const QByteArray &jsonSource, + const QVersionNumber &version) const { QJsonDocument doc = QJsonDocument::fromJson(jsonSource); QJsonObject rootObj = doc.object(); @@ -265,7 +266,7 @@ int BatchRenderer::parse(BMBase *rootElement, const QByteArray &jsonSource) cons QString refId = jsonLayer.value("refId").toString(); jsonLayer.insert("asset", assets.value(refId)); } - BMLayer *layer = BMLayer::construct(jsonLayer); + BMLayer *layer = BMLayer::construct(jsonLayer, version); if (layer) { layer->setParent(rootElement); // Mask layers must be rendered before the layers they affect to diff --git a/src/imports/rasterrenderer/batchrenderer.h b/src/imports/rasterrenderer/batchrenderer.h index 7e5830e..827cdb9 100644 --- a/src/imports/rasterrenderer/batchrenderer.h +++ b/src/imports/rasterrenderer/batchrenderer.h @@ -39,6 +39,7 @@ QT_BEGIN_NAMESPACE class BMBase; class QImage; +class QVersionNumber; class LottieAnimation; class BatchRenderer : public QThread @@ -81,7 +82,8 @@ public slots: protected: void run() override; - int parse(BMBase *rootElement, const QByteArray &jsonSource) const; + int parse(BMBase *rootElement, const QByteArray &jsonSource, + const QVersionNumber &version) const; void prerender(Entry *animEntry); diff --git a/src/imports/rasterrenderer/lottierasterrenderer.cpp b/src/imports/rasterrenderer/lottierasterrenderer.cpp index 12790b5..901af79 100644 --- a/src/imports/rasterrenderer/lottierasterrenderer.cpp +++ b/src/imports/rasterrenderer/lottierasterrenderer.cpp @@ -204,7 +204,10 @@ void LottieRasterRenderer::render(const BMFill &fill) if (m_fillEffect) return; - m_painter->setBrush(fill.color()); + float alpha = fill.color().alphaF() * fill.opacity() / 100.0f; + QColor color = fill.color(); + color.setAlphaF(alpha); + m_painter->setBrush(color); } void LottieRasterRenderer::render(const BMGFill &gradient) diff --git a/tests/auto/bodymovin/shape/ellipse/tst_bmellipse.cpp b/tests/auto/bodymovin/shape/ellipse/tst_bmellipse.cpp index 021adde..ffca2fc 100644 --- a/tests/auto/bodymovin/shape/ellipse/tst_bmellipse.cpp +++ b/tests/auto/bodymovin/shape/ellipse/tst_bmellipse.cpp @@ -283,6 +283,12 @@ void tst_BMEllipse::loadTestData(const QByteArray &filename) if (rootObj.empty()) QFAIL("Cannot parse test file"); + QStringList vs = rootObj.value(QLatin1String("v")).toString().split(u'.'); + QList<int> vi; + foreach (QString v, vs) + vi.append(v.toInt()); + QVersionNumber version = QVersionNumber(vi); + QJsonArray layers = rootObj.value(QLatin1String("layers")).toArray(); QJsonObject layerObj = layers[0].toObject(); int type = layerObj.value(QLatin1String("ty")).toInt(); @@ -294,7 +300,7 @@ void tst_BMEllipse::loadTestData(const QByteArray &filename) BMShape* shape = nullptr; while (shapesIt != shapes.end()) { QJsonObject childObj = (*shapesIt).toObject(); - shape = BMShape::construct(childObj); + shape = BMShape::construct(childObj, version); QVERIFY(shape != nullptr); if (shape->type() == BM_SHAPE_ELLIPSE_IX) break; diff --git a/tests/auto/bodymovin/shape/fill/tst_bmfill.cpp b/tests/auto/bodymovin/shape/fill/tst_bmfill.cpp index 70a86d7..81de85f 100644 --- a/tests/auto/bodymovin/shape/fill/tst_bmfill.cpp +++ b/tests/auto/bodymovin/shape/fill/tst_bmfill.cpp @@ -204,6 +204,12 @@ void tst_BMFill::loadTestData(const QByteArray &filename) if (rootObj.empty()) QFAIL("Cannot parse test file"); + QStringList vs = rootObj.value(QLatin1String("v")).toString().split(u'.'); + QList<int> vi; + foreach (QString v, vs) + vi.append(v.toInt()); + QVersionNumber version = QVersionNumber(vi); + QJsonArray layers = rootObj.value(QLatin1String("layers")).toArray(); QJsonObject layerObj = layers[0].toObject(); int type = layerObj.value(QLatin1String("ty")).toInt(); @@ -215,7 +221,7 @@ void tst_BMFill::loadTestData(const QByteArray &filename) BMShape* shape = nullptr; while (shapesIt != shapes.end()) { QJsonObject childObj = (*shapesIt).toObject(); - shape = BMShape::construct(childObj); + shape = BMShape::construct(childObj, version); QVERIFY(shape != nullptr); if (shape->type() == BM_SHAPE_FILL_IX) break; diff --git a/tests/auto/bodymovin/shape/path/tst_bmpath.cpp b/tests/auto/bodymovin/shape/path/tst_bmpath.cpp index b029e24..8e1f968 100644 --- a/tests/auto/bodymovin/shape/path/tst_bmpath.cpp +++ b/tests/auto/bodymovin/shape/path/tst_bmpath.cpp @@ -1132,6 +1132,12 @@ void tst_BMPath::loadTestData(const QByteArray &filename) if (rootObj.empty()) QFAIL("Cannot parse test file"); + QStringList vs = rootObj.value(QLatin1String("v")).toString().split(u'.'); + QList<int> vi; + foreach (QString v, vs) + vi.append(v.toInt()); + QVersionNumber version = QVersionNumber(vi); + QJsonArray layers = rootObj.value(QLatin1String("layers")).toArray(); QJsonObject layerObj = layers[0].toObject(); int type = layerObj.value(QLatin1String("ty")).toInt(); @@ -1143,7 +1149,7 @@ void tst_BMPath::loadTestData(const QByteArray &filename) BMShape* shape = nullptr; while (shapesIt != shapes.end()) { QJsonObject childObj = (*shapesIt).toObject(); - shape = BMShape::construct(childObj); + shape = BMShape::construct(childObj, version); QVERIFY(shape != nullptr); if (shape->type() == BM_SHAPE_SHAPE_IX) break; diff --git a/tests/auto/bodymovin/shape/rect/tst_bmrect.cpp b/tests/auto/bodymovin/shape/rect/tst_bmrect.cpp index 6efccda..c0d76e5 100644 --- a/tests/auto/bodymovin/shape/rect/tst_bmrect.cpp +++ b/tests/auto/bodymovin/shape/rect/tst_bmrect.cpp @@ -317,6 +317,12 @@ void tst_BMRect::loadTestData(const QByteArray &filename) if (rootObj.empty()) QFAIL("Cannot parse test file"); + QStringList vs = rootObj.value(QLatin1String("v")).toString().split(u'.'); + QList<int> vi; + foreach (QString v, vs) + vi.append(v.toInt()); + QVersionNumber version = QVersionNumber(vi); + QJsonArray layers = rootObj.value(QLatin1String("layers")).toArray(); QJsonObject layerObj = layers[0].toObject(); int type = layerObj.value(QLatin1String("ty")).toInt(); @@ -328,7 +334,7 @@ void tst_BMRect::loadTestData(const QByteArray &filename) BMShape* shape = nullptr; while (shapesIt != shapes.end()) { QJsonObject childObj = (*shapesIt).toObject(); - shape = BMShape::construct(childObj); + shape = BMShape::construct(childObj, version); QVERIFY(shape != nullptr); if (shape->type() == BM_SHAPE_RECT_IX) break; diff --git a/tests/auto/bodymovin/shape/repeater/tst_bmrepeater.cpp b/tests/auto/bodymovin/shape/repeater/tst_bmrepeater.cpp index 98d8228..24b561f 100644 --- a/tests/auto/bodymovin/shape/repeater/tst_bmrepeater.cpp +++ b/tests/auto/bodymovin/shape/repeater/tst_bmrepeater.cpp @@ -199,6 +199,12 @@ void tst_BMRepeater::loadTestData(const QByteArray &filename) if (rootObj.empty()) QFAIL("Cannot parse test file"); + QStringList vs = rootObj.value(QLatin1String("v")).toString().split(u'.'); + QList<int> vi; + foreach (QString v, vs) + vi.append(v.toInt()); + QVersionNumber version = QVersionNumber(vi); + QJsonArray layers = rootObj.value(QLatin1String("layers")).toArray(); QJsonObject layerObj = layers[0].toObject(); int type = layerObj.value(QLatin1String("ty")).toInt(); @@ -210,7 +216,7 @@ void tst_BMRepeater::loadTestData(const QByteArray &filename) BMShape* shape = nullptr; while (shapesIt != shapes.end()) { QJsonObject childObj = (*shapesIt).toObject(); - shape = BMShape::construct(childObj); + shape = BMShape::construct(childObj, version); QVERIFY(shape != nullptr); if (shape->type() == BM_SHAPE_REPEATER_IX) break; diff --git a/tests/auto/bodymovin/shape/repeatertransform/tst_bmrepeatertransform.cpp b/tests/auto/bodymovin/shape/repeatertransform/tst_bmrepeatertransform.cpp index e6f2e41..88d2b27 100644 --- a/tests/auto/bodymovin/shape/repeatertransform/tst_bmrepeatertransform.cpp +++ b/tests/auto/bodymovin/shape/repeatertransform/tst_bmrepeatertransform.cpp @@ -428,6 +428,12 @@ void tst_BMRepeaterTransform::loadTestData(const QByteArray &filename) if (rootObj.empty()) QFAIL("Cannot parse test file"); + QStringList vs = rootObj.value(QLatin1String("v")).toString().split(u'.'); + QList<int> vi; + foreach (QString v, vs) + vi.append(v.toInt()); + QVersionNumber version = QVersionNumber(vi); + QJsonArray layers = rootObj.value(QLatin1String("layers")).toArray(); QJsonObject layerObj = layers[0].toObject(); int type = layerObj.value(QLatin1String("ty")).toInt(); @@ -439,7 +445,7 @@ void tst_BMRepeaterTransform::loadTestData(const QByteArray &filename) BMShape* shape = nullptr; while (shapesIt != shapes.end()) { QJsonObject childObj = (*shapesIt).toObject(); - shape = BMShape::construct(childObj); + shape = BMShape::construct(childObj, version); QVERIFY(shape != nullptr); if (shape->type() == BM_SHAPE_REPEATER_IX) break; diff --git a/tests/auto/bodymovin/shape/shapelayer/tst_bmshapelayer.cpp b/tests/auto/bodymovin/shape/shapelayer/tst_bmshapelayer.cpp index 6454ab7..266f199 100644 --- a/tests/auto/bodymovin/shape/shapelayer/tst_bmshapelayer.cpp +++ b/tests/auto/bodymovin/shape/shapelayer/tst_bmshapelayer.cpp @@ -172,6 +172,12 @@ void tst_BMShapeLayer::loadTestData(const QByteArray &filename) if (rootObj.empty()) QFAIL("Cannot parse test file"); + QStringList vs = rootObj.value(QLatin1String("v")).toString().split(u'.'); + QList<int> vi; + foreach (QString v, vs) + vi.append(v.toInt()); + QVersionNumber version = QVersionNumber(vi); + m_width = rootObj.value(QLatin1String("w")).toVariant().toReal(); m_height = rootObj.value(QLatin1String("h")).toVariant().toReal(); @@ -180,7 +186,7 @@ void tst_BMShapeLayer::loadTestData(const QByteArray &filename) int type = layerObj.value(QLatin1String("ty")).toInt(); if (type != 4) QFAIL("It's not shape layer"); - m_layer = new BMShapeLayer(layerObj); + m_layer = new BMShapeLayer(layerObj, version); QVERIFY(m_layer != nullptr); if (layers.size() > 1) { @@ -188,7 +194,7 @@ void tst_BMShapeLayer::loadTestData(const QByteArray &filename) type = layerObj.value(QLatin1String("ty")).toInt(); if (type != 4) QFAIL("it's not shape layer"); - m_clippedlayer = new BMShapeLayer(layerObj); + m_clippedlayer = new BMShapeLayer(layerObj, version); QVERIFY(m_clippedlayer != nullptr); } } diff --git a/tests/auto/bodymovin/shape/shapetransform/tst_bmshapetransform.cpp b/tests/auto/bodymovin/shape/shapetransform/tst_bmshapetransform.cpp index 3fbe5f8..61c36aa 100644 --- a/tests/auto/bodymovin/shape/shapetransform/tst_bmshapetransform.cpp +++ b/tests/auto/bodymovin/shape/shapetransform/tst_bmshapetransform.cpp @@ -484,12 +484,18 @@ void tst_BMShapeTransform::loadTestData(const QByteArray &filename) if (type != 4) QFAIL("It's not shape layer"); + QStringList vs = rootObj.value(QLatin1String("v")).toString().split(u'.'); + QList<int> vi; + foreach (QString v, vs) + vi.append(v.toInt()); + QVersionNumber version = QVersionNumber(vi); + QJsonArray shapes = layerObj.value(QLatin1String("shapes")).toArray(); QJsonArray::const_iterator shapesIt = shapes.constBegin(); BMGroup* group = nullptr; while (shapesIt != shapes.end()) { QJsonObject childObj = (*shapesIt).toObject(); - BMShape *shape = BMShape::construct(childObj); + BMShape *shape = BMShape::construct(childObj, version); QVERIFY(shape != nullptr); if (shape->type() == BM_SHAPE_GROUP_IX) { group = static_cast<BMGroup *>(shape); diff --git a/tests/auto/bodymovin/shape/stroke/tst_bmstroke.cpp b/tests/auto/bodymovin/shape/stroke/tst_bmstroke.cpp index faa036f..c2faa5f 100644 --- a/tests/auto/bodymovin/shape/stroke/tst_bmstroke.cpp +++ b/tests/auto/bodymovin/shape/stroke/tst_bmstroke.cpp @@ -317,6 +317,12 @@ void tst_BMStroke::loadTestData(const QByteArray &filename) if (rootObj.empty()) QFAIL("Cannot parse test file"); + QStringList vs = rootObj.value(QLatin1String("v")).toString().split(u'.'); + QList<int> vi; + foreach (QString v, vs) + vi.append(v.toInt()); + QVersionNumber version = QVersionNumber(vi); + QJsonArray layers = rootObj.value(QLatin1String("layers")).toArray(); QJsonObject layerObj = layers[0].toObject(); int type = layerObj.value(QLatin1String("ty")).toInt(); @@ -328,7 +334,7 @@ void tst_BMStroke::loadTestData(const QByteArray &filename) BMShape* shape = nullptr; while (shapesIt != shapes.end()) { QJsonObject childObj = (*shapesIt).toObject(); - shape = BMShape::construct(childObj); + shape = BMShape::construct(childObj, version); QVERIFY(shape != nullptr); if (shape->type() == BM_SHAPE_STROKE_IX) break; diff --git a/tests/auto/bodymovin/shape/transform/tst_bmbasictransform.cpp b/tests/auto/bodymovin/shape/transform/tst_bmbasictransform.cpp index 912dbe1..a8491fa 100644 --- a/tests/auto/bodymovin/shape/transform/tst_bmbasictransform.cpp +++ b/tests/auto/bodymovin/shape/transform/tst_bmbasictransform.cpp @@ -392,6 +392,12 @@ void tst_BMBasicTransform::loadTestData(const QByteArray &filename) if (rootObj.empty()) QFAIL("Cannot parse test file"); + QStringList vs = rootObj.value(QLatin1String("v")).toString().split(u'.'); + QList<int> vi; + foreach (QString v, vs) + vi.append(v.toInt()); + QVersionNumber version = QVersionNumber(vi); + QJsonArray layers = rootObj.value(QLatin1String("layers")).toArray(); QJsonObject layerObj = layers[0].toObject(); int type = layerObj.value(QLatin1String("ty")).toInt(); @@ -399,7 +405,7 @@ void tst_BMBasicTransform::loadTestData(const QByteArray &filename) QFAIL("It's not shape layer"); QJsonObject transformObj = layerObj.value(QLatin1String("ks")).toObject(); - m_transform = new BMBasicTransform(transformObj); + m_transform = new BMBasicTransform(transformObj, version); QVERIFY(m_transform != nullptr); } diff --git a/tests/auto/bodymovin/shape/trimpath/tst_bmtrimpath.cpp b/tests/auto/bodymovin/shape/trimpath/tst_bmtrimpath.cpp index dcab10e..fd446af 100644 --- a/tests/auto/bodymovin/shape/trimpath/tst_bmtrimpath.cpp +++ b/tests/auto/bodymovin/shape/trimpath/tst_bmtrimpath.cpp @@ -279,6 +279,12 @@ void tst_BMTrimPath::loadTestData(const QByteArray &filename) if (rootObj.empty()) QFAIL("Cannot parse test file"); + QStringList vs = rootObj.value(QLatin1String("v")).toString().split(u'.'); + QList<int> vi; + foreach (QString v, vs) + vi.append(v.toInt()); + QVersionNumber version = QVersionNumber(vi); + QJsonArray layers = rootObj.value(QLatin1String("layers")).toArray(); QJsonObject layerObj = layers[0].toObject(); int type = layerObj.value(QLatin1String("ty")).toInt(); @@ -290,7 +296,7 @@ void tst_BMTrimPath::loadTestData(const QByteArray &filename) BMShape* shape = nullptr; while (shapesIt != shapes.end()) { QJsonObject childObj = (*shapesIt).toObject(); - shape = BMShape::construct(childObj); + shape = BMShape::construct(childObj, version); QVERIFY(shape != nullptr); if (shape->type() == BM_SHAPE_TRIM_IX) break; |