Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 16 additions & 78 deletions video/out/wayland_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ struct vo_wayland_text_input {

struct vo_wayland_preferred_description_info {
struct vo_wayland_state *wl;
bool is_parametric;
struct pl_color_space csp;
float min_luma;
float max_luma;
Expand All @@ -323,7 +322,7 @@ static int spawn_cursor(struct vo_wayland_state *wl);
static void add_feedback(struct vo_wayland_feedback_pool *fback_pool,
struct wp_presentation_feedback *fback);
static void apply_keepaspect(struct vo_wayland_state *wl, int *width, int *height);
static void get_compositor_preferred_description(struct vo_wayland_state *wl, bool parametric);
static void get_compositor_preferred_description(struct vo_wayland_state *wl);
static void get_shape_device(struct vo_wayland_state *wl, struct vo_wayland_seat *s);
static void guess_focus(struct vo_wayland_state *wl);
static void handle_key_input(struct vo_wayland_seat *s, uint32_t key, uint32_t state, bool no_emit);
Expand Down Expand Up @@ -2034,26 +2033,10 @@ static void supported_feature(void *data, struct wp_color_manager_v1 *color_mana
struct vo_wayland_state *wl = data;

switch (feature) {
case WP_COLOR_MANAGER_V1_FEATURE_ICC_V2_V4:
MP_VERBOSE(wl, "Compositor supports ICC creator requests.\n");
wl->supports_icc = true;
break;
case WP_COLOR_MANAGER_V1_FEATURE_PARAMETRIC:
MP_VERBOSE(wl, "Compositor supports parametric image description creator.\n");
wl->supports_parametric = true;
break;
case WP_COLOR_MANAGER_V1_FEATURE_SET_PRIMARIES:
MP_VERBOSE(wl, "Compositor supports setting primaries.\n");
wl->supports_primaries = true;
break;
case WP_COLOR_MANAGER_V1_FEATURE_SET_TF_POWER:
MP_VERBOSE(wl, "Compositor supports setting transfer functions.\n");
wl->supports_tf_power = true;
break;
case WP_COLOR_MANAGER_V1_FEATURE_SET_LUMINANCES:
MP_VERBOSE(wl, "Compositor supports setting luminances.\n");
wl->supports_luminances = true;
break;
case WP_COLOR_MANAGER_V1_FEATURE_SET_MASTERING_DISPLAY_PRIMARIES:
MP_VERBOSE(wl, "Compositor supports setting mastering display primaries.\n");
wl->supports_display_primaries = true;
Expand Down Expand Up @@ -2156,7 +2139,7 @@ static void info_done(void *data, struct wp_image_description_info_v1 *image_des
struct vo_wayland_preferred_description_info *wd = data;
struct vo_wayland_state *wl = wd->wl;
wp_image_description_info_v1_destroy(image_description_info);
if (wd->is_parametric) {
if (!wd->icc_file) {
wl->preferred_csp = wd->csp;
MP_VERBOSE(wl, "Preferred surface feedback received:\n");
log_color_space(wl->log, wd);
Expand All @@ -2165,16 +2148,12 @@ static void info_done(void *data, struct wp_image_description_info_v1 *image_des
wl->preferred_csp.transfer = PL_COLOR_TRC_PQ;
}
} else {
if (wd->icc_file) {
if (wl->icc_size) {
munmap(wl->icc_file, wl->icc_size);
}
wl->icc_file = wd->icc_file;
wl->icc_size = wd->icc_size;
wl->pending_vo_events |= VO_EVENT_ICC_PROFILE_CHANGED;
} else {
MP_VERBOSE(wl, "No ICC profile retrieved from the compositor.\n");
if (wl->icc_size) {
munmap(wl->icc_file, wl->icc_size);
}
wl->icc_file = wd->icc_file;
wl->icc_size = wd->icc_size;
wl->pending_vo_events |= VO_EVENT_ICC_PROFILE_CHANGED;
}
talloc_free(wd);
}
Expand All @@ -2183,9 +2162,6 @@ static void info_icc_file(void *data, struct wp_image_description_info_v1 *image
int32_t icc, uint32_t icc_size)
{
struct vo_wayland_preferred_description_info *wd = data;
if (wd->is_parametric)
return;

void *icc_file = mmap(NULL, icc_size, PROT_READ, MAP_PRIVATE, icc, 0);
close(icc);

Expand All @@ -2205,8 +2181,6 @@ static void info_primaries_named(void *data, struct wp_image_description_info_v1
uint32_t primaries)
{
struct vo_wayland_preferred_description_info *wd = data;
if (!wd->is_parametric)
return;
wd->csp.primaries = map_primaries(primaries);
}

Expand All @@ -2219,17 +2193,13 @@ static void info_tf_named(void *data, struct wp_image_description_info_v1 *image
uint32_t tf)
{
struct vo_wayland_preferred_description_info *wd = data;
if (!wd->is_parametric)
return;
wd->csp.transfer = map_tf(tf);
}

static void info_luminances(void *data, struct wp_image_description_info_v1 *image_description_info,
uint32_t min_lum, uint32_t max_lum, uint32_t reference_lum)
{
struct vo_wayland_preferred_description_info *wd = data;
if (!wd->is_parametric)
return;
wd->min_luma = min_lum / (float)WAYLAND_MIN_LUM_FACTOR;
wd->max_luma = max_lum;
wd->ref_luma = reference_lum;
Expand All @@ -2240,8 +2210,6 @@ static void info_target_primaries(void *data, struct wp_image_description_info_v
int32_t w_x, int32_t w_y)
{
struct vo_wayland_preferred_description_info *wd = data;
if (!wd->is_parametric)
return;
wd->csp.hdr.prim.red.x = (float)r_x / WAYLAND_COLOR_FACTOR;
wd->csp.hdr.prim.red.y = (float)r_y / WAYLAND_COLOR_FACTOR;
wd->csp.hdr.prim.green.x = (float)g_x / WAYLAND_COLOR_FACTOR;
Expand All @@ -2256,8 +2224,6 @@ static void info_target_luminance(void *data, struct wp_image_description_info_v
uint32_t min_lum, uint32_t max_lum)
{
struct vo_wayland_preferred_description_info *wd = data;
if (!wd->is_parametric)
return;
wd->csp.hdr.min_luma = (float)min_lum / WAYLAND_MIN_LUM_FACTOR;
wd->csp.hdr.max_luma = (float)max_lum;
}
Expand All @@ -2266,17 +2232,13 @@ static void info_target_max_cll(void *data, struct wp_image_description_info_v1
uint32_t max_cll)
{
struct vo_wayland_preferred_description_info *wd = data;
if (!wd->is_parametric)
return;
wd->csp.hdr.max_cll = (float)max_cll;
}

static void info_target_max_fall(void *data, struct wp_image_description_info_v1 *image_description_info,
uint32_t max_fall)
{
struct vo_wayland_preferred_description_info *wd = data;
if (!wd->is_parametric)
return;
wd->csp.hdr.max_fall = (float)max_fall;
}

Expand All @@ -2298,10 +2260,7 @@ static void preferred_changed(void *data, struct wp_color_management_surface_fee
uint32_t identity)
{
struct vo_wayland_state *wl = data;
if (wl->supports_icc)
get_compositor_preferred_description(wl, false);
if (wl->supports_parametric)
get_compositor_preferred_description(wl, true);
get_compositor_preferred_description(wl);
}

static const struct wp_color_management_surface_feedback_v1_listener surface_feedback_listener = {
Expand Down Expand Up @@ -3104,19 +3063,14 @@ static int get_mods(struct vo_wayland_seat *s)
return modifiers;
}

static void get_compositor_preferred_description(struct vo_wayland_state *wl, bool parametric)
static void get_compositor_preferred_description(struct vo_wayland_state *wl)
{
#if HAVE_WAYLAND_PROTOCOLS_1_41
struct vo_wayland_preferred_description_info *wd = talloc_zero(NULL, struct vo_wayland_preferred_description_info);
wd->wl = wl;
wd->is_parametric = parametric;

struct wp_image_description_v1 *image_description;
if (parametric) {
image_description = wp_color_management_surface_feedback_v1_get_preferred_parametric(wl->color_surface_feedback);
} else {
image_description = wp_color_management_surface_feedback_v1_get_preferred(wl->color_surface_feedback);
}
struct wp_image_description_v1 *image_description =
wp_color_management_surface_feedback_v1_get_preferred(wl->color_surface_feedback);
struct wp_image_description_info_v1 *description_info =
wp_image_description_v1_get_information(image_description);
wp_image_description_info_v1_add_listener(description_info, &image_description_info_listener, wd);
Expand Down Expand Up @@ -3569,7 +3523,9 @@ static void set_color_representation(struct vo_wayland_state *wl)
enum mp_imgfmt imgfmt = wl->target_params.hw_subfmt ? wl->target_params.hw_subfmt : wl->target_params.imgfmt;
bool is_420_subsampled = mp_imgfmt_is_420_subsampled(imgfmt);

MP_VERBOSE(wl, "Setting color representation:\n");
if ((coefficients && range) || alpha || (is_420_subsampled && chroma_location))
MP_VERBOSE(wl, "Setting color representation:\n");

if (coefficients && range) {
MP_VERBOSE(wl, " Coefficients: %s, Range: %s\n",
m_opt_choice_str(pl_csp_names, repr.sys),
Expand Down Expand Up @@ -4084,8 +4040,6 @@ int vo_wayland_control(struct vo *vo, int *events, int request, void *arg)
return VO_TRUE;
}
case VOCTRL_GET_ICC_PROFILE: {
if (!wl->supports_icc)
MP_WARN(wl, "Compositor does not support ICC profiles!\n");
if (!wl->icc_file)
return VO_FALSE;
MP_VERBOSE(wl, "Retrieving ICC profile from compositor.\n");
Expand Down Expand Up @@ -4441,28 +4395,12 @@ bool vo_wayland_init(struct vo *vo)
if (wl->color_manager && wl->supports_parametric && !strcmp(wl->vo->driver->name, "dmabuf-wayland"))
wl->color_surface = wp_color_manager_v1_get_surface(wl->color_manager, wl->callback_surface);

if (wl->color_manager && (wl->supports_parametric || wl->supports_icc)) {
if (wl->color_manager) {
wl->color_surface_feedback = wp_color_manager_v1_get_surface_feedback(wl->color_manager, wl->callback_surface);
wp_color_management_surface_feedback_v1_add_listener(wl->color_surface_feedback, &surface_feedback_listener, wl);
}
#endif

if (wl->supports_parametric)
get_compositor_preferred_description(wl, true);
else
MP_VERBOSE(wl, "Compositor does not support parametric image descriptions!\n");


struct gl_video_opts *gl_opts = mp_get_config_group(NULL, vo->global, &gl_video_conf);
if (wl->supports_icc) {
// dumb workaround for avoiding -Wunused-function
get_compositor_preferred_description(wl, false);
} else {
int msg_level = gl_opts->icc_opts->profile_auto ? MSGL_WARN : MSGL_V;
mp_msg(wl->log, msg_level, "Compositor does not support ICC profiles!\n");
}
talloc_free(gl_opts);

get_compositor_preferred_description(wl);
return true;

err:
Expand Down
4 changes: 0 additions & 4 deletions video/out/wayland_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,7 @@ struct vo_wayland_state {
struct wp_color_management_surface_feedback_v1 *color_surface_feedback;
struct wp_image_description_creator_icc_v1 *icc_creator;
struct mp_image_params target_params;
bool supports_icc;
bool supports_parametric;
bool supports_primaries;
bool supports_tf_power;
bool supports_luminances;
bool supports_display_primaries;
int primaries_map[PL_COLOR_PRIM_COUNT];
int transfer_map[PL_COLOR_TRC_COUNT];
Expand Down
Loading