QtLottie: Add partial support for masksProperties.

This commit is contained in:
John Preston 2019-05-12 22:48:15 +03:00
parent f2ef2fab4f
commit 246e4e45bd
9 changed files with 203 additions and 8 deletions

@ -1 +1 @@
Subproject commit 2f299eed51619c3943fb22a7efb6dcd9727703d6
Subproject commit 741b80b10cf8b2a06ed7dfda1bf9d64896ac0249

View File

@ -46,6 +46,7 @@
QT_BEGIN_NAMESPACE
class LottieRenderer;
class BMMasks;
class BODYMOVIN_EXPORT BMLayer : public BMBase
{
@ -63,7 +64,6 @@ public:
void parse(const QJsonObject &definition) override;
void updateProperties(int frame) override;
void render(LottieRenderer &renderer, int frame) const override;
BMBase *findChild(const QString &childName) override;
@ -90,6 +90,7 @@ protected:
BMBase *m_effects = nullptr;
qreal m_stretch;
BMBasicTransform *m_layerTransform = nullptr;
BMMasks *m_masks = nullptr;
int m_parentLayer = 0;
int m_td = 0;
@ -99,6 +100,7 @@ protected:
private:
void parseEffects(const QJsonArray &definition, BMBase *effectRoot = nullptr);
void parseMasks(const QJsonArray &definition);
BMLayer *m_linkedLayer = nullptr;
};

View File

@ -0,0 +1,67 @@
/****************************************************************************
**
** 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 BMMASKS_P_H
#define BMMASKS_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 BMMasks : public BMBase
{
public:
BMBase *clone() const override;
void render(LottieRenderer &renderer, int frame) const override;
};
QT_END_NAMESPACE
#endif // BMMASKCLIP_P_H

View File

@ -0,0 +1,118 @@
/****************************************************************************
**
** 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 BMMASKSHAPE_P_H
#define BMMASKSHAPE_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 BMMaskShape : public BMShape
{
public:
BMMaskShape();
explicit BMMaskShape(const BMMaskShape &other);
BMMaskShape(const QJsonObject &definition, BMBase *parent = nullptr);
BMBase *clone() const override;
void construct(const QJsonObject &definition);
void updateProperties(int frame) override;
void render(LottieRenderer &renderer, int frame) const override;
enum class Mode {
Additive,
Intersect,
};
Mode mode() const;
bool inverted() const;
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;
bool m_inverted = false;
BMProperty<qreal> m_opacity;
Mode m_mode = Mode::Additive;
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 // BMMASKSHAPE_P_H

View File

@ -68,9 +68,6 @@ public:
QString refId() const;
protected:
QList<int> m_maskProperties;
private:
QString m_refId;
BMBase *m_layers = nullptr;

View File

@ -131,6 +131,10 @@ public:
return m_value;
}
bool animated() const {
return m_animated;
}
virtual bool update(int frame)
{
if (!m_animated)

View File

@ -65,9 +65,6 @@ public:
void updateProperties(int frame) override;
void render(LottieRenderer &render, int frame) const override;
protected:
QList<int> m_maskProperties;
private:
BMTrimPath *m_appliedTrim = nullptr;
};

View File

@ -65,6 +65,9 @@ class BMTrimPath;
class BMFillEffect;
class BMRepeater;
class BMMasks;
class BMMaskShape;
class BODYMOVIN_EXPORT LottieRenderer
{
public:
@ -95,6 +98,9 @@ public:
virtual void render(const BMFillEffect &effect) = 0;
virtual void render(const BMRepeater &repeater) = 0;
virtual void render(const BMMaskShape &shape) = 0;
virtual void render(const BMMasks &masks) = 0;
protected:
void saveTrimmingState();
void restoreTrimmingState();

View File

@ -128,12 +128,16 @@
'<(lottie_loc)/bodymovin/bmnulllayer.cpp',
'<(lottie_loc)/bodymovin/bmprecomplayer.cpp',
'<(lottie_loc)/bodymovin/bmscene.cpp',
'<(lottie_loc)/bodymovin/bmmasks.cpp',
'<(lottie_loc)/bodymovin/bmmaskshape.cpp',
'<(lottie_loc)/bodymovin/bmasset_p.h',
'<(lottie_loc)/bodymovin/bmprecompasset_p.h',
'<(lottie_loc)/bodymovin/bmnulllayer_p.h',
'<(lottie_loc)/bodymovin/bmprecomplayer_p.h',
'<(lottie_loc)/bodymovin/bmscene_p.h',
'<(lottie_loc)/bodymovin/bmmasks_p.h',
'<(lottie_loc)/bodymovin/bmmaskshape_p.h',
],
'conditions': [[ 'build_macold', {
'xcode_settings': {