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>bb10
parent
b3819d9cc2
commit
96d0f2af75
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue