From d8208154728f10c82635c5695f37fdb1058ba124 Mon Sep 17 00:00:00 2001 From: "Miguel A. Vico" Date: Sat, 6 May 2017 03:41:51 +0200 Subject: [PATCH] wayland: Always realize buffers at surface commit time Clients using EGLStream-backed buffers will expect the stream to be functional after wl_surface::attach(). That means the compositor-side stream must be created and a consumer attached to it. To resolve the above, this change realizes buffers even when the attach operation is deferred (e.g. synchronized subsurfaces). https://bugzilla.gnome.org/show_bug.cgi?id=782575 (cherry picked from commit 22723ca37173955d8ef4c6981795e91a85f4feb9) --- src/wayland/meta-wayland-buffer.c | 21 +++++++++------------ src/wayland/meta-wayland-buffer.h | 2 ++ src/wayland/meta-wayland-surface.c | 4 ++++ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/wayland/meta-wayland-buffer.c b/src/wayland/meta-wayland-buffer.c index 3396f450c..b4b1e7825 100644 --- a/src/wayland/meta-wayland-buffer.c +++ b/src/wayland/meta-wayland-buffer.c @@ -94,13 +94,13 @@ meta_wayland_buffer_get_resource (MetaWaylandBuffer *buffer) return buffer->resource; } -static gboolean +gboolean meta_wayland_buffer_is_realized (MetaWaylandBuffer *buffer) { return buffer->type != META_WAYLAND_BUFFER_TYPE_UNKNOWN; } -static gboolean +gboolean meta_wayland_buffer_realize (MetaWaylandBuffer *buffer) { EGLint format; @@ -131,13 +131,12 @@ meta_wayland_buffer_realize (MetaWaylandBuffer *buffer) { CoglTexture2D *texture; - buffer->egl_stream.stream = stream; - buffer->type = META_WAYLAND_BUFFER_TYPE_EGL_STREAM; - texture = meta_wayland_egl_stream_create_texture (stream, NULL); if (!texture) return FALSE; + buffer->egl_stream.stream = stream; + buffer->type = META_WAYLAND_BUFFER_TYPE_EGL_STREAM; buffer->texture = COGL_TEXTURE (texture); buffer->is_y_inverted = meta_wayland_egl_stream_is_y_inverted (stream); @@ -344,13 +343,11 @@ meta_wayland_buffer_attach (MetaWaylandBuffer *buffer, if (!meta_wayland_buffer_is_realized (buffer)) { - if (!meta_wayland_buffer_realize (buffer)) - { - g_set_error (error, G_IO_ERROR, - G_IO_ERROR_FAILED, - "Unknown buffer type"); - return FALSE; - } + /* The buffer should have been realized at surface commit time */ + g_set_error (error, G_IO_ERROR, + G_IO_ERROR_FAILED, + "Unknown buffer type"); + return FALSE; } switch (buffer->type) diff --git a/src/wayland/meta-wayland-buffer.h b/src/wayland/meta-wayland-buffer.h index e00a41e09..036f9d428 100644 --- a/src/wayland/meta-wayland-buffer.h +++ b/src/wayland/meta-wayland-buffer.h @@ -69,6 +69,8 @@ G_DECLARE_FINAL_TYPE (MetaWaylandBuffer, meta_wayland_buffer, MetaWaylandBuffer * meta_wayland_buffer_from_resource (struct wl_resource *resource); struct wl_resource * meta_wayland_buffer_get_resource (MetaWaylandBuffer *buffer); +gboolean meta_wayland_buffer_is_realized (MetaWaylandBuffer *buffer); +gboolean meta_wayland_buffer_realize (MetaWaylandBuffer *buffer); gboolean meta_wayland_buffer_attach (MetaWaylandBuffer *buffer, GError **error); CoglTexture * meta_wayland_buffer_get_texture (MetaWaylandBuffer *buffer); diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c index c9c229e6c..3c9a404c7 100644 --- a/src/wayland/meta-wayland-surface.c +++ b/src/wayland/meta-wayland-surface.c @@ -765,6 +765,10 @@ cleanup: static void meta_wayland_surface_commit (MetaWaylandSurface *surface) { + if (surface->pending->buffer && + !meta_wayland_buffer_is_realized (surface->pending->buffer)) + meta_wayland_buffer_realize (surface->pending->buffer); + /* * If this is a sub-surface and it is in effective synchronous mode, only * cache the pending surface state until either one of the following two