From baeb42184402454da3e337bbfa2f4d5c7346435f Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 12 Jul 2012 10:54:05 +0200 Subject: Support high resolution screens in QUIKit plugin We need to duplicate the scale factor of the screen for the UIView to avoid the final blit to scale the framebuffer, and we need to report scaled metrics to Qt. Change-Id: I79f9a06708436e70e8e7f632f2248b70813214f9 Reviewed-by: Jiang Jiang --- src/plugins/platforms/uikit/quikitscreen.mm | 6 +++++- src/plugins/platforms/uikit/quikitwindow.mm | 9 ++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/uikit/quikitscreen.mm b/src/plugins/platforms/uikit/quikitscreen.mm index 42a0cd6..b7e2324 100644 --- a/src/plugins/platforms/uikit/quikitscreen.mm +++ b/src/plugins/platforms/uikit/quikitscreen.mm @@ -54,7 +54,11 @@ QUIKitScreen::QUIKitScreen(int screenIndex) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; CGRect bounds = [uiScreen() bounds]; - m_geometry = QRect(bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height); + CGFloat scale = [uiScreen() scale]; + m_geometry = QRect(bounds.origin.x * scale, + bounds.origin.y * scale, + bounds.size.width * scale, + bounds.size.height * scale); m_format = QImage::Format_ARGB32_Premultiplied; diff --git a/src/plugins/platforms/uikit/quikitwindow.mm b/src/plugins/platforms/uikit/quikitwindow.mm index 288944c..99ba149 100644 --- a/src/plugins/platforms/uikit/quikitwindow.mm +++ b/src/plugins/platforms/uikit/quikitwindow.mm @@ -262,7 +262,8 @@ private: { UITouch *touch = [touches anyObject]; CGPoint locationInView = [touch locationInView:self]; - QPoint p(locationInView.x, locationInView.y); + CGFloat scaleFactor = [self contentScaleFactor]; + QPoint p(locationInView.x * scaleFactor, locationInView.y * scaleFactor); // TODO handle global touch point? for status bar? QWindowSystemInterface::handleMouseEvent(mWindow->widget(), (ulong)(event.timestamp*1000), p, p, buttons); @@ -370,6 +371,7 @@ UIWindow *QUIKitWindow::ensureNativeWindow() // view [mView deleteFramebuffer]; mView.frame = CGRectMake(0, 0, mWindow.bounds.size.width, mWindow.bounds.size.height); // fill + [mView setContentScaleFactor:[mWindow.screen scale]]; [mView setMultipleTouchEnabled:YES]; [mView setWindow:this]; [mWindow addSubview:mView]; @@ -413,6 +415,11 @@ void QUIKitWindow::updateGeometryAndOrientation() angle = +M_PI/2.; break; } + + CGFloat scale = [mScreen->uiScreen() scale]; + geom = QRect(geom.x() * scale, geom.y() * scale, + geom.width() * scale, geom.height() * scale); + if (angle != 0) { [mView layer].transform = CATransform3DMakeRotation(angle, 0, 0, 1.); } else { -- cgit v0.12