wayland/buffer: Move scanout lifetime handling

There doesn't seem to be a good reason to keep this code in
`MetaWaylandSurface`. Moving it to `MetaWaylandBuffer` cleans things
up and will allow us to tread buffers differently depending on their
type.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3559>
This commit is contained in:
Robert Mader
2024-02-02 17:52:27 +01:00
parent 03a98343d2
commit a422ae022b
2 changed files with 21 additions and 26 deletions

View File

@ -897,6 +897,16 @@ try_acquire_egl_image_scanout (MetaWaylandBuffer *buffer,
#endif
}
static void
scanout_destroyed (gpointer data,
GObject *where_the_object_was)
{
MetaWaylandBuffer *buffer = data;
meta_wayland_buffer_dec_use_count (buffer);
g_object_unref (buffer);
}
CoglScanout *
meta_wayland_buffer_try_acquire_scanout (MetaWaylandBuffer *buffer,
CoglOnscreen *onscreen)
@ -936,9 +946,15 @@ meta_wayland_buffer_try_acquire_scanout (MetaWaylandBuffer *buffer,
return NULL;
}
if (scanout)
g_signal_connect (scanout, "scanout-failed",
G_CALLBACK (on_scanout_failed), buffer);
if (!scanout)
return NULL;
g_signal_connect (scanout, "scanout-failed",
G_CALLBACK (on_scanout_failed), buffer);
g_object_ref (buffer);
meta_wayland_buffer_inc_use_count (buffer);
g_object_weak_ref (G_OBJECT (scanout), scanout_destroyed, buffer);
return scanout;
}