| 1 | // Copyright (C) 2019 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 | #ifndef QSGRHILAYER_P_H |
| 4 | #define QSGRHILAYER_P_H |
| 5 | |
| 6 | // |
| 7 | // W A R N I N G |
| 8 | // ------------- |
| 9 | // |
| 10 | // This file is not part of the Qt API. It exists purely as an |
| 11 | // implementation detail. This header file may change from version to |
| 12 | // version without notice, or even be removed. |
| 13 | // |
| 14 | // We mean it. |
| 15 | // |
| 16 | |
| 17 | #include <private/qsgadaptationlayer_p.h> |
| 18 | #include <private/qsgcontext_p.h> |
| 19 | #include <private/qsgtexture_p.h> |
| 20 | #include <rhi/qrhi.h> |
| 21 | |
| 22 | QT_BEGIN_NAMESPACE |
| 23 | |
| 24 | class QSGDefaultRenderContext; |
| 25 | |
| 26 | class Q_QUICK_EXPORT QSGRhiLayer : public QSGLayer |
| 27 | { |
| 28 | Q_OBJECT |
| 29 | |
| 30 | public: |
| 31 | QSGRhiLayer(QSGRenderContext *context); |
| 32 | ~QSGRhiLayer(); |
| 33 | |
| 34 | bool updateTexture() override; |
| 35 | |
| 36 | bool hasAlphaChannel() const override; |
| 37 | bool hasMipmaps() const override; |
| 38 | QSize textureSize() const override { return m_pixelSize; } |
| 39 | |
| 40 | qint64 comparisonKey() const override; |
| 41 | QRhiTexture *rhiTexture() const override; |
| 42 | void commitTextureOperations(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates) override; |
| 43 | |
| 44 | void setItem(QSGNode *item) override; |
| 45 | void setRect(const QRectF &logicalRect) override; |
| 46 | void setSize(const QSize &pixelSize) override; |
| 47 | void setHasMipmaps(bool mipmap) override; |
| 48 | void setFormat(Format format) override; |
| 49 | void setLive(bool live) override; |
| 50 | void setRecursive(bool recursive) override; |
| 51 | void setDevicePixelRatio(qreal ratio) override { m_dpr = ratio; } |
| 52 | void setMirrorHorizontal(bool mirror) override; |
| 53 | void setMirrorVertical(bool mirror) override; |
| 54 | QRectF normalizedTextureSubRect() const override; |
| 55 | void setSamples(int samples) override { m_samples = samples; } |
| 56 | |
| 57 | void scheduleUpdate() override; |
| 58 | QImage toImage() const override; |
| 59 | |
| 60 | public Q_SLOTS: |
| 61 | void markDirtyTexture() override; |
| 62 | void invalidated() override; |
| 63 | |
| 64 | private: |
| 65 | void grab(); |
| 66 | void releaseResources(); |
| 67 | |
| 68 | QSGNode *m_item = nullptr; |
| 69 | QRectF m_logicalRect; |
| 70 | QSize m_pixelSize; |
| 71 | qreal m_dpr = 1; |
| 72 | QRhiTexture::Format m_format = QRhiTexture::RGBA8; |
| 73 | |
| 74 | QSGRenderer *m_renderer = nullptr; |
| 75 | QRhiTexture *m_texture = nullptr; |
| 76 | QRhiRenderBuffer *m_ds = nullptr; |
| 77 | QRhiRenderBuffer *m_msaaColorBuffer = nullptr; |
| 78 | QRhiTexture *m_secondaryTexture = nullptr; |
| 79 | QRhiTextureRenderTarget *m_rt = nullptr; |
| 80 | QRhiRenderPassDescriptor *m_rtRp = nullptr; |
| 81 | |
| 82 | QSGDefaultRenderContext *m_context = nullptr; |
| 83 | QRhi *m_rhi = nullptr; |
| 84 | int m_samples = 0; |
| 85 | |
| 86 | uint m_mipmap : 1; |
| 87 | uint m_live : 1; |
| 88 | uint m_recursive : 1; |
| 89 | uint m_dirtyTexture : 1; |
| 90 | uint m_multisampling : 1; |
| 91 | uint m_grab : 1; |
| 92 | uint m_mirrorHorizontal : 1; |
| 93 | uint m_mirrorVertical : 1; |
| 94 | }; |
| 95 | |
| 96 | QT_END_NAMESPACE |
| 97 | |
| 98 | #endif // QSGRHILAYER_P_H |
| 99 |
