mirror of https://github.com/procxx/kepka.git
QtLottie: Add support for precomp layer.
This commit is contained in:
parent
da845a089e
commit
2f02198ac7
|
@ -173,6 +173,35 @@ void Animation::parse(const QByteArray &content) {
|
|||
_unsupported = true;
|
||||
}
|
||||
}
|
||||
|
||||
resolveAssets();
|
||||
}
|
||||
|
||||
void Animation::resolveAssets() {
|
||||
if (_assets.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::function<BMAsset*(QString)> resolver = [&](const QString &refId)
|
||||
-> BMAsset* {
|
||||
const auto i = _assetIndexById.find(refId);
|
||||
if (i == end(_assetIndexById)) {
|
||||
return nullptr;
|
||||
}
|
||||
const auto result = _assets[i->second].get();
|
||||
result->resolveAssets(resolver);
|
||||
return result->clone();
|
||||
};
|
||||
for (const auto &asset : _assets) {
|
||||
asset->resolveAssets(resolver);
|
||||
}
|
||||
|
||||
_treeBlueprint->resolveAssets([&](const QString &refId) {
|
||||
const auto i = _assetIndexById.find(refId);
|
||||
return (i != end(_assetIndexById))
|
||||
? _assets[i->second]->clone()
|
||||
: nullptr;
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace Lottie
|
||||
|
|
|
@ -62,6 +62,7 @@ public:
|
|||
|
||||
private:
|
||||
void parse(const QByteArray &content);
|
||||
void resolveAssets();
|
||||
|
||||
int _startFrame = 0;
|
||||
int _endFrame = 0;
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 1e81797fd7ec924f49e13866b08f57708537251a
|
||||
Subproject commit 57e54b3d5839431d935899c111f63daec3f53c30
|
|
@ -54,16 +54,19 @@ public:
|
|||
explicit BMAsset (const BMAsset &other) = default;
|
||||
~BMAsset() = default;
|
||||
|
||||
BMBase *clone() const override;
|
||||
BMAsset *clone() const override;
|
||||
|
||||
static BMAsset *construct(QJsonObject definition);
|
||||
|
||||
void parse(const QJsonObject &definition) override;
|
||||
|
||||
void resolveAssets(const std::function<BMAsset*(QString)> &resolver) override;
|
||||
|
||||
QString id() const;
|
||||
|
||||
private:
|
||||
QString m_id;
|
||||
bool m_resolved = false;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -49,8 +49,12 @@
|
|||
|
||||
#include <QtBodymovin/private/lottierenderer_p.h>
|
||||
|
||||
#include <functional>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class BMAsset;
|
||||
|
||||
class BODYMOVIN_EXPORT BMBase
|
||||
{
|
||||
public:
|
||||
|
@ -86,6 +90,8 @@ public:
|
|||
virtual void updateProperties(int frame);
|
||||
virtual void render(LottieRenderer &renderer) const;
|
||||
|
||||
virtual void resolveAssets(const std::function<BMAsset*(QString)> &resolver);
|
||||
|
||||
protected:
|
||||
void resolveTopRoot();
|
||||
BMBase *topRoot() const;
|
||||
|
|
|
@ -55,11 +55,7 @@ public:
|
|||
BMPreCompAsset(const QJsonObject &definition);
|
||||
~BMPreCompAsset() = default;
|
||||
|
||||
BMBase *clone() const override;
|
||||
|
||||
private:
|
||||
void parseLayers(const QJsonArray &definition);
|
||||
|
||||
BMPreCompAsset *clone() const override;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2018 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the lottie-qt module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:GPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 or (at your option) any later version
|
||||
** approved by the KDE Free Qt Foundation. The licenses are as published by
|
||||
** the Free Software Foundation and appearing in the file LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef BMPRECOMPLAYER_P_H
|
||||
#define BMPRECOMPLAYER_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtBodymovin/private/bmlayer_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QJsonObject;
|
||||
|
||||
class LottieRenderer;
|
||||
class BMShape;
|
||||
class BMTrimPath;
|
||||
class BMBasicTransform;
|
||||
|
||||
class BODYMOVIN_EXPORT BMPreCompLayer : public BMLayer
|
||||
{
|
||||
public:
|
||||
BMPreCompLayer() = default;
|
||||
explicit BMPreCompLayer(const BMPreCompLayer &other);
|
||||
BMPreCompLayer(const QJsonObject &definition);
|
||||
~BMPreCompLayer() override;
|
||||
|
||||
BMBase *clone() const override;
|
||||
|
||||
void updateProperties(int frame) override;
|
||||
void render(LottieRenderer &renderer) const;
|
||||
void resolveAssets(const std::function<BMAsset*(QString)> &resolver) override;
|
||||
|
||||
QString refId() const;
|
||||
|
||||
protected:
|
||||
QList<int> m_maskProperties;
|
||||
|
||||
private:
|
||||
QString m_refId;
|
||||
BMBase *m_layers = nullptr;
|
||||
int m_layersFrame = 0;
|
||||
bool m_resolving = false;
|
||||
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // BMPRECOMPLAYER_P_H
|
|
@ -126,10 +126,12 @@
|
|||
'<(lottie_loc)/bodymovin/bmasset.cpp',
|
||||
'<(lottie_loc)/bodymovin/bmprecompasset.cpp',
|
||||
'<(lottie_loc)/bodymovin/bmnulllayer.cpp',
|
||||
'<(lottie_loc)/bodymovin/bmprecomplayer.cpp',
|
||||
|
||||
'<(lottie_loc)/bodymovin/bmasset_p.h',
|
||||
'<(lottie_loc)/bodymovin/bmprecompasset_p.h',
|
||||
'<(lottie_loc)/bodymovin/bmnulllayer_p.h',
|
||||
'<(lottie_loc)/bodymovin/bmprecomplayer_p.h',
|
||||
],
|
||||
'conditions': [[ 'build_macold', {
|
||||
'xcode_settings': {
|
||||
|
|
Loading…
Reference in New Issue