1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef LOTTIERASTERRENDERER_H
5#define LOTTIERASTERRENDERER_H
6
7#include <QPainterPath>
8#include <QPainter>
9#include <QStack>
10#include <QRegion>
11
12#include <QtBodymovin/private/lottierenderer_p.h>
13
14QT_BEGIN_NAMESPACE
15
16class QPainter;
17
18class LottieRasterRenderer : public LottieRenderer
19{
20public:
21 explicit LottieRasterRenderer(QPainter *m_painter);
22 ~LottieRasterRenderer() override = default;
23
24 void saveState() override;
25 void restoreState() override;
26
27 void render(const BMLayer &layer) override;
28 void render(const BMRect &rect) override;
29 void render(const BMEllipse &ellipse) override;
30 void render(const BMRound &round) override;
31 void render(const BMFill &fill) override;
32 void render(const BMGFill &shape) override;
33 void render(const BMImage &image) override;
34 void render(const BMStroke &stroke) override;
35 void render(const BMBasicTransform &transform) override;
36 void render(const BMShapeTransform &transform) override;
37 void render(const BMFreeFormShape &shape) override;
38 void render(const BMTrimPath &trans) override;
39 void render(const BMFillEffect &effect) override;
40 void render(const BMRepeater &repeater) override;
41
42protected:
43 QPainter *m_painter = nullptr;
44 QPainterPath m_unitedPath;
45 // TODO: create a context to handle paths and effect
46 // instead of pushing each to a stack independently
47 QStack<QPainterPath> m_pathStack;
48 QStack<const BMFillEffect*> m_fillEffectStack;
49 const BMFillEffect *m_fillEffect = nullptr;
50 const BMRepeaterTransform *m_repeaterTransform = nullptr;
51 int m_repeatCount = 1;
52 qreal m_repeatOffset = 0.0;
53 bool m_buildingClipRegion = false;
54 QPainterPath m_clipPath;
55
56private:
57 void applyRepeaterTransform(int instance);
58};
59
60QT_END_NAMESPACE
61
62#endif // LOTTIERASTERRENDERER_H
63
64

source code of qtlottie/src/imports/rasterrenderer/lottierasterrenderer.h