static void cogland_surface_commit (struct wl_client *client, struct wl_resource *resource) { CoglandSurface *surface = wl_resource_get_user_data (resource); CoglandCompositor *compositor = surface->compositor; /* wl_surface.attach */ if (surface->pending.newly_attached && surface->buffer_ref.buffer != surface->pending.buffer) { CoglError *error = NULL; if (surface->texture) { cogl_object_unref (surface->texture); surface->texture = NULL; } cogland_buffer_reference (&surface->buffer_ref, surface->pending.buffer); if (surface->pending.buffer) { struct wl_resource *buffer_resource = surface->pending.buffer->resource; surface->texture = cogl_wayland_texture_2d_new_from_buffer (compositor->cogl_context, buffer_resource, &error); if (!surface->texture) { g_error ("Failed to create texture_2d from wayland buffer: %s", error->message); cogl_error_free (error); } } } if (surface->pending.buffer) { wl_list_remove (&surface->pending.buffer_destroy_listener.link); surface->pending.buffer = NULL; } surface->pending.sx = 0; surface->pending.sy = 0; surface->pending.newly_attached = FALSE; /* wl_surface.damage */ if (surface->buffer_ref.buffer && surface->texture && !region_is_empty (&surface->pending.damage)) { CoglandRegion *region = &surface->pending.damage; CoglTexture *texture = surface->texture; if (region->x2 > cogl_texture_get_width (texture)) region->x2 = cogl_texture_get_width (texture); if (region->y2 > cogl_texture_get_height (texture)) region->y2 = cogl_texture_get_height (texture); if (region->x1 < 0) region->x1 = 0; if (region->y1 < 0) region->y1 = 0; surface_damaged (surface, region->x1, region->y1, region->x2 - region->x1, region->y2 - region->y1); } region_init (&surface->pending.damage); /* wl_surface.frame */ wl_list_insert_list (&compositor->frame_callbacks, &surface->pending.frame_callback_list); wl_list_init (&surface->pending.frame_callback_list); }
static void move_resources(struct wl_list *destination, struct wl_list *source) { wl_list_insert_list(destination, source); wl_list_init(source); }