Merge branch 'matthiasc/for-main' into 'main'

wayland: Switch to v4 of the color management protocol

See merge request GNOME/gtk!7489
This commit is contained in:
Matthias Clasen 2024-07-24 06:24:20 +00:00
commit b435f3c543
3 changed files with 663 additions and 422 deletions

View File

@ -2,27 +2,27 @@
#include "gdkwaylandcolor-private.h" #include "gdkwaylandcolor-private.h"
#include "gdksurface-wayland-private.h" #include "gdksurface-wayland-private.h"
#include <gdk/wayland/xx-color-management-v2-client-protocol.h> #include <gdk/wayland/xx-color-management-v4-client-protocol.h>
struct _GdkWaylandColor struct _GdkWaylandColor
{ {
struct xx_color_manager_v2 *color_manager; struct xx_color_manager_v4 *color_manager;
struct { struct {
unsigned int intents; unsigned int intents;
unsigned int features; unsigned int features;
unsigned int transfers; unsigned int transfers;
unsigned int primaries; unsigned int primaries;
} color_manager_supported; } color_manager_supported;
struct xx_image_description_v2 *srgb; struct xx_image_description_v4 *srgb;
struct xx_image_description_v2 *srgb_linear; struct xx_image_description_v4 *srgb_linear;
struct xx_image_description_v2 *rec2100_pq; struct xx_image_description_v4 *rec2100_pq;
struct xx_image_description_v2 *rec2100_linear; struct xx_image_description_v4 *rec2100_linear;
}; };
static void static void
xx_color_manager_v2_supported_intent (void *data, xx_color_manager_v4_supported_intent (void *data,
struct xx_color_manager_v2 *xx_color_manager_v2, struct xx_color_manager_v4 *xx_color_manager_v2,
uint32_t render_intent) uint32_t render_intent)
{ {
GdkWaylandColor *color = data; GdkWaylandColor *color = data;
@ -31,8 +31,8 @@ xx_color_manager_v2_supported_intent (void *data,
} }
static void static void
xx_color_manager_v2_supported_feature (void *data, xx_color_manager_v4_supported_feature (void *data,
struct xx_color_manager_v2 *xx_color_manager_v2, struct xx_color_manager_v4 *xx_color_manager_v2,
uint32_t feature) uint32_t feature)
{ {
GdkWaylandColor *color = data; GdkWaylandColor *color = data;
@ -41,8 +41,8 @@ xx_color_manager_v2_supported_feature (void *data,
} }
static void static void
xx_color_manager_v2_supported_tf_named (void *data, xx_color_manager_v4_supported_tf_named (void *data,
struct xx_color_manager_v2 *xx_color_manager_v2, struct xx_color_manager_v4 *xx_color_manager_v2,
uint32_t tf) uint32_t tf)
{ {
GdkWaylandColor *color = data; GdkWaylandColor *color = data;
@ -51,8 +51,8 @@ xx_color_manager_v2_supported_tf_named (void *data,
} }
static void static void
xx_color_manager_v2_supported_primaries_named (void *data, xx_color_manager_v4_supported_primaries_named (void *data,
struct xx_color_manager_v2 *xx_color_manager_v2, struct xx_color_manager_v4 *xx_color_manager_v2,
uint32_t primaries) uint32_t primaries)
{ {
GdkWaylandColor *color = data; GdkWaylandColor *color = data;
@ -60,11 +60,11 @@ xx_color_manager_v2_supported_primaries_named (void *data,
color->color_manager_supported.primaries |= (1 << primaries); color->color_manager_supported.primaries |= (1 << primaries);
} }
static struct xx_color_manager_v2_listener color_manager_listener = { static struct xx_color_manager_v4_listener color_manager_listener = {
xx_color_manager_v2_supported_intent, xx_color_manager_v4_supported_intent,
xx_color_manager_v2_supported_feature, xx_color_manager_v4_supported_feature,
xx_color_manager_v2_supported_tf_named, xx_color_manager_v4_supported_tf_named,
xx_color_manager_v2_supported_primaries_named, xx_color_manager_v4_supported_primaries_named,
}; };
GdkWaylandColor * GdkWaylandColor *
@ -78,10 +78,10 @@ gdk_wayland_color_new (struct wl_registry *registry,
color->color_manager = wl_registry_bind (registry, color->color_manager = wl_registry_bind (registry,
id, id,
&xx_color_manager_v2_interface, &xx_color_manager_v4_interface,
MIN (version, 2)); MIN (version, 2));
xx_color_manager_v2_add_listener (color->color_manager, xx_color_manager_v4_add_listener (color->color_manager,
&color_manager_listener, &color_manager_listener,
color); color);
@ -91,11 +91,11 @@ gdk_wayland_color_new (struct wl_registry *registry,
void void
gdk_wayland_color_free (GdkWaylandColor *color) gdk_wayland_color_free (GdkWaylandColor *color)
{ {
g_clear_pointer (&color->color_manager, xx_color_manager_v2_destroy); g_clear_pointer (&color->color_manager, xx_color_manager_v4_destroy);
g_clear_pointer (&color->srgb, xx_image_description_v2_destroy); g_clear_pointer (&color->srgb, xx_image_description_v4_destroy);
g_clear_pointer (&color->srgb_linear, xx_image_description_v2_destroy); g_clear_pointer (&color->srgb_linear, xx_image_description_v4_destroy);
g_clear_pointer (&color->rec2100_pq, xx_image_description_v2_destroy); g_clear_pointer (&color->rec2100_pq, xx_image_description_v4_destroy);
g_clear_pointer (&color->rec2100_linear, xx_image_description_v2_destroy); g_clear_pointer (&color->rec2100_linear, xx_image_description_v4_destroy);
g_free (color); g_free (color);
} }
@ -107,25 +107,25 @@ gdk_wayland_color_get_color_manager (GdkWaylandColor *color)
static void static void
std_image_desc_failed (void *data, std_image_desc_failed (void *data,
struct xx_image_description_v2 *desc, struct xx_image_description_v4 *desc,
uint32_t cause, uint32_t cause,
const char *msg) const char *msg)
{ {
g_warning ("Failed to get one of the standard image descriptions: %s", msg); g_warning ("Failed to get one of the standard image descriptions: %s", msg);
xx_image_description_v2_destroy (desc); xx_image_description_v4_destroy (desc);
} }
static void static void
std_image_desc_ready (void *data, std_image_desc_ready (void *data,
struct xx_image_description_v2 *desc, struct xx_image_description_v4 *desc,
uint32_t identity) uint32_t identity)
{ {
struct xx_image_description_v2 **ptr = data; struct xx_image_description_v4 **ptr = data;
*ptr = desc; *ptr = desc;
} }
static struct xx_image_description_v2_listener std_image_desc_listener = { static struct xx_image_description_v4_listener std_image_desc_listener = {
std_image_desc_failed, std_image_desc_failed,
std_image_desc_ready, std_image_desc_ready,
}; };
@ -134,19 +134,19 @@ static void
create_image_desc (GdkWaylandColor *color, create_image_desc (GdkWaylandColor *color,
uint32_t primaries, uint32_t primaries,
uint32_t tf, uint32_t tf,
struct xx_image_description_v2 **out_desc) struct xx_image_description_v4 **out_desc)
{ {
struct xx_image_description_creator_params_v2 *creator; struct xx_image_description_creator_params_v4 *creator;
struct xx_image_description_v2 *desc; struct xx_image_description_v4 *desc;
creator = xx_color_manager_v2_new_parametric_creator (color->color_manager); creator = xx_color_manager_v4_new_parametric_creator (color->color_manager);
xx_image_description_creator_params_v2_set_primaries_named (creator, primaries); xx_image_description_creator_params_v4_set_primaries_named (creator, primaries);
xx_image_description_creator_params_v2_set_tf_named (creator, tf); xx_image_description_creator_params_v4_set_tf_named (creator, tf);
desc = xx_image_description_creator_params_v2_create (creator); desc = xx_image_description_creator_params_v4_create (creator);
xx_image_description_v2_add_listener (desc, &std_image_desc_listener, out_desc); xx_image_description_v4_add_listener (desc, &std_image_desc_listener, out_desc);
} }
gboolean gboolean
@ -158,7 +158,7 @@ gdk_wayland_color_prepare (GdkWaylandColor *color)
"perceptual", "relative", "saturation", "absolute", "relative-bpc" "perceptual", "relative", "saturation", "absolute", "relative-bpc"
}; };
const char *features[] = { const char *features[] = {
"icc-v2-v4", "parametric", "set-primaries", "set-tf-power", "icc-v4-v4", "parametric", "set-primaries", "set-tf-power",
"set-mastering-display-primaries", "extended-target-volume" "set-mastering-display-primaries", "extended-target-volume"
}; };
const char *tf[] = { const char *tf[] = {
@ -196,47 +196,47 @@ gdk_wayland_color_prepare (GdkWaylandColor *color)
} }
if (color->color_manager && if (color->color_manager &&
!(color->color_manager_supported.intents & (1 << XX_COLOR_MANAGER_V2_RENDER_INTENT_PERCEPTUAL))) !(color->color_manager_supported.intents & (1 << XX_COLOR_MANAGER_V4_RENDER_INTENT_PERCEPTUAL)))
{ {
GDK_DEBUG (MISC, "Not using color management: Missing perceptual render intent"); GDK_DEBUG (MISC, "Not using color management: Missing perceptual render intent");
g_clear_pointer (&color->color_manager, xx_color_manager_v2_destroy); g_clear_pointer (&color->color_manager, xx_color_manager_v4_destroy);
} }
if (color->color_manager && if (color->color_manager &&
(!(color->color_manager_supported.features & (1 << XX_COLOR_MANAGER_V2_FEATURE_PARAMETRIC)) || (!(color->color_manager_supported.features & (1 << XX_COLOR_MANAGER_V4_FEATURE_PARAMETRIC)) ||
!(color->color_manager_supported.transfers & (1 << XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_SRGB)) || !(color->color_manager_supported.transfers & (1 << XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB)) ||
!(color->color_manager_supported.primaries & (1 << XX_COLOR_MANAGER_V2_PRIMARIES_SRGB)))) !(color->color_manager_supported.primaries & (1 << XX_COLOR_MANAGER_V4_PRIMARIES_SRGB))))
{ {
GDK_DEBUG (MISC, "Not using color management: Can't create srgb image description"); GDK_DEBUG (MISC, "Not using color management: Can't create srgb image description");
g_clear_pointer (&color->color_manager, xx_color_manager_v2_destroy); g_clear_pointer (&color->color_manager, xx_color_manager_v4_destroy);
} }
if (color->color_manager) if (color->color_manager)
{ {
create_image_desc (color, create_image_desc (color,
XX_COLOR_MANAGER_V2_PRIMARIES_SRGB, XX_COLOR_MANAGER_V4_PRIMARIES_SRGB,
XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_SRGB, XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB,
&color->srgb); &color->srgb);
if (color->color_manager_supported.transfers & (1 << XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_LINEAR)) if (color->color_manager_supported.transfers & (1 << XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_LINEAR))
create_image_desc (color, create_image_desc (color,
XX_COLOR_MANAGER_V2_PRIMARIES_SRGB, XX_COLOR_MANAGER_V4_PRIMARIES_SRGB,
XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_LINEAR, XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_LINEAR,
&color->srgb_linear); &color->srgb_linear);
if (color->color_manager_supported.primaries & (1 << XX_COLOR_MANAGER_V2_PRIMARIES_BT2020)) if (color->color_manager_supported.primaries & (1 << XX_COLOR_MANAGER_V4_PRIMARIES_BT2020))
{ {
if (color->color_manager_supported.transfers & (1 << XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_ST2084_PQ)) if (color->color_manager_supported.transfers & (1 << XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_ST2084_PQ))
create_image_desc (color, create_image_desc (color,
XX_COLOR_MANAGER_V2_PRIMARIES_BT2020, XX_COLOR_MANAGER_V4_PRIMARIES_BT2020,
XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_ST2084_PQ, XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_ST2084_PQ,
&color->rec2100_pq); &color->rec2100_pq);
if (color->color_manager_supported.transfers & (1 << XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_LINEAR)) if (color->color_manager_supported.transfers & (1 << XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_LINEAR))
create_image_desc (color, create_image_desc (color,
XX_COLOR_MANAGER_V2_PRIMARIES_BT2020, XX_COLOR_MANAGER_V4_PRIMARIES_BT2020,
XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_LINEAR, XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_LINEAR,
&color->rec2100_linear); &color->rec2100_linear);
} }
} }
@ -247,7 +247,8 @@ gdk_wayland_color_prepare (GdkWaylandColor *color)
struct _GdkWaylandColorSurface struct _GdkWaylandColorSurface
{ {
GdkWaylandColor *color; GdkWaylandColor *color;
struct xx_color_management_surface_v2 *surface; struct xx_color_management_surface_v4 *surface;
struct xx_color_management_feedback_surface_v4 *feedback;
GdkColorStateChanged callback; GdkColorStateChanged callback;
gpointer data; gpointer data;
}; };
@ -256,16 +257,17 @@ typedef struct
{ {
GdkWaylandColorSurface *surface; GdkWaylandColorSurface *surface;
struct xx_image_description_v2 *image_desc; struct xx_image_description_v4 *image_desc;
struct xx_image_description_info_v2 *info; struct xx_image_description_info_v4 *info;
int32_t icc; int32_t icc;
uint32_t icc_size; uint32_t icc_size;
uint32_t r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y; int32_t r_x, r_y, g_x, g_y, b_x, b_y, w_x, w_y;
uint32_t primaries; uint32_t primaries;
uint32_t tf_power; uint32_t tf_power;
uint32_t tf_named; uint32_t tf_named;
uint32_t target_r_x, target_r_y, target_g_x, target_g_y, target_b_x, target_b_y, target_w_x, target_w_y; uint32_t min_lum, max_lum, ref_lum;
int32_t target_r_x, target_r_y, target_g_x, target_g_y, target_b_x, target_b_y, target_w_x, target_w_y;
uint32_t target_min_lum, target_max_lum; uint32_t target_min_lum, target_max_lum;
uint32_t target_max_cll, target_max_fall; uint32_t target_max_cll, target_max_fall;
@ -274,6 +276,7 @@ typedef struct
unsigned int has_primaries_named : 1; unsigned int has_primaries_named : 1;
unsigned int has_tf_power : 1; unsigned int has_tf_power : 1;
unsigned int has_tf_named : 1; unsigned int has_tf_named : 1;
unsigned int has_luminances : 1;
unsigned int has_target_primaries : 1; unsigned int has_target_primaries : 1;
unsigned int has_target_luminance : 1; unsigned int has_target_luminance : 1;
unsigned int has_target_max_cll : 1; unsigned int has_target_max_cll : 1;
@ -287,23 +290,23 @@ gdk_color_state_from_image_description_bits (ImageDescription *desc)
if (desc->has_primaries_named && desc->has_tf_named) if (desc->has_primaries_named && desc->has_tf_named)
{ {
if (desc->primaries == XX_COLOR_MANAGER_V2_PRIMARIES_SRGB && if (desc->primaries == XX_COLOR_MANAGER_V4_PRIMARIES_SRGB &&
desc->tf_named == XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_SRGB) desc->tf_named == XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB)
{ {
cs = GDK_COLOR_STATE_SRGB; cs = GDK_COLOR_STATE_SRGB;
} }
else if (desc->primaries == XX_COLOR_MANAGER_V2_PRIMARIES_SRGB && else if (desc->primaries == XX_COLOR_MANAGER_V4_PRIMARIES_SRGB &&
desc->tf_named == XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_LINEAR) desc->tf_named == XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_LINEAR)
{ {
cs = GDK_COLOR_STATE_SRGB_LINEAR; cs = GDK_COLOR_STATE_SRGB_LINEAR;
} }
else if (desc->primaries == XX_COLOR_MANAGER_V2_PRIMARIES_BT2020 && else if (desc->primaries == XX_COLOR_MANAGER_V4_PRIMARIES_BT2020 &&
desc->tf_named == XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_ST2084_PQ) desc->tf_named == XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_ST2084_PQ)
{ {
cs = GDK_COLOR_STATE_REC2100_PQ; cs = GDK_COLOR_STATE_REC2100_PQ;
} }
else if (desc->primaries == XX_COLOR_MANAGER_V2_PRIMARIES_BT2020 && else if (desc->primaries == XX_COLOR_MANAGER_V4_PRIMARIES_BT2020 &&
desc->tf_named == XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_LINEAR) desc->tf_named == XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_LINEAR)
{ {
cs = GDK_COLOR_STATE_REC2100_LINEAR; cs = GDK_COLOR_STATE_REC2100_LINEAR;
} }
@ -314,7 +317,7 @@ gdk_color_state_from_image_description_bits (ImageDescription *desc)
static void static void
image_desc_info_done (void *data, image_desc_info_done (void *data,
struct xx_image_description_info_v2 *info) struct xx_image_description_info_v4 *info)
{ {
ImageDescription *desc = data; ImageDescription *desc = data;
GdkWaylandColorSurface *self = desc->surface; GdkWaylandColorSurface *self = desc->surface;
@ -327,14 +330,14 @@ image_desc_info_done (void *data,
gdk_color_state_unref (cs); gdk_color_state_unref (cs);
xx_image_description_v2_destroy (desc->image_desc); xx_image_description_v4_destroy (desc->image_desc);
xx_image_description_info_v2_destroy (desc->info); xx_image_description_info_v4_destroy (desc->info);
g_free (desc); g_free (desc);
} }
static void static void
image_desc_info_icc_file (void *data, image_desc_info_icc_file (void *data,
struct xx_image_description_info_v2 *info, struct xx_image_description_info_v4 *info,
int32_t icc, int32_t icc,
uint32_t icc_size) uint32_t icc_size)
{ {
@ -347,11 +350,11 @@ image_desc_info_icc_file (void *data,
static void static void
image_desc_info_primaries (void *data, image_desc_info_primaries (void *data,
struct xx_image_description_info_v2 *info, struct xx_image_description_info_v4 *info,
uint32_t r_x, uint32_t r_y, int32_t r_x, int32_t r_y,
uint32_t g_x, uint32_t g_y, int32_t g_x, int32_t g_y,
uint32_t b_x, uint32_t b_y, int32_t b_x, int32_t b_y,
uint32_t w_x, uint32_t w_y) int32_t w_x, int32_t w_y)
{ {
ImageDescription *desc = data; ImageDescription *desc = data;
@ -364,7 +367,7 @@ image_desc_info_primaries (void *data,
static void static void
image_desc_info_primaries_named (void *data, image_desc_info_primaries_named (void *data,
struct xx_image_description_info_v2 *info, struct xx_image_description_info_v4 *info,
uint32_t primaries) uint32_t primaries)
{ {
ImageDescription *desc = data; ImageDescription *desc = data;
@ -375,7 +378,7 @@ image_desc_info_primaries_named (void *data,
static void static void
image_desc_info_tf_power (void *data, image_desc_info_tf_power (void *data,
struct xx_image_description_info_v2 *info, struct xx_image_description_info_v4 *info,
uint32_t tf_power) uint32_t tf_power)
{ {
ImageDescription *desc = data; ImageDescription *desc = data;
@ -386,7 +389,7 @@ image_desc_info_tf_power (void *data,
static void static void
image_desc_info_tf_named (void *data, image_desc_info_tf_named (void *data,
struct xx_image_description_info_v2 *info, struct xx_image_description_info_v4 *info,
uint32_t tf) uint32_t tf)
{ {
ImageDescription *desc = data; ImageDescription *desc = data;
@ -395,13 +398,28 @@ image_desc_info_tf_named (void *data,
desc->has_tf_named = 1; desc->has_tf_named = 1;
} }
static void
image_desc_info_luminances (void *data,
struct xx_image_description_info_v4 *info,
uint32_t min_lum,
uint32_t max_lum,
uint32_t ref_lum)
{
ImageDescription *desc = data;
desc->min_lum = min_lum;
desc->max_lum = max_lum;
desc->ref_lum = ref_lum;
desc->has_luminances = 1;
}
static void static void
image_desc_info_target_primaries (void *data, image_desc_info_target_primaries (void *data,
struct xx_image_description_info_v2 *info, struct xx_image_description_info_v4 *info,
uint32_t r_x, uint32_t r_y, int32_t r_x, int32_t r_y,
uint32_t g_x, uint32_t g_y, int32_t g_x, int32_t g_y,
uint32_t b_x, uint32_t b_y, int32_t b_x, int32_t b_y,
uint32_t w_x, uint32_t w_y) int32_t w_x, int32_t w_y)
{ {
ImageDescription *desc = data; ImageDescription *desc = data;
@ -414,7 +432,7 @@ image_desc_info_target_primaries (void *data,
static void static void
image_desc_info_target_luminance (void *data, image_desc_info_target_luminance (void *data,
struct xx_image_description_info_v2 *info, struct xx_image_description_info_v4 *info,
uint32_t min_lum, uint32_t min_lum,
uint32_t max_lum) uint32_t max_lum)
{ {
@ -427,7 +445,7 @@ image_desc_info_target_luminance (void *data,
static void static void
image_desc_info_target_max_cll (void *data, image_desc_info_target_max_cll (void *data,
struct xx_image_description_info_v2 *info, struct xx_image_description_info_v4 *info,
uint32_t max_cll) uint32_t max_cll)
{ {
ImageDescription *desc = data; ImageDescription *desc = data;
@ -438,7 +456,7 @@ image_desc_info_target_max_cll (void *data,
static void static void
image_desc_info_target_max_fall (void *data, image_desc_info_target_max_fall (void *data,
struct xx_image_description_info_v2 *info, struct xx_image_description_info_v4 *info,
uint32_t max_fall) uint32_t max_fall)
{ {
ImageDescription *desc = data; ImageDescription *desc = data;
@ -447,13 +465,14 @@ image_desc_info_target_max_fall (void *data,
desc->has_target_max_fall = 1; desc->has_target_max_fall = 1;
} }
static struct xx_image_description_info_v2_listener info_listener = { static struct xx_image_description_info_v4_listener info_listener = {
image_desc_info_done, image_desc_info_done,
image_desc_info_icc_file, image_desc_info_icc_file,
image_desc_info_primaries, image_desc_info_primaries,
image_desc_info_primaries_named, image_desc_info_primaries_named,
image_desc_info_tf_power, image_desc_info_tf_power,
image_desc_info_tf_named, image_desc_info_tf_named,
image_desc_info_luminances,
image_desc_info_target_primaries, image_desc_info_target_primaries,
image_desc_info_target_luminance, image_desc_info_target_luminance,
image_desc_info_target_max_cll, image_desc_info_target_max_cll,
@ -462,7 +481,7 @@ static struct xx_image_description_info_v2_listener info_listener = {
static void static void
image_desc_failed (void *data, image_desc_failed (void *data,
struct xx_image_description_v2 *image_desc, struct xx_image_description_v4 *image_desc,
uint32_t cause, uint32_t cause,
const char *msg) const char *msg)
{ {
@ -471,30 +490,30 @@ image_desc_failed (void *data,
self->callback (self, GDK_COLOR_STATE_SRGB, self->data); self->callback (self, GDK_COLOR_STATE_SRGB, self->data);
xx_image_description_v2_destroy (desc->image_desc); xx_image_description_v4_destroy (desc->image_desc);
g_free (desc); g_free (desc);
} }
static void static void
image_desc_ready (void *data, image_desc_ready (void *data,
struct xx_image_description_v2 *image_desc, struct xx_image_description_v4 *image_desc,
uint32_t identity) uint32_t identity)
{ {
ImageDescription *desc = data; ImageDescription *desc = data;
desc->info = xx_image_description_v2_get_information (image_desc); desc->info = xx_image_description_v4_get_information (image_desc);
xx_image_description_info_v2_add_listener (desc->info, &info_listener, desc); xx_image_description_info_v4_add_listener (desc->info, &info_listener, desc);
} }
static const struct xx_image_description_v2_listener image_desc_listener = { static const struct xx_image_description_v4_listener image_desc_listener = {
image_desc_failed, image_desc_failed,
image_desc_ready image_desc_ready
}; };
static void static void
preferred_changed (void *data, preferred_changed (void *data,
struct xx_color_management_surface_v2 *color_mgmt_surface) struct xx_color_management_feedback_surface_v4 *feedback)
{ {
GdkWaylandColorSurface *self = data; GdkWaylandColorSurface *self = data;
ImageDescription *desc; ImageDescription *desc;
@ -503,12 +522,12 @@ preferred_changed (void *data,
desc->surface = self; desc->surface = self;
desc->image_desc = xx_color_management_surface_v2_get_preferred (self->surface); desc->image_desc = xx_color_management_feedback_surface_v4_get_preferred (self->feedback);
xx_image_description_v2_add_listener (desc->image_desc, &image_desc_listener, desc); xx_image_description_v4_add_listener (desc->image_desc, &image_desc_listener, desc);
} }
static const struct xx_color_management_surface_v2_listener color_listener = { static const struct xx_color_management_feedback_surface_v4_listener color_listener = {
preferred_changed, preferred_changed,
}; };
@ -524,12 +543,13 @@ gdk_wayland_color_surface_new (GdkWaylandColor *color,
self->color = color; self->color = color;
self->surface = xx_color_manager_v2_get_surface (color->color_manager, wl_surface); self->surface = xx_color_manager_v4_get_surface (color->color_manager, wl_surface);
self->feedback = xx_color_manager_v4_get_feedback_surface (color->color_manager, wl_surface);
self->callback = callback; self->callback = callback;
self->data = data; self->data = data;
xx_color_management_surface_v2_add_listener (self->surface, &color_listener, self); xx_color_management_feedback_surface_v4_add_listener (self->feedback, &color_listener, self);
return self; return self;
} }
@ -537,13 +557,14 @@ gdk_wayland_color_surface_new (GdkWaylandColor *color,
void void
gdk_wayland_color_surface_free (GdkWaylandColorSurface *self) gdk_wayland_color_surface_free (GdkWaylandColorSurface *self)
{ {
xx_color_management_surface_v2_destroy (self->surface); xx_color_management_surface_v4_destroy (self->surface);
xx_color_management_feedback_surface_v4_destroy (self->feedback);
g_free (self); g_free (self);
} }
static struct xx_image_description_v2 * static struct xx_image_description_v4 *
gdk_wayland_color_get_image_description (GdkWaylandColor *color, gdk_wayland_color_get_image_description (GdkWaylandColor *color,
GdkColorState *cs) GdkColorState *cs)
{ {
@ -563,16 +584,16 @@ void
gdk_wayland_color_surface_set_color_state (GdkWaylandColorSurface *self, gdk_wayland_color_surface_set_color_state (GdkWaylandColorSurface *self,
GdkColorState *cs) GdkColorState *cs)
{ {
struct xx_image_description_v2 *desc; struct xx_image_description_v4 *desc;
desc = gdk_wayland_color_get_image_description (self->color, cs); desc = gdk_wayland_color_get_image_description (self->color, cs);
if (desc) if (desc)
xx_color_management_surface_v2_set_image_description (self->surface, xx_color_management_surface_v4_set_image_description (self->surface,
desc, desc,
XX_COLOR_MANAGER_V2_RENDER_INTENT_PERCEPTUAL); XX_COLOR_MANAGER_V4_RENDER_INTENT_PERCEPTUAL);
else else
xx_color_management_surface_v2_unset_image_description (self->surface); xx_color_management_surface_v4_unset_image_description (self->surface);
} }
gboolean gboolean

View File

@ -149,7 +149,7 @@ proto_sources = [
{ {
'name': 'xx-color-management', 'name': 'xx-color-management',
'stability': 'private', 'stability': 'private',
'version': 2, 'version': 4,
}, },
] ]