summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den.exter@jollamobile.com>2015-06-25 12:33:41 +0000
committerAndrew den Exter <andrew.den.exter@qinetic.com.au>2015-06-29 11:32:03 +0000
commit05ea6b992f32443df27e38bdc8b21cf970755b57 (patch)
tree253fbc5cbb85c5737bc36b5e2c0a5761359b1aa5
parent1a4c9511e66a7d9d6c9a6be19b42c9bd58a112ed (diff)
downloadqtwayland-05ea6b992f32443df27e38bdc8b21cf970755b57.tar.gz
qtwayland-05ea6b992f32443df27e38bdc8b21cf970755b57.tar.bz2
qtwayland-05ea6b992f32443df27e38bdc8b21cf970755b57.zip
Prevent QWaylandQuickSurface from holding onto multiple buffers indefinitely.
With a queue of just two buffers BufferAttacher can end up holding references to both after the renderer is stopped starving the client application and causing it to block in the glSwapBuffers until the renderer restarts or the surface is destroyed. Release the current buffer to the client when the renderer is stopped so it can continue. Change-Id: Ica0e13ef78f7e6058e273c26b517a88d07f958c7 Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
-rw-r--r--src/compositor/compositor_api/qwaylandquicksurface.cpp14
-rw-r--r--src/compositor/compositor_api/qwaylandsurfaceitem.cpp7
-rw-r--r--src/compositor/compositor_api/qwaylandsurfaceitem.h2
3 files changed, 20 insertions, 3 deletions
diff --git a/src/compositor/compositor_api/qwaylandquicksurface.cpp b/src/compositor/compositor_api/qwaylandquicksurface.cpp
index 44e0edf5..ef78c884 100644
--- a/src/compositor/compositor_api/qwaylandquicksurface.cpp
+++ b/src/compositor/compositor_api/qwaylandquicksurface.cpp
@@ -103,9 +103,12 @@ public:
void invalidateTexture()
{
+ if (bufferRef)
+ bufferRef.destroyTexture();
delete texture;
texture = 0;
update = true;
+ bufferRef = QWaylandBufferRef();
}
QWaylandQuickSurface *surface;
@@ -209,6 +212,8 @@ bool QWaylandQuickSurface::event(QEvent *e)
this, &QWaylandQuickSurface::updateTexture);
disconnect(oldWindow, &QQuickWindow::sceneGraphInvalidated,
this, &QWaylandQuickSurface::invalidateTexture);
+ disconnect(oldWindow, &QQuickWindow::sceneGraphAboutToStop,
+ this, &QWaylandQuickSurface::invalidateTexture);
}
return true;
@@ -225,6 +230,9 @@ bool QWaylandQuickSurface::event(QEvent *e)
connect(window, &QQuickWindow::sceneGraphInvalidated,
this, &QWaylandQuickSurface::invalidateTexture,
Qt::DirectConnection);
+ connect(window, &QQuickWindow::sceneGraphAboutToStop,
+ this, &QWaylandQuickSurface::invalidateTexture,
+ Qt::DirectConnection);
}
return true;
@@ -236,10 +244,11 @@ bool QWaylandQuickSurface::event(QEvent *e)
void QWaylandQuickSurface::updateTexture()
{
Q_D(QWaylandQuickSurface);
+ const bool update = d->buffer->update;
if (d->buffer->update)
d->buffer->createTexture();
foreach (QWaylandSurfaceView *view, views())
- static_cast<QWaylandSurfaceItem *>(view)->updateTexture();
+ static_cast<QWaylandSurfaceItem *>(view)->updateTexture(update);
}
void QWaylandQuickSurface::invalidateTexture()
@@ -247,7 +256,8 @@ void QWaylandQuickSurface::invalidateTexture()
Q_D(QWaylandQuickSurface);
d->buffer->invalidateTexture();
foreach (QWaylandSurfaceView *view, views())
- static_cast<QWaylandSurfaceItem *>(view)->updateTexture();
+ static_cast<QWaylandSurfaceItem *>(view)->updateTexture(true);
+ emit redraw();
}
bool QWaylandQuickSurface::clientRenderingEnabled() const
diff --git a/src/compositor/compositor_api/qwaylandsurfaceitem.cpp b/src/compositor/compositor_api/qwaylandsurfaceitem.cpp
index 90a68c4f..93cfaf00 100644
--- a/src/compositor/compositor_api/qwaylandsurfaceitem.cpp
+++ b/src/compositor/compositor_api/qwaylandsurfaceitem.cpp
@@ -356,6 +356,11 @@ void QWaylandSurfaceItem::updateBuffer(bool hasBuffer)
void QWaylandSurfaceItem::updateTexture()
{
+ updateTexture(false);
+}
+
+void QWaylandSurfaceItem::updateTexture(bool changed)
+{
if (!m_provider)
m_provider = new QWaylandSurfaceTextureProvider();
@@ -363,7 +368,7 @@ void QWaylandSurfaceItem::updateTexture()
if (mapped)
m_provider->t = static_cast<QWaylandQuickSurface *>(surface())->texture();
m_provider->smooth = smooth();
- if (m_newTexture)
+ if (m_newTexture || changed)
emit m_provider->textureChanged();
m_newTexture = false;
}
diff --git a/src/compositor/compositor_api/qwaylandsurfaceitem.h b/src/compositor/compositor_api/qwaylandsurfaceitem.h
index 91dc6879..cb51b6bf 100644
--- a/src/compositor/compositor_api/qwaylandsurfaceitem.h
+++ b/src/compositor/compositor_api/qwaylandsurfaceitem.h
@@ -125,7 +125,9 @@ protected:
private:
friend class QWaylandSurfaceNode;
+ friend class QWaylandQuickSurface;
void init(QWaylandQuickSurface *);
+ void updateTexture(bool changed);
static QMutex *mutex;