Blame SOURCES/0015-xwayland-eglstream-Drop-the-list-of-pending-streams.patch

b6a310
From a68e939342aed0ea11c737d166e506442e048e90 Mon Sep 17 00:00:00 2001
b6a310
From: Olivier Fourdan <ofourdan@redhat.com>
b6a310
Date: Tue, 27 Apr 2021 14:17:19 +0200
b6a310
Subject: [PATCH xserver 15/27] xwayland/eglstream: Drop the list of pending
b6a310
 streams
b6a310
MIME-Version: 1.0
b6a310
Content-Type: text/plain; charset=UTF-8
b6a310
Content-Transfer-Encoding: 8bit
b6a310
b6a310
Now that the pending stream is associated with the xwl_pixmap for
b6a310
EGLStream and the xwl_pixmap itself is associated to the pixmap, we have
b6a310
a reliable way to get to those data from any pending stream.
b6a310
b6a310
As a result, the list of pending streams that we keep in the EGLStream
b6a310
global structure becomes useless.
b6a310
b6a310
So we can drop the pending stream's xwl_pixmap and also the list of
b6a310
pending streams altogether, and save us a walk though that list for each
b6a310
callback.
b6a310
b6a310
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
b6a310
Suggested-by: Michel Dänzer <mdaenzer@redhat.com>
b6a310
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
b6a310
(cherry picked from commit bee2ebb29f0999862ab39af26c673c00af40b082)
b6a310
---
b6a310
 hw/xwayland/xwayland-glamor-eglstream.c | 41 ++++++-------------------
b6a310
 1 file changed, 9 insertions(+), 32 deletions(-)
b6a310
b6a310
diff --git a/hw/xwayland/xwayland-glamor-eglstream.c b/hw/xwayland/xwayland-glamor-eglstream.c
b6a310
index 807bfcb1d..399a691d3 100644
b6a310
--- a/hw/xwayland/xwayland-glamor-eglstream.c
b6a310
+++ b/hw/xwayland/xwayland-glamor-eglstream.c
b6a310
@@ -55,12 +55,9 @@ struct xwl_eglstream_pending_stream {
b6a310
     PixmapPtr pixmap;
b6a310
     WindowPtr window;
b6a310
 
b6a310
-    struct xwl_pixmap *xwl_pixmap;
b6a310
     struct wl_callback *cb;
b6a310
 
b6a310
     Bool is_valid;
b6a310
-
b6a310
-    struct xorg_list link;
b6a310
 };
b6a310
 
