summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi/qrhigles2.cpp
diff options
context:
space:
mode:
authorMorten Sørvig <morten.sorvig@qt.io>2023-11-07 14:44:13 +0100
committerMorten Johan Sørvig <morten.sorvig@qt.io>2023-11-27 18:53:41 +0000
commit96d0f2af75aa069f2b6973a621b3bf6ebaafc9a5 (patch)
treefd045151db98b0a3cb44b2aa3f6a93b44a46c260 /src/gui/rhi/qrhigles2.cpp
parentb3819d9cc200100bcf3fc30bcd3353c50cc73c4c (diff)
Fix off-by-one surface pixel size on Android
m_window->size() may have been rounded for devices with DPI which results in a fractional DPR (e.g. 650 DPI / 160 DPI = 3.5 DPR). In this case scaling by devicePixelRatio does not give the correct result. Instead, use QPlatformWindow geometry and DPR to determine the device size, without using the (possibly) rounded device independent window size. Fixes: QTBUG-87334 Pick-to: 6.6 6.5 6.2 Change-Id: I280236a06516cdb2a1a259fd0cfa8084c1ce7f46 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/gui/rhi/qrhigles2.cpp')
-rw-r--r--src/gui/rhi/qrhigles2.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp
index 7148d59d18..fc57cbd072 100644
--- a/src/gui/rhi/qrhigles2.cpp
+++ b/src/gui/rhi/qrhigles2.cpp
@@ -7,6 +7,7 @@
#include <QtCore/qmap.h>
#include <QtGui/private/qopenglextensions_p.h>
#include <QtGui/private/qopenglprogrambinarycache_p.h>
+#include <QtGui/private/qwindow_p.h>
#include <qpa/qplatformopenglcontext.h>
#include <qmath.h>
@@ -6222,7 +6223,12 @@ QRhiRenderTarget *QGles2SwapChain::currentFrameRenderTarget(StereoTargetBuffer t
QSize QGles2SwapChain::surfacePixelSize()
{
Q_ASSERT(m_window);
- return m_window->size() * m_window->devicePixelRatio();
+ if (QPlatformWindow *platformWindow = m_window->handle())
+ // Prefer using QPlatformWindow geometry and DPR in order to avoid
+ // errors due to rounded QWindow geometry.
+ return platformWindow->geometry().size() * platformWindow->devicePixelRatio();
+ else
+ return m_window->size() * m_window->devicePixelRatio();
}
bool QGles2SwapChain::isFormatSupported(Format f)