1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QSGABSTRACTSOFTWARERENDERER_H
5#define QSGABSTRACTSOFTWARERENDERER_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 <private/qsgrenderer_p.h>
19
20#include <QtCore/QHash>
21
22QT_BEGIN_NAMESPACE
23
24class QSGSimpleRectNode;
25
26class QSGSoftwareRenderableNode;
27class QSGSoftwareRenderableNodeUpdater;
28
29class Q_QUICK_PRIVATE_EXPORT QSGAbstractSoftwareRenderer : public QSGRenderer
30{
31public:
32 QSGAbstractSoftwareRenderer(QSGRenderContext *context);
33 virtual ~QSGAbstractSoftwareRenderer();
34
35 QSGSoftwareRenderableNode *renderableNode(QSGNode *node) const;
36 void addNodeMapping(QSGNode *node, QSGSoftwareRenderableNode *renderableNode);
37 void appendRenderableNode(QSGSoftwareRenderableNode *node);
38
39 void nodeChanged(QSGNode *node, QSGNode::DirtyState state) override;
40
41 void markDirty();
42
43protected:
44 QRegion renderNodes(QPainter *painter);
45 void buildRenderList();
46 QRegion optimizeRenderList();
47
48 void setBackgroundColor(const QColor &color);
49 void setBackgroundRect(const QRect &rect, qreal devicePixelRatio);
50 QColor backgroundColor();
51 QRect backgroundRect();
52 // only known after calling optimizeRenderList()
53 bool isOpaque() const { return m_isOpaque; }
54 const QVector<QSGSoftwareRenderableNode*> &renderableNodes() const;
55
56private:
57 void nodeAdded(QSGNode *node);
58 void nodeRemoved(QSGNode *node);
59 void nodeGeometryUpdated(QSGNode *node);
60 void nodeMaterialUpdated(QSGNode *node);
61 void nodeMatrixUpdated(QSGNode *node);
62 void nodeOpacityUpdated(QSGNode *node);
63
64 QHash<QSGNode*, QSGSoftwareRenderableNode*> m_nodes;
65 QVector<QSGSoftwareRenderableNode*> m_renderableNodes;
66
67 QSGSimpleRectNode *m_background;
68
69 QRegion m_dirtyRegion;
70 QRegion m_obscuredRegion;
71 qreal m_devicePixelRatio = 1;
72 bool m_isOpaque = false;
73
74 QSGSoftwareRenderableNodeUpdater *m_nodeUpdater;
75};
76
77QT_END_NAMESPACE
78
79#endif // QSGABSTRACTSOFTWARERENDERER_H
80

source code of qtdeclarative/src/quick/scenegraph/adaptations/software/qsgabstractsoftwarerenderer_p.h