mirror of
https://github.com/brl/mutter.git
synced 2024-11-30 03:50:47 -05:00
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:
parent
03a98343d2
commit
a422ae022b
@ -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,10 +946,16 @@ meta_wayland_buffer_try_acquire_scanout (MetaWaylandBuffer *buffer,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (scanout)
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -2253,39 +2253,18 @@ meta_wayland_surface_get_buffer_height (MetaWaylandSurface *surface)
|
||||
return 0;
|
||||
}
|
||||
|
||||
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_surface_try_acquire_scanout (MetaWaylandSurface *surface,
|
||||
CoglOnscreen *onscreen)
|
||||
{
|
||||
CoglScanout *scanout;
|
||||
MetaWaylandBuffer *buffer;
|
||||
|
||||
if (!surface->buffer)
|
||||
return NULL;
|
||||
|
||||
if (surface->buffer->use_count == 0)
|
||||
return NULL;
|
||||
|
||||
scanout = meta_wayland_buffer_try_acquire_scanout (surface->buffer,
|
||||
return meta_wayland_buffer_try_acquire_scanout (surface->buffer,
|
||||
onscreen);
|
||||
if (!scanout)
|
||||
return NULL;
|
||||
|
||||
buffer = g_object_ref (surface->buffer);
|
||||
meta_wayland_buffer_inc_use_count (buffer);
|
||||
g_object_weak_ref (G_OBJECT (scanout), scanout_destroyed, buffer);
|
||||
|
||||
return scanout;
|
||||
}
|
||||
|
||||
MetaCrtc *
|
||||
|
Loading…
Reference in New Issue
Block a user