summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@digia.com>2013-11-11 15:38:43 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-14 19:26:20 +0100
commite6eadd6f61ae38a49a6bb355c02532cad2aacf4e (patch)
treeda8fc9bf190f104de010ff16a27d4e708475137a /src/plugins/platforms
parent08d7bacacc46debef2df695996b5408e2039ce7e (diff)
iOS: Flesh out device-pixel-ratio handling in QIOSWindow
We don't need to cache the device-pixel-ratio, as we can ask the UIView directly. We do need to set it though, as the default behavior of matching the screen scale does not apply for EAGL-backed views, but the ratio needs to match the current screen the view is on. Change-Id: I29e4a4fa4f4b767d86265ec899fb43a355b5c3a3 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/ios/qioswindow.h1
-rw-r--r--src/plugins/platforms/ios/qioswindow.mm22
2 files changed, 11 insertions, 12 deletions
diff --git a/src/plugins/platforms/ios/qioswindow.h b/src/plugins/platforms/ios/qioswindow.h
index b60290e479..9ab9a3a45e 100644
--- a/src/plugins/platforms/ios/qioswindow.h
+++ b/src/plugins/platforms/ios/qioswindow.h
@@ -87,7 +87,6 @@ private:
QRect m_normalGeometry;
int m_windowLevel;
- qreal m_devicePixelRatio;
void raiseOrLower(bool raise);
void updateWindowLevel();
diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm
index f46616db1d..6d7b793f0b 100644
--- a/src/plugins/platforms/ios/qioswindow.mm
+++ b/src/plugins/platforms/ios/qioswindow.mm
@@ -127,6 +127,16 @@
return self;
}
+- (void)willMoveToWindow:(UIWindow *)newWindow
+{
+ // UIKIt will normally set the scale factor of a view to match the corresponding
+ // screen scale factor, but views backed by CAEAGLLayers need to do this manually.
+ self.contentScaleFactor = newWindow && newWindow.screen ?
+ newWindow.screen.scale : [[UIScreen mainScreen] scale];
+
+ // FIXME: Allow the scale factor to be customized through QSurfaceFormat.
+}
+
- (void)layoutSubviews
{
// This method is the de facto way to know that view has been resized,
@@ -331,19 +341,9 @@ QIOSWindow::QIOSWindow(QWindow *window)
, m_view([[QUIView alloc] initWithQIOSWindow:this])
, m_normalGeometry(QPlatformWindow::geometry())
, m_windowLevel(0)
- , m_devicePixelRatio(1.0)
{
setParent(parent());
setWindowState(window->windowState());
-
- // Retina support: get screen scale factor and set it in the content view.
- // This will make framebufferObject() create a 2x frame buffer on retina
- // displays. Also set m_devicePixelRatio which is used for scaling the
- // paint device.
- if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] == YES) {
- m_devicePixelRatio = [[UIScreen mainScreen] scale];
- [m_view setContentScaleFactor: m_devicePixelRatio];
- }
}
QIOSWindow::~QIOSWindow()
@@ -522,7 +522,7 @@ void QIOSWindow::handleContentOrientationChange(Qt::ScreenOrientation orientatio
qreal QIOSWindow::devicePixelRatio() const
{
- return m_devicePixelRatio;
+ return m_view.contentScaleFactor;
}
QT_END_NAMESPACE