Don't create screen surface if there are no raster windows.

Change-Id: Idaf5df814bb087707654d7ad7046ba8799f99c0a
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Reviewed-by: BogDan Vatra <bogdan@kde.org>
bb10
BogDan Vatra 2014-03-22 08:22:25 +02:00 committed by The Qt Project
parent bd9f490d45
commit 18d031fb18
3 changed files with 15 additions and 3 deletions

View File

@ -576,7 +576,8 @@ static void updateWindow(JNIEnv */*env*/, jobject /*thiz*/)
}
QAndroidPlatformScreen *screen = static_cast<QAndroidPlatformScreen *>(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)

View File

@ -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);
}

View File

@ -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;
};