Changeset View
Changeset View
Standalone View
Standalone View
files/implement-missing-merge-shape.patch
- This file was added.
| --- a/src/bodymovin/CMakeLists.txt | |||||
| +++ b/src/bodymovin/CMakeLists.txt | |||||
| @@ -15,6 +15,7 @@ qt_internal_add_module(BodymovinPrivate | |||||
| bmimage.cpp bmimage_p.h | |||||
| bmimagelayer.cpp bmimagelayer_p.h | |||||
| bmlayer.cpp bmlayer_p.h | |||||
| + bmmergepath.cpp bmmergepath_p.h | |||||
| bmnulllayer.cpp bmnulllayer_p.h | |||||
| bmpathtrimmer.cpp bmpathtrimmer_p.h | |||||
| bmproperty_p.h | |||||
| --- /dev/null | |||||
| +++ b/src/bodymovin/bmmergepath.cpp | |||||
| @@ -0,0 +1,111 @@ | |||||
| +/**************************************************************************** | |||||
| +** | |||||
| +** Copyright (C) 2021 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$ | |||||
| +** | |||||
| +****************************************************************************/ | |||||
| + | |||||
| +#include "bmmergepath_p.h" | |||||
| + | |||||
| +BMMergePath::BMMergePath(const BMMergePath &other) | |||||
| + : BMShape(other) | |||||
| +{ | |||||
| + m_mergemode = other.m_mergemode; | |||||
| +} | |||||
| + | |||||
| +BMMergePath::BMMergePath(const QJsonObject &definition, BMBase *parent) | |||||
| +{ | |||||
| + setParent(parent); | |||||
| + | |||||
| + qCDebug(lcLottieQtBodymovinParser) << "BMMerge::construct():" << m_name; | |||||
| + | |||||
| + BMBase::parse(definition); | |||||
| + if (m_hidden) | |||||
| + return; | |||||
| + | |||||
| + m_mergemode = definition.value(QLatin1String("mm")).toVariant().toInt(); | |||||
| +} | |||||
| + | |||||
| +BMBase *BMMergePath::clone() const | |||||
| +{ | |||||
| + return new BMMergePath(*this); | |||||
| +} | |||||
| + | |||||
| +/* void BMMerge::updateProperties(int frame) | |||||
| +{ | |||||
| +} */ | |||||
| + | |||||
| +void BMMergePath::render(LottieRenderer &renderer) const | |||||
| +{ | |||||
| + renderer.render(*this); | |||||
| +} | |||||
| + | |||||
| +QPainterPath BMMergePath::merge(const QPainterPath &path) const | |||||
| +{ | |||||
| + QPainterPath mergedPath; | |||||
| + | |||||
| + switch (m_mergemode) { | |||||
| + case 1: | |||||
| + { | |||||
| + /* merge */ | |||||
| + /* combine */ | |||||
| + mergedPath = m_path; | |||||
| + mergedPath.addPath(path); | |||||
| + break; | |||||
| + } | |||||
| + case 2: | |||||
| + { | |||||
| + /* add */ | |||||
| + mergedPath = m_path.united(path); | |||||
| + break; | |||||
| + } | |||||
| + case 3: | |||||
| + { | |||||
| + /* substract */ | |||||
| + mergedPath = m_path.subtracted(path); | |||||
| + break; | |||||
| + } | |||||
| + case 4: | |||||
| + { | |||||
| + /* intersect */ | |||||
| + mergedPath = m_path.intersected(path); | |||||
| + break; | |||||
| + } | |||||
| + case 5: | |||||
| + { | |||||
| + /* exclude */ | |||||
| + /* XOR */ | |||||
| + QPainterPath tempUnion, tempInter; | |||||
| + tempUnion = m_path.united(path); | |||||
| + tempInter = m_path.intersected(path); | |||||
| + mergedPath = tempUnion.subtracted(tempInter); | |||||
| + break; | |||||
| + } | |||||
| + default: | |||||
| + qCDebug(lcLottieQtBodymovinParser) << "Unknown merge mode in BMMerge"; | |||||
| + } | |||||
| + | |||||
| + return mergedPath; | |||||
| +} | |||||
| --- /dev/null | |||||
| +++ b/src/bodymovin/bmmergepath_p.h | |||||
| @@ -0,0 +1,71 @@ | |||||
| +/**************************************************************************** | |||||
| +** | |||||
| +** Copyright (C) 2021 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 BMMERGEPATH_P_H | |||||
| +#define BMMERGEPATH_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 BMMergePath : public BMShape | |||||
| +{ | |||||
| +public: | |||||
| + BMMergePath() = default; | |||||
| + explicit BMMergePath(const BMMergePath &other); | |||||
| + BMMergePath(const QJsonObject &definition, BMBase *parent = nullptr); | |||||
| + | |||||
| + BMBase *clone() const override; | |||||
| + | |||||
| + void render(LottieRenderer &renderer) const override; | |||||
| + | |||||
| + QPainterPath merge(const QPainterPath &path) const; | |||||
| + | |||||
| +protected: | |||||
| + int m_mergemode; | |||||
| +}; | |||||
| + | |||||
| +QT_END_NAMESPACE | |||||
| + | |||||
| +#endif // BMMERGEPATH_P_H | |||||
| --- a/src/bodymovin/bmshape.cpp | |||||
| +++ b/src/bodymovin/bmshape.cpp | |||||
| @@ -41,6 +41,7 @@ | |||||
| #include "bmellipse_p.h" | |||||
| #include "bmround_p.h" | |||||
| #include "bmtrimpath_p.h" | |||||
| +#include "bmmergepath_p.h" | |||||
| #include "bmshapetransform_p.h" | |||||
| #include "bmfreeformshape_p.h" | |||||
| #include "bmrepeater_p.h" | |||||
| @@ -156,6 +157,13 @@ BMShape *BMShape::construct(QJsonObject | |||||
| shape->setType(BM_SHAPE_REPEATER_IX); | |||||
| break; | |||||
| } | |||||
| + case BM_SHAPE_TAG('m', 'm'): | |||||
| + { | |||||
| + qCDebug(lcLottieQtBodymovinParser) << "Parse merge path"; | |||||
| + shape = new BMMergePath(definition, parent); | |||||
| + shape->setType(BM_SHAPE_MERGE_IX); | |||||
| + break; | |||||
| + } | |||||
| case BM_SHAPE_TAG('g', 's'): // ### BM_SHAPE_GSTROKE_IX | |||||
| case BM_SHAPE_TAG('s', 'r'): // ### BM_SHAPE_STAR_IX | |||||
| // fall through | |||||
| --- a/src/bodymovin/bmshape_p.h | |||||
| +++ b/src/bodymovin/bmshape_p.h | |||||
| @@ -66,6 +66,7 @@ class BMTrimPath; | |||||
| #define BM_SHAPE_TRIM_IX 10 | |||||
| #define BM_SHAPE_TRANS_IX 11 | |||||
| #define BM_SHAPE_REPEATER_IX 12 | |||||
| +#define BM_SHAPE_MERGE_IX 13 | |||||
| class BODYMOVIN_EXPORT BMShape : public BMBase | |||||
| { | |||||
| --- a/src/bodymovin/lottierenderer_p.h | |||||
| +++ b/src/bodymovin/lottierenderer_p.h | |||||
| @@ -63,6 +63,7 @@ class BMEllipse; | |||||
| class BMRound; | |||||
| class BMFreeFormShape; | |||||
| class BMTrimPath; | |||||
| +class BMMergePath; | |||||
| class BMFillEffect; | |||||
| class BMRepeater; | |||||
| @@ -91,6 +92,7 @@ public: | |||||
| 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 BMMergePath &trans) = 0; | |||||
| virtual void render(const BMFillEffect &effect) = 0; | |||||
| virtual void render(const BMRepeater &repeater) = 0; | |||||
| --- a/src/imports/rasterrenderer/lottierasterrenderer.cpp | |||||
| +++ b/src/imports/rasterrenderer/lottierasterrenderer.cpp | |||||
| @@ -47,6 +47,7 @@ | |||||
| #include <QtBodymovin/private/bmround_p.h> | |||||
| #include <QtBodymovin/private/bmfreeformshape_p.h> | |||||
| #include <QtBodymovin/private/bmtrimpath_p.h> | |||||
| +#include <QtBodymovin/private/bmmergepath_p.h> | |||||
| #include <QtBodymovin/private/bmfilleffect_p.h> | |||||
| #include <QtBodymovin/private/bmrepeater_p.h> | |||||
| @@ -338,6 +339,31 @@ void LottieRasterRenderer::render(const | |||||
| m_painter->restore(); | |||||
| } | |||||
| +void LottieRasterRenderer::render(const BMMergePath &mergePath) | |||||
| +{ | |||||
| + // TODO: Remove "Individual" trimming to the prerendering thread | |||||
| + // Now it is done in the GUI thread | |||||
| + | |||||
| + m_painter->save(); | |||||
| + | |||||
| + for (int i = 0; i < m_repeatCount; i ++) { | |||||
| + qCDebug(lcLottieQtBodymovinRender) << "Render shape:" | |||||
| + << mergePath.name() << "of" | |||||
| + << mergePath.parent()->name(); | |||||
| + applyRepeaterTransform(i); | |||||
| + if (!qFuzzyCompare(0.0, m_unitedPath.length())) { | |||||
| + qCDebug(lcLottieQtBodymovinRender) << "Render trim path in the GUI thread"; | |||||
| + QPainterPath tr = mergePath.merge(m_unitedPath); | |||||
| + // Do not use the applied transform, as the transform | |||||
| + // is already included in m_unitedPath | |||||
| + m_painter->setTransform(QTransform()); | |||||
| + m_painter->drawPath(tr); | |||||
| + } | |||||
| + } | |||||
| + | |||||
| + m_painter->restore(); | |||||
| +} | |||||
| + | |||||
| void LottieRasterRenderer::render(const BMFillEffect &effect) | |||||
| { | |||||
| qCDebug(lcLottieQtBodymovinRender) << "Fill:" <<effect.name() | |||||
| --- a/src/imports/rasterrenderer/lottierasterrenderer.h | |||||
| +++ b/src/imports/rasterrenderer/lottierasterrenderer.h | |||||
| @@ -62,6 +62,7 @@ public: | |||||
| void render(const BMShapeTransform &transform) override; | |||||
| void render(const BMFreeFormShape &shape) override; | |||||
| void render(const BMTrimPath &trans) override; | |||||
| + void render(const BMMergePath &trans) override; | |||||
| void render(const BMFillEffect &effect) override; | |||||
| void render(const BMRepeater &repeater) override; | |||||
Copyright © 2015-2021 Solus Project. The Solus logo is Copyright © 2016-2021 Solus Project. All Rights Reserved.