First attempt to use QtLottie.

This commit is contained in:
John Preston 2019-04-27 13:12:53 +04:00
parent b2e5ab36d4
commit 22c2054dcf
40 changed files with 3383 additions and 0 deletions

3
.gitmodules vendored
View File

@ -16,3 +16,6 @@
[submodule "Telegram/ThirdParty/xxHash"]
path = Telegram/ThirdParty/xxHash
url = https://github.com/Cyan4973/xxHash.git
[submodule "Telegram/ThirdParty/qtlottie"]
path = Telegram/ThirdParty/qtlottie
url = https://github.com/telegramdesktop/qtlottie.git

View File

@ -0,0 +1,196 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "lottie/lottie_animation.h"
#include "lottie/lottie_frame_renderer.h"
#include "base/algorithm.h"
#include <range/v3/view/reverse.hpp>
#include <QtMath>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonValue>
#include <QFile>
#include <QPointF>
#include <QPainter>
#include <QImage>
#include <QTimer>
#include <QMetaObject>
#include <QLoggingCategory>
#include <QThread>
#include <math.h>
#include <QtBodymovin/private/bmbase_p.h>
#include <QtBodymovin/private/bmlayer_p.h>
#include "rasterrenderer/lottierasterrenderer.h"
namespace Lottie {
bool ValidateFile(const QString &path) {
if (!path.endsWith(qstr(".json"), Qt::CaseInsensitive)) {
return false;
}
return true;
}
std::unique_ptr<Animation> FromFile(const QString &path) {
if (!path.endsWith(qstr(".json"), Qt::CaseInsensitive)) {
return nullptr;
}
auto f = QFile(path);
if (!f.open(QIODevice::ReadOnly)) {
return nullptr;
}
const auto content = f.readAll();
if (content.isEmpty()) {
return nullptr;
}
return std::make_unique<Lottie::Animation>(content);
}
Animation::Animation(const QByteArray &content) {
parse(content);
}
Animation::~Animation() {
}
QImage Animation::frame(crl::time now) const {
if (_startFrame == _endFrame || _realWidth <= 0 || _realHeight <= 0) {
return QImage();
}
auto result = QImage(
qCeil(_realWidth),
qCeil(_realHeight),
QImage::Format_ARGB32_Premultiplied);
result.fill(Qt::transparent);
{
QPainter p(&result);
p.setRenderHints(QPainter::Antialiasing);
p.setRenderHints(QPainter::SmoothPixmapTransform);
const auto position = now;
const auto elapsed = int((_frameRate * position + 500) / 1000);
const auto frames = (_endFrame - _startFrame);
const auto frame = _options.loop
? (_startFrame + (elapsed % frames))
: std::min(_startFrame + elapsed, _endFrame);
auto tree = BMBase(*_treeBlueprint);
for (const auto element : tree.children()) {
if (element->active(frame)) {
element->updateProperties(frame);
}
}
LottieRasterRenderer renderer(&p);
for (const auto element : tree.children()) {
if (element->active(frame)) {
element->render(renderer);
}
}
}
return result;
}
int Animation::frameRate() const {
return _frameRate;
}
void Animation::play(const PlaybackOptions &options) {
_options = options;
_started = crl::now();
}
void Animation::parse(const QByteArray &content) {
const auto document = QJsonDocument::fromJson(content);
const auto root = document.object();
if (root.empty()) {
_failed = true;
return;
}
_startFrame = root.value(qstr("ip")).toVariant().toInt();
_endFrame = root.value(qstr("op")).toVariant().toInt();
_frameRate = root.value(qstr("fr")).toVariant().toInt();
_realWidth = root.value(qstr("w")).toVariant().toReal();
_realHeight = root.value(qstr("h")).toVariant().toReal();
const auto markers = root.value(qstr("markers")).toArray();
for (const auto &entry : markers) {
const auto object = entry.toObject();
const auto name = object.value(qstr("cm")).toString();
const auto frame = object.value(qstr("tm")).toInt();
_markers.emplace(name, frame);
if (object.value(qstr("dr")).toInt()) {
_unsupported = true;
}
}
if (root.value(qstr("assets")).toArray().count()) {
_unsupported = true;
}
if (root.value(qstr("chars")).toArray().count()) {
_unsupported = true;
}
_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);
} 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

View File

@ -0,0 +1,83 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "base/basic_types.h"
#include "base/flat_map.h"
#include <crl/crl_time.h>
#include <QString>
#include <QHash>
#include <QPainter>
class BMBase;
class BMLayer;
namespace Lottie {
class Animation;
bool ValidateFile(const QString &path);
std::unique_ptr<Animation> FromFile(const QString &path);
struct PlaybackOptions {
float64 speed = 1.;
bool loop = true;
};
class Animation final {
public:
explicit Animation(const QByteArray &content);
~Animation();
void play(const PlaybackOptions &options);
QImage frame(crl::time now) const;
int frameRate() const;
crl::time duration() const;
void play();
void pause();
void resume();
void stop();
[[nodiscard]] bool active() const;
[[nodiscard]] bool ready() const;
[[nodiscard]] bool unsupported() const;
[[nodiscard]] float64 speed() const;
void setSpeed(float64 speed); // 0.5 <= speed <= 2.
[[nodiscard]] bool playing() const;
[[nodiscard]] bool buffering() const;
[[nodiscard]] bool paused() const;
[[nodiscard]] bool finished() const;
private:
void parse(const QByteArray &content);
int _startFrame = 0;
int _endFrame = 0;
int _frameRate = 30;
qreal _realWidth = 0;
qreal _realHeight = 0;
base::flat_map<QString, int> _markers;
bool _initialized = false;
bool _unsupported = false;
bool _failed = false;
bool _paused = false;
crl::time _started = 0;
PlaybackOptions _options;
std::unique_ptr<BMBase> _treeBlueprint;
};
} // namespace Lottie

View File

