7#include <QtCore/QCoreApplication>
9#include <QtQuick/private/qquickanimatorcontroller_p.h>
10#include <QtQuick/private/qsgdefaultrendercontext_p.h>
11#include <QtQuick/private/qsgrhisupport_p.h>
13#include <private/qsgrhishadereffectnode_p.h>
15#include <QtGui/private/qguiapplication_p.h>
16#include <qpa/qplatformintegration.h>
17#include <QtGui/qoffscreensurface.h>
19#include <QtQml/private/qqmlglobal_p.h>
21#include <QtQuick/QQuickWindow>
22#include <QtQuick/QQuickRenderTarget>
23#include <QtQuick/private/qquickwindow_p.h>
24#include <QtQuick/private/qquickitem_p.h>
25#include <QtQuick/private/qsgsoftwarerenderer_p.h>
26#include <QtCore/private/qobject_p.h>
28#include <QtQuick/private/qquickwindow_p.h>
125 frameStatus(NotRecordingFrame)
131 rc =
sg->createRenderContext();
178 d->windowDestroyed();
200#if QT_CONFIG(quick_shadereffect)
218 d->rc->moveToThread(targetThread);
238 d->sampleCount =
qMax(1, sampleCount);
249 return d->sampleCount;
303 qWarning(
"QQuickRenderControl::initialize called with no associated window");
317 params.sampleCount =
d->sampleCount;
318 params.initialSurfacePixelSize =
d->window->size() *
d->window->effectiveDevicePixelRatio();
319 params.maybeSurface =
d->window;
321 d->initialized =
true;
323 qWarning(
"QRhi is only compatible with default adaptation");
345 emit d->window->afterAnimating();
366 if (!
d->rhi->isRecordingFrame()) {
367 qWarning(
"QQuickRenderControl can only sync when beginFrame() has been called");
371 qWarning(
"QQuickRenderControl cannot be used with QRhi when no QRhiCommandBuffer is provided "
372 "(perhaps beginFrame() was not called or it was unsuccessful?)");
420 d->initialized =
false;
435 if (!
d->rhi->isRecordingFrame()) {
436 qWarning(
"QQuickRenderControl can only render when beginFrame() has been called");
440 qWarning(
"QQuickRenderControl cannot be used with QRhi when no QRhiCommandBuffer is provided");
492 if (softwareRenderer) {
497 QPaintDevice *prevDev = softwareRenderer->currentPaintDevice();
498 softwareRenderer->setCurrentPaintDevice(&grabContent);
499 softwareRenderer->markDirty();
502 softwareRenderer->setCurrentPaintDevice(prevDev);
506 qWarning(
"QQuickRenderControl: grabs are not supported with the current Qt Quick backend");
515 emit q->renderRequested();
521 emit q->sceneChanged();
569 return q->renderWindowFor(
window,
nullptr) ==
w;
689 qWarning(
"QQuickRenderControl: No QRhi in beginFrame()");
693 qWarning(
"QQuickRenderControl: beginFrame() must be followed by a call to endFrame() before calling beginFrame() again");
696 if (
d->rhi->isRecordingFrame()) {
697 qWarning(
"QQuickRenderControl: Attempted to beginFrame() while the QRhi is already recording a frame");
701 emit d->window->beforeFrameBegin();
741 qWarning(
"QQuickRenderControl: No QRhi in endFrame()");
745 qWarning(
"QQuickRenderControl: endFrame() must only be called after a successful beginFrame()");
748 if (!
d->rhi->isRecordingFrame()) {
749 qWarning(
"QQuickRenderControl: Attempted to endFrame() while the QRhi is not recording a frame");
753 d->rhi->endOffscreenFrame();
758 emit d->window->afterFrameEnd();
775 qWarning(
"QQuickRenderControl: No QVulkanInstance set for QQuickWindow, cannot initialize");
786 qWarning(
"QQuickRenderControl: Failed to initialize QRhi");
809#include "moc_qquickrendercontrol.cpp"
@ Format_ARGB32_Premultiplied
void setDevicePixelRatio(qreal scaleFactor)
Sets the device pixel ratio for the image.
\inmodule QtCore\reentrant
void flushFrameSynchronousEvents(QQuickWindow *win)
QQuickGraphicsConfiguration controls lower level graphics settings for the QQuickWindow.
void resetRhi(const QQuickGraphicsConfiguration &config)
QQuickRenderControlPrivate(QQuickRenderControl *renderControl)
QOffscreenSurface * offscreenSurface
static QQuickRenderControlPrivate * get(QQuickRenderControl *renderControl)
virtual bool isRenderWindow(const QWindow *w)
static bool isRenderWindowFor(QQuickWindow *quickWin, const QWindow *renderWin)
The QQuickRenderControl class provides a mechanism for rendering the Qt Quick scenegraph onto an offs...
virtual QWindow * renderWindow(QPoint *offset)
Reimplemented in subclasses to return the real window this render control is rendering into.
bool initialize()
Initializes the scene graph resources.
void endFrame()
Specifies the end of a graphics frame.
void prepareThread(QThread *targetThread)
Prepares rendering the Qt Quick scene outside the GUI thread.
void render()
Renders the scenegraph using the current context.
void setSamples(int sampleCount)
Sets the number of samples to use for multisampling.
~QQuickRenderControl() override
Destroys the instance.
QQuickRenderControl(QObject *parent=nullptr)
Constructs a QQuickRenderControl object, with parent object parent.
static QWindow * renderWindowFor(QQuickWindow *win, QPoint *offset=nullptr)
Returns the real window that win is being rendered to, if any.
QRhiCommandBuffer * commandBuffer() const
void beginFrame()
Specifies the start of a graphics frame.
void polishItems()
This function should be called as late as possible before sync().
QQuickWindow * window() const
bool sync()
This function is used to synchronize the QML scene with the rendering scene graph.
void invalidate()
Stop rendering and release resources.
QQuickGraphicsConfiguration graphicsConfig
static QQuickWindowPrivate * get(QQuickWindow *c)
QQuickRenderControl * renderControl
void cleanupNodesOnShutdown()
void setCustomCommandBuffer(QRhiCommandBuffer *cb)
QQuickDeliveryAgentPrivate * deliveryAgentPrivate() const
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
FrameOpResult
Describes the result of operations that can have a soft failure.
@ FrameOpSwapChainOutOfDate
The QSGContext holds the scene graph entry points for one QML engine.
static QSGContext * createDefaultContext()
Creates a default scene graph context for the current hardware.
void initialize(const QSGRenderContext::InitParams *params) override
Initializes the scene graph render context with the GL context context.
virtual void invalidate()
virtual GraphicsApi graphicsApi() const =0
Returns the graphics API that is in use by the Qt Quick scenegraph.
static void resetMaterialTypeCache(void *materialTypeCacheKey)
QOffscreenSurface * maybeCreateOffscreenSurface(QWindow *window)
RhiCreateResult createRhi(QQuickWindow *window, QSurface *offscreenSurface, bool forcePreferSwRenderer=false)
QRhi::Implementation rhiBackend() const
static QSGRhiSupport * instance()
Combined button and popup list for selecting options.
void qAddPostRoutine(QtCleanUpFunction p)
constexpr const T & qMax(const T &a, const T &b)
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLintptr offset
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei imageSize
GLdouble GLdouble GLdouble GLdouble q
static QT_BEGIN_NAMESPACE qreal dpr(const QWindow *w)
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)