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
|
#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 *
|
CoglScanout *
|
||||||
meta_wayland_buffer_try_acquire_scanout (MetaWaylandBuffer *buffer,
|
meta_wayland_buffer_try_acquire_scanout (MetaWaylandBuffer *buffer,
|
||||||
CoglOnscreen *onscreen)
|
CoglOnscreen *onscreen)
|
||||||
@ -936,9 +946,15 @@ meta_wayland_buffer_try_acquire_scanout (MetaWaylandBuffer *buffer,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scanout)
|
if (!scanout)
|
||||||
g_signal_connect (scanout, "scanout-failed",
|
return NULL;
|
||||||
G_CALLBACK (on_scanout_failed), buffer);
|
|
||||||
|
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;
|
return scanout;
|
||||||
}
|
}
|
||||||
|
@ -2253,39 +2253,18 @@ meta_wayland_surface_get_buffer_height (MetaWaylandSurface *surface)
|
|||||||
return 0;
|
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 *
|
CoglScanout *
|
||||||
meta_wayland_surface_try_acquire_scanout (MetaWaylandSurface *surface,
|
meta_wayland_surface_try_acquire_scanout (MetaWaylandSurface *surface,
|
||||||
CoglOnscreen *onscreen)
|
CoglOnscreen *onscreen)
|
||||||
{
|
{
|
||||||
CoglScanout *scanout;
|
|
||||||
MetaWaylandBuffer *buffer;
|
|
||||||
|
|
||||||
if (!surface->buffer)
|
if (!surface->buffer)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (surface->buffer->use_count == 0)
|
if (surface->buffer->use_count == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
scanout = meta_wayland_buffer_try_acquire_scanout (surface->buffer,
|
return meta_wayland_buffer_try_acquire_scanout (surface->buffer,
|
||||||
onscreen);
|
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 *
|
MetaCrtc *
|
||||||
|
Loading…
Reference in New Issue
Block a user