5#include <private/qguiapplication_p.h>
6#include <qpa/qplatformintegration.h>
7#include <private/qwidgetrepaintmanager_p.h>
178 qWarning(
"QRhiWidget: QRhi is not supported on this platform.");
180 d->setRenderToTexture();
182 d->config.setEnabled(
true);
183#if defined(Q_OS_DARWIN)
185#elif defined(Q_OS_WIN)
200 d->rhi->removeCleanupCallback(
this);
203 d->resetRenderTargetObjects();
204 d->resetColorBufferObjects();
208 d->offscreenRenderer.reset();
260 bool needsInit =
false;
261 d->ensureTexture(&needsInit);
262 if (
d->colorTexture ||
d->msaaColorBuffer) {
263 bool canRender =
true;
265 canRender =
d->invokeInitialize(
cb);
270 d->rhi->endOffscreenFrame();
283 d->textureInvalid =
true;
285 if (
d->rhi &&
d->rhi !=
d->offscreenRenderer.rhi()) {
290 d->rhi->removeCleanupCallback(
this);
292 d->releaseResources();
347 emit q->frameSubmitted();
373 qWarning(
"QRhiWidget: Failed to create dedicated QRhi for grabbing");
374 emit q->renderFailed();
384 bool readCompleted =
false;
385 bool needsInit =
false;
389 bool canRender =
true;
396 readResult.completed = [&readCompleted] { readCompleted =
true; };
398 cb->resourceUpdate(readbackBatch);
418 QImage wrapperImage(
reinterpret_cast<const uchar *
>(readResult.data.constData()),
419 readResult.pixelSize.width(), readResult.pixelSize.height(),
480 qWarning(
"The top-level window is already using another graphics API for composition, "
481 "'%s' is not compatible with this widget",
487 if (currentRhi &&
rhi != currentRhi) {
492 q->releaseResources();
511 q->releaseResources();
528 newSize =
q->size() *
q->devicePixelRatio();
559 qWarning(
"QRhiWidget: The requested texture format (%d) is not supported by the "
564 qWarning(
"Failed to create backing texture for QRhiWidget");
576 qWarning(
"QRhiWidget: Multisample renderbuffers are reported as unsupported; "
577 "sample count %d will not work as expected",
samples);
580 qWarning(
"QRhiWidget: The requested texture format (%d) is not supported by the "
585 qWarning(
"Failed to create multisample color buffer for QRhiWidget");
596 qWarning(
"Failed to create resolve texture for QRhiWidget");
612 qWarning(
"Failed to rebuild texture for QRhiWidget after resizing");
620 qWarning(
"Failed to rebuild multisample color buffer for QRhiWidget after resizing");
628 qWarning(
"Failed to rebuild resolve texture for QRhiWidget after resizing");
645 qWarning(
"Failed to create depth-stencil buffer for QRhiWidget");
652 qWarning(
"Failed to rebuild depth-stencil buffer for QRhiWidget with new size");
670 qWarning(
"Failed to create render target for QRhiWidget");
692 switch (
d->config.api()) {
761 return d->config.isDebugLayerEnabled();
782 d->config.setDebugLayer(
enable);
807 return d->widgetTextureFormat;
813 if (
d->widgetTextureFormat !=
format) {
814 d->widgetTextureFormat =
format;
910 if (
d->fixedSize != pixelSize) {
911 d->fixedSize = pixelSize;
930 return d->mirrorVertically;
936 if (
d->mirrorVertically !=
enabled) {
954 return d->autoRenderTarget;
974 if (
d->autoRenderTarget !=
enabled) {
1178 return d->colorTexture;
1220 return d->msaaColorBuffer;
1244 return d->resolveTexture;
1262 return d->depthStencilBuffer;
1286 return d->renderTarget;
void setConfig(const QPlatformBackingStoreRhiConfig &config)
static QRhi::Implementation apiToRhiBackend(QPlatformBackingStoreRhiConfig::Api api)
@ WindowAboutToChangeInternal
Type type() const
Returns the event type.
static QPlatformIntegration * platformIntegration()
QImage copy(const QRect &rect=QRect()) const
Returns a sub-area of the image as a new image.
Format
The following image formats are available in Qt.
QImage mirrored(bool horizontally=false, bool vertically=true) const &
void setDevicePixelRatio(qreal scaleFactor)
Sets the device pixel ratio for the image.
The QPaintEvent class contains event parameters for paint events.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
The QResizeEvent class contains event parameters for resize events.
const QSize & size() const
Returns the new size of the widget.
void setPixelSize(const QSize &sz)
Sets the size (in pixels) to sz.
virtual QRhiTexture::Format backingFormat() const =0
virtual bool create()=0
Creates the corresponding native graphics resources.
void setRenderPassDescriptor(QRhiRenderPassDescriptor *desc)
Sets the QRhiRenderPassDescriptor desc for use with this render target.
void readBackTexture(const QRhiReadbackDescription &rb, QRhiReadbackResult *result)
Enqueues a texture-to-host copy operation as described by rb.
void deleteLater()
When called without a frame being recorded, this function is equivalent to deleting the object.
virtual QRhiRenderPassDescriptor * newCompatibleRenderPassDescriptor()=0
virtual bool create()=0
Creates the corresponding native graphics resources.
virtual bool create()=0
Creates the corresponding native graphics resources.
void setPixelSize(const QSize &sz)
Sets the texture size, specified in pixels, to sz.
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
FrameOpResult endOffscreenFrame(EndFrameFlags flags={})
Ends, submits, and waits for the offscreen frame.
bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags={}) const
int resourceLimit(ResourceLimit limit) const
bool isYUpInFramebuffer() const
bool isFeatureSupported(QRhi::Feature feature) const
QRhiRenderBuffer * newRenderBuffer(QRhiRenderBuffer::Type type, const QSize &pixelSize, int sampleCount=1, QRhiRenderBuffer::Flags flags={}, QRhiTexture::Format backingFormatHint=QRhiTexture::UnknownFormat)
Implementation backend() const
FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, BeginFrameFlags flags={})
Starts a new offscreen frame.
QRhiTextureRenderTarget * newTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc, QRhiTextureRenderTarget::Flags flags={})
const char * backendName() const
void addCleanupCallback(const CleanupCallback &callback)
Registers a callback that is invoked either when the QRhi is destroyed, or when runCleanup() is calle...
QRhiTexture * newTexture(QRhiTexture::Format format, const QSize &pixelSize, int sampleCount=1, QRhiTexture::Flags flags={})
@ MultisampleRenderBuffer
QRhiResourceUpdateBatch * nextResourceUpdateBatch()
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
constexpr void setWidth(int w) noexcept
Sets the width to the given width.
constexpr bool isEmpty() const noexcept
Returns true if either of the width and height is less than or equal to 0; otherwise returns false.
constexpr void setHeight(int h) noexcept
Sets the height to the given height.
qDeleteAll(list.begin(), list.end())
Combined button and popup list for selecting options.
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLint GLsizei GLsizei GLenum format
GLdouble GLdouble GLdouble GLdouble q
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
QNetworkRequestFactory api
[0]
QRhiTexture * textureLeft