@ -0,0 +1,229 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "lottie/lottie_frame_renderer.h"
#include "lottie/lottie_animation.h"
#include <QImage>
#include <QPainter>
#include <QHash>
#include <QMutexLocker>
#include <QLoggingCategory>
#include <QThread>
#include <QJsonDocument>
#include <QJsonArray>
#include <QtBodymovin/private/bmconstants_p.h>
#include <QtBodymovin/private/bmbase_p.h>
#include <QtBodymovin/private/bmlayer_p.h>
#include "rasterrenderer/lottierasterrenderer.h"
Q_LOGGING_CATEGORY(lcLottieQtBodymovinRenderThread, "qt.lottieqt.bodymovin.render.thread");
namespace Lottie {
//
//FrameRenderer *FrameRenderer::_rendererInstance = nullptr;
//
//FrameRenderer::~FrameRenderer()
//{
// QMutexLocker mlocker(&_mutex);
// qDeleteAll(_animData);
// qDeleteAll(_frameCache);
//}
//
//FrameRenderer *FrameRenderer::instance()
//{
// if (!_rendererInstance)
// _rendererInstance = new FrameRenderer;
//
// return _rendererInstance;
//}
//
//void FrameRenderer::deleteInstance()
//{
// delete _rendererInstance;
// _rendererInstance = nullptr;
//}
//
//void FrameRenderer::registerAnimator(Animation *animator)
//{
// QMutexLocker mlocker(&_mutex);
//
// qCDebug(lcLottieQtBodymovinRenderThread) << "Register Animator:"
// << static_cast<void*>(animator);
//
// Entry *entry = new Entry;
// entry->animator = animator;
// entry->startFrame = animator->startFrame();
// entry->endFrame = animator->endFrame();
// entry->currentFrame = animator->startFrame();
// entry->animDir = animator->direction();
// entry->bmTreeBlueprint = new BMBase;
// parse(entry->bmTreeBlueprint, animator->jsonSource());
// _animData.insert(animator, entry);
// _waitCondition.wakeAll();
//}
//
//void FrameRenderer::deregisterAnimator(Animation *animator)
//{
// QMutexLocker mlocker(&_mutex);
//
// qCDebug(lcLottieQtBodymovinRenderThread) << "Deregister Animator:"
// << static_cast<void*>(animator);
//
// Entry *entry = _animData.value(animator, nullptr);
// if (entry) {
// qDeleteAll(entry->frameCache);
// delete entry->bmTreeBlueprint;
// delete entry;
// _animData.remove(animator);
// }
//}
//
//bool FrameRenderer::gotoFrame(Animation *animator, int frame)
//{
// QMutexLocker mlocker(&_mutex);
// Entry *entry = _animData.value(animator, nullptr);
// if (entry) {
// qCDebug(lcLottieQtBodymovinRenderThread) << "Animator:"
// << static_cast<void*>(animator)
// << "Goto frame:" << frame;
// entry->currentFrame = frame;
// entry->animDir = animator->direction();
// pruneFrameCache(entry);
// _waitCondition.wakeAll();
// return true;
// }
// return false;
//}
//
//FrameRenderer::FrameRenderer() : QThread() {
// const QByteArray cacheStr = qgetenv("QLOTTIE_RENDER_CACHE_SIZE");
// int cacheSize = cacheStr.toInt();
// if (cacheSize > 0) {
// qCDebug(lcLottieQtBodymovinRenderThread) << "Setting frame cache size to" << cacheSize;
// _cacheSize = cacheSize;
// }
//}
//
//void FrameRenderer::pruneFrameCache(Entry* e)
//{
// QHash<int, BMBase*>::iterator it = e->frameCache.begin();
//
// while (it != e->frameCache.end()) {
// if (it.key() == e->currentFrame) {
// ++it;
// } else {
// delete it.value();
// it = e->frameCache.erase(it);
// }
// }
//}
//
//BMBase *FrameRenderer::getFrame(Animation *animator, int frameNumber)
//{
// QMutexLocker mlocker(&_mutex);
//
// Entry *entry = _animData.value(animator, nullptr);
// if (entry)
// return entry->frameCache.value(frameNumber, nullptr);
// else
// return nullptr;
//}
//
//void FrameRenderer::prerender(Entry *animEntry)
//{
// while (animEntry->frameCache.count() < _cacheSize) {
// if (!animEntry->frameCache.contains(animEntry->currentFrame)) {
// BMBase *bmTree = new BMBase(*animEntry->bmTreeBlueprint);
//
// for (BMBase *elem : bmTree->children()) {
// if (elem->active(animEntry->currentFrame))
// elem->updateProperties( animEntry->currentFrame);
// }
//
// animEntry->frameCache.insert( animEntry->currentFrame, bmTree);
// }
//
// qCDebug(lcLottieQtBodymovinRenderThread) << "Animator:"
// << static_cast<void*>(animEntry->animator)
// << "Frame drawn to cache. FN:"
// << animEntry->currentFrame;
// emit frameReady(animEntry->animator, animEntry->currentFrame);
//
// animEntry->currentFrame += animEntry->animDir;
//
// if (animEntry->currentFrame > animEntry->endFrame) {
// animEntry->currentFrame = animEntry->startFrame;
// } else if (animEntry->currentFrame < animEntry->startFrame) {
// animEntry->currentFrame = animEntry->endFrame;
// }
// }
//}
//
//void FrameRenderer::frameRendered(Animation *animator, int frameNumber)
//{
// QMutexLocker mlocker(&_mutex);
// Entry *entry = _animData.value(animator, nullptr);
// if (entry) {
// qCDebug(lcLottieQtBodymovinRenderThread) << "Animator:" << static_cast<void*>(animator)
// << "Remove frame from cache" << frameNumber;
//
// BMBase *root = entry->frameCache.value(frameNumber, nullptr);
// delete root;
// entry->frameCache.remove(frameNumber);
// _waitCondition.wakeAll();
// }
//}
//
//void FrameRenderer::run()
//{
// qCDebug(lcLottieQtBodymovinRenderThread) << "rendering thread" << QThread::currentThread();
//
// while (!isInterruptionRequested()) {
// QMutexLocker mlocker(&_mutex);
//
// for (Entry *e : qAsConst(_animData))
// prerender(e);
//
// _waitCondition.wait(&_mutex);
// }
//}
//
//int FrameRenderer::parse(BMBase* rootElement, const QByteArray &jsonSource)
//{
// QJsonDocument doc = QJsonDocument::fromJson(jsonSource);
// QJsonObject rootObj = doc.object();
//
// if (rootObj.empty())
// return -1;
//
// QJsonArray jsonLayers = rootObj.value(QLatin1String("layers")).toArray();
// QJsonArray::const_iterator jsonLayerIt = jsonLayers.constEnd();
// while (jsonLayerIt != jsonLayers.constBegin()) {
// jsonLayerIt--;
// QJsonObject jsonLayer = (*jsonLayerIt).toObject();
// BMLayer *layer = BMLayer::construct(jsonLayer);
// if (layer) {
// layer->setParent(rootElement);
// // 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())
// rootElement->prependChild(layer);
// else
// rootElement->appendChild(layer);
// }
// }
//
// return 0;
//}
} // namespace Lottie

View File

@ -0,0 +1,84 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include <QHash>
#include <QThread>
#include <QMutex>
#include <QWaitCondition>
class BMBase;
class QImage;
namespace Lottie {
class Animation;
//
//class FrameRenderer : public QThread {
// Q_OBJECT
//
// struct Entry {
// Animation* animator = nullptr;
// BMBase *bmTreeBlueprint = nullptr;
// int startFrame = 0;
// int endFrame = 0;
// int currentFrame = 0;
// int animDir = 1;
// QHash<int, BMBase*> frameCache;
// };
//
//public:
// ~FrameRenderer();
//
// FrameRenderer(const FrameRenderer &other) = delete;
// void operator=(const FrameRenderer &other) = delete;
//
// static FrameRenderer *instance();
// static void deleteInstance();
//
// BMBase *getFrame(Animation *animator, int frameNumber);
//
//signals:
// void frameReady(Animation *animator, int frameNumber);
//
//public slots:
// void registerAnimator(Animation *animator);
// void deregisterAnimator(Animation *animator);
//
// bool gotoFrame(Animation *animator, int frame);
//
// void frameRendered(Animation *animator, int frameNumber);
//
//protected:
// void run() override;
//
// int parse(BMBase* rootElement, const QByteArray &jsonSource);
//
// void prerender(Entry *animEntry);
//
//protected:
// QHash<Animation*, Entry*> _animData;
// int _cacheSize = 2;
// int _currentFrame = 0;
//
// Animation *_animation = nullptr;
// QHash<int, QImage*> _frameCache;
//
//private:
// FrameRenderer();
//
// void pruneFrameCache(Entry* e);
//
//private:
// static FrameRenderer *_rendererInstance;
//
// QMutex _mutex;
// QWaitCondition _waitCondition;
//};
} // namespace Lottie

View File

@ -0,0 +1,9 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "lottie/lottie_pch.h"

View File

@ -0,0 +1,10 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#define qAsConst(X) std::as_const(X)

View File

@ -38,6 +38,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "auth_session.h"
#include "layout.h"
#include "storage/file_download.h"
#include "lottie/lottie_animation.h"
#include "calls/calls_instance.h"
#include "styles/style_mediaview.h"
#include "styles/style_history.h"

1
Telegram/ThirdParty/qtlottie vendored Submodule

@ -0,0 +1 @@
Subproject commit 553ec1bc799f344a12e34c91720e13a469d85365

View File

