From 18d031fb1896001a9edbd42edfa8b2b7a6ba9825 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Sat, 22 Mar 2014 08:22:25 +0200 Subject: Don't create screen surface if there are no raster windows. Change-Id: Idaf5df814bb087707654d7ad7046ba8799f99c0a Reviewed-by: Sean Harmer Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/androidjnimain.cpp | 3 ++- src/plugins/platforms/android/qandroidplatformscreen.cpp | 13 +++++++++++-- src/plugins/platforms/android/qandroidplatformscreen.h | 2 ++ 3 files changed, 15 insertions(+), 3 deletions(-) (limited to 'src/plugins/platforms/android') diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index 784cc2e38b..ff1a40bfc5 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -576,7 +576,8 @@ static void updateWindow(JNIEnv */*env*/, jobject /*thiz*/) } QAndroidPlatformScreen *screen = static_cast(m_androidPlatformIntegration->screen()); - QMetaObject::invokeMethod(screen, "setDirty", Qt::QueuedConnection, Q_ARG(QRect,screen->geometry())); + if (screen->rasterSurfaces()) + QMetaObject::invokeMethod(screen, "setDirty", Qt::QueuedConnection, Q_ARG(QRect,screen->geometry())); } static void updateApplicationState(JNIEnv */*env*/, jobject /*thiz*/, jint state) diff --git a/src/plugins/platforms/android/qandroidplatformscreen.cpp b/src/plugins/platforms/android/qandroidplatformscreen.cpp index dbf317696f..678f4e6b5a 100644 --- a/src/plugins/platforms/android/qandroidplatformscreen.cpp +++ b/src/plugins/platforms/android/qandroidplatformscreen.cpp @@ -133,8 +133,10 @@ void QAndroidPlatformScreen::addWindow(QAndroidPlatformWindow *window) return; m_windowStack.prepend(window); - if (window->isRaster()) + if (window->isRaster()) { + m_rasterSurfaces.ref(); setDirty(window->geometry()); + } QWindow *w = topWindow(); QWindowSystemInterface::handleWindowActivated(w); @@ -148,8 +150,10 @@ void QAndroidPlatformScreen::removeWindow(QAndroidPlatformWindow *window) m_windowStack.removeOne(window); if (window->isRaster()) { + m_rasterSurfaces.deref(); setDirty(window->geometry()); } + QWindow *w = topWindow(); QWindowSystemInterface::handleWindowActivated(w); topWindowChanged(w); @@ -238,6 +242,11 @@ void QAndroidPlatformScreen::topWindowChanged(QWindow *w) } } +int QAndroidPlatformScreen::rasterSurfaces() +{ + return m_rasterSurfaces; +} + void QAndroidPlatformScreen::doRedraw() { PROFILE_SCOPE; @@ -246,7 +255,7 @@ void QAndroidPlatformScreen::doRedraw() return; QMutexLocker lock(&m_surfaceMutex); - if (m_id == -1) { + if (m_id == -1 && m_rasterSurfaces) { m_id = QtAndroid::createSurface(this, m_geometry, true, m_depth); m_surfaceWaitCondition.wait(&m_surfaceMutex); } diff --git a/src/plugins/platforms/android/qandroidplatformscreen.h b/src/plugins/platforms/android/qandroidplatformscreen.h index 625e77840e..96a91fbf06 100644 --- a/src/plugins/platforms/android/qandroidplatformscreen.h +++ b/src/plugins/platforms/android/qandroidplatformscreen.h @@ -82,6 +82,7 @@ public: void scheduleUpdate(); void topWindowChanged(QWindow *w); + int rasterSurfaces(); public slots: void setDirty(const QRect &rect); @@ -110,6 +111,7 @@ private slots: private: int m_id = -1; + QAtomicInt m_rasterSurfaces = 0; ANativeWindow* m_nativeSurface = nullptr; QWaitCondition m_surfaceWaitCondition; }; -- cgit v1.2.1