// Copyright (C) 2025 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QLOTTIEVISITOR_P_H #define QLOTTIEVISITOR_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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include QT_BEGIN_NAMESPACE class QLottieRoot; class Q_LOTTIEVECTORIMAGEGENERATOR_EXPORT QLottieVisitor : public QLottieRenderer { public: struct PaintInfo { QBrush fill = Qt::transparent; QPen stroke = QPen(Qt::transparent); qreal opacity = 1.0; Qt::FillRule fillRule = Qt::WindingFill; QPainterPath unitedPath; PathTrimInfo trim; QTransform transform; struct TransformAnimationInfo { QTransform::TransformationType animationType; QMap frames; QMap easingPerFrame; }; QList transformAnimations; }; QLottieVisitor(const QString lottieFileName, QQuickGenerator *generator); virtual ~QLottieVisitor() {} void saveState() override; void restoreState() override; void render(const QLottieRoot &layer); void render(const QLottieLayer &layer) override; void render(const QLottieSolidLayer &layer) override; void render(const QLottieGroup &group) override; void finish(const QLottieLayer &layer) override; void finish(const QLottieGroup &group) override; void render(const QLottieRect &rect) override; void render(const QLottieEllipse &ellipse) override; void render(const QLottiePolyStar &star) override; void render(const QLottieRound &round) override; void render(const QLottieFill &fill) override; void render(const QLottieGFill &shape) override; void render(const QLottieImage &image) override; void render(const QLottieStroke &stroke) override; void render(const QLottieBasicTransform &transform) override; void render(const QLottieShapeTransform &transform) override; void render(const QLottieFreeFormShape &shape) override; void render(const QLottieTrimPath &trim) override; void render(const QLottieFillEffect &effect) override; void render(const QLottieRepeater &repeater) override; void fillCommonNodeInfo(const QLottieBase *node, NodeInfo *info); void fillAnimationNodeInfo(const QLottieBase *node, NodeInfo *info); void fillBasicPathInfo(const QLottieShape *strokeOrFill, PathNodeInfo *pathInfo); void fillLayerAnimationInfo(const QLottieLayer *node, NodeInfo *info); private: static bool nodeIsGraphicElement(const QLottieBase *node); static bool nodeIsShape(const QLottieBase *node); static bool hasAnimations(const QLottieBasicTransform *transform, bool isShapeTransform = false); void processShape(const QLottieShape *shape); void processShape(const QLottieShape *shape, const QPainterPath &path); void collectTransformAnimations(const QLottieBasicTransform *transform, bool isShapeTransform = false); void enumerateLayerChildren(const QLottieBase *node); QString scrub(const QString &raw); QString m_lottieFileName; QQuickGenerator *m_generator; PaintInfo m_currentPaintInfo; QList m_savedPaintInfos; int m_frameRate = 30; int m_duration = 1000; qreal m_frameOffset = 0; QList m_layers; QStack m_currentStructElements; }; QT_END_NAMESPACE #endif // QLOTTIEVISITOR_P_H