Report 2.x scale factor for UIView on visionOS

The docs claim that this is the default, but in practice it's not
the case.

Change-Id: I5f6184cbfded2efedbac88023644d3c1e80e9901
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit a05f5457ca033214c1efcf528b85a09a9c758920)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2024-06-07 14:34:28 +02:00 committed by Qt Cherry-pick Bot
parent ad8b330ecc
commit c410163173
2 changed files with 12 additions and 1 deletions

View File

@ -322,7 +322,10 @@ QDpi QIOSScreen::logicalBaseDpi() const
qreal QIOSScreen::devicePixelRatio() const
{
#if defined(Q_OS_VISIONOS)
return 2.0; // Based on what iPad app reports
// Based on what iPad app reports, and what Apple
// documents to be the default scale factor on
// visionOS, and the minimum scale for assets.
return 2.0;
#else
return [m_uiScreen scale];
#endif

View File

@ -139,6 +139,14 @@ inline ulong getTimeStamp(UIEvent *event)
};
}
#endif
#if defined(Q_OS_VISIONOS)
// Although the "Drawing sharp layer-based content in visionOS" docs
// claim that by default a CALayer rasterizes at a 2x scale this does
// not seem to be the case in practice. So we explicitly set the view's
// scale factor based on the screen, where we hard-code it to 2.0.
self.contentScaleFactor = self.platformWindow->screen()->devicePixelRatio();
#endif
}
return self;