From 7212b52e85f254cb079698ee2d63b0444a900466 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 11 Mar 2015 21:25:09 +0100 Subject: iOS: Clarify implementation of QIOSWindow::isExposed() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We treat windows as exposed even if the application state is still inactive (e.g. during startup), otherwise there's a visible moment of black screen between the launch screen fading out and the app rendering its first pixel. Change-Id: I48368459a8a46fa1c5b2853ea88adfe1ac61b6f7 Reviewed-by: Richard Moe Gustavsen Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qioswindow.mm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index b22fa4ec58..95a4c28246 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -206,6 +206,25 @@ void QIOSWindow::applyGeometry(const QRect &rect) bool QIOSWindow::isExposed() const { + // Note: At startup of an iOS app it will enter UIApplicationStateInactive + // while showing the launch screen, and once the application returns from + // applicationDidFinishLaunching it will hide the launch screen and enter + // UIApplicationStateActive. Technically, a window is not exposed until + // it's actually visible on screen, and Apple also documents that "Apps + // that use OpenGL ES for drawing must not use didFinishLaunching to + // prepare their drawing environment. Instead, defer any OpenGL ES + // drawing calls to applicationDidBecomeActive". Unfortunately, if we + // wait until the applicationState reaches ApplicationActive to signal + // that the window is exposed, we get a lag between hiding the launch + // screen and blitting the first pixels of the application, as Qt + // spends some time drawing those pixels in response to the expose. + // In practice there doesn't seem to be any issues starting GL setup + // and drawing from within applicationDidFinishLaunching, and this is + // also the recommended approach for other 3rd party GL toolkits on iOS, + // so we 'cheat', and report that a window is exposed even if the app + // is in UIApplicationStateInactive, so that the startup transition + // between the launch screen and the application content is smooth. + return qApp->applicationState() > Qt::ApplicationHidden && window()->isVisible() && !window()->geometry().isEmpty(); } -- cgit v1.2.3