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 defined(Q_OS_MACOS) || defined(Q_OS_IOS) || defined(Q_QDOC)
15Q_FORWARD_DECLARE_OBJC_CLASS(MTLTexture);
16#endif
17
18QT_BEGIN_NAMESPACE
19
20class QQuickRenderTargetPrivate;
21class QRhiRenderTarget;
22class QPaintDevice;
23
24class Q_QUICK_EXPORT QQuickRenderTarget
25{
26public:
27 QQuickRenderTarget();
28 ~QQuickRenderTarget();
29 QQuickRenderTarget(const QQuickRenderTarget &other);
30 QQuickRenderTarget &operator=(const QQuickRenderTarget &other);
31
32 bool isNull() const;
33
34 qreal devicePixelRatio() const;
35 void setDevicePixelRatio(qreal ratio);
36
37 bool mirrorVertically() const;
38 void setMirrorVertically(bool enable);
39
40#if QT_CONFIG(opengl) || defined(Q_QDOC)
41 static QQuickRenderTarget fromOpenGLTexture(uint textureId, uint format, const QSize &pixelSize, int sampleCount = 1);
42 static QQuickRenderTarget fromOpenGLTexture(uint textureId, const QSize &pixelSize, int sampleCount = 1);
43 static QQuickRenderTarget fromOpenGLRenderBuffer(uint renderbufferId, const QSize &pixelSize, int sampleCount = 1);
44#endif
45
46#if defined(Q_OS_WIN) || defined(Q_QDOC)
47 static QQuickRenderTarget fromD3D11Texture(void *texture, uint format, const QSize &pixelSize, int sampleCount = 1);
48 static QQuickRenderTarget fromD3D11Texture(void *texture, const QSize &pixelSize, int sampleCount = 1);
49 static QQuickRenderTarget fromD3D12Texture(void *texture, int resourceState, uint format, const QSize &pixelSize, int sampleCount = 1);
50#endif
51
52#if defined(Q_OS_MACOS) || defined(Q_OS_IOS) || defined(Q_QDOC)
53 static QQuickRenderTarget fromMetalTexture(MTLTexture *texture, uint format, const QSize &pixelSize, int sampleCount = 1);
54 static QQuickRenderTarget fromMetalTexture(MTLTexture *texture, const QSize &pixelSize, int sampleCount = 1);
55#endif
56
57#if QT_CONFIG(vulkan) || defined(Q_QDOC)
58 static QQuickRenderTarget fromVulkanImage(VkImage image, VkImageLayout layout, VkFormat format, const QSize &pixelSize, int sampleCount = 1);
59 static QQuickRenderTarget fromVulkanImage(VkImage image, VkImageLayout layout, const QSize &pixelSize, int sampleCount = 1);
60#endif
61
62 static QQuickRenderTarget fromRhiRenderTarget(QRhiRenderTarget *renderTarget);
63
64 static QQuickRenderTarget fromPaintDevice(QPaintDevice *device);
65
66private:
67 void detach();
68 bool isEqual(const QQuickRenderTarget &other) const noexcept;
69 QQuickRenderTargetPrivate *d;
70 friend class QQuickRenderTargetPrivate;
71
72 friend bool operator==(const QQuickRenderTarget &lhs, const QQuickRenderTarget &rhs) noexcept
73 { return lhs.isEqual(other: rhs); }
74 friend bool operator!=(const QQuickRenderTarget &lhs, const QQuickRenderTarget &rhs) noexcept
75 { return !lhs.isEqual(other: rhs); }
76};
77
78QT_END_NAMESPACE
79
80#endif // QQUICKRENDERTARGET_H
81

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