From 33b3fa68f0641d71bfeacd9ea64cd807fc8a1cca Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 30 Apr 2019 11:01:17 +0400 Subject: [PATCH] QtLottie: Rebase onto upstream/dev. --- .../SourceFiles/lottie/lottie_animation.cpp | 44 ++++--------------- Telegram/ThirdParty/qtlottie | 2 +- .../QtBodymovin/private/bmbase_p.h | 14 +++--- .../QtBodymovin/private/bmconstants_p.h | 14 ------ .../QtBodymovin/private/bmshape_p.h | 8 +--- 5 files changed, 20 insertions(+), 62 deletions(-) diff --git a/Telegram/SourceFiles/lottie/lottie_animation.cpp b/Telegram/SourceFiles/lottie/lottie_animation.cpp index 731813b62b..3977cdf197 100644 --- a/Telegram/SourceFiles/lottie/lottie_animation.cpp +++ b/Telegram/SourceFiles/lottie/lottie_animation.cpp @@ -149,48 +149,22 @@ void Animation::parse(const QByteArray &content) { _treeBlueprint = std::make_unique(); const auto blueprint = _treeBlueprint.get(); const auto layers = root.value(QLatin1String("layers")).toArray(); - //for (const auto &entry : ranges::view::reverse(layers)) { - // if (const auto layer = BMLayer::construct(entry.toObject())) { - // layer->setParent(blueprint); - - // // Mask layers must be rendered before the layers they affect to - // // although they appear before in layer hierarchy. For this reason - // // move a mask after the affected layers, so it will be rendered first - // if (layer->isMaskLayer()) { - // blueprint->prependChild(layer); - // } else { - // blueprint->appendChild(layer); - // } - // } else { - // _unsupported = true; - // } - //} for (const auto &entry : ranges::view::reverse(layers)) { if (const auto layer = BMLayer::construct(entry.toObject())) { layer->setParent(blueprint); - blueprint->addChild(layer); + + // Mask layers must be rendered before the layers they affect to + // although they appear before in layer hierarchy. For this reason + // move a mask after the affected layers, so it will be rendered first + if (layer->isMaskLayer()) { + blueprint->prependChild(layer); + } else { + blueprint->appendChild(layer); + } } else { _unsupported = true; } } - // Mask layers must be rendered before the layers they affect to - // although they appear before in layer hierarchy. For this reason - // move a mask after the affected layers, so it will be rendered first - auto &children = blueprint->children(); - auto moveTo = -1; - for (int i = 0; i < children.count(); i++) { - const auto layer = static_cast(children.at(i)); - if (layer->isClippedLayer()) - moveTo = i; - if (layer->isMaskLayer()) { - qCDebug(lcLottieQtBodymovinParser()) << "Move mask layer" - << children.at(i)->name() - << "before" << children.at(moveTo)->name(); - children.move(i, moveTo); - } - } - - } } // namespace Lottie diff --git a/Telegram/ThirdParty/qtlottie b/Telegram/ThirdParty/qtlottie index 92c5c182fd..99604e470f 160000 --- a/Telegram/ThirdParty/qtlottie +++ b/Telegram/ThirdParty/qtlottie @@ -1 +1 @@ -Subproject commit 92c5c182fd6578a4f9b2036dc86791da82c2ad6f +Subproject commit 99604e470f4ebebcb817e6ee5374b34d6b0dd8e4 diff --git a/Telegram/ThirdParty/qtlottie_helper/QtBodymovin/private/bmbase_p.h b/Telegram/ThirdParty/qtlottie_helper/QtBodymovin/private/bmbase_p.h index efbd4c05aa..90818dc532 100644 --- a/Telegram/ThirdParty/qtlottie_helper/QtBodymovin/private/bmbase_p.h +++ b/Telegram/ThirdParty/qtlottie_helper/QtBodymovin/private/bmbase_p.h @@ -74,10 +74,13 @@ public: virtual bool active(int frame) const; bool hidden() const; - BMBase *parent() const; + inline BMBase *parent() const { return m_parent; } void setParent(BMBase *parent); - void addChild(BMBase *child, bool priority = false); - QList& children(); + + const QList &children() const { return m_children; } + void prependChild(BMBase *child); + void appendChild(BMBase *child); + virtual BMBase *findChild(const QString &childName); virtual void updateProperties(int frame); @@ -95,13 +98,14 @@ protected: QString m_name; QString m_matchName; bool m_autoOrient = false; - BMBase *m_parent = nullptr; - QList m_children; friend class BMRasterRenderer; friend class BMRenderer; private: + BMBase *m_parent = nullptr; + QList m_children; + // Handle to the topmost element on which this element resides // Will be resolved when traversing effects BMBase *m_topRoot = nullptr; diff --git a/Telegram/ThirdParty/qtlottie_helper/QtBodymovin/private/bmconstants_p.h b/Telegram/ThirdParty/qtlottie_helper/QtBodymovin/private/bmconstants_p.h index 046e633a30..a88b49d1a2 100644 --- a/Telegram/ThirdParty/qtlottie_helper/QtBodymovin/private/bmconstants_p.h +++ b/Telegram/ThirdParty/qtlottie_helper/QtBodymovin/private/bmconstants_p.h @@ -55,20 +55,6 @@ #define BM_EFFECT_FILL 0x20000 -#define BM_SHAPE_ELLIPSE_STR "el" -#define BM_SHAPE_FILL_STR "fl" -#define BM_SHAPE_GFILL_STR "gf" -#define BM_SHAPE_GSTROKE_STR "gs" -#define BM_SHAPE_GROUP_STR "gr" -#define BM_SHAPE_RECT_STR "rc" -#define BM_SHAPE_ROUND_STR "rd" -#define BM_SHAPE_SHAPE_STR "sh" -#define BM_SHAPE_STAR_STR "sr" -#define BM_SHAPE_STROKE_STR "st" -#define BM_SHAPE_TRIM_STR "tm" -#define BM_SHAPE_TRANSFORM_STR "tr" -#define BM_SHAPE_REPEATER_STR "rp" - QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(lcLottieQtBodymovinParser); diff --git a/Telegram/ThirdParty/qtlottie_helper/QtBodymovin/private/bmshape_p.h b/Telegram/ThirdParty/qtlottie_helper/QtBodymovin/private/bmshape_p.h index 43ca20c21f..97caad6346 100644 --- a/Telegram/ThirdParty/qtlottie_helper/QtBodymovin/private/bmshape_p.h +++ b/Telegram/ThirdParty/qtlottie_helper/QtBodymovin/private/bmshape_p.h @@ -41,7 +41,6 @@ // We mean it. // -#include #include #include @@ -76,7 +75,7 @@ public: BMBase *clone() const override; - static BMShape *construct(QJsonObject definition, BMBase *parent = nullptr, int constructAs = BM_SHAPE_ANY_TYPE_IX); + static BMShape *construct(QJsonObject definition, BMBase *parent = nullptr); virtual const QPainterPath &path() const; virtual bool acceptsTrim() const; @@ -88,11 +87,6 @@ protected: QPainterPath m_path; BMTrimPath *m_appliedTrim = nullptr; int m_direction = 0; - -private: - static QMap setShapeMap(); - - static const QMap m_shapeMap; }; QT_END_NAMESPACE