aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorten Sørvig <morten.sorvig@qt.io>2022-11-23 10:11:52 +0100
committerMorten Sørvig <morten.sorvig@qt.io>2023-01-30 23:46:37 +0100
commit2a6897b9cee24c1631655c02cd41c3640e9d807a (patch)
treeb555aa50d41a70b3c6095d4b955c9ddf9454c169
parent6dc7fa90efa592dc555008b0e8d666c72801f31d (diff)
Fix "white line on top and left side of screen" issue
Reproduced on Android, where devices sometimes have screen sizes which are not evenly dividable by the device scale factor (see QTBUG-87334 for examples). Get the surface size for renderSceneGraph() directly from the QPlatformWindow size. This avoids using the QWindow size, which might have been rounded and can yield a surface size which are off by a one or two of pixels. Also change the "logicalSize" calculation to always use the size passed to renderSceneGraph(), in order to avoid rounding errors also here. Fixes: QTBUG-87334 Change-Id: I23b5784305a876e1ef15ff6b01be09c6ce28409e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
-rw-r--r--src/quick/items/qquickwindow.cpp12
-rw-r--r--src/quick/scenegraph/qsgthreadedrenderloop.cpp12
2 files changed, 13 insertions, 11 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index c6c7b6171e..5d993e4698 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -591,15 +591,7 @@ void QQuickWindowPrivate::renderSceneGraph(const QSize &size, const QSize &surfa
renderer->setDevicePixelRatio(1);
}
} else {
- QSize pixelSize;
- QSizeF logicalSize;
- if (surfaceSize.isEmpty()) {
- pixelSize = size * devicePixelRatio;
- logicalSize = size;
- } else {
- pixelSize = surfaceSize;
- logicalSize = QSizeF(surfaceSize) / devicePixelRatio;
- }
+ const QSize pixelSize = surfaceSize.isEmpty() ? size * devicePixelRatio : surfaceSize;
QRect rect(QPoint(0, 0), pixelSize);
renderer->setDeviceRect(rect);
renderer->setViewportRect(rect);
@@ -607,7 +599,7 @@ void QQuickWindowPrivate::renderSceneGraph(const QSize &size, const QSize &surfa
QSGAbstractRenderer::MatrixTransformFlags matrixFlags;
if (flipY)
matrixFlags |= QSGAbstractRenderer::MatrixTransformFlipY;
- renderer->setProjectionMatrixToRect(QRectF(QPoint(0, 0), logicalSize), matrixFlags);
+ renderer->setProjectionMatrixToRect(QRectF(QPoint(0, 0), size), matrixFlags);
renderer->setDevicePixelRatio(devicePixelRatio);
}
diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
index da0e8bdc7c..457e362b80 100644
--- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp
+++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
@@ -368,6 +368,7 @@ public:
QQuickWindow *window; // Will be 0 when window is not exposed
QSize windowSize;
+ QSize windowPixelSize;
float dpr = 1;
int rhiSampleCount = 1;
bool rhiDeviceLost = false;
@@ -406,6 +407,8 @@ bool QSGRenderThread::event(QEvent *e)
stopEventProcessing = true;
window = se->window;
windowSize = se->size;
+ if (window)
+ windowPixelSize = window->handle()->geometry().size();
dpr = se->dpr;
pendingUpdate |= SyncRequest;
@@ -833,7 +836,14 @@ void QSGRenderThread::syncAndRender(QImage *grabImage)
}
}
if (current) {
- d->renderSceneGraph(windowSize, rhi ? cd->swapchain->currentPixelSize() : QSize());
+ const QSize surfaceSize = [this, cd]{
+ if (rhi)
+ return cd->swapchain->currentPixelSize();
+ if (windowPixelSize.isValid())
+ return windowPixelSize;
+ return QSize();
+ }();
+ d->renderSceneGraph(windowSize, surfaceSize);
if (profileFrames)
renderTime = threadTimer.nsecsElapsed();