summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>2014-05-22 14:10:53 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-06-04 09:29:43 +0200
commit90808ead98edbab33a6bcc724d123864842a5ed3 (patch)
tree96c6bf1ef410a877c5b932ae4f7a6b1531ba7f56 /src/plugins
parentac7bf97f51837eecc5e5570d5d62996746f378ed (diff)
Android: Fix flashing on startup/shutdown
There were several issues on startup of the application which were caused by the fact that we would get the wrong available screen geometry on startup, set this as the initial surface size and then expose native windows with this size. This would cause first a flicker of white on the early expose and the window contents to jump around as the window was resized to the actual available space on screen. The fix for this is to postpone the first expose until we have actually got a proper screen size from the main layout. We use width,height = 0 as an indicator that the available geometry is not yet known, and we skip posting any expose events before this is set by the layout. In addition, since we removed the surface before we shut down the application, it was by a white rectangle before the shutdown transition happens, and this white rectangle will be animated instead of application contents. To rectify this, we make sure the last surface in the stack remains in the layout until it is either replaced by a different surface or until the application has shut down. This way, the shutdown animation will work on this surface instead. [ChangeLog][Android] Fixed regression where there would be flickering on startup and shutdown of the application. Task-number: QTBUG-38960 Change-Id: Ia1579ca8c522d8beeab066f78070ad49009d0238 Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/android/androidjnimain.cpp7
-rw-r--r--src/plugins/platforms/android/qandroidplatformopenglwindow.cpp24
-rw-r--r--src/plugins/platforms/android/qandroidplatformscreen.cpp15
-rw-r--r--src/plugins/platforms/android/qandroidplatformwindow.cpp4
4 files changed, 44 insertions, 6 deletions
diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp
index 7ca4db710b..d484a2faff 100644
--- a/src/plugins/platforms/android/androidjnimain.cpp
+++ b/src/plugins/platforms/android/androidjnimain.cpp
@@ -573,8 +573,11 @@ static void updateWindow(JNIEnv */*env*/, jobject /*thiz*/)
return;
if (QGuiApplication::instance() != 0) {
- foreach (QWindow *w, QGuiApplication::topLevelWindows())
- QWindowSystemInterface::handleExposeEvent(w, QRegion(w->geometry()));
+ foreach (QWindow *w, QGuiApplication::topLevelWindows()) {
+ QRect availableGeometry = w->screen()->availableGeometry();
+ if (w->geometry().width() > 0 && w->geometry().height() > 0 && availableGeometry.width() > 0 && availableGeometry.height() > 0)
+ QWindowSystemInterface::handleExposeEvent(w, QRegion(w->geometry()));
+ }
}
QAndroidPlatformScreen *screen = static_cast<QAndroidPlatformScreen *>(m_androidPlatformIntegration->screen());
diff --git a/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp b/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp
index 34db729289..5a028e8a5b 100644
--- a/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp
+++ b/src/plugins/platforms/android/qandroidplatformopenglwindow.cpp
@@ -47,7 +47,8 @@
#include <QSurfaceFormat>
#include <qpa/qwindowsysteminterface.h>
-
+#include <qpa/qplatformscreen.h>
+#include <QtPlatformSupport/private/qeglconvenience_p.h>
#include <android/native_window.h>
#include <android/native_window_jni.h>
@@ -77,8 +78,20 @@ void QAndroidPlatformOpenGLWindow::setGeometry(const QRect &rect)
if (rect == geometry())
return;
+ QRect oldGeometry = geometry();
+
QAndroidPlatformWindow::setGeometry(rect);
QtAndroid::setSurfaceGeometry(m_nativeSurfaceId, rect);
+
+ QRect availableGeometry = screen()->availableGeometry();
+ if (oldGeometry.width() == 0
+ && oldGeometry.height() == 0
+ && rect.width() > 0
+ && rect.height() > 0
+ && availableGeometry.width() > 0
+ && availableGeometry.height() > 0) {
+ QWindowSystemInterface::handleExposeEvent(window(), QRegion(rect));
+ }
}
EGLSurface QAndroidPlatformOpenGLWindow::eglSurface(EGLConfig config)
@@ -100,8 +113,11 @@ void QAndroidPlatformOpenGLWindow::checkNativeSurface(EGLConfig config)
createEgl(config);
+
// we've create another surface, the window should be repainted
- QWindowSystemInterface::handleExposeEvent(window(), QRegion(geometry()));
+ QRect availableGeometry = screen()->availableGeometry();
+ if (geometry().width() > 0 && geometry().height() > 0 && availableGeometry.width() > 0 && availableGeometry.height() > 0)
+ QWindowSystemInterface::handleExposeEvent(window(), QRegion(geometry()));
}
void QAndroidPlatformOpenGLWindow::createEgl(EGLConfig config)
@@ -143,7 +159,9 @@ void QAndroidPlatformOpenGLWindow::surfaceChanged(JNIEnv *jniEnv, jobject surfac
unlockSurface();
// repaint the window
- QWindowSystemInterface::handleExposeEvent(window(), QRegion(geometry()));
+ QRect availableGeometry = screen()->availableGeometry();
+ if (geometry().width() > 0 && geometry().height() > 0 && availableGeometry.width() > 0 && availableGeometry.height() > 0)
+ QWindowSystemInterface::handleExposeEvent(window(), QRegion(geometry()));
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/android/qandroidplatformscreen.cpp b/src/plugins/platforms/android/qandroidplatformscreen.cpp
index 678f4e6b5a..11472ce1da 100644
--- a/src/plugins/platforms/android/qandroidplatformscreen.cpp
+++ b/src/plugins/platforms/android/qandroidplatformscreen.cpp
@@ -55,6 +55,9 @@
#include <android/bitmap.h>
#include <android/native_window_jni.h>
+#include <QtGui/QGuiApplication>
+#include <QtGui/QWindow>
+
QT_BEGIN_NAMESPACE
#ifdef QANDROIDPLATFORMSCREEN_DEBUG
@@ -217,11 +220,23 @@ void QAndroidPlatformScreen::setGeometry(const QRect &rect)
if (m_geometry == rect)
return;
+ QRect oldGeometry = m_geometry;
+
m_geometry = rect;
QWindowSystemInterface::handleScreenGeometryChange(QPlatformScreen::screen(), geometry());
QWindowSystemInterface::handleScreenAvailableGeometryChange(QPlatformScreen::screen(), availableGeometry());
resizeMaximizedWindows();
+ if (oldGeometry.width() == 0 && oldGeometry.height() == 0 && rect.width() > 0 && rect.height() > 0) {
+ QList<QWindow *> windows = QGuiApplication::allWindows();
+ for (int i = 0; i < windows.size(); ++i) {
+ QWindow *w = windows.at(i);
+ QRect geometry = w->handle()->geometry();
+ if (geometry.width() > 0 && geometry.height() > 0)
+ QWindowSystemInterface::handleExposeEvent(w, QRegion(geometry));
+ }
+ }
+
if (m_id != -1) {
if (m_nativeSurface) {
ANativeWindow_release(m_nativeSurface);
diff --git a/src/plugins/platforms/android/qandroidplatformwindow.cpp b/src/plugins/platforms/android/qandroidplatformwindow.cpp
index b4231f0283..558525b78c 100644
--- a/src/plugins/platforms/android/qandroidplatformwindow.cpp
+++ b/src/plugins/platforms/android/qandroidplatformwindow.cpp
@@ -88,7 +88,9 @@ void QAndroidPlatformWindow::setVisible(bool visible)
setGeometry(platformScreen()->availableGeometry());
}
- QPlatformWindow::setVisible(visible);
+ QRect availableGeometry = screen()->availableGeometry();
+ if (geometry().width() > 0 && geometry().height() > 0 && availableGeometry.width() > 0 && availableGeometry.height() > 0)
+ QPlatformWindow::setVisible(visible);
if (visible)
platformScreen()->addWindow(this);