| 1 | // Copyright (C) 2018 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QLOTTIERASTERRENDERER_H |
| 5 | #define QLOTTIERASTERRENDERER_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 <QPainterPath> |
| 19 | #include <QPainter> |
| 20 | #include <QStack> |
| 21 | #include <QRegion> |
| 22 | |
| 23 | #include <QtLottie/private/qlottierenderer_p.h> |
| 24 | |
| 25 | QT_BEGIN_NAMESPACE |
| 26 | |
| 27 | class QPainter; |
| 28 | |
| 29 | class QLottieRasterRenderer : public QLottieRenderer |
| 30 | { |
| 31 | public: |
| 32 | explicit QLottieRasterRenderer(QPainter *m_painter); |
| 33 | ~QLottieRasterRenderer() override = default; |
| 34 | |
| 35 | void saveState() override; |
| 36 | void restoreState() override; |
| 37 | |
| 38 | void render(const QLottieLayer &layer) override; |
| 39 | void render(const QLottieSolidLayer &layer) override; |
| 40 | void render(const QLottieRect &rect) override; |
| 41 | void render(const QLottieEllipse &ellipse) override; |
| 42 | void render(const QLottiePolyStar &star) override; |
| 43 | void render(const QLottieRound &round) override; |
| 44 | void render(const QLottieFill &fill) override; |
| 45 | void render(const QLottieGFill &shape) override; |
| 46 | void render(const QLottieImage &image) override; |
| 47 | void render(const QLottieStroke &stroke) override; |
| 48 | void render(const QLottieBasicTransform &transform) override; |
| 49 | void render(const QLottieShapeTransform &transform) override; |
| 50 | void render(const QLottieFreeFormShape &shape) override; |
| 51 | void render(const QLottieTrimPath &trans) override; |
| 52 | void render(const QLottieFillEffect &effect) override; |
| 53 | void render(const QLottieRepeater &repeater) override; |
| 54 | |
| 55 | protected: |
| 56 | QPainter *m_painter = nullptr; |
| 57 | QPainterPath m_unitedPath; |
| 58 | // TODO: create a context to handle paths and effect |
| 59 | // instead of pushing each to a stack independently |
| 60 | QStack<QPainterPath> m_pathStack; |
| 61 | QStack<const QLottieFillEffect*> m_fillEffectStack; |
| 62 | const QLottieFillEffect *m_fillEffect = nullptr; |
| 63 | const QLottieRepeaterTransform *m_repeaterTransform = nullptr; |
| 64 | int m_repeatCount = 1; |
| 65 | qreal m_repeatOffset = 0.0; |
| 66 | bool m_buildingClipRegion = false; |
| 67 | QPainterPath m_clipPath; |
| 68 | |
| 69 | private: |
| 70 | void applyRepeaterTransform(int instance); |
| 71 | }; |
| 72 | |
| 73 | QT_END_NAMESPACE |
| 74 | |
| 75 | #endif // QLOTTIERASTERRENDERER_H |
| 76 | |
| 77 |
