|
|
4c4b8b |
From 9966356963803db35997f26330fb1245777012a1 Mon Sep 17 00:00:00 2001
|
|
|
4c4b8b |
From: Olivier Fourdan <ofourdan@redhat.com>
|
|
|
4c4b8b |
Date: Thu, 15 Apr 2021 10:59:36 +0200
|
|
|
4c4b8b |
Subject: [PATCH xserver 11/27] xwayland/eglstream: Small refactoring
|
|
|
4c4b8b |
MIME-Version: 1.0
|
|
|
4c4b8b |
Content-Type: text/plain; charset=UTF-8
|
|
|
4c4b8b |
Content-Transfer-Encoding: 8bit
|
|
|
4c4b8b |
|
|
|
4c4b8b |
Some functions are called "callback" whereas they are not longer
|
|
|
4c4b8b |
callback functions or "unref" while they no longer deal with a reference
|
|
|
4c4b8b |
counter anymore, which is quite confusing. Rename those functions to be
|
|
|
4c4b8b |
more explicit.
|
|
|
4c4b8b |
|
|
|
4c4b8b |
Also, the pending streams can be destroyed in different places, move the
|
|
|
4c4b8b |
common code to separate function to avoid duplicating code and help with
|
|
|
4c4b8b |
readability of the code.
|
|
|
4c4b8b |
|
|
|
4c4b8b |
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
|
|
|
4c4b8b |
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
|
|
|
4c4b8b |
(cherry picked from commit 823f3254fabd16e5e721da57cd260beac9b8f8bd)
|
|
|
4c4b8b |
---
|
|
|
4c4b8b |
hw/xwayland/xwayland-glamor-eglstream.c | 42 ++++++++++++++-----------
|
|
|
4c4b8b |
1 file changed, 24 insertions(+), 18 deletions(-)
|
|
|
4c4b8b |
|
|
|
4c4b8b |
diff --git a/hw/xwayland/xwayland-glamor-eglstream.c b/hw/xwayland/xwayland-glamor-eglstream.c
|
|
|
4c4b8b |
index 64fe93b7c..9abb7b779 100644
|
|
|
4c4b8b |
--- a/hw/xwayland/xwayland-glamor-eglstream.c
|
|
|
4c4b8b |
+++ b/hw/xwayland/xwayland-glamor-eglstream.c
|
|
|
4c4b8b |
@@ -287,7 +287,7 @@ xwl_glamor_egl_device_has_egl_extensions(void *device,
|
|
|
4c4b8b |
}
|
|
|
4c4b8b |
|
|
|
4c4b8b |
static void
|
|
|
4c4b8b |
-xwl_eglstream_unref_pixmap_stream(struct xwl_pixmap *xwl_pixmap)
|
|
|
4c4b8b |
+xwl_eglstream_destroy_pixmap_stream(struct xwl_pixmap *xwl_pixmap)
|
|
|
4c4b8b |
{
|
|
|
4c4b8b |
struct xwl_screen *xwl_screen = xwl_pixmap->xwl_screen;
|
|
|
4c4b8b |
|
|
|
4c4b8b |
@@ -319,7 +319,17 @@ xwl_eglstream_unref_pixmap_stream(struct xwl_pixmap *xwl_pixmap)
|
|
|
4c4b8b |
}
|
|
|
4c4b8b |
|
|
|
4c4b8b |
static void
|
|
|
4c4b8b |
-xwl_glamor_eglstream_del_pending_stream_cb(struct xwl_pixmap *xwl_pixmap)
|
|
|
4c4b8b |
+xwl_glamor_eglstream_destroy_pending_stream(struct xwl_eglstream_pending_stream *pending)
|
|
|
4c4b8b |
+{
|
|
|
4c4b8b |
+ if (pending->cb)
|
|
|
4c4b8b |
+ wl_callback_destroy(pending->cb);
|
|
|
4c4b8b |
+ xwl_eglstream_window_set_pending(pending->window, NULL);
|
|
|
4c4b8b |
+ xorg_list_del(&pending->link);
|
|
|
4c4b8b |
+ free(pending);
|
|
|
4c4b8b |
+}
|
|
|
4c4b8b |
+
|
|
|
4c4b8b |
+static void
|
|
|
4c4b8b |
+xwl_glamor_eglstream_remove_pending_stream(struct xwl_pixmap *xwl_pixmap)
|
|
|
4c4b8b |
{
|
|
|
4c4b8b |
struct xwl_eglstream_private *xwl_eglstream =
|
|
|
4c4b8b |
xwl_eglstream_get(xwl_pixmap->xwl_screen);
|
|
|
4c4b8b |
@@ -328,10 +338,7 @@ xwl_glamor_eglstream_del_pending_stream_cb(struct xwl_pixmap *xwl_pixmap)
|
|
|
4c4b8b |
xorg_list_for_each_entry(pending,
|
|
|
4c4b8b |
&xwl_eglstream->pending_streams, link) {
|
|
|
4c4b8b |
if (pending->xwl_pixmap == xwl_pixmap) {
|
|
|
4c4b8b |
- wl_callback_destroy(pending->cb);
|
|
|
4c4b8b |
- xwl_eglstream_window_set_pending(pending->window, NULL);
|
|
|
4c4b8b |
- xorg_list_del(&pending->link);
|
|
|
4c4b8b |
- free(pending);
|
|
|
4c4b8b |
+ xwl_glamor_eglstream_destroy_pending_stream(pending);
|
|
|
4c4b8b |
break;
|
|
|
4c4b8b |
}
|
|
|
4c4b8b |
}
|
|
|
4c4b8b |
@@ -343,9 +350,9 @@ xwl_glamor_eglstream_destroy_pixmap(PixmapPtr pixmap)
|
|
|
4c4b8b |
struct xwl_pixmap *xwl_pixmap = xwl_pixmap_get(pixmap);
|
|
|
4c4b8b |
|
|
|
4c4b8b |
if (xwl_pixmap && pixmap->refcnt == 1) {
|
|
|
4c4b8b |
- xwl_glamor_eglstream_del_pending_stream_cb(xwl_pixmap);
|
|
|
4c4b8b |
+ xwl_glamor_eglstream_remove_pending_stream(xwl_pixmap);
|
|
|
4c4b8b |
+ xwl_eglstream_destroy_pixmap_stream(xwl_pixmap);
|
|
|
4c4b8b |
xwl_pixmap_del_buffer_release_cb(pixmap);
|
|
|
4c4b8b |
- xwl_eglstream_unref_pixmap_stream(xwl_pixmap);
|
|
|
4c4b8b |
}
|
|
|
4c4b8b |
return glamor_destroy_pixmap(pixmap);
|
|
|
4c4b8b |
}
|
|
|
4c4b8b |
@@ -432,8 +439,6 @@ xwl_eglstream_consumer_ready_callback(void *data,
|
|
|
4c4b8b |
struct xwl_eglstream_pending_stream *pending;
|
|
|
4c4b8b |
Bool found = FALSE;
|
|
|
4c4b8b |
|
|
|
4c4b8b |
- wl_callback_destroy(callback);
|
|
|
4c4b8b |
-
|
|
|
4c4b8b |
xorg_list_for_each_entry(pending, &xwl_eglstream->pending_streams, link) {
|
|
|
4c4b8b |
if (pending->cb == callback) {
|
|
|
4c4b8b |
found = TRUE;
|
|
|
4c4b8b |
@@ -442,8 +447,11 @@ xwl_eglstream_consumer_ready_callback(void *data,
|
|
|
4c4b8b |
}
|
|
|
4c4b8b |
assert(found);
|
|
|
4c4b8b |
|
|
|
4c4b8b |
+ wl_callback_destroy(callback);
|
|
|
4c4b8b |
+ pending->cb = NULL;
|
|
|
4c4b8b |
+
|
|
|
4c4b8b |
if (!pending->is_valid) {
|
|
|
4c4b8b |
- xwl_eglstream_unref_pixmap_stream(pending->xwl_pixmap);
|
|
|
4c4b8b |
+ xwl_eglstream_destroy_pixmap_stream(pending->xwl_pixmap);
|
|
|
4c4b8b |
goto out;
|
|
|
4c4b8b |
}
|
|
|
4c4b8b |
|
|
|
4c4b8b |
@@ -462,9 +470,7 @@ xwl_eglstream_consumer_ready_callback(void *data,
|
|
|
4c4b8b |
pending->window->drawable.id, pending->pixmap);
|
|
|
4c4b8b |
|
|
|
4c4b8b |
out:
|
|
|
4c4b8b |
- xwl_eglstream_window_set_pending(pending->window, NULL);
|
|
|
4c4b8b |
- xorg_list_del(&pending->link);
|
|
|
4c4b8b |
- free(pending);
|
|
|
4c4b8b |
+ xwl_glamor_eglstream_destroy_pending_stream(pending);
|
|
|
4c4b8b |
}
|
|
|
4c4b8b |
|
|
|
4c4b8b |
static const struct wl_callback_listener consumer_ready_listener = {
|
|
|
4c4b8b |
@@ -514,8 +520,8 @@ static const struct wl_buffer_listener xwl_eglstream_buffer_release_listener = {
|
|
|
4c4b8b |
};
|
|
|
4c4b8b |
|
|
|
4c4b8b |
static void
|
|
|
4c4b8b |
-xwl_eglstream_create_pending_stream(struct xwl_screen *xwl_screen,
|
|
|
4c4b8b |
- WindowPtr window, PixmapPtr pixmap)
|
|
|
4c4b8b |
+xwl_eglstream_create_pixmap_and_stream(struct xwl_screen *xwl_screen,
|
|
|
4c4b8b |
+ WindowPtr window, PixmapPtr pixmap)
|
|
|
4c4b8b |
{
|
|
|
4c4b8b |
struct xwl_eglstream_private *xwl_eglstream =
|
|
|
4c4b8b |
xwl_eglstream_get(xwl_screen);
|
|
|
4c4b8b |
@@ -599,8 +605,8 @@ xwl_glamor_eglstream_allow_commits(struct xwl_window *xwl_window)
|
|
|
4c4b8b |
/* Glamor pixmap has no backing stream yet; begin making one and disallow
|
|
|
4c4b8b |
* commits until then
|
|
|
4c4b8b |
*/
|
|
|
4c4b8b |
- xwl_eglstream_create_pending_stream(xwl_screen, xwl_window->window,
|
|
|
4c4b8b |
- pixmap);
|
|
|
4c4b8b |
+ xwl_eglstream_create_pixmap_and_stream(xwl_screen, xwl_window->window,
|
|
|
4c4b8b |
+ pixmap);
|
|
|
4c4b8b |
|
|
|
4c4b8b |
return FALSE;
|
|
|
4c4b8b |
}
|
|
|
4c4b8b |
--
|
|
|
4c4b8b |
2.31.1
|
|
|
4c4b8b |
|