From 22c058afd75f18ee4cffb43442fb46455076f3fb Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 30 Nov 2011 15:59:54 +0100 Subject: [PATCH] Direct rendering fixes MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Make sure that we release the right buffer at the right time. Change-Id: I181f92ad3eb27fda43a616dcf26aa611e144a2f1 Reviewed-by: Jørgen Lind --- .../wayland_egl/waylandeglintegration.cpp | 14 +++++++++++--- src/qt-compositor/wayland_wrapper/wlcompositor.cpp | 10 ++++++++++ src/qt-compositor/wayland_wrapper/wlcompositor.h | 3 +++ src/qt-compositor/wayland_wrapper/wlsurface.cpp | 10 ++++++---- 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/qt-compositor/hardware_integration/wayland_egl/waylandeglintegration.cpp b/src/qt-compositor/hardware_integration/wayland_egl/waylandeglintegration.cpp index 80e1aec..0b55571 100644 --- a/src/qt-compositor/hardware_integration/wayland_egl/waylandeglintegration.cpp +++ b/src/qt-compositor/hardware_integration/wayland_egl/waylandeglintegration.cpp @@ -39,6 +39,7 @@ ****************************************************************************/ #include "waylandeglintegration.h" +#include "wayland_wrapper/wlcompositor.h" #include #include @@ -63,17 +64,17 @@ class WaylandEglIntegrationPrivate { public: WaylandEglIntegrationPrivate() - : egl_display(EGL_NO_DISPLAY) + : egl_display(EGL_NO_DISPLAY), valid(false), flipperConnected(false) { } EGLDisplay egl_display; bool valid; + bool flipperConnected; }; WaylandEglIntegration::WaylandEglIntegration(WaylandCompositor *compositor) : GraphicsHardwareIntegration(compositor) , d_ptr(new WaylandEglIntegrationPrivate) { - d_ptr->valid = false; } void WaylandEglIntegration::initializeHardware(Wayland::Display *waylandDisplay) @@ -131,8 +132,15 @@ GLuint WaylandEglIntegration::createTextureFromBuffer(wl_buffer *buffer, QOpenGL bool WaylandEglIntegration::setDirectRenderSurface(WaylandSurface *) { + Q_D(WaylandEglIntegration); + QPlatformScreen *screen = QPlatformScreen::platformScreenForWindow(m_compositor->window()); - return screen && screen->pageFlipper(); + QPlatformScreenPageFlipper *flipper = screen ? screen->pageFlipper() : 0; + if (flipper && !d->flipperConnected) { + QObject::connect(flipper, SIGNAL(bufferReleased(void*)), m_compositor->handle(), SLOT(releaseBuffer(void*))); + d->flipperConnected = true; + } + return flipper; } diff --git a/src/qt-compositor/wayland_wrapper/wlcompositor.cpp b/src/qt-compositor/wayland_wrapper/wlcompositor.cpp index 493c9e4..60dabc0 100644 --- a/src/qt-compositor/wayland_wrapper/wlcompositor.cpp +++ b/src/qt-compositor/wayland_wrapper/wlcompositor.cpp @@ -243,6 +243,16 @@ uint Compositor::currentTimeMsecs() return 0; } +void Compositor::releaseBuffer(void *bufferHandle) +{ + struct wl_buffer *buffer = static_cast(bufferHandle); + if (buffer) { + qDebug() << "WL_BUFFER_RELEASE" << buffer<< buffer->resource.client; + wl_resource_post_event(&buffer->resource, WL_BUFFER_RELEASE); + } + +} + void Compositor::processWaylandEvents() { int ret = wl_event_loop_dispatch(m_loop, 0); diff --git a/src/qt-compositor/wayland_wrapper/wlcompositor.h b/src/qt-compositor/wayland_wrapper/wlcompositor.h index 1eec509..9aaba77 100644 --- a/src/qt-compositor/wayland_wrapper/wlcompositor.h +++ b/src/qt-compositor/wayland_wrapper/wlcompositor.h @@ -115,6 +115,9 @@ public: void sendDragMoveEvent(const QPoint &global, const QPoint &local, Surface *surface); void sendDragEndEvent(); +public slots: + void releaseBuffer(void*); + signals: void clientAdded(wl_client *client); diff --git a/src/qt-compositor/wayland_wrapper/wlsurface.cpp b/src/qt-compositor/wayland_wrapper/wlsurface.cpp index 2ccb649..1edbeb7 100644 --- a/src/qt-compositor/wayland_wrapper/wlsurface.cpp +++ b/src/qt-compositor/wayland_wrapper/wlsurface.cpp @@ -246,11 +246,13 @@ void Surface::damage(const QRect &rect) glDeleteTextures(1,&d->texture_id); d->textureCreatedForBuffer = false; } + if (d->previousBuffer) { //previousBuffer means previous buffer turned into texture + wl_resource_post_event(&d->previousBuffer->resource,WL_BUFFER_RELEASE); + d->previousBuffer = 0; + } if (d->compositor->graphicsHWIntegration()->postBuffer(d->buffer())) { - if (d->previousBuffer) { - wl_resource_post_event(&d->previousBuffer->resource,WL_BUFFER_RELEASE); - } - d->directRenderBuffer = d->previousBuffer = d->buffer(); + d->directRenderBuffer = d->buffer(); + emit d->qtSurface->damaged(rect); return; } } -- 2.7.4