mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-01 22:58:38 -04:00
color-management-v1: add setter for surface feedback
This commit is contained in:
parent
95c85af87c
commit
fa6cd856e3
2 changed files with 33 additions and 5 deletions
|
|
@ -71,6 +71,7 @@ struct wlr_color_manager_v1 {
|
||||||
size_t primaries_len;
|
size_t primaries_len;
|
||||||
|
|
||||||
struct wl_list outputs; // wlr_color_management_output_v1.link
|
struct wl_list outputs; // wlr_color_management_output_v1.link
|
||||||
|
struct wl_list surface_feedbacks; // wlr_color_management_surface_feedback_v1.link
|
||||||
|
|
||||||
uint32_t last_image_desc_identity;
|
uint32_t last_image_desc_identity;
|
||||||
|
|
||||||
|
|
@ -84,4 +85,8 @@ struct wlr_color_manager_v1 *wlr_color_manager_v1_create(struct wl_display *disp
|
||||||
const struct wlr_image_description_v1_data *
|
const struct wlr_image_description_v1_data *
|
||||||
wlr_surface_get_image_description_v1_data(struct wlr_surface *surface);
|
wlr_surface_get_image_description_v1_data(struct wlr_surface *surface);
|
||||||
|
|
||||||
|
void wlr_color_manager_v1_set_surface_preferred_image_description(
|
||||||
|
struct wlr_color_manager_v1 *manager, struct wlr_surface *surface,
|
||||||
|
const struct wlr_image_description_v1_data *data);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,9 @@ struct wlr_color_management_surface_feedback_v1 {
|
||||||
struct wl_resource *resource;
|
struct wl_resource *resource;
|
||||||
struct wlr_surface *surface;
|
struct wlr_surface *surface;
|
||||||
struct wlr_color_manager_v1 *manager;
|
struct wlr_color_manager_v1 *manager;
|
||||||
|
struct wl_list link;
|
||||||
|
|
||||||
|
struct wlr_image_description_v1_data data;
|
||||||
|
|
||||||
struct wl_listener surface_destroy;
|
struct wl_listener surface_destroy;
|
||||||
};
|
};
|
||||||
|
|
@ -364,12 +367,8 @@ static void surface_feedback_handle_get_preferred(struct wl_client *client,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_image_description_v1_data data = {
|
|
||||||
.tf_named = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB,
|
|
||||||
.primaries_named = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB,
|
|
||||||
};
|
|
||||||
image_desc_create_ready(surface_feedback->manager,
|
image_desc_create_ready(surface_feedback->manager,
|
||||||
surface_feedback_resource, id, &data, true);
|
surface_feedback_resource, id, &surface_feedback->data, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct wp_color_management_surface_feedback_v1_interface surface_feedback_impl = {
|
static const struct wp_color_management_surface_feedback_v1_interface surface_feedback_impl = {
|
||||||
|
|
@ -383,6 +382,7 @@ static void surface_feedback_destroy(struct wlr_color_management_surface_feedbac
|
||||||
}
|
}
|
||||||
wl_resource_set_user_data(surface_feedback->resource, NULL); // make inert
|
wl_resource_set_user_data(surface_feedback->resource, NULL); // make inert
|
||||||
wl_list_remove(&surface_feedback->surface_destroy.link);
|
wl_list_remove(&surface_feedback->surface_destroy.link);
|
||||||
|
wl_list_remove(&surface_feedback->link);
|
||||||
free(surface_feedback);
|
free(surface_feedback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -761,9 +761,15 @@ static void manager_handle_get_surface_feedback(struct wl_client *client,
|
||||||
surface_feedback, surface_feedback_handle_resource_destroy);
|
surface_feedback, surface_feedback_handle_resource_destroy);
|
||||||
|
|
||||||
surface_feedback->surface = surface;
|
surface_feedback->surface = surface;
|
||||||
|
surface_feedback->data = (struct wlr_image_description_v1_data){
|
||||||
|
.tf_named = WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB,
|
||||||
|
.primaries_named = WP_COLOR_MANAGER_V1_PRIMARIES_SRGB,
|
||||||
|
};
|
||||||
|
|
||||||
surface_feedback->surface_destroy.notify = surface_feedback_handle_surface_destroy;
|
surface_feedback->surface_destroy.notify = surface_feedback_handle_surface_destroy;
|
||||||
wl_signal_add(&surface->events.destroy, &surface_feedback->surface_destroy);
|
wl_signal_add(&surface->events.destroy, &surface_feedback->surface_destroy);
|
||||||
|
|
||||||
|
wl_list_insert(&manager->surface_feedbacks, &surface_feedback->link);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void manager_handle_create_icc_creator(struct wl_client *client,
|
static void manager_handle_create_icc_creator(struct wl_client *client,
|
||||||
|
|
@ -925,6 +931,7 @@ struct wlr_color_manager_v1 *wlr_color_manager_v1_create(struct wl_display *disp
|
||||||
manager->primaries_len = options->primaries_len;
|
manager->primaries_len = options->primaries_len;
|
||||||
|
|
||||||
wl_list_init(&manager->outputs);
|
wl_list_init(&manager->outputs);
|
||||||
|
wl_list_init(&manager->surface_feedbacks);
|
||||||
|
|
||||||
manager->global = wl_global_create(display, &wp_color_manager_v1_interface,
|
manager->global = wl_global_create(display, &wp_color_manager_v1_interface,
|
||||||
version, manager, manager_bind);
|
version, manager, manager_bind);
|
||||||
|
|
@ -953,3 +960,19 @@ wlr_surface_get_image_description_v1_data(struct wlr_surface *surface) {
|
||||||
}
|
}
|
||||||
return &cm_surface->current.image_desc_data;
|
return &cm_surface->current.image_desc_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wlr_color_manager_v1_set_surface_preferred_image_description(
|
||||||
|
struct wlr_color_manager_v1 *manager, struct wlr_surface *surface,
|
||||||
|
const struct wlr_image_description_v1_data *data) {
|
||||||
|
// TODO: de-duplicate identity
|
||||||
|
uint32_t identity = ++manager->last_image_desc_identity;
|
||||||
|
|
||||||
|
struct wlr_color_management_surface_feedback_v1 *surface_feedback;
|
||||||
|
wl_list_for_each(surface_feedback, &manager->surface_feedbacks, link) {
|
||||||
|
if (surface_feedback->surface == surface) {
|
||||||
|
surface_feedback->data = *data;
|
||||||
|
wp_color_management_surface_feedback_v1_send_preferred_changed(
|
||||||
|
surface_feedback->resource, identity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue