| 1 | // Copyright (C) 2020 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QLOTTIERENDERER_H |
| 5 | #define QLOTTIERENDERER_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QStack> |
| 19 | // #include <private/qglobal_p.h> |
| 20 | |
| 21 | #include <QtLottie/qtlottieexports.h> |
| 22 | |
| 23 | QT_BEGIN_NAMESPACE |
| 24 | |
| 25 | class QLottieBase; |
| 26 | class QLottieLayer; |
| 27 | class QLottieSolidLayer; |
| 28 | class QLottieGroup; |
| 29 | class QLottieRect; |
| 30 | class QLottieFill; |
| 31 | class QLottieGFill; |
| 32 | class QLottieImage; |
| 33 | class QLottieStroke; |
| 34 | class QLottieBasicTransform; |
| 35 | class QLottieLayerTransform; |
| 36 | class QLottieShapeTransform; |
| 37 | class QLottieRepeaterTransform; |
| 38 | class QLottieShapeLayer; |
| 39 | class QLottieEllipse; |
| 40 | class QLottiePolyStar; |
| 41 | class QLottieRound; |
| 42 | class QLottieFreeFormShape; |
| 43 | class QLottieTrimPath; |
| 44 | class QLottieFillEffect; |
| 45 | class QLottieRepeater; |
| 46 | |
| 47 | class Q_LOTTIE_EXPORT QLottieRenderer |
| 48 | { |
| 49 | public: |
| 50 | enum TrimmingState { Off = 0, Parallel, Sequential }; |
| 51 | |
| 52 | virtual ~QLottieRenderer() = default; |
| 53 | |
| 54 | virtual void saveState() = 0; |
| 55 | virtual void restoreState() = 0; |
| 56 | |
| 57 | virtual void setTrimmingState(TrimmingState state); |
| 58 | virtual TrimmingState trimmingState() const; |
| 59 | |
| 60 | virtual void render(const QLottieLayer &layer) = 0; |
| 61 | virtual void render(const QLottieSolidLayer &layer) = 0; |
| 62 | virtual void render(const QLottieGroup &) {} |
| 63 | virtual void render(const QLottieRect &rect) = 0; |
| 64 | virtual void render(const QLottieEllipse &ellipse) = 0; |
| 65 | virtual void render(const QLottiePolyStar &star) = 0; |
| 66 | virtual void render(const QLottieRound &round) = 0; |
| 67 | virtual void render(const QLottieFill &fill) = 0; |
| 68 | virtual void render(const QLottieGFill &fill) = 0; |
| 69 | virtual void render(const QLottieImage &image) = 0; |
| 70 | virtual void render(const QLottieStroke &stroke) = 0; |
| 71 | virtual void render(const QLottieBasicTransform &trans) = 0; |
| 72 | virtual void render(const QLottieShapeTransform &trans) = 0; |
| 73 | virtual void render(const QLottieFreeFormShape &shape) = 0; |
| 74 | virtual void render(const QLottieTrimPath &trans) = 0; |
| 75 | virtual void render(const QLottieFillEffect &effect) = 0; |
| 76 | virtual void render(const QLottieRepeater &repeater) = 0; |
| 77 | |
| 78 | virtual void finish(const QLottieLayer &) {} |
| 79 | virtual void finish(const QLottieGroup &) {} |
| 80 | |
| 81 | protected: |
| 82 | void saveTrimmingState(); |
| 83 | void restoreTrimmingState(); |
| 84 | static void applyTransform(QTransform *xf, const QLottieBasicTransform &lottieXf, bool isShapeTransform = false); |
| 85 | |
| 86 | TrimmingState m_trimmingState = Off; |
| 87 | |
| 88 | private: |
| 89 | QStack<QLottieRenderer::TrimmingState> m_trimStateStack; |
| 90 | }; |
| 91 | |
| 92 | QT_END_NAMESPACE |
| 93 | |
| 94 | #endif // QLOTTIERENDERER_H |
| 95 | |