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

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