| 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_EXPORT QSGAbstractRenderer : public QObject |
| 31 | { |
| 32 | Q_OBJECT |
| 33 | public: |
| 34 | enum MatrixTransformFlag |
| 35 | { |
| 36 | MatrixTransformFlipY = 0x01 |
| 37 | }; |
| 38 | Q_DECLARE_FLAGS(MatrixTransformFlags, MatrixTransformFlag) |
| 39 | Q_FLAG(MatrixTransformFlags) |
| 40 | |
| 41 | ~QSGAbstractRenderer() override; |
| 42 | |
| 43 | void setRootNode(QSGRootNode *node); |
| 44 | QSGRootNode *rootNode() const; |
| 45 | void setDeviceRect(const QRect &rect); |
| 46 | inline void setDeviceRect(const QSize &size) { setDeviceRect(QRect(QPoint(), size)); } |
| 47 | QRect deviceRect() const; |
| 48 | |
| 49 | void setViewportRect(const QRect &rect); |
| 50 | inline void setViewportRect(const QSize &size) { setViewportRect(QRect(QPoint(), size)); } |
| 51 | QRect viewportRect() const; |
| 52 | |
| 53 | void setProjectionMatrixToRect(const QRectF &rect); |
| 54 | void setProjectionMatrixToRect(const QRectF &rect, MatrixTransformFlags flags); |
| 55 | void setProjectionMatrixToRect(const QRectF &rect, MatrixTransformFlags flags, |
| 56 | bool nativeNDCFlipY); |
| 57 | void setProjectionMatrix(const QMatrix4x4 &matrix, int index = 0); |
| 58 | void setProjectionMatrixWithNativeNDC(const QMatrix4x4 &matrix, int index = 0); |
| 59 | QMatrix4x4 projectionMatrix(int index) const; |
| 60 | QMatrix4x4 projectionMatrixWithNativeNDC(int index) const; |
| 61 | int projectionMatrixCount() const; |
| 62 | int projectionMatrixWithNativeNDCCount() const; |
| 63 | |
| 64 | void setClearColor(const QColor &color); |
| 65 | QColor clearColor() const; |
| 66 | |
| 67 | virtual void renderScene() = 0; |
| 68 | |
| 69 | virtual void prepareSceneInline(); |
| 70 | virtual void renderSceneInline(); |
| 71 | |
| 72 | Q_SIGNALS: |
| 73 | void sceneGraphChanged(); |
| 74 | |
| 75 | protected: |
| 76 | explicit QSGAbstractRenderer(QObject *parent = nullptr); |
| 77 | virtual void nodeChanged(QSGNode *node, QSGNode::DirtyState state) = 0; |
| 78 | |
| 79 | private: |
| 80 | Q_DECLARE_PRIVATE(QSGAbstractRenderer) |
| 81 | friend class QSGRootNode; |
| 82 | }; |
| 83 | |
| 84 | QT_END_NAMESPACE |
| 85 | |
| 86 | #endif |
| 87 | |