diff options
author | Jørgen Lind <jorgen.lind@digia.com> | 2013-05-31 12:48:04 +0200 |
---|---|---|
committer | Andy Nichols <andy.nichols@digia.com> | 2013-06-03 15:43:08 +0200 |
commit | 63482addec06d2bbab0330271cb7d21869156760 (patch) | |
tree | 3ccd1c661a783a7350fc39d2d1b5137e9b5db380 /src | |
parent | df0faa069406e7a15669a62cfdd4414d7f815c1e (diff) | |
download | qtwayland-63482addec06d2bbab0330271cb7d21869156760.tar.gz |
Handle the commit protocol better in QtCompositor
Change-Id: I06477ee97ce95dcdb26ca4fae3cf7eeb7f1a2ace
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/compositor/wayland_wrapper/qwlsurface.cpp | 53 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/qwlsurfacebuffer.cpp | 3 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/qwlsurfacebuffer_p.h | 3 |
3 files changed, 48 insertions, 11 deletions
diff --git a/src/compositor/wayland_wrapper/qwlsurface.cpp b/src/compositor/wayland_wrapper/qwlsurface.cpp index f5e6db38..85dfddb4 100644 --- a/src/compositor/wayland_wrapper/qwlsurface.cpp +++ b/src/compositor/wayland_wrapper/qwlsurface.cpp @@ -71,6 +71,8 @@ QT_BEGIN_NAMESPACE namespace QtWayland { +static bool QT_WAYLAND_PRINT_BUFFERING_WARNINGS = qEnvironmentVariableIsSet("QT_WAYLAND_PRINT_BUFFERING_WARNINGS"); + Surface::Surface(struct wl_client *client, uint32_t id, Compositor *compositor) : QtWaylandServer::wl_surface(client, &base()->resource, id) , m_compositor(compositor) @@ -297,6 +299,8 @@ bool Surface::advanceBufferQueue() //do we have another buffer in the queue //and does it have a valid damage rect + if (m_backBuffer && !m_backBuffer->isDisplayed()) + return true; if (m_bufferQueue.size()) { int width = 0; int height = 0; @@ -305,6 +309,9 @@ bool Surface::advanceBufferQueue() height = m_backBuffer->height(); } + if (!m_bufferQueue.first()->isComitted()) + return false; + m_backBuffer = m_bufferQueue.takeFirst(); while (m_backBuffer && m_backBuffer->isDestroyed()) { m_backBuffer->disown(); @@ -347,6 +354,7 @@ void Surface::doUpdate() { sendFrameCallback(); } else { SurfaceBuffer *surfaceBuffer = currentSurfaceBuffer(); + if (surfaceBuffer) { if (surfaceBuffer->damageRect().isValid()) { m_compositor->markSurfaceAsDirty(this); @@ -382,7 +390,8 @@ bool Surface::postBuffer() { m_compositor->setDirectRenderingActive(true); return true; } else { - qDebug() << "could not post buffer"; + if (QT_WAYLAND_PRINT_BUFFERING_WARNINGS) + qWarning() << "could not post buffer"; } } } @@ -395,15 +404,19 @@ void Surface::attach(struct wl_buffer *buffer) { SurfaceBuffer *last = m_bufferQueue.size()?m_bufferQueue.last():0; if (last) { - if (last->waylandBufferHandle() == buffer) + if (last->waylandBufferHandle() == buffer) { + if (QT_WAYLAND_PRINT_BUFFERING_WARNINGS) + qWarning() << "attaching already attached buffer"; return; - if (!last->damageRect().isValid() || isCursorSurface() ){ + } + if (!last->damageRect().isValid() || !last->isComitted() || isCursorSurface() ){ last->disown(); m_bufferQueue.takeLast(); } } - m_bufferQueue << createSurfaceBuffer(buffer); + SurfaceBuffer *surfBuf = createSurfaceBuffer(buffer); + m_bufferQueue << surfBuf; if (!buffer) { InputDevice *inputDevice = m_compositor->defaultInputDevice(); @@ -416,12 +429,18 @@ void Surface::attach(struct wl_buffer *buffer) void Surface::damage(const QRect &rect) { - SurfaceBuffer *surfaceBuffer = m_bufferQueue.isEmpty() ? currentSurfaceBuffer() : m_bufferQueue.last(); - - if (surfaceBuffer) + if (m_bufferQueue.empty()) { + if (QT_WAYLAND_PRINT_BUFFERING_WARNINGS) + qWarning() << "Surface::damage() null buffer"; + return; + } + SurfaceBuffer *surfaceBuffer = m_bufferQueue.last(); + if (surfaceBuffer->isComitted()) { + if (QT_WAYLAND_PRINT_BUFFERING_WARNINGS) + qWarning("Surface::damage() on a committed surface"); + } else{ surfaceBuffer->setDamage(rect); - else - qWarning() << "Surface::damage() null buffer"; + } } void Surface::surface_destroy_resource(Resource *) @@ -466,9 +485,21 @@ void Surface::surface_set_input_region(Resource *, struct wl_resource *region) void Surface::surface_commit(Resource *) { - if (!m_bufferQueue.isEmpty() && !m_backBuffer) - advanceBufferQueue(); + if (m_bufferQueue.empty()) { + if (QT_WAYLAND_PRINT_BUFFERING_WARNINGS) + qWarning("Commit on invalid surface"); + return; + } + + SurfaceBuffer *surfaceBuffer = m_bufferQueue.last(); + if (surfaceBuffer->isComitted()) { + if (QT_WAYLAND_PRINT_BUFFERING_WARNINGS) + qWarning("Committing buffer that has already been committed"); + } else { + surfaceBuffer->setCommitted(); + } + advanceBufferQueue(); doUpdate(); } diff --git a/src/compositor/wayland_wrapper/qwlsurfacebuffer.cpp b/src/compositor/wayland_wrapper/qwlsurfacebuffer.cpp index a5b340bd..064d7be7 100644 --- a/src/compositor/wayland_wrapper/qwlsurfacebuffer.cpp +++ b/src/compositor/wayland_wrapper/qwlsurfacebuffer.cpp @@ -59,6 +59,7 @@ SurfaceBuffer::SurfaceBuffer(Surface *surface) , m_surface(surface) , m_compositor(surface->compositor()) , m_buffer(0) + , m_committed(false) , m_is_registered_for_buffer(false) , m_surface_has_buffer(false) , m_page_flipper_has_buffer(false) @@ -82,6 +83,7 @@ void SurfaceBuffer::initialize(wl_buffer *buffer) m_buffer = buffer; m_texture = 0; m_guard = 0; + m_committed = false; m_is_registered_for_buffer = true; m_surface_has_buffer = true; m_page_flipper_has_buffer = false; @@ -119,6 +121,7 @@ void SurfaceBuffer::destructBufferState() } m_buffer = 0; m_handle = 0; + m_committed = false; m_is_registered_for_buffer = false; m_is_displayed = false; m_image = QImage(); diff --git a/src/compositor/wayland_wrapper/qwlsurfacebuffer_p.h b/src/compositor/wayland_wrapper/qwlsurfacebuffer_p.h index 7d0fc627..2595f1fd 100644 --- a/src/compositor/wayland_wrapper/qwlsurfacebuffer_p.h +++ b/src/compositor/wayland_wrapper/qwlsurfacebuffer_p.h @@ -91,6 +91,8 @@ public: void setDisplayed(); + inline bool isComitted() const { return m_committed; } + inline void setCommitted() { m_committed = true; } inline bool isDisplayed() const { return m_is_displayed; } inline QRect damageRect() const { return m_damageRect; } @@ -115,6 +117,7 @@ private: struct wl_buffer *m_buffer; struct surface_buffer_destroy_listener m_destroy_listener; QRect m_damageRect; + bool m_committed; bool m_is_registered_for_buffer; bool m_surface_has_buffer; bool m_page_flipper_has_buffer; |