Commit 05ea6b99 authored by Andrew den Exter's avatar Andrew den Exter Committed by Andrew den Exter
Browse files

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: default avatarGiulio Camuffo <giulio.camuffo@jollamobile.com>
Showing with 20 additions and 3 deletions
......@@ -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
......
......@@ -355,6 +355,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;
}
......
......@@ -125,7 +125,9 @@ protected:
private:
friend class QWaylandSurfaceNode;
friend class QWaylandQuickSurface;
void init(QWaylandQuickSurface *);
void updateTexture(bool changed);
static QMutex *mutex;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment