Blame 0031-wayland-Always-realize-buffers-at-surface-commit-tim.patch

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