@ -0,0 +1,44 @@
/****************************************************************************
**
** 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 BMGLOBAL_H
#define BMGLOBAL_H
#include <QtGlobal>
#if defined(BODYMOVIN_LIBRARY)
# define BODYMOVIN_EXPORT Q_DECL_EXPORT
#else
# define BODYMOVIN_EXPORT Q_DECL_IMPORT
#endif
QT_BEGIN_NAMESPACE
QT_END_NAMESPACE
#endif // BMGLOBAL_H

View File

@ -0,0 +1,61 @@
/****************************************************************************
**
** 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 BEZIEREASING_P_H
#define BEZIEREASING_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 <private/qbezier_p.h>
QT_BEGIN_NAMESPACE
class BezierEasing
{
public:
void addCubicBezierSegment(const QPointF &c1, const QPointF &c2, const QPointF &endPoint);
qreal valueForProgress(qreal progress) const;
private:
qreal tForX(qreal x) const;
QBezier mBezier;
};
QT_END_NAMESPACE
#endif // BEZIEREASING_P_H

View File

@ -0,0 +1,112 @@
/****************************************************************************
**
** 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 BMBASE_P_H
#define BMBASE_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 <QJsonObject>
#include <QList>
#include <QtBodymovin/bmglobal.h>
#include <QtBodymovin/private/bmconstants_p.h>
#include <QtBodymovin/private/lottierenderer_p.h>
QT_BEGIN_NAMESPACE
class BODYMOVIN_EXPORT BMBase
{
public:
BMBase() = default;
explicit BMBase(const BMBase &other);
virtual ~BMBase();
virtual BMBase *clone() const;
virtual bool setProperty(BMLiteral::PropertyType propertyType, QVariant value);
QString name() const;
void setName(const QString &name);
int type() const;
void setType(int type);
virtual void parse(const QJsonObject &definition);
const QJsonObject& definition() const;
virtual bool active(int frame) const;
bool hidden() const;
BMBase *parent() const;
void setParent(BMBase *parent);
void addChild(BMBase *child, bool priority = false);
QList<BMBase *>& children();
virtual BMBase *findChild(const QString &childName);
virtual void updateProperties(int frame);
virtual void render(LottieRenderer &renderer) const;
protected:
void resolveTopRoot();
BMBase *topRoot() const;
const QJsonObject resolveExpression(const QJsonObject& definition);
protected:
QJsonObject m_definition;
int m_type;
bool m_hidden = false;
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:
// Handle to the topmost element on which this element resides
// Will be resolved when traversing effects
BMBase *m_topRoot = nullptr;
};
QT_END_NAMESPACE
#endif // BMBASE_P_H

View File

@ -0,0 +1,87 @@
/****************************************************************************
**
** 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 BMBASICTRANSFORM_P_H
#define BMBASICTRANSFORM_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 <QPointF>
#include <QtBodymovin/private/bmshape_p.h>
#include <QtBodymovin/private/bmproperty_p.h>
#include <QtBodymovin/private/bmspatialproperty_p.h>
QT_BEGIN_NAMESPACE
class QJsonObject;
class BODYMOVIN_EXPORT BMBasicTransform : public BMShape
{
public:
BMBasicTransform() = default;
explicit BMBasicTransform(const BMBasicTransform &other);
BMBasicTransform(const QJsonObject &definition, BMBase *parent = nullptr);
BMBase *clone() const override;
void construct(const QJsonObject &definition);
void updateProperties(int frame) override;
void render(LottieRenderer &renderer) const override;
QPointF anchorPoint() const;
virtual QPointF position() const;
QPointF scale() const;
qreal rotation() const;
qreal opacity() const;
protected:
BMSpatialProperty m_anchorPoint;
bool m_splitPosition = false;
BMSpatialProperty m_position;
BMProperty<qreal> m_xPos;
BMProperty<qreal> m_yPos;
BMProperty2D<QPointF> m_scale;
BMProperty<qreal> m_rotation;
BMProperty<qreal> m_opacity;
};
QT_END_NAMESPACE
#endif // BMBASICTRANSFORM_P_H

View File

@ -0,0 +1,103 @@
/****************************************************************************
**
** 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 BMCONSTANTS_P_H
#define BMCONSTANTS_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 <QObject>
#include <QLoggingCategory>
#include <QtBodymovin/bmglobal.h>
#define BM_LAYER_PRECOMP_IX 0x10000
#define BM_LAYER_SOLID_IX 0x10001
#define BM_LAYER_IMAGE_IX 0x10002
#define BM_LAYER_NULL_IX 0x10004
#define BM_LAYER_SHAPE_IX 0x10008
#define BM_LAYER_TEXT_IX 0x1000f
#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);
Q_DECLARE_LOGGING_CATEGORY(lcLottieQtBodymovinUpdate);
Q_DECLARE_LOGGING_CATEGORY(lcLottieQtBodymovinRender);
Q_DECLARE_LOGGING_CATEGORY(lcLottieQtBodymovinRenderThread);
class BODYMOVIN_EXPORT BMLiteral : public QObject
{
Q_OBJECT
public:
enum ElementType {
Animation = 0,
LayerImage,
LayerNull,
LayerPrecomp,
LayerShape
};
enum PropertyType {
RectPosition,
RectSize,
RectRoundness
};
Q_ENUM(PropertyType)
explicit BMLiteral(QObject *parent = nullptr) : QObject(parent) {}
};
QT_END_NAMESPACE
#endif // BMCONSTANTS_P_H

View File

@ -0,0 +1,86 @@
/****************************************************************************
**
** 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 BMELLIPSE_P_H
#define BMELLIPSE_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 <QRect>
#include <QPointF>
#include <QBrush>
#include <QPen>
#include <QPainterPath>
#include <QtBodymovin/private/bmshape_p.h>
#include <QtBodymovin/private/bmproperty_p.h>
#include <QtBodymovin/private/bmspatialproperty_p.h>
#include <QtBodymovin/private/bmfill_p.h>
#include <QtBodymovin/private/bmstroke_p.h>
QT_BEGIN_NAMESPACE
class QJsonObject;
class BODYMOVIN_EXPORT BMEllipse : public BMShape
{
public:
BMEllipse() = default;
explicit BMEllipse(const BMEllipse &other);
BMEllipse(const QJsonObject &definition, BMBase *parent = nullptr);
BMBase *clone() const override;
void construct(const QJsonObject &definition);
void updateProperties(int frame) override;
void render(LottieRenderer &renderer) const override;
bool acceptsTrim() const override;
QPointF position() const;
QSizeF size() const;
protected:
BMSpatialProperty m_position;
BMProperty2D<QSizeF> m_size;
};
QT_END_NAMESPACE
#endif // BMELLIPSE_P_H

View File

@ -0,0 +1,75 @@
/****************************************************************************
**
** 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 BMFILL_P_H
#define BMFILL_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 <QColor>
#include <QVector4D>
#include <QtBodymovin/private/bmgroup_p.h>
#include <QtBodymovin/private/bmproperty_p.h>
QT_BEGIN_NAMESPACE
class BODYMOVIN_EXPORT BMFill : public BMShape
{
public:
BMFill() = default;
explicit BMFill(const BMFill &other);
BMFill(const QJsonObject &definition, BMBase *parent = nullptr);
BMBase *clone() const override;
void updateProperties(int frame) override;
void render(LottieRenderer &renderer) const override;
QColor color() const;
qreal opacity() const;
protected:
BMProperty4D<QVector4D> m_color;
BMProperty<qreal> m_opacity;
};
QT_END_NAMESPACE
#endif // BMFILL_P_H

View File

@ -0,0 +1,77 @@
/****************************************************************************
**
** 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 BMFILLEFFECT_P_H
#define BMFILLEFFECT_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 <QColor>
#include <QVector4D>
#include <QtBodymovin/private/bmbase_p.h>
#include <QtBodymovin/private/bmproperty_p.h>
QT_BEGIN_NAMESPACE
class QJsonObject;
class BODYMOVIN_EXPORT BMFillEffect : public BMBase
{
public:
BMFillEffect() = default;
explicit BMFillEffect(const BMFillEffect &other);
BMBase *clone() const override;
void construct(const QJsonObject &definition);
void updateProperties(int frame) override;
void render(LottieRenderer &renderer) const override;
QColor color() const;
qreal opacity() const;
protected:
BMProperty4D<QVector4D> m_color;
BMProperty<qreal> m_opacity;
};
QT_END_NAMESPACE
#endif // BMFILLEFFECT_P_H

View File

@ -0,0 +1,107 @@
/****************************************************************************
**
** 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 BMFEEFORMSHAPE_P_H
#define BMFEEFORMSHAPE_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 <QPainterPath>
#include <QJsonArray>
#include <QtBodymovin/bmglobal.h>
#include <QtBodymovin/private/bmshape_p.h>
#include <QtBodymovin/private/bmtrimpath_p.h>
#include <QtBodymovin/private/lottierenderer_p.h>
QT_BEGIN_NAMESPACE
class QJsonObject;
class BODYMOVIN_EXPORT BMFreeFormShape : public BMShape
{
public:
BMFreeFormShape();
explicit BMFreeFormShape(const BMFreeFormShape &other);
BMFreeFormShape(const QJsonObject &definition, BMBase *parent = nullptr);
BMBase *clone() const override;
void construct(const QJsonObject &definition);
void updateProperties(int frame) override;
void render(LottieRenderer &renderer) const override;
bool acceptsTrim() const override;
protected:
struct VertexInfo {
BMProperty2D<QPointF> pos;
BMProperty2D<QPointF> ci;
BMProperty2D<QPointF> co;
};
void parseShapeKeyframes(QJsonObject &keyframes);
void buildShape(const QJsonObject &keyframe);
void buildShape(int frame);
void parseEasedVertices(const QJsonObject &keyframe, int startFrame);
QHash<int, QJsonObject> m_vertexMap;
QList<VertexInfo> m_vertexList;
QMap<int, bool> m_closedShape;
private:
struct VertexBuildInfo
{
QJsonArray posKeyframes;
QJsonArray ciKeyframes;
QJsonArray coKeyframes;
};
void finalizeVertices();
QMap<int, VertexBuildInfo*> m_vertexInfos;
QJsonObject createKeyframe(QJsonArray startValue, QJsonArray endValue,
int startFrame, QJsonObject easingIn,
QJsonObject easingOut);
};
QT_END_NAMESPACE
#endif // BMFEEFORMSHAPE_P_H

View File

@ -0,0 +1,91 @@
/****************************************************************************
**
** 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 BMGFILL_P_H
#define BMGFILL_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 <QVector4D>
#include <QGradient>
#include <QtBodymovin/private/bmgroup_p.h>
#include <QtBodymovin/private/bmproperty_p.h>
#include <QtBodymovin/private/bmproperty_p.h>
#include <QtBodymovin/private/bmspatialproperty_p.h>
QT_BEGIN_NAMESPACE
class BODYMOVIN_EXPORT BMGFill : public BMShape
{
public:
BMGFill() = default;
explicit BMGFill(const BMGFill &other);
BMGFill(const QJsonObject &definition, BMBase *parent = nullptr);
~BMGFill() override;
BMBase *clone() const override;
void updateProperties(int frame) override;
void render(LottieRenderer &renderer) const override;
QGradient *value() const;
QGradient::Type gradientType() const;
QPointF startPoint() const;
QPointF endPoint() const;
qreal highlightLength() const;
qreal highlightAngle() const;
qreal opacity() const;
private:
void setGradient();
protected:
BMProperty<qreal> m_opacity;
BMSpatialProperty m_startPoint;
BMSpatialProperty m_endPoint;
BMProperty<qreal> m_highlightLength;
BMProperty<qreal> m_highlightAngle;
QList<BMProperty4D<QVector4D>> m_colors;
QGradient *m_gradient = nullptr;
};
QT_END_NAMESPACE
#endif // BMGFILL_P_H

View File

@ -0,0 +1,76 @@
/****************************************************************************
**
** 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 BMGROUP_P_H
#define BMGROUP_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 <QJsonObject>
#include <QColor>
#include <QtBodymovin/private/bmshape_p.h>
#include <QtBodymovin/private/bmproperty_p.h>
#include <QtBodymovin/private/bmpathtrimmer_p.h>
QT_BEGIN_NAMESPACE
class BMFill;
class BMTrimPath;
class BMPathTrimmer;
class BODYMOVIN_EXPORT BMGroup : public BMShape
{
public:
BMGroup() = default;
BMGroup(const QJsonObject &definition, BMBase *parent = nullptr);
BMBase *clone() const override;
void construct(const QJsonObject& definition);
void updateProperties(int frame) override;
void render(LottieRenderer &renderer) const override;
bool acceptsTrim() const override;
void applyTrim(const BMTrimPath &trimmer) override;
};
QT_END_NAMESPACE
#endif // BMGROUP_P_H

View File

@ -0,0 +1,107 @@
/****************************************************************************
**
** 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 BMLAYER_P_H
#define BMLAYER_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/bmbase_p.h>
QT_BEGIN_NAMESPACE
class LottieRenderer;
class BODYMOVIN_EXPORT BMLayer : public BMBase
{
public:
enum MatteClipMode {NoClip, Alpha, InvertedAlpha, Luminence, InvertedLuminence};
BMLayer() = default;
explicit BMLayer (const BMLayer &other);
~BMLayer() override;
BMBase *clone() const override;
static BMLayer *construct(QJsonObject definition);
bool active(int frame) const override;
void parse(const QJsonObject &definition) override;
void updateProperties(int frame) override;
void render(LottieRenderer &renderer) const override;
BMBase *findChild(const QString &childName) override;
bool isClippedLayer() const;
bool isMaskLayer() const;
MatteClipMode clipMode() const;
int layerId() const;
BMBasicTransform *transform() const;
protected:
void renderEffects(LottieRenderer &renderer) const;
virtual BMLayer *resolveLinkedLayer();
virtual BMLayer *linkedLayer() const;
int m_layerIndex = 0;
int m_startFrame;
int m_endFrame;
qreal m_startTime;
int m_blendMode;
bool m_3dLayer = false;
BMBase *m_effects = nullptr;
qreal m_stretch;
BMBasicTransform *m_layerTransform = nullptr;
int m_parentLayer = 0;
int m_td = 0;
MatteClipMode m_clipMode = NoClip;
private:
void parseEffects(const QJsonArray &definition, BMBase *effectRoot = nullptr);
BMLayer *m_linkedLayer = nullptr;
};
QT_END_NAMESPACE
#endif // BMLAYER_P_H

View File

@ -0,0 +1,78 @@
/****************************************************************************
**
** 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 BMPATHTRIMMER_P_H
#define BMPATHTRIMMER_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 <QList>
#include <QtBodymovin/bmglobal.h>
QT_BEGIN_NAMESPACE
class QJsonObject;
class BMTrimPath;
class LottieRenderer;
class BMBase;
class BMShape;
class BODYMOVIN_EXPORT BMPathTrimmer
{
public:
BMPathTrimmer(BMBase *root);
void addTrim(BMTrimPath* trim);
bool inUse() const;
void applyTrim(BMShape *shape);
void updateProperties(int frame);
void render(LottieRenderer &renderer) const;
private:
BMBase *m_root = nullptr;
QList<BMTrimPath*> m_trimPaths;
BMTrimPath *m_appliedTrim = nullptr;
};
QT_END_NAMESPACE
#endif // BMPATHTRIMMER_P_H

View File

@ -0,0 +1,395 @@
/****************************************************************************
**
** 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 BMPROPERTY_P_H
#define BMPROPERTY_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 <QJsonObject>
#include <QJsonArray>
#include <QJsonValue>
#include <QPointF>
#include <QLoggingCategory>
#include <QtMath>
#include <QDebug>
#include <QtBodymovin/private/bmconstants_p.h>
#include <QtBodymovin/private/bmlayer_p.h>
#include <QtBodymovin/private/beziereasing_p.h>
QT_BEGIN_NAMESPACE
template<typename T>
struct EasingSegment {
bool complete = false;
double startFrame = 0;
double endFrame = 0;
T startValue;
T endValue;
BezierEasing easing;
};
template<typename T>
class BODYMOVIN_EXPORT BMProperty
{
public:
virtual ~BMProperty() = default;
virtual void construct(const QJsonObject &definition)
{
if (definition.value(QLatin1String("s")).toVariant().toInt())
qCWarning(lcLottieQtBodymovinParser)
<< "Property is split into separate x and y but it is not supported";
bool fromExpression = definition.value(QLatin1String("fromExpression")).toBool();
m_animated = definition.value(QLatin1String("a")).toDouble() > 0;
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;
}
m_value = T();
} else
m_value = getValue(definition.value(QLatin1String("k")));
}
void setValue(const T& value)
{
m_value = value;
}
const T& value() const
{
return m_value;
}
virtual bool update(int frame)
{
if (!m_animated)
return false;
int adjustedFrame = qBound(m_startFrame, frame, m_endFrame);
if (const EasingSegment<T> *easing = getEasingSegment(adjustedFrame)) {
qreal progress;
if (easing->endFrame == easing->startFrame)
progress = 1;
else
progress = ((adjustedFrame - easing->startFrame) * 1.0) /
(easing->endFrame - easing->startFrame);
qreal easedValue = easing->easing.valueForProgress(progress);
m_value = easing->startValue + easedValue *
((easing->endValue - easing->startValue));
return true;
}
return false;
}
protected:
void addEasing(EasingSegment<T>& easing)
{
if (m_easingCurves.length()) {
EasingSegment<T> prevEase = m_easingCurves.last();
// The end value has to be hand picked to the
// previous easing segment, as the json data does
// not contain end values for segments
prevEase.endFrame = easing.startFrame - 1;
m_easingCurves.replace(m_easingCurves.length() - 1, prevEase);
}
m_easingCurves.push_back(easing);
}
const EasingSegment<T>* getEasingSegment(int frame)
{
// TODO: Improve with a faster search algorithm
const EasingSegment<T> *easing = m_currentEasing;
if (!easing || easing->startFrame < frame ||
easing->endFrame > frame) {
for (int i=0; i < m_easingCurves.length(); i++) {
if (m_easingCurves.at(i).startFrame <= frame &&
m_easingCurves.at(i).endFrame >= frame) {
m_currentEasing = &m_easingCurves.at(i);
break;
}
}
}
if (!m_currentEasing) {
qCWarning(lcLottieQtBodymovinParser)
<< "Property is animated but easing cannot be found";
}
return m_currentEasing;
}
virtual EasingSegment<T> parseKeyframe(const QJsonObject keyframe,
bool fromExpression)
{
Q_UNUSED(fromExpression);
EasingSegment<T> easing;
int startTime = keyframe.value(QLatin1String("t")).toVariant().toInt();
// AE exported Bodymovin file includes the last
// key frame but no other properties.
// No need to process in that case
if (!keyframe.contains(QLatin1String("s")) && !keyframe.contains(QLatin1String("e"))) {
// In this case start time is the last frame for the property
this->m_endFrame = startTime;
easing.startFrame = startTime;
easing.endFrame = startTime;
if (m_easingCurves.length()) {
easing.startValue = m_easingCurves.last().endValue;
easing.endValue = m_easingCurves.last().endValue;
}
return easing;
}
if (m_startFrame > startTime)
m_startFrame = startTime;
easing.startValue = getValue(keyframe.value(QLatin1String("s")).toArray());
easing.endValue = getValue(keyframe.value(QLatin1String("e")).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())
return getValue(value.toArray());
else {
QVariant val = value.toVariant();
if (val.canConvert<T>()) {
T t = val.value<T>();
return t;
}
else
return T();
}
}
virtual T getValue(const QJsonArray &value)
{
QVariant val = value.at(0).toVariant();
if (val.canConvert<T>()) {
T t = val.value<T>();
return t;
}
else
return T();
}
protected:
bool m_animated = false;
QList<EasingSegment<T>> m_easingCurves;
const EasingSegment<T> *m_currentEasing = nullptr;
int m_startFrame = INT_MAX;
int m_endFrame = 0;
T m_value;
};
template <typename T>
class BODYMOVIN_EXPORT BMProperty2D : public BMProperty<T>
{
protected:
T getValue(const QJsonArray &value) override
{
if (value.count() > 1)
return T(value.at(0).toDouble(),
value.at(1).toDouble());
else
return T();
}
EasingSegment<T> parseKeyframe(const QJsonObject keyframe,
bool fromExpression) override
{
QJsonArray startValues = keyframe.value(QLatin1String("s")).toArray();
QJsonArray endValues = keyframe.value(QLatin1String("e")).toArray();
int startTime = keyframe.value(QLatin1String("t")).toVariant().toInt();
EasingSegment<T> easingCurve;
easingCurve.startFrame = startTime;
// AE exported Bodymovin file includes the last
// key frame but no other properties.
// No need to process in that case
if (startValues.isEmpty() && endValues.isEmpty()) {
// In this case start time is the last frame for the property
this->m_endFrame = startTime;
easingCurve.startFrame = startTime;
easingCurve.endFrame = startTime;
if (this->m_easingCurves.length()) {
easingCurve.startValue = this->m_easingCurves.last().endValue;
easingCurve.endValue = this->m_easingCurves.last().endValue;
}
return easingCurve;
}
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();
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;
}
};
template <typename T>
class BODYMOVIN_EXPORT BMProperty4D : public BMProperty<T>
{
public:
bool update(int frame) override
{
if (!this->m_animated)
return false;
int adjustedFrame = qBound(this->m_startFrame, frame, this->m_endFrame);
if (const EasingSegment<T> *easing = BMProperty<T>::getEasingSegment(adjustedFrame)) {
qreal progress = ((adjustedFrame - this->m_startFrame) * 1.0) /
(this->m_endFrame - this->m_startFrame);
qreal easedValue = easing->easing.valueForProgress(progress);
// For the time being, 4D vectors are used only for colors, and
// the value must be restricted to between [0, 1]
easedValue = qBound(0.0, easedValue, 1.0);
T sv = easing->startValue;
T ev = easing->endValue;
qreal x = sv.x() + easedValue * (ev.x() - sv.x());
qreal y = sv.y() + easedValue * (ev.y() - sv.y());
qreal z = sv.z() + easedValue * (ev.z() - sv.z());
qreal w = sv.w() + easedValue * (ev.w() - sv.w());
this->m_value = T(x, y, z, w);
}
return true;
}
protected:
T getValue(const QJsonArray &value) override
{
if (value.count() > 3)
return T(value.at(0).toDouble(), value.at(1).toDouble(),
value.at(2).toDouble(), value.at(3).toDouble());
else
return T();
}
};
QT_END_NAMESPACE
#endif // BMPROPERTY_P_H

View File

@ -0,0 +1,86 @@
/****************************************************************************
**
** 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 BMRECT_P_H
#define BMRECT_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 <QRect>
#include <QPointF>
#include <QBrush>
#include <QPen>
#include <QtBodymovin/private/bmshape_p.h>
#include <QtBodymovin/private/bmproperty_p.h>
#include <QtBodymovin/private/bmspatialproperty_p.h>
#include <QtBodymovin/private/bmfill_p.h>
#include <QtBodymovin/private/bmstroke_p.h>
QT_BEGIN_NAMESPACE
class BODYMOVIN_EXPORT BMRect : public BMShape
{
public:
BMRect() = default;
explicit BMRect(const BMRect &other);
BMRect(const QJsonObject &definition, BMBase *parent = nullptr);
BMBase *clone() const override;
void construct(const QJsonObject &definition);
bool setProperty(BMLiteral::PropertyType propertyType, QVariant value) override;
void updateProperties(int frame) override;
void render(LottieRenderer &renderer) const override;
bool acceptsTrim() const override;
QPointF position() const;
QSizeF size() const;
qreal roundness() const;
protected:
BMSpatialProperty m_position;
BMProperty2D<QSizeF> m_size;
BMProperty<qreal> m_roundness;
};
QT_END_NAMESPACE
#endif // BMRECT_P_H

View File

@ -0,0 +1,79 @@
/****************************************************************************
**
** 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 BMREPEATER_P_H
#define BMREPEATER_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/bmglobal.h>
#include <QtBodymovin/private/bmshape_p.h>
#include <QtBodymovin/private/bmproperty_p.h>
#include <QtBodymovin/private/bmrepeatertransform_p.h>
QT_BEGIN_NAMESPACE
class QJsonObject;
class BODYMOVIN_EXPORT BMRepeater : public BMShape
{
public:
BMRepeater() = default;
explicit BMRepeater(const BMRepeater &other);
BMRepeater(const QJsonObject &definition, BMBase *parent = nullptr);
BMBase *clone() const override;
void construct(const QJsonObject& definition);
void updateProperties(int frame) override;
void render(LottieRenderer &renderer) const override;
int copies() const;
qreal offset() const;
const BMRepeaterTransform &transform() const;
protected:
BMProperty<int> m_copies;
BMProperty<qreal> m_offset;
BMRepeaterTransform m_transform;
};
QT_END_NAMESPACE
#endif // BMREPEATER_P_H

View File

@ -0,0 +1,79 @@
/****************************************************************************
**
** 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 BMREPEATERTRANSFORM_P_H
#define BMREPEATERTRANSFORM_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/bmbasictransform_p.h>
QT_BEGIN_NAMESPACE
class QJsonObject;
class BODYMOVIN_EXPORT BMRepeaterTransform : public BMBasicTransform
{
public:
BMRepeaterTransform() = default;
explicit BMRepeaterTransform(const BMRepeaterTransform &other);
BMRepeaterTransform(const QJsonObject &definition, BMBase *parent);
BMBase *clone() const override;
void construct(const QJsonObject &definition);
void updateProperties(int frame) override;
void render(LottieRenderer &renderer) const override;
qreal startOpacity() const;
qreal endOpacity() const;
void setInstanceCount(int copies);
qreal opacityAtInstance(int instance) const;
protected:
int m_copies = 0;
BMProperty<qreal> m_startOpacity;
BMProperty<qreal> m_endOpacity;
QList<qreal> m_opacities;
};
QT_END_NAMESPACE
#endif // BMREPEATERTRANSFORM_P_H

View File

@ -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 BMROUND_P_H
#define BMROUND_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 <QRect>
#include <QPointF>
#include <QBrush>
#include <QPen>
#include <QtBodymovin/private/bmshape_p.h>
#include <QtBodymovin/private/bmproperty_p.h>
#include <QtBodymovin/private/bmspatialproperty_p.h>
#include <QtBodymovin/private/bmfill_p.h>
#include <QtBodymovin/private/bmstroke_p.h>
QT_BEGIN_NAMESPACE
class QJsonObject;
class BODYMOVIN_EXPORT BMRound : public BMShape
{
public:
BMRound() = default;
explicit BMRound(const BMRound &other);
BMRound(const QJsonObject &definition, BMBase *parent = nullptr);
BMBase *clone() const override;
void construct(const QJsonObject &definition);
void updateProperties(int frame) override;
void render(LottieRenderer &renderer) const override;
bool acceptsTrim() const override;
QPointF position() const;
qreal radius() const;
protected:
BMSpatialProperty m_position;
BMProperty<qreal> m_radius;
};
QT_END_NAMESPACE
#endif // BMROUND_P_H

View File

@ -0,0 +1,100 @@
/****************************************************************************
**
** 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 BMSHAPE_P_H
#define BMSHAPE_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 <QLatin1String>
#include <QPainterPath>
#include <QtBodymovin/private/bmbase_p.h>
#include <QtBodymovin/private/bmproperty_p.h>
QT_BEGIN_NAMESPACE
class BMFill;
class BMStroke;
class BMTrimPath;
#define BM_SHAPE_ANY_TYPE_IX -1
#define BM_SHAPE_ELLIPSE_IX 0
#define BM_SHAPE_FILL_IX 1
#define BM_SHAPE_GFILL_IX 2
#define BM_SHAPE_GSTROKE_IX 3
#define BM_SHAPE_GROUP_IX 4
#define BM_SHAPE_RECT_IX 5
#define BM_SHAPE_ROUND_IX 6
#define BM_SHAPE_SHAPE_IX 7
#define BM_SHAPE_STAR_IX 8
#define BM_SHAPE_STROKE_IX 9
#define BM_SHAPE_TRIM_IX 10
#define BM_SHAPE_TRANS_IX 11
#define BM_SHAPE_REPEATER_IX 12
class BODYMOVIN_EXPORT BMShape : public BMBase
{
public:
BMShape() = default;
explicit BMShape(const BMShape &other);
BMBase *clone() const override;
static BMShape *construct(QJsonObject definition, BMBase *parent = nullptr, int constructAs = BM_SHAPE_ANY_TYPE_IX);
virtual const QPainterPath &path() const;
virtual bool acceptsTrim() const;
virtual void applyTrim(const BMTrimPath& trimmer);
int direction() const;
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
#endif // BMSHAPE_P_H

View File

@ -0,0 +1,77 @@
/****************************************************************************
**
** 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 BMSHAPELAYER_P_H
#define BMSHAPELAYER_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 BMShapeLayer : public BMLayer
{
public:
BMShapeLayer() = default;
explicit BMShapeLayer(const BMShapeLayer &other);
BMShapeLayer(const QJsonObject &definition);
~BMShapeLayer() override;
BMBase *clone() const override;
void updateProperties(int frame) override;
void render(LottieRenderer &render) const override;
protected:
QList<int> m_maskProperties;
private:
BMTrimPath *m_appliedTrim = nullptr;
};
QT_END_NAMESPACE
#endif // BMSHAPELAYER_P_H

View File

@ -0,0 +1,83 @@
/****************************************************************************
**
** 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 BMSHAPETRANSFORM_P_H
#define BMSHAPETRANSFORM_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 <QPointF>
#include <QtBodymovin/private/bmshape_p.h>
#include <QtBodymovin/private/bmbasictransform_p.h>
#include <QtBodymovin/private/bmproperty_p.h>
QT_BEGIN_NAMESPACE
class QJsonObject;
class BODYMOVIN_EXPORT BMShapeTransform : public BMBasicTransform
{
public:
explicit BMShapeTransform(const BMShapeTransform &other);
BMShapeTransform(const QJsonObject &definition, BMBase *parent);
BMBase *clone() const override;
void construct(const QJsonObject &definition);
void updateProperties(int frame) override;
void render(LottieRenderer &renderer) const override;
qreal skew() const;
qreal skewAxis() const;
qreal shearX() const;
qreal shearY() const;
qreal shearAngle() const;
protected:
BMProperty<qreal> m_skew;
BMProperty<qreal> m_skewAxis;
qreal m_shearX;
qreal m_shearY;
qreal m_shearAngle;
};
QT_END_NAMESPACE
#endif // BMSHAPETRANSFORM_P_H

View File

@ -0,0 +1,129 @@
/****************************************************************************
**
** 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 BMSPATIALPROPERTY_P_H
#define BMSPATIALPROPERTY_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 <QPointF>
#include <QPainterPath>
#include <QtBodymovin/private/bmproperty_p.h>
QT_BEGIN_NAMESPACE
class BMSpatialProperty : public BMProperty2D<QPointF>
{
public:
virtual void construct(const QJsonObject &definition) override
{
qCDebug(lcLottieQtBodymovinParser) << "BMSpatialProperty::construct()";
BMProperty2D<QPointF>::construct(definition);
}
virtual EasingSegment<QPointF> parseKeyframe(const QJsonObject keyframe, bool fromExpression) override
{
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 bool update(int frame) override
{
if (!m_animated)
return false;
int adjustedFrame = qBound(m_startFrame, frame, m_endFrame);
if (const EasingSegment<QPointF> *easing = getEasingSegment(adjustedFrame)) {
qreal progress = ((adjustedFrame - m_startFrame) * 1.0) / (m_endFrame - m_startFrame);
qreal easedValue = easing->easing.valueForProgress(progress);
m_value = m_bezierPath.pointAtPercent(easedValue);
}
return true;
}
private:
QPainterPath m_bezierPath;
};
QT_END_NAMESPACE
#endif // BMSPATIALPROPERTY_P_H

View File

@ -0,0 +1,81 @@
/****************************************************************************
**
** 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 BMSTROKE_P_H
#define BMSTROKE_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 <QPen>
#include <QVector4D>
#include <QtBodymovin/private/bmshape_p.h>
#include <QtBodymovin/private/bmproperty_p.h>
QT_BEGIN_NAMESPACE
class BODYMOVIN_EXPORT BMStroke : public BMShape
{
public:
BMStroke() = default;
explicit BMStroke(const BMStroke &other);
BMStroke(const QJsonObject &definition, BMBase *parent = nullptr);
BMBase *clone() const override;
void updateProperties(int frame) override;
void render(LottieRenderer &renderer) const override;
QPen pen() const;
qreal opacity() const;
protected:
QColor getColor() const;
protected:
BMProperty<qreal> m_opacity;
BMProperty<qreal> m_width;
BMProperty4D<QVector4D> m_color;
Qt::PenCapStyle m_capStyle;
Qt::PenJoinStyle m_joinStyle;
qreal m_miterLimit;
};
QT_END_NAMESPACE
#endif // BMSTROKE_P_H

View File

@ -0,0 +1,87 @@
/****************************************************************************
**
** 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 BMTRIMPATH_P_H
#define BMTRIMPATH_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 <QPainterPath>
#include <QJsonObject>
#include <QtBodymovin/private/bmproperty_p.h>
#include <QtBodymovin/private/bmgroup_p.h>
QT_BEGIN_NAMESPACE
class BODYMOVIN_EXPORT BMTrimPath : public BMShape
{
public:
BMTrimPath();
BMTrimPath(const QJsonObject &definition, BMBase *parent = nullptr);
explicit BMTrimPath(const BMTrimPath &other);
void inherit(const BMTrimPath &other);
BMBase *clone() const override;
void construct(const QJsonObject &definition);
void updateProperties(int frame) override;
void render(LottieRenderer &renderer) const override;
bool acceptsTrim() const override;
void applyTrim(const BMTrimPath &trimmer) override;
qreal start() const;
qreal end() const;
qreal offset() const;
bool simultaneous() const;
QPainterPath trim(const QPainterPath &path) const;
protected:
BMProperty<qreal> m_start;
BMProperty<qreal> m_end;
BMProperty<qreal> m_offset;
bool m_simultaneous = false;
};
QT_END_NAMESPACE
#endif // BMTRIMPATH_P_H

View File

@ -0,0 +1,107 @@
/****************************************************************************
**
** 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 LOTTIERENDERER_H
#define LOTTIERENDERER_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 <QStack>
#include "bmglobal.h"
QT_BEGIN_NAMESPACE
class BMBase;
class BMLayer;
class BMRect;
class BMFill;
class BMGFill;
class BMStroke;
class BMBasicTransform;
class BMLayerTransform;
class BMShapeTransform;
class BMRepeaterTransform;
class BMShapeLayer;
class BMEllipse;
class BMRound;
class BMFreeFormShape;
class BMTrimPath;
class BMFillEffect;
class BMRepeater;
class BODYMOVIN_EXPORT LottieRenderer
{
public:
enum TrimmingState{Off = 0, Simultaneous, Individual};
virtual ~LottieRenderer() = default;
virtual void saveState() = 0;
virtual void restoreState() = 0;
virtual void setTrimmingState(TrimmingState state);
virtual TrimmingState trimmingState() const;
virtual void render(const BMLayer &layer) = 0;
virtual void render(const BMRect &rect) = 0;
virtual void render(const BMEllipse &ellipse) = 0;
virtual void render(const BMRound &round) = 0;
virtual void render(const BMFill &fill) = 0;
virtual void render(const BMGFill &fill) = 0;
virtual void render(const BMStroke &stroke) = 0;
virtual void render(const BMBasicTransform &trans) = 0;
virtual void render(const BMShapeTransform &trans) = 0;
virtual void render(const BMFreeFormShape &shape) = 0;
virtual void render(const BMTrimPath &trans) = 0;
virtual void render(const BMFillEffect &effect) = 0;
virtual void render(const BMRepeater &repeater) = 0;
protected:
void saveTrimmingState();
void restoreTrimmingState();
TrimmingState m_trimmingState = Off;
private:
QStack<LottieRenderer::TrimmingState> m_trimStateStack;
};
QT_END_NAMESPACE
#endif // LOTTIERENDERER_H

View File

@ -0,0 +1,93 @@
/****************************************************************************
**
** 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 TRIMPATH_P_H
#define TRIMPATH_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 <QPainterPath>
QT_BEGIN_NAMESPACE
class TrimPath {
public:
TrimPath() = default;
TrimPath(const QPainterPath &path)
: mPath(path) {}
TrimPath(const TrimPath &other)
: mPath(other.mPath), mLens(other.mLens) {}
~TrimPath() {}
void setPath(const QPainterPath &path) {
mPath = path;
mLens.clear();
}
QPainterPath path() const {
return mPath;
}
QPainterPath trimmed(qreal f1, qreal f2, qreal offset = 0.0) const;
private:
bool lensIsDirty() const {
return mLens.size() != mPath.elementCount();
}
void updateLens() const;
int elementAtLength(qreal len) const;
QPointF endPointOfElement(int elemIdx) const;
void appendTrimmedElement(QPainterPath *to, int elemIdx, bool trimStart, qreal startLen, bool trimEnd, qreal endLen) const;
void appendStartOfElement(QPainterPath *to, int elemIdx, qreal len) const {
appendTrimmedElement(to, elemIdx, false, 0.0, true, len);
}
void appendEndOfElement(QPainterPath *to, int elemIdx, qreal len) const {
appendTrimmedElement(to, elemIdx, true, len, false, 1.0);
}
void appendElementRange(QPainterPath *to, int first, int last) const;
QPainterPath mPath;
mutable QVector<qreal> mLens;
};
QT_END_NAMESPACE
Q_DECLARE_METATYPE(TrimPath);
#endif // TRIMPATH_P_H

View File

@ -81,6 +81,7 @@
'lib_base.gyp:lib_base',
'lib_export.gyp:lib_export',
'lib_storage.gyp:lib_storage',
'lib_lottie.gyp:lib_lottie',
],
'defines': [

131
Telegram/gyp/lib_lottie.gyp Normal file
View File

@ -0,0 +1,131 @@
# This file is part of Telegram Desktop,
# the official desktop application for the Telegram messaging service.
#
# For license and copyright information please follow this link:
# https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
{
'includes': [
'common.gypi',
],
'variables': {
'variables': {
'moc_to_sources%': '1',
},
'moc_to_sources%': '<(moc_to_sources)',
},
'targets': [{
'target_name': 'lib_lottie',
'type': 'static_library',
'includes': [
'common.gypi',
'openssl.gypi',
'qt.gypi',
'qt_moc.gypi',
'telegram_linux.gypi',
'pch.gypi',
],
'variables': {
'src_loc': '../SourceFiles',
'res_loc': '../Resources',
'libs_loc': '../../../Libraries',
'official_build_target%': '',
'submodules_loc': '../ThirdParty',
'lottie_loc': '<(submodules_loc)/qtlottie/src',
'lottie_helper_loc': '<(submodules_loc)/qtlottie_helper',
'pch_source': '<(src_loc)/lottie/lottie_pch.cpp',
'pch_header': '<(src_loc)/lottie/lottie_pch.h',
},
'dependencies': [
'crl.gyp:crl',
'lib_base.gyp:lib_base',
],
'export_dependent_settings': [
'crl.gyp:crl',
'lib_base.gyp:lib_base',
],
'defines': [
'BODYMOVIN_LIBRARY',
],
'include_dirs': [
'<(src_loc)',
'<(SHARED_INTERMEDIATE_DIR)',
'<(libs_loc)/range-v3/include',
'<(lottie_loc)',
'<(lottie_loc)/bodymovin',
'<(lottie_loc)/imports',
'<(lottie_helper_loc)',
'<(submodules_loc)/GSL/include',
'<(submodules_loc)/variant/include',
'<(submodules_loc)/crl/src',
],
'sources': [
'<(src_loc)/lottie/lottie_animation.cpp',
'<(src_loc)/lottie/lottie_animation.h',
'<(src_loc)/lottie/lottie_frame_renderer.cpp',
'<(src_loc)/lottie/lottie_frame_renderer.h',
'<(lottie_loc)/bodymovin/bmbase.cpp',
'<(lottie_loc)/bodymovin/bmlayer.cpp',
'<(lottie_loc)/bodymovin/bmshape.cpp',
'<(lottie_loc)/bodymovin/bmshapelayer.cpp',
'<(lottie_loc)/bodymovin/bmrect.cpp',
'<(lottie_loc)/bodymovin/bmfill.cpp',
'<(lottie_loc)/bodymovin/bmgfill.cpp',
'<(lottie_loc)/bodymovin/bmgroup.cpp',
'<(lottie_loc)/bodymovin/bmstroke.cpp',
'<(lottie_loc)/bodymovin/bmbasictransform.cpp',
'<(lottie_loc)/bodymovin/bmshapetransform.cpp',
'<(lottie_loc)/bodymovin/bmellipse.cpp',
'<(lottie_loc)/bodymovin/bmround.cpp',
'<(lottie_loc)/bodymovin/bmfreeformshape.cpp',
'<(lottie_loc)/bodymovin/bmtrimpath.cpp',
'<(lottie_loc)/bodymovin/bmpathtrimmer.cpp',
'<(lottie_loc)/bodymovin/lottierenderer.cpp',
'<(lottie_loc)/bodymovin/trimpath.cpp',
'<(lottie_loc)/bodymovin/bmfilleffect.cpp',
'<(lottie_loc)/bodymovin/bmrepeater.cpp',
'<(lottie_loc)/bodymovin/bmrepeatertransform.cpp',
'<(lottie_loc)/bodymovin/beziereasing.cpp',
'<(lottie_loc)/bodymovin/beziereasing_p.h',
'<(lottie_loc)/bodymovin/bmbase_p.h',
'<(lottie_loc)/bodymovin/bmbasictransform_p.h',
'<(lottie_loc)/bodymovin/bmconstants_p.h',
'<(lottie_loc)/bodymovin/bmellipse_p.h',
'<(lottie_loc)/bodymovin/bmfill_p.h',
'<(lottie_loc)/bodymovin/bmfilleffect_p.h',
'<(lottie_loc)/bodymovin/bmfreeformshape_p.h',
'<(lottie_loc)/bodymovin/bmgfill_p.h',
'<(lottie_loc)/bodymovin/bmgroup_p.h',
'<(lottie_loc)/bodymovin/bmlayer_p.h',
'<(lottie_loc)/bodymovin/bmproperty_p.h',
'<(lottie_loc)/bodymovin/bmrect_p.h',
'<(lottie_loc)/bodymovin/bmrepeater_p.h',
'<(lottie_loc)/bodymovin/bmrepeatertransform_p.h',
'<(lottie_loc)/bodymovin/bmround_p.h',
'<(lottie_loc)/bodymovin/bmshape_p.h',
'<(lottie_loc)/bodymovin/bmshapelayer_p.h',
'<(lottie_loc)/bodymovin/bmshapetransform_p.h',
'<(lottie_loc)/bodymovin/bmspatialproperty_p.h',
'<(lottie_loc)/bodymovin/bmstroke_p.h',
'<(lottie_loc)/bodymovin/bmtrimpath_p.h',
'<(lottie_loc)/bodymovin/trimpath_p.h',
'<(lottie_loc)/bodymovin/lottierenderer_p.h',
'<(lottie_loc)/bodymovin/bmpathtrimmer_p.h',
'<(lottie_loc)/bodymovin/bmglobal.h',
'<(lottie_loc)/imports/rasterrenderer/lottierasterrenderer.cpp',
'<(lottie_loc)/imports/rasterrenderer/lottierasterrenderer.h',
],
'conditions': [[ 'build_macold', {
'xcode_settings': {
'OTHER_CPLUSPLUSFLAGS': [ '-nostdinc++' ],
},
'include_dirs': [
'/usr/local/macold/include/c++/v1',
],
}]],
}],
}

View File

@ -0,0 +1,13 @@
@echo OFF
setlocal enabledelayedexpansion
set "FullScriptPath=%~dp0"
python %FullScriptPath%lottie_helper.py
if %errorlevel% neq 0 goto error
exit /b
:error
echo FAILED
exit /b 1

View File

@ -0,0 +1,34 @@
'''
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
'''
import sys, os, re, subprocess, shutil
def finish(code):
global executePath
os.chdir(executePath)
sys.exit(code)
if sys.platform == 'win32' and not 'COMSPEC' in os.environ:
print('[ERROR] COMSPEC environment variable is not set.')
finish(1)
executePath = os.getcwd()
scriptPath = os.path.dirname(os.path.realpath(__file__))
src = scriptPath + '/../ThirdParty/qtlottie/src/bodymovin'
dst = scriptPath + '/../ThirdParty/qtlottie_helper/QtBodymovin'
shutil.rmtree(dst, ignore_errors=True)
os.makedirs(dst + '/private')
for r, d, f in os.walk(src):
for file in f:
if re.search(r'_p\.h$', file):
shutil.copyfile(src + '/' + file, dst + '/private/' + file)
elif re.search(r'\.h$', file):
shutil.copyfile(src + '/' + file, dst + '/' + file)
finish(0)

View File

@ -5,6 +5,9 @@
# https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
{
'variables': {
'moc_to_sources%': '0',
},
'rules': [{
'rule_name': 'qt_moc',
'extension': 'h',
@ -23,5 +26,6 @@
'-o', '<(SHARED_INTERMEDIATE_DIR)/<(_target_name)/moc/moc_<(RULE_INPUT_ROOT).cpp',
],
'message': 'Moc-ing <(RULE_INPUT_ROOT).h..',
'process_outputs_as_sources': '<(moc_to_sources)',
}],
}