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 QSGABSTRACTRENDERER_P_H |
5 | #define QSGABSTRACTRENDERER_P_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 <QtQuick/private/qtquickglobal_p.h> |
19 | #include <QtQuick/qsgnode.h> |
20 | #include <QtCore/qobject.h> |
21 | |
22 | #ifndef GLuint |
23 | #define GLuint uint |
24 | #endif |
25 | |
26 | QT_BEGIN_NAMESPACE |
27 | |
28 | class QSGAbstractRendererPrivate; |
29 | |
30 | class Q_QUICK_PRIVATE_EXPORT QSGAbstractRenderer : public QObject |
31 | { |
32 | Q_OBJECT |
33 | public: |
34 | enum ClearModeBit |
35 | { |
36 | ClearColorBuffer = 0x0001, |
37 | ClearDepthBuffer = 0x0002, |
38 | ClearStencilBuffer = 0x0004 |
39 | }; |
40 | Q_DECLARE_FLAGS(ClearMode, ClearModeBit) |
41 | Q_FLAG(ClearMode) |
42 | |
43 | enum MatrixTransformFlag |
44 | { |
45 | MatrixTransformFlipY = 0x01 |
46 | }; |
47 | Q_DECLARE_FLAGS(MatrixTransformFlags, MatrixTransformFlag) |
48 | Q_FLAG(MatrixTransformFlags) |
49 | |
50 | ~QSGAbstractRenderer() override; |
51 | |
52 | void setRootNode(QSGRootNode *node); |
53 | QSGRootNode *rootNode() const; |
54 | void setDeviceRect(const QRect &rect); |
55 | inline void setDeviceRect(const QSize &size) { setDeviceRect(QRect(QPoint(), size)); } |
56 | QRect deviceRect() const; |
57 | |
58 | void setViewportRect(const QRect &rect); |
59 | inline void setViewportRect(const QSize &size) { setViewportRect(QRect(QPoint(), size)); } |
60 | QRect viewportRect() const; |
61 | |
62 | void setProjectionMatrixToRect(const QRectF &rect); |
63 | void setProjectionMatrixToRect(const QRectF &rect, MatrixTransformFlags flags); |
64 | void setProjectionMatrixToRect(const QRectF &rect, MatrixTransformFlags flags, |
65 | bool nativeNDCFlipY); |
66 | void setProjectionMatrix(const QMatrix4x4 &matrix); |
67 | void setProjectionMatrixWithNativeNDC(const QMatrix4x4 &matrix); |
68 | QMatrix4x4 projectionMatrix() const; |
69 | QMatrix4x4 projectionMatrixWithNativeNDC() const; |
70 | |
71 | void setClearColor(const QColor &color); |
72 | QColor clearColor() const; |
73 | |
74 | void setClearMode(ClearMode mode); |
75 | ClearMode clearMode() const; |
76 | |
77 | virtual void renderScene() = 0; |
78 | |
79 | virtual void prepareSceneInline(); |
80 | virtual void renderSceneInline(); |
81 | |
82 | Q_SIGNALS: |
83 | void sceneGraphChanged(); |
84 | |
85 | protected: |
86 | explicit QSGAbstractRenderer(QObject *parent = nullptr); |
87 | virtual void nodeChanged(QSGNode *node, QSGNode::DirtyState state) = 0; |
88 | |
89 | private: |
90 | Q_DECLARE_PRIVATE(QSGAbstractRenderer) |
91 | friend class QSGRootNode; |
92 | }; |
93 | |
94 | Q_DECLARE_OPERATORS_FOR_FLAGS(QSGAbstractRenderer::ClearMode) |
95 | |
96 | QT_END_NAMESPACE |
97 | |
98 | #endif |
99 | |