aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickwindow.cpp
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2014-10-29 10:48:54 +0100
committerFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2014-10-29 10:48:54 +0100
commit4e33b069c426c975319d91e11223114fd0d8ad40 (patch)
treed73e1251bc313b7303fdb000c0789cdfb4c7bb1f /src/quick/items/qquickwindow.cpp
parentd9e70d1a49af347f79db7e64bdd8e2e8083a77b5 (diff)
parent05d8ffb4dff5e693967c8ee7cee6d6158eadccbd (diff)
Merge remote-tracking branch 'origin/5.4' into dev
Conflicts: src/quick/items/qquickaccessibleattached_p.h src/quick/items/qquickwindow.cpp src/quick/scenegraph/qsgthreadedrenderloop.cpp Change-Id: I8bf07487a75f9d1b0d6efa5914dd06875fc9654d
Diffstat (limited to 'src/quick/items/qquickwindow.cpp')
-rw-r--r--src/quick/items/qquickwindow.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 34b1c474ed..6e82be383b 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -366,7 +366,7 @@ void QQuickWindowPrivate::renderSceneGraph(const QSize &size)
runAndClearJobs(&beforeRenderingJobs);
if (!customRenderStage || !customRenderStage->render()) {
int fboId = 0;
- const qreal devicePixelRatio = q->devicePixelRatio();
+ const qreal devicePixelRatio = q->effectiveDevicePixelRatio();
renderer->setDeviceRect(QRect(QPoint(0, 0), size * devicePixelRatio));
if (renderTargetId) {
fboId = renderTargetId;
@@ -375,11 +375,10 @@ void QQuickWindowPrivate::renderSceneGraph(const QSize &size)
renderer->setViewportRect(QRect(QPoint(0, 0), size * devicePixelRatio));
}
renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), size));
- renderer->setDevicePixelRatio(q->devicePixelRatio());
+ renderer->setDevicePixelRatio(devicePixelRatio);
context->renderNextFrame(renderer, fboId);
}
-
emit q->afterRendering();
runAndClearJobs(&afterRenderingJobs);
}
@@ -463,8 +462,7 @@ void QQuickWindowPrivate::init(QQuickWindow *c, QQuickRenderControl *control)
q->setSurfaceType(windowManager ? windowManager->windowSurfaceType() : QSurface::OpenGLSurface);
q->setFormat(sg->defaultSurfaceFormat());
- animationController = new QQuickAnimatorController();
- animationController->m_window = q;
+ animationController = new QQuickAnimatorController(q);
delayedTouch = 0;
@@ -3178,7 +3176,7 @@ QImage QQuickWindow::grabWindow()
d->syncSceneGraph();
d->renderSceneGraph(size());
- QImage image = qt_gl_read_framebuffer(size() * devicePixelRatio(), false, false);
+ QImage image = qt_gl_read_framebuffer(size() * effectiveDevicePixelRatio(), false, false);
d->cleanupNodesOnShutdown();
d->context->invalidate();
context.doneCurrent();
@@ -3941,6 +3939,23 @@ void QQuickWindow::runJobsAfterSwap()
d->runAndClearJobs(&d->afterSwapJobs);
}
+/*!
+ * Returns the device pixel ratio for this window.
+ *
+ * This is different from QWindow::devicePixelRatio() in that it supports
+ * redirected rendering via QQuickRenderControl. When using a
+ * QQuickRenderControl, the QQuickWindow is often not created, meaning it is
+ * never shown and there is no underlying native window created in the
+ * windowing system. As a result, querying properties like the device pixel
+ * ratio cannot give correct results. Use this function instead.
+ *
+ * \sa QWindow::devicePixelRatio()
+ */
+int QQuickWindow::effectiveDevicePixelRatio() const
+{
+ QWindow *w = QQuickRenderControl::renderWindowFor(const_cast<QQuickWindow *>(this));
+ return w ? w->devicePixelRatio() : devicePixelRatio();
+}
#include "moc_qquickwindow.cpp"