6#include <QtQuick/private/qquickitem_p.h>
7#include <QtQuick/private/qquickwindow_p.h>
8#include <QtQuick/private/qsgrhisupport_p.h>
31 pixelSize(
other->pixelSize),
32 devicePixelRatio(
other->devicePixelRatio),
33 sampleCount(
other->sampleCount),
35 mirrorVertically(
other->mirrorVertically)
51void QQuickRenderTarget::detach()
89 return d->
type == QQuickRenderTargetPrivate::Type::Null;
194#if QT_CONFIG(opengl) || defined(Q_QDOC)
196 const QSize &pixelSize,
int sampleCount)
202 qWarning(
"QQuickRenderTarget: textureId is invalid");
207 qWarning(
"QQuickRenderTarget: Cannot create with empty size");
211 d->type = QQuickRenderTargetPrivate::Type::NativeTexture;
212 d->pixelSize = pixelSize;
213 d->sampleCount =
qMax(1, sampleCount);
215 auto rhiFormat = QSGRhiSupport::toRhiTextureFormatFromGL(
format);
251 return fromOpenGLTexture(textureId, 0, pixelSize, sampleCount);
285 if (!renderbufferId) {
286 qWarning(
"QQuickRenderTarget: renderbufferId is invalid");
291 qWarning(
"QQuickRenderTarget: Cannot create with empty size");
295 d->type = QQuickRenderTargetPrivate::Type::NativeRenderbuffer;
296 d->pixelSize = pixelSize;
297 d->sampleCount =
qMax(1, sampleCount);
298 d->u.nativeRenderbufferObject = renderbufferId;
331#if defined(Q_OS_WIN) || defined(Q_QDOC)
333 const QSize &pixelSize,
int sampleCount)
339 qWarning(
"QQuickRenderTarget: texture is null");
344 qWarning(
"QQuickRenderTarget: Cannot create with empty size");
348 d->type = QQuickRenderTargetPrivate::Type::NativeTexture;
349 d->pixelSize = pixelSize;
350 d->sampleCount =
qMax(1, sampleCount);
352 QRhiTexture::Flags
flags;
353 auto rhiFormat = QSGRhiSupport::toRhiTextureFormatFromDXGI(
format, &
flags);
386 return fromD3D11Texture(
texture, 0 , pixelSize, sampleCount);
422 const QSize &pixelSize,
429 qWarning(
"QQuickRenderTarget: texture is null");
434 qWarning(
"QQuickRenderTarget: Cannot create with empty size");
438 d->type = QQuickRenderTargetPrivate::Type::NativeTexture;
439 d->pixelSize = pixelSize;
440 d->sampleCount =
qMax(1, sampleCount);
442 QRhiTexture::Flags
flags;
443 auto rhiFormat = QSGRhiSupport::toRhiTextureFormatFromDXGI(
format, &
flags);
477#if defined(Q_OS_MACOS) || defined(Q_OS_IOS) || defined(Q_QDOC)
479 const QSize &pixelSize,
int sampleCount)
485 qWarning(
"QQuickRenderTarget: texture is null");
490 qWarning(
"QQuickRenderTarget: Cannot create with empty size");
494 d->type = QQuickRenderTargetPrivate::Type::NativeTexture;
495 d->pixelSize = pixelSize;
496 d->sampleCount =
qMax(1, sampleCount);
498 QRhiTexture::Flags
flags;
499 auto rhiFormat = QSGRhiSupport::toRhiTextureFormatFromMetal(
format, &
flags);
532 return fromMetalTexture(
texture, 0 , pixelSize, sampleCount);
564#if QT_CONFIG(vulkan) || defined(Q_QDOC)
566 const QSize &pixelSize,
int sampleCount)
571 if (
image == VK_NULL_HANDLE) {
572 qWarning(
"QQuickRenderTarget: image is invalid");
577 qWarning(
"QQuickRenderTarget: Cannot create with empty size");
581 d->type = QQuickRenderTargetPrivate::Type::NativeTexture;
582 d->pixelSize = pixelSize;
583 d->sampleCount =
qMax(1, sampleCount);
585 QRhiTexture::Flags
flags;
586 auto rhiFormat = QSGRhiSupport::toRhiTextureFormatFromVulkan(
format, &
flags);
619 return fromVulkanImage(
image,
layout, VK_FORMAT_UNDEFINED, pixelSize, sampleCount);
645 qWarning(
"QQuickRenderTarget: Needs a valid QRhiRenderTarget");
649 d->type = QQuickRenderTargetPrivate::Type::RhiRenderTarget;
652 d->u.rhiRt = renderTarget;
676 d->type = QQuickRenderTargetPrivate::Type::PaintDevice;
700 if (
d->type !=
other.d->type
701 ||
d->pixelSize !=
other.d->pixelSize
702 ||
d->devicePixelRatio !=
other.d->devicePixelRatio
703 ||
d->sampleCount !=
other.d->sampleCount
704 ||
d->mirrorVertically !=
other.d->mirrorVertically)
710 case QQuickRenderTargetPrivate::Type::Null:
712 case QQuickRenderTargetPrivate::Type::NativeTexture:
713 if (
d->u.nativeTexture.object !=
other.d->u.nativeTexture.object
714 ||
d->u.nativeTexture.layoutOrState !=
other.d->u.nativeTexture.layoutOrState
715 ||
d->u.nativeTexture.rhiFormat !=
other.d->u.nativeTexture.rhiFormat
716 ||
d->u.nativeTexture.rhiFlags !=
other.d->u.nativeTexture.rhiFlags)
719 case QQuickRenderTargetPrivate::Type::NativeRenderbuffer:
720 if (
d->u.nativeRenderbufferObject !=
other.d->u.nativeRenderbufferObject)
723 case QQuickRenderTargetPrivate::Type::RhiRenderTarget:
724 if (
d->u.rhiRt !=
other.d->u.rhiRt)
727 case QQuickRenderTargetPrivate::Type::PaintDevice:
728 if (
d->u.paintDevice !=
other.d->u.paintDevice)
739 const QSize &pixelSize,
745 if (!depthStencil->create()) {
746 qWarning(
"Failed to build depth-stencil buffer for QQuickRenderTarget");
753 std::unique_ptr<QRhiRenderPassDescriptor> rp(rt->newCompatibleRenderPassDescriptor());
754 rt->setRenderPassDescriptor(rp.get());
757 qWarning(
"Failed to build texture render target for QQuickRenderTarget");
761 dst->renderTarget = rt.release();
762 dst->rpDesc = rp.release();
763 dst->depthStencil = depthStencil.release();
773 dst->renderTarget =
nullptr;
774 dst->paintDevice =
nullptr;
778 case Type::NativeTexture:
784 if (!
texture->createFrom({ u.nativeTexture.object, u.nativeTexture.layoutOrState })) {
785 qWarning(
"Failed to build wrapper texture for QQuickRenderTarget");
795 case Type::NativeRenderbuffer:
798 if (!
renderbuffer->createFrom({ u.nativeRenderbufferObject })) {
799 qWarning(
"Failed to build wrapper renderbuffer for QQuickRenderTarget");
809 case Type::RhiRenderTarget:
810 dst->renderTarget =
u.rhiRt;
811 dst->rpDesc =
u.rhiRt->renderPassDescriptor();
814 case Type::PaintDevice:
815 dst->paintDevice =
u.paintDevice;
IOBluetoothDevice * device
static QQuickRenderTargetPrivate * get(QQuickRenderTarget *rt)
QQuickRenderTargetPrivate()
bool resolve(QRhi *rhi, QQuickWindowRenderTarget *dst)
union QQuickRenderTargetPrivate::@687 u
The QQuickRenderTarget class provides an opaque container for native graphics resources specifying a ...
static QQuickRenderTarget fromPaintDevice(QPaintDevice *device)
void setMirrorVertically(bool enable)
Sets the size of the render target contents should be mirrored vertically to enable when drawing.
~QQuickRenderTarget()
Destructor.
QQuickRenderTarget & operator=(const QQuickRenderTarget &other)
qreal devicePixelRatio() const
void setDevicePixelRatio(qreal ratio)
Sets the device pixel ratio for this render target to ratio.
bool mirrorVertically() const
QQuickRenderTarget()
Constructs a default QQuickRenderTarget that does not reference any native objects.
static QQuickRenderTarget fromRhiRenderTarget(QRhiRenderTarget *renderTarget)
virtual QSize pixelSize() const =0
virtual int sampleCount() const =0
void setDepthStencilBuffer(QRhiRenderBuffer *renderBuffer)
Sets the renderBuffer for depth-stencil.
Format
Specifies the texture format.
QRhiRenderBuffer * newRenderBuffer(QRhiRenderBuffer::Type type, const QSize &pixelSize, int sampleCount=1, QRhiRenderBuffer::Flags flags={}, QRhiTexture::Format backingFormatHint=QRhiTexture::UnknownFormat)
QRhiTextureRenderTarget * newTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc, QRhiTextureRenderTarget::Flags flags={})
QRhiTexture * newTexture(QRhiTexture::Format format, const QSize &pixelSize, int sampleCount=1, QRhiTexture::Flags flags={})
constexpr bool isEmpty() const noexcept
Returns true if either of the width and height is less than or equal to 0; otherwise returns false.
Combined button and popup list for selecting options.
QT_WARNING_POP void qAtomicAssign(T *&d, T *x)
This is a helper for the assignment operators of implicitly shared classes.
void qAtomicDetach(T *&d)
This is a helper for the detach method of implicitly shared classes.
constexpr const T & qMax(const T &a, const T &b)
GLint GLsizei GLsizei GLenum format
static bool createRhiRenderTarget(const QRhiColorAttachment &colorAttachment, const QSize &pixelSize, int sampleCount, QRhi *rhi, QQuickWindowRenderTarget *dst)
unsigned long long quint64