mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 19:42:05 +00:00
wayland: Simply store a MetaWaylandBuffer
There's no need for the MetaWaylandBufferReference abstraction...
This commit is contained in:
parent
13651949ed
commit
2f6f0f252c
@ -102,10 +102,9 @@ gboolean meta_wayland_compositor_handle_event (MetaWaylandComp
|
||||
MetaLauncher *meta_wayland_compositor_get_launcher (MetaWaylandCompositor *compositor);
|
||||
gboolean meta_wayland_compositor_is_native (MetaWaylandCompositor *compositor);
|
||||
|
||||
MetaWaylandBuffer * meta_wayland_buffer_from_resource (struct wl_resource *resource);
|
||||
|
||||
void meta_wayland_buffer_reference (MetaWaylandBufferReference *ref,
|
||||
MetaWaylandBuffer *buffer);
|
||||
MetaWaylandBuffer * meta_wayland_buffer_from_resource (struct wl_resource *resource);
|
||||
void meta_wayland_buffer_ref (MetaWaylandBuffer *buffer);
|
||||
void meta_wayland_buffer_unref (MetaWaylandBuffer *buffer);
|
||||
|
||||
void meta_wayland_compositor_update (MetaWaylandCompositor *compositor,
|
||||
const ClutterEvent *event);
|
||||
|
@ -72,8 +72,8 @@ meta_wayland_seat_update_cursor_surface (MetaWaylandSeat *seat)
|
||||
if (seat->cursor_tracker == NULL)
|
||||
return;
|
||||
|
||||
if (seat->cursor_surface && seat->cursor_surface->buffer_ref.buffer)
|
||||
buffer = seat->cursor_surface->buffer_ref.buffer->resource;
|
||||
if (seat->cursor_surface && seat->cursor_surface->buffer)
|
||||
buffer = seat->cursor_surface->buffer->resource;
|
||||
else
|
||||
buffer = NULL;
|
||||
|
||||
|
@ -71,6 +71,22 @@ typedef struct
|
||||
struct wl_listener sibling_destroy_listener;
|
||||
} MetaWaylandSubsurfacePlacementOp;
|
||||
|
||||
static void
|
||||
surface_set_buffer (MetaWaylandSurface *surface,
|
||||
MetaWaylandBuffer *buffer)
|
||||
{
|
||||
if (surface->buffer == buffer)
|
||||
return;
|
||||
|
||||
if (surface->buffer)
|
||||
meta_wayland_buffer_unref (surface->buffer);
|
||||
|
||||
surface->buffer = buffer;
|
||||
|
||||
if (surface->buffer)
|
||||
meta_wayland_buffer_ref (surface->buffer);
|
||||
}
|
||||
|
||||
static void
|
||||
surface_process_damage (MetaWaylandSurface *surface,
|
||||
cairo_region_t *region)
|
||||
@ -298,8 +314,8 @@ toplevel_surface_commit (MetaWaylandSurface *surface,
|
||||
int new_width;
|
||||
int new_height;
|
||||
|
||||
new_width = surface->buffer_ref.buffer->width;
|
||||
new_height = surface->buffer_ref.buffer->height;
|
||||
new_width = surface->buffer->width;
|
||||
new_height = surface->buffer->height;
|
||||
if (new_width != window->rect.width ||
|
||||
new_height != window->rect.height ||
|
||||
pending->dx != 0 ||
|
||||
@ -449,9 +465,9 @@ commit_double_buffered_state (MetaWaylandSurface *surface,
|
||||
gboolean buffer_changed = FALSE;
|
||||
|
||||
/* wl_surface.attach */
|
||||
if (pending->newly_attached && pending->buffer != surface->buffer_ref.buffer)
|
||||
if (pending->newly_attached && surface->buffer != pending->buffer)
|
||||
{
|
||||
meta_wayland_buffer_reference (&surface->buffer_ref, pending->buffer);
|
||||
surface_set_buffer (surface, pending->buffer);
|
||||
buffer_changed = TRUE;
|
||||
}
|
||||
|
||||
@ -528,7 +544,7 @@ meta_wayland_surface_free (MetaWaylandSurface *surface)
|
||||
|
||||
compositor->surfaces = g_list_remove (compositor->surfaces, surface);
|
||||
|
||||
meta_wayland_buffer_reference (&surface->buffer_ref, NULL);
|
||||
surface_set_buffer (surface, NULL);
|
||||
double_buffered_state_destroy (&surface->pending);
|
||||
g_object_unref (surface->surface_actor);
|
||||
if (surface->resource)
|
||||
|
@ -39,13 +39,7 @@ struct _MetaWaylandBuffer
|
||||
|
||||
CoglTexture *texture;
|
||||
int32_t width, height;
|
||||
uint32_t busy_count;
|
||||
};
|
||||
|
||||
struct _MetaWaylandBufferReference
|
||||
{
|
||||
MetaWaylandBuffer *buffer;
|
||||
struct wl_listener destroy_listener;
|
||||
uint32_t ref_count;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
@ -77,7 +71,7 @@ struct _MetaWaylandSurface
|
||||
{
|
||||
struct wl_resource *resource;
|
||||
MetaWaylandCompositor *compositor;
|
||||
MetaWaylandBufferReference buffer_ref;
|
||||
MetaWaylandBuffer *buffer;
|
||||
MetaSurfaceActor *surface_actor;
|
||||
MetaWindow *window;
|
||||
MetaWaylandSurfaceExtension xdg_surface;
|
||||
|
@ -138,6 +138,24 @@ meta_wayland_buffer_destroy_handler (struct wl_listener *listener,
|
||||
g_slice_free (MetaWaylandBuffer, buffer);
|
||||
}
|
||||
|
||||
void
|
||||
meta_wayland_buffer_ref (MetaWaylandBuffer *buffer)
|
||||
{
|
||||
buffer->ref_count++;
|
||||
}
|
||||
|
||||
void
|
||||
meta_wayland_buffer_unref (MetaWaylandBuffer *buffer)
|
||||
{
|
||||
buffer->ref_count--;
|
||||
if (buffer->ref_count == 0)
|
||||
{
|
||||
g_clear_pointer (&buffer->texture, cogl_object_unref);
|
||||
g_assert (wl_resource_get_client (buffer->resource));
|
||||
wl_resource_queue_event (buffer->resource, WL_BUFFER_RELEASE);
|
||||
}
|
||||
}
|
||||
|
||||
MetaWaylandBuffer *
|
||||
meta_wayland_buffer_from_resource (struct wl_resource *resource)
|
||||
{
|
||||
@ -165,46 +183,6 @@ meta_wayland_buffer_from_resource (struct wl_resource *resource)
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_wayland_buffer_reference_handle_destroy (struct wl_listener *listener,
|
||||
void *data)
|
||||
{
|
||||
MetaWaylandBufferReference *ref =
|
||||
wl_container_of (listener, ref, destroy_listener);
|
||||
|
||||
g_assert (data == ref->buffer);
|
||||
|
||||
ref->buffer = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
meta_wayland_buffer_reference (MetaWaylandBufferReference *ref,
|
||||
MetaWaylandBuffer *buffer)
|
||||
{
|
||||
if (ref->buffer && buffer != ref->buffer)
|
||||
{
|
||||
ref->buffer->busy_count--;
|
||||
|
||||
if (ref->buffer->busy_count == 0)
|
||||
{
|
||||
g_clear_pointer (&ref->buffer->texture, cogl_object_unref);
|
||||
g_assert (wl_resource_get_client (ref->buffer->resource));
|
||||
wl_resource_queue_event (ref->buffer->resource, WL_BUFFER_RELEASE);
|
||||
}
|
||||
|
||||
wl_list_remove (&ref->destroy_listener.link);
|
||||
}
|
||||
|
||||
if (buffer && buffer != ref->buffer)
|
||||
{
|
||||
buffer->busy_count++;
|
||||
wl_signal_add (&buffer->destroy_signal, &ref->destroy_listener);
|
||||
}
|
||||
|
||||
ref->buffer = buffer;
|
||||
ref->destroy_listener.notify = meta_wayland_buffer_reference_handle_destroy;
|
||||
}
|
||||
|
||||
void
|
||||
meta_wayland_compositor_set_input_focus (MetaWaylandCompositor *compositor,
|
||||
MetaWindow *window)
|
||||
|
Loading…
Reference in New Issue
Block a user