Fix rendering to QQuickWindow::renderTarget.
authorGunnar Sletta <gunnar@sletta.org>
Thu, 20 Aug 2015 12:16:15 +0000 (14:16 +0200)
committerGunnar Sletta <gunnar@sletta.org>
Thu, 20 Aug 2015 12:29:12 +0000 (12:29 +0000)
When setting an FBO, the size of the window should be irrelevant,
so we need to use the renderTargetSize to specify the viewport and
device rect.

Change-Id: Id76736cfaf6c511439bb8af80e3c641025d9d547
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
src/quick/items/qquickwindow.cpp

index 99dbf1d83e5d9bc8a1e8887fef0de619ef8f68d4..8ab910f299d1143c7e260b2890e8bd82778bd64b 100644 (file)
@@ -368,12 +368,15 @@ void QQuickWindowPrivate::renderSceneGraph(const QSize &size)
     if (!customRenderStage || !customRenderStage->render()) {
         int fboId = 0;
         const qreal devicePixelRatio = q->effectiveDevicePixelRatio();
-        renderer->setDeviceRect(QRect(QPoint(0, 0), size * devicePixelRatio));
         if (renderTargetId) {
+            QRect rect(QPoint(0, 0), renderTargetSize);
             fboId = renderTargetId;
-            renderer->setViewportRect(QRect(QPoint(0, 0), renderTargetSize));
+            renderer->setDeviceRect(rect);
+            renderer->setViewportRect(rect);
         } else {
-            renderer->setViewportRect(QRect(QPoint(0, 0), size * devicePixelRatio));
+            QRect rect(QPoint(0, 0), devicePixelRatio * size);
+            renderer->setDeviceRect(rect);
+            renderer->setViewportRect(rect);
         }
         renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), size));
         renderer->setDevicePixelRatio(devicePixelRatio);