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>bb10
parent
08d7bacacc
commit
e6eadd6f61
|
|
@ -87,7 +87,6 @@ private:
|
|||
|
||||
QRect m_normalGeometry;
|
||||
int m_windowLevel;
|
||||
qreal m_devicePixelRatio;
|
||||
|
||||
void raiseOrLower(bool raise);
|
||||
void updateWindowLevel();
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue