QtLottie: Rebase onto upstream/dev.

This commit is contained in:
John Preston 2019-04-30 11:01:17 +04:00
parent 2fae2278f7
commit 33b3fa68f0
5 changed files with 20 additions and 62 deletions

View File

@ -149,48 +149,22 @@ void Animation::parse(const QByteArray &content) {
_treeBlueprint = std::make_unique<BMBase>();
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<BMLayer*>(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

@ -1 +1 @@
Subproject commit 92c5c182fd6578a4f9b2036dc86791da82c2ad6f
Subproject commit 99604e470f4ebebcb817e6ee5374b34d6b0dd8e4

View File

@ -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<BMBase *>& children();
const QList<BMBase *> &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<BMBase *> m_children;
friend class BMRasterRenderer;
friend class BMRenderer;
private:
BMBase *m_parent = nullptr;
QList<BMBase *> m_children;
// Handle to the topmost element on which this element resides
// Will be resolved when traversing effects
BMBase *m_topRoot = nullptr;

View File

@ -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);

View File

@ -41,7 +41,6 @@
// We mean it.
//
#include <QLatin1String>
#include <QPainterPath>
#include <QtBodymovin/private/bmbase_p.h>
@ -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<QLatin1String, int> setShapeMap();
static const QMap<QLatin1String, int> m_shapeMap;
};
QT_END_NAMESPACE