[mutter/wip/carlosg/performance-improvements: 38/38] wayland: Use weak ref to keep track of buffers
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/performance-improvements: 38/38] wayland: Use weak ref to keep track of buffers
- Date: Mon, 22 May 2017 15:44:55 +0000 (UTC)
commit 8d75ea69e3eb022cc29b242c5bd484cdae7e86fa
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat May 6 22:46:06 2017 +0200
wayland: Use weak ref to keep track of buffers
Instead of using a one-shot signal meant to happen then the buffer
is being destroyed.
https://bugzilla.gnome.org/show_bug.cgi?id=782344
src/wayland/meta-wayland-surface.c | 34 +++++++++++++---------------------
src/wayland/meta-wayland-surface.h | 1 -
2 files changed, 13 insertions(+), 22 deletions(-)
---
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index 10a7aab..b67aa97 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -471,14 +471,6 @@ queue_surface_actor_frame_callbacks (MetaWaylandSurface *surface,
}
static void
-pending_buffer_resource_destroyed (MetaWaylandBuffer *buffer,
- MetaWaylandPendingState *pending)
-{
- g_signal_handler_disconnect (buffer, pending->buffer_destroy_handler_id);
- pending->buffer = NULL;
-}
-
-static void
pending_state_init (MetaWaylandPendingState *state)
{
state->newly_attached = FALSE;
@@ -510,8 +502,9 @@ pending_state_destroy (MetaWaylandPendingState *state)
g_clear_pointer (&state->opaque_region, cairo_region_destroy);
if (state->buffer)
- g_signal_handler_disconnect (state->buffer,
- state->buffer_destroy_handler_id);
+ g_object_remove_weak_pointer (G_OBJECT (state->buffer),
+ (gpointer *) &state->buffer);
+
wl_list_for_each_safe (cb, next, &state->frame_callback_list, link)
wl_resource_destroy (cb->resource);
}
@@ -528,7 +521,10 @@ move_pending_state (MetaWaylandPendingState *from,
MetaWaylandPendingState *to)
{
if (from->buffer)
- g_signal_handler_disconnect (from->buffer, from->buffer_destroy_handler_id);
+ {
+ g_object_remove_weak_pointer (G_OBJECT (from->buffer),
+ (gpointer *) &from->buffer);
+ }
to->newly_attached = from->newly_attached;
to->buffer = from->buffer;
@@ -554,10 +550,8 @@ move_pending_state (MetaWaylandPendingState *from,
if (to->buffer)
{
- to->buffer_destroy_handler_id =
- g_signal_connect (to->buffer, "resource-destroyed",
- G_CALLBACK (pending_buffer_resource_destroyed),
- to);
+ g_object_add_weak_pointer (G_OBJECT (to->buffer),
+ (gpointer *) &to->buffer);
}
pending_state_init (from);
@@ -913,8 +907,8 @@ wl_surface_attach (struct wl_client *client,
if (surface->pending->buffer)
{
- g_signal_handler_disconnect (surface->pending->buffer,
- surface->pending->buffer_destroy_handler_id);
+ g_object_remove_weak_pointer (G_OBJECT (surface->pending->buffer),
+ (gpointer *) &surface->pending->buffer);
}
surface->pending->newly_attached = TRUE;
@@ -924,10 +918,8 @@ wl_surface_attach (struct wl_client *client,
if (buffer)
{
- surface->pending->buffer_destroy_handler_id =
- g_signal_connect (buffer, "resource-destroyed",
- G_CALLBACK (pending_buffer_resource_destroyed),
- surface->pending);
+ g_object_add_weak_pointer (G_OBJECT (surface->pending->buffer),
+ (gpointer *) &surface->pending->buffer);
}
}
diff --git a/src/wayland/meta-wayland-surface.h b/src/wayland/meta-wayland-surface.h
index 36e066f..deda384 100644
--- a/src/wayland/meta-wayland-surface.h
+++ b/src/wayland/meta-wayland-surface.h
@@ -123,7 +123,6 @@ struct _MetaWaylandPendingState
/* wl_surface.attach */
gboolean newly_attached;
MetaWaylandBuffer *buffer;
- gulong buffer_destroy_handler_id;
int32_t dx;
int32_t dy;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]