b6a310
 struct xwl_eglstream_private {
b6a310
@@ -73,8 +70,6 @@ struct xwl_eglstream_private {
b6a310
 
b6a310
     SetWindowPixmapProcPtr SetWindowPixmap;
b6a310
 
b6a310
-    struct xorg_list pending_streams;
b6a310
-
b6a310
     Bool have_egl_damage;
b6a310
 
b6a310
     GLint blit_prog;
b6a310
@@ -308,7 +303,6 @@ xwl_glamor_eglstream_destroy_pending_stream(struct xwl_eglstream_pending_stream
b6a310
 {
b6a310
     if (pending->cb)
b6a310
         wl_callback_destroy(pending->cb);
b6a310
-    xorg_list_del(&pending->link);
b6a310
     free(pending);
b6a310
 }
b6a310
 
b6a310
@@ -514,28 +508,16 @@ xwl_eglstream_consumer_ready_callback(void *data,
b6a310
                                       struct wl_callback *callback,
b6a310
                                       uint32_t time)
b6a310
 {
b6a310
-    struct xwl_screen *xwl_screen = data;
b6a310
+    struct xwl_eglstream_pending_stream *pending = data;
b6a310
+    PixmapPtr pixmap = pending->pixmap;
b6a310
+    struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap);
b6a310
+    struct xwl_screen *xwl_screen = xwl_pixmap->xwl_screen;
b6a310
     struct xwl_eglstream_private *xwl_eglstream =
b6a310
         xwl_eglstream_get(xwl_screen);
b6a310
-    struct xwl_pixmap *xwl_pixmap;
b6a310
-    struct xwl_eglstream_pending_stream *pending;
b6a310
-    PixmapPtr pixmap;
b6a310
-    Bool found = FALSE;
b6a310
-
b6a310
-    xorg_list_for_each_entry(pending, &xwl_eglstream->pending_streams, link) {
b6a310
-        if (pending->cb == callback) {
b6a310
-            found = TRUE;
b6a310
-            break;
b6a310
-        }
b6a310
-    }
b6a310
-    assert(found);
b6a310
 
b6a310
     wl_callback_destroy(callback);
b6a310
     pending->cb = NULL;
b6a310
 
b6a310
-    xwl_pixmap = pending->xwl_pixmap;
b6a310
-    pixmap = pending->pixmap;
b6a310
-
b6a310
     if (!pending->is_valid) {
b6a310
         xwl_glamor_eglstream_remove_pending_stream(xwl_pixmap);
b6a310
         dixDestroyPixmap(pixmap, 0);
b6a310
@@ -571,11 +553,10 @@ static const struct wl_callback_listener consumer_ready_listener = {
b6a310
 };
b6a310
 
b6a310
 static struct xwl_eglstream_pending_stream *
b6a310
-xwl_eglstream_queue_pending_stream(struct xwl_screen *xwl_screen,
b6a310
-                                   WindowPtr window, PixmapPtr pixmap)
b6a310
+xwl_eglstream_queue_pending_stream(WindowPtr window, PixmapPtr pixmap)
b6a310
 {
b6a310
-    struct xwl_eglstream_private *xwl_eglstream =
b6a310
-        xwl_eglstream_get(xwl_screen);
b6a310
+    struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap);
b6a310
+    struct xwl_screen *xwl_screen = xwl_pixmap->xwl_screen;
b6a310
     struct xwl_eglstream_pending_stream *pending_stream;
b6a310
 
b6a310
     DebugF("eglstream: win %d queues new pending stream for pixmap %p\n",
b6a310
@@ -584,14 +565,11 @@ xwl_eglstream_queue_pending_stream(struct xwl_screen *xwl_screen,
b6a310
     pending_stream = malloc(sizeof(*pending_stream));
b6a310
     pending_stream->window = window;
b6a310
     pending_stream->pixmap = pixmap;
b6a310
-    pending_stream->xwl_pixmap = xwl_pixmap_get(pixmap);
b6a310
     pending_stream->is_valid = TRUE;
b6a310
-    xorg_list_init(&pending_stream->link);
b6a310
-    xorg_list_add(&pending_stream->link, &xwl_eglstream->pending_streams);
b6a310
 
b6a310
     pending_stream->cb = wl_display_sync(xwl_screen->display);
b6a310
     wl_callback_add_listener(pending_stream->cb, &consumer_ready_listener,
b6a310
-                             xwl_screen);
b6a310
+                             pending_stream);
b6a310
 
b6a310
     return pending_stream;
b6a310
 }
b6a310
@@ -667,7 +645,7 @@ xwl_eglstream_create_pixmap_and_stream(struct xwl_screen *xwl_screen,
b6a310
         xwl_eglstream->controller, xwl_window->surface, xwl_pixmap->buffer);
b6a310
 
b6a310
     xwl_pixmap->pending_stream =
b6a310
-        xwl_eglstream_queue_pending_stream(xwl_screen, window, pixmap);
b6a310
+        xwl_eglstream_queue_pending_stream(window, pixmap);
b6a310
 
b6a310
 fail:
b6a310
     if (stream_fd >= 0)
b6a310
@@ -1249,7 +1227,6 @@ xwl_glamor_init_eglstream(struct xwl_screen *xwl_screen)
b6a310
                   &xwl_eglstream_private_key, xwl_eglstream);
b6a310
 
b6a310
     xwl_eglstream->egl_device = egl_device;
b6a310
-    xorg_list_init(&xwl_eglstream->pending_streams);
b6a310
 
b6a310
     xwl_screen->eglstream_backend.init_egl = xwl_glamor_eglstream_init_egl;
b6a310
     xwl_screen->eglstream_backend.init_wl_registry = xwl_glamor_eglstream_init_wl_registry;
b6a310
-- 
b6a310
2.31.1
b6a310