1// Copyright (C) 2020 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 QQUICKRENDERTARGET_H
5#define QQUICKRENDERTARGET_H
6
7#include <QtQuick/qtquickglobal.h>
8#include <QtCore/qsize.h>
9
10#if QT_CONFIG(vulkan)
11#include <QtGui/qvulkaninstance.h>
12#endif
13
14#if QT_CONFIG(metal) || defined(Q_QDOC)
15Q_FORWARD_DECLARE_OBJC_CLASS(MTLTexture);
16#endif
17
18QT_BEGIN_NAMESPACE
19
20class QQuickRenderTargetPrivate;
21class QRhiRenderTarget;
22class QRhiTexture;
23class QPaintDevice;
24
25class Q_QUICK_EXPORT QQuickRenderTarget
26{
27public:
28 enum class Flag {
29 MultisampleResolve = 0x01,
30 };
31 Q_DECLARE_FLAGS(Flags, Flag)
32
33 QQuickRenderTarget();
34 ~QQuickRenderTarget();
35 QQuickRenderTarget(const QQuickRenderTarget &other);
36 QQuickRenderTarget &operator=(const QQuickRenderTarget &other);
37
38 bool isNull() const;
39
40 qreal devicePixelRatio() const;
41 void setDevicePixelRatio(qreal ratio);
42
43 bool mirrorVertically() const;
44 void setMirrorVertically(bool enable);
45
46 QRhiTexture *depthTexture() const;
47 void setDepthTexture(QRhiTexture *texture);
48
49#if QT_CONFIG(opengl) || defined(Q_QDOC)
50 static QQuickRenderTarget fromOpenGLTexture(uint textureId, const QSize &pixelSize, int sampleCount = 1);
51 static QQuickRenderTarget fromOpenGLTexture(uint textureId, uint format, const QSize &pixelSize, int sampleCount = 1);
52 static QQuickRenderTarget fromOpenGLTexture(uint textureId, uint format, QSize pixelSize, int sampleCount, int arraySize, Flags flags);
53
54 static QQuickRenderTarget fromOpenGLRenderBuffer(uint renderbufferId, const QSize &pixelSize, int sampleCount = 1);
55#endif
56
57#if defined(Q_OS_WIN) || defined(Q_QDOC)
58 static QQuickRenderTarget fromD3D11Texture(void *texture, const QSize &pixelSize, int sampleCount = 1);
59 static QQuickRenderTarget fromD3D11Texture(void *texture, uint format, const QSize &pixelSize, int sampleCount = 1);
60 static QQuickRenderTarget fromD3D11Texture(void *texture, uint format, QSize pixelSize, int sampleCount, Flags flags);
61
62 static QQuickRenderTarget fromD3D12Texture(void *texture, int resourceState, uint format, const QSize &pixelSize, int sampleCount = 1);
63 static QQuickRenderTarget fromD3D12Texture(void *texture, int resourceState, uint format, uint viewFormat, QSize pixelSize, int sampleCount, int arraySize, Flags flags);
64#endif
65
66#if QT_CONFIG(metal) || defined(Q_QDOC)
67 static QQuickRenderTarget fromMetalTexture(MTLTexture *texture, const QSize &pixelSize, int sampleCount = 1);
68 static QQuickRenderTarget fromMetalTexture(MTLTexture *texture, uint format, const QSize &pixelSize, int sampleCount = 1);
69 static QQuickRenderTarget fromMetalTexture(MTLTexture *texture, uint format, uint viewFormat, QSize pixelSize, int sampleCount, int arraySize, Flags flags);
70#endif
71
72#if QT_CONFIG(vulkan) || defined(Q_QDOC)
73 static QQuickRenderTarget fromVulkanImage(VkImage image, VkImageLayout layout, const QSize &pixelSize, int sampleCount = 1);
74 static QQuickRenderTarget fromVulkanImage(VkImage image, VkImageLayout layout, VkFormat format, const QSize &pixelSize, int sampleCount = 1);
75 static QQuickRenderTarget fromVulkanImage(VkImage image, VkImageLayout layout, VkFormat format, VkFormat viewFormat, QSize pixelSize, int sampleCount, int arraySize, Flags flags);
76#endif
77
78 static QQuickRenderTarget fromRhiRenderTarget(QRhiRenderTarget *renderTarget);
79
80 static QQuickRenderTarget fromPaintDevice(QPaintDevice *device);
81
82private:
83 void detach();
84 bool isEqual(const QQuickRenderTarget &other) const noexcept;
85 QQuickRenderTargetPrivate *d;
86 friend class QQuickRenderTargetPrivate;
87
88 friend bool operator==(const QQuickRenderTarget &lhs, const QQuickRenderTarget &rhs) noexcept
89 { return lhs.isEqual(other: rhs); }
90 friend bool operator!=(const QQuickRenderTarget &lhs, const QQuickRenderTarget &rhs) noexcept
91 { return !lhs.isEqual(other: rhs); }
92};
93
94Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickRenderTarget::Flags)
95
96QT_END_NAMESPACE
97
98#endif // QQUICKRENDERTARGET_H
99

Provided by KDAB

Privacy Policy
Learn Advanced QML with KDAB
Find out more

source code of qtdeclarative/src/quick/items/qquickrendertarget.h