presentation-time: drop wlr_presentation arg

There can only be a single presentation-time global advertised to
clients, this it's unnecessary to pass around the wlr_presentation
pointer.
This commit is contained in:
Simon Ser 2023-12-05 16:06:51 +01:00
parent 1968ada213
commit d68ba9d6c2
3 changed files with 19 additions and 42 deletions

View file

@ -71,7 +71,7 @@ struct wlr_presentation *wlr_presentation_create(struct wl_display *display,
* this surface. * this surface.
*/ */
struct wlr_presentation_feedback *wlr_presentation_surface_sampled( struct wlr_presentation_feedback *wlr_presentation_surface_sampled(
struct wlr_presentation *presentation, struct wlr_surface *surface); struct wlr_surface *surface);
void wlr_presentation_feedback_send_presented( void wlr_presentation_feedback_send_presented(
struct wlr_presentation_feedback *feedback, struct wlr_presentation_feedback *feedback,
const struct wlr_presentation_event *event); const struct wlr_presentation_event *event);
@ -92,8 +92,7 @@ void wlr_presentation_event_from_output(struct wlr_presentation_event *event,
* before a wlr_output_commit() call to indicate that the surface's current * before a wlr_output_commit() call to indicate that the surface's current
* contents have been copied to a buffer which will be displayed on the output. * contents have been copied to a buffer which will be displayed on the output.
*/ */
void wlr_presentation_surface_textured_on_output( void wlr_presentation_surface_textured_on_output(struct wlr_surface *surface,
struct wlr_presentation *presentation, struct wlr_surface *surface,
struct wlr_output *output); struct wlr_output *output);
/** /**
* Mark the current surface's buffer as scanned out on the given output. * Mark the current surface's buffer as scanned out on the given output.
@ -101,8 +100,7 @@ void wlr_presentation_surface_textured_on_output(
* Same as wlr_presentation_surface_textured_on_output(), but indicates direct * Same as wlr_presentation_surface_textured_on_output(), but indicates direct
* scan-out. * scan-out.
*/ */
void wlr_presentation_surface_scanned_out_on_output( void wlr_presentation_surface_scanned_out_on_output(struct wlr_surface *surface,
struct wlr_presentation *presentation, struct wlr_surface *surface,
struct wlr_output *output); struct wlr_output *output);
#endif #endif

View file

@ -54,11 +54,9 @@ static void handle_scene_buffer_output_sample(
} }
if (event->direct_scanout) { if (event->direct_scanout) {
wlr_presentation_surface_scanned_out_on_output( wlr_presentation_surface_scanned_out_on_output(surface->surface, scene_output->output);
root->presentation, surface->surface, scene_output->output);
} else { } else {
wlr_presentation_surface_textured_on_output( wlr_presentation_surface_textured_on_output(surface->surface, scene_output->output);
root->presentation, surface->surface, scene_output->output);
} }
} }

View file

@ -89,24 +89,13 @@ static const struct wlr_surface_synced_impl surface_synced_impl = {
.move_state = surface_synced_move_state, .move_state = surface_synced_move_state,
}; };
static const struct wp_presentation_interface presentation_impl;
static struct wlr_presentation *presentation_from_resource(
struct wl_resource *resource) {
assert(wl_resource_instance_of(resource, &wp_presentation_interface,
&presentation_impl));
return wl_resource_get_user_data(resource);
}
static void presentation_handle_feedback(struct wl_client *client, static void presentation_handle_feedback(struct wl_client *client,
struct wl_resource *presentation_resource, struct wl_resource *presentation_resource,
struct wl_resource *surface_resource, uint32_t id) { struct wl_resource *surface_resource, uint32_t id) {
struct wlr_presentation *presentation =
presentation_from_resource(presentation_resource);
struct wlr_surface *surface = wlr_surface_from_resource(surface_resource); struct wlr_surface *surface = wlr_surface_from_resource(surface_resource);
struct wlr_addon *addon = wlr_addon_find(&surface->addons, struct wlr_addon *addon =
presentation, &presentation_surface_addon_impl); wlr_addon_find(&surface->addons, NULL, &presentation_surface_addon_impl);
struct wlr_presentation_surface *p_surface = NULL; struct wlr_presentation_surface *p_surface = NULL;
if (addon != NULL) { if (addon != NULL) {
p_surface = wl_container_of(addon, p_surface, addon); p_surface = wl_container_of(addon, p_surface, addon);
@ -117,7 +106,7 @@ static void presentation_handle_feedback(struct wl_client *client,
return; return;
} }
wlr_addon_init(&p_surface->addon, &surface->addons, wlr_addon_init(&p_surface->addon, &surface->addons,
presentation, &presentation_surface_addon_impl); NULL, &presentation_surface_addon_impl);
if (!wlr_surface_synced_init(&p_surface->synced, surface, if (!wlr_surface_synced_init(&p_surface->synced, surface,
&surface_synced_impl, &p_surface->pending, &p_surface->current)) { &surface_synced_impl, &p_surface->pending, &p_surface->current)) {
free(p_surface); free(p_surface);
@ -163,16 +152,13 @@ static const struct wp_presentation_interface presentation_impl = {
static void presentation_bind(struct wl_client *client, void *data, static void presentation_bind(struct wl_client *client, void *data,
uint32_t version, uint32_t id) { uint32_t version, uint32_t id) {
struct wlr_presentation *presentation = data;
struct wl_resource *resource = wl_resource_create(client, struct wl_resource *resource = wl_resource_create(client,
&wp_presentation_interface, version, id); &wp_presentation_interface, version, id);
if (resource == NULL) { if (resource == NULL) {
wl_client_post_no_memory(client); wl_client_post_no_memory(client);
return; return;
} }
wl_resource_set_implementation(resource, &presentation_impl, presentation, wl_resource_set_implementation(resource, &presentation_impl, NULL, NULL);
NULL);
wp_presentation_send_clock_id(resource, CLOCK_MONOTONIC); wp_presentation_send_clock_id(resource, CLOCK_MONOTONIC);
} }
@ -194,7 +180,7 @@ struct wlr_presentation *wlr_presentation_create(struct wl_display *display,
} }
presentation->global = wl_global_create(display, &wp_presentation_interface, presentation->global = wl_global_create(display, &wp_presentation_interface,
PRESENTATION_VERSION, presentation, presentation_bind); PRESENTATION_VERSION, NULL, presentation_bind);
if (presentation->global == NULL) { if (presentation->global == NULL) {
free(presentation); free(presentation);
return NULL; return NULL;
@ -218,9 +204,9 @@ void wlr_presentation_feedback_send_presented(
} }
struct wlr_presentation_feedback *wlr_presentation_surface_sampled( struct wlr_presentation_feedback *wlr_presentation_surface_sampled(
struct wlr_presentation *presentation, struct wlr_surface *surface) { struct wlr_surface *surface) {
struct wlr_addon *addon = wlr_addon_find(&surface->addons, struct wlr_addon *addon =
presentation, &presentation_surface_addon_impl); wlr_addon_find(&surface->addons, NULL, &presentation_surface_addon_impl);
if (addon != NULL) { if (addon != NULL) {
struct wlr_presentation_surface *p_surface = struct wlr_presentation_surface *p_surface =
wl_container_of(addon, p_surface, addon); wl_container_of(addon, p_surface, addon);
@ -313,11 +299,10 @@ static void feedback_handle_output_destroy(struct wl_listener *listener,
wlr_presentation_feedback_destroy(feedback); wlr_presentation_feedback_destroy(feedback);
} }
static void presentation_surface_queued_on_output( static void presentation_surface_queued_on_output(struct wlr_surface *surface,
struct wlr_presentation *presentation, struct wlr_surface *surface,
struct wlr_output *output, bool zero_copy) { struct wlr_output *output, bool zero_copy) {
struct wlr_presentation_feedback *feedback = struct wlr_presentation_feedback *feedback =
wlr_presentation_surface_sampled(presentation, surface); wlr_presentation_surface_sampled(surface);
if (feedback == NULL) { if (feedback == NULL) {
return; return;
} }
@ -334,16 +319,12 @@ static void presentation_surface_queued_on_output(
wl_signal_add(&output->events.destroy, &feedback->output_destroy); wl_signal_add(&output->events.destroy, &feedback->output_destroy);
} }
void wlr_presentation_surface_textured_on_output( void wlr_presentation_surface_textured_on_output(struct wlr_surface *surface,
struct wlr_presentation *presentation, struct wlr_surface *surface,
struct wlr_output *output) { struct wlr_output *output) {
return presentation_surface_queued_on_output(presentation, surface, return presentation_surface_queued_on_output(surface, output, false);
output, false);
} }
void wlr_presentation_surface_scanned_out_on_output( void wlr_presentation_surface_scanned_out_on_output(struct wlr_surface *surface,
struct wlr_presentation *presentation, struct wlr_surface *surface,
struct wlr_output *output) { struct wlr_output *output) {
return presentation_surface_queued_on_output(presentation, surface, return presentation_surface_queued_on_output(surface, output, true);
output, true);
} }