Skip to content

Commit

Permalink
wayland/color-management: Update to upstream wp_color_management_v1
Browse files Browse the repository at this point in the history
  • Loading branch information
swick authored and Marge Bot committed Feb 25, 2025
1 parent b1ef99b commit 4fe1e41
Show file tree
Hide file tree
Showing 11 changed files with 257 additions and 1,659 deletions.
6 changes: 1 addition & 5 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ variables:
- .skip-git-clone
variables:
FDO_DISTRIBUTION_VERSION: 41
BASE_TAG: '2025-02-13.0'
BASE_TAG: '2025-02-19.1'
MUTTER_USER: 'meta-user'
FDO_DISTRIBUTION_PACKAGES:
accountsservice-devel
Expand Down Expand Up @@ -158,10 +158,6 @@ variables:
https://gitlab.gnome.org/GNOME/gi-docgen.git \
main
./.gitlab-ci/install-meson-project.sh \
https://gitlab.freedesktop.org/wayland/wayland-protocols.git \
1.38
./.gitlab-ci/install-common-dependencies.sh
rpm -e --nodeps gnome-bluetooth-libs-devel \
Expand Down
8 changes: 8 additions & 0 deletions .gitlab-ci/install-common-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,11 @@ then
https://gitlab.gnome.org/GNOME/gjs.git \
master
fi

if ! pkgconf --atleast-version 1.41 wayland-protocols
then
./$SCRIPTS_DIR/install-meson-project.sh \
"${OPTIONS[@]}" \
https://gitlab.freedesktop.org/wayland/wayland-protocols.git \
1.41
fi
10 changes: 9 additions & 1 deletion clutter/clutter/clutter-color-state-params.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ static const ClutterLuminance sdr_default_luminance = {
.ref = 80.0f,
};

static const ClutterLuminance bt709_default_luminance = {
.type = CLUTTER_LUMINANCE_TYPE_DERIVED,
.min = 0.01f,
.max = 100.0f,
.ref = 100.0f,
};

static const ClutterLuminance pq_default_luminance = {
.type = CLUTTER_LUMINANCE_TYPE_DERIVED,
.min = 0.005f,
Expand All @@ -165,9 +172,10 @@ clutter_eotf_get_default_luminance (ClutterEOTF eotf)
switch (eotf.tf_name)
{
case CLUTTER_TRANSFER_FUNCTION_SRGB:
case CLUTTER_TRANSFER_FUNCTION_BT709:
case CLUTTER_TRANSFER_FUNCTION_LINEAR:
return &sdr_default_luminance;
case CLUTTER_TRANSFER_FUNCTION_BT709:
return &bt709_default_luminance;
case CLUTTER_TRANSFER_FUNCTION_PQ:
return &pq_default_luminance;
}
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ gudev_req = '>= 238'

# wayland version requirements
wayland_server_req = '>= 1.23'
wayland_protocols_req = '>= 1.38'
wayland_protocols_req = '>= 1.41'

# native backend version requirements
libinput_req = '>= 1.27.0'
Expand Down
2 changes: 1 addition & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ if have_wayland
# - protocol stability ('private', 'stable' or 'unstable')
# - protocol version (if stability is 'unstable')
wayland_protocols = [
['color-management-v1', 'private', ],
['color-management', 'staging', 'v1', ],
['commit-timing', 'staging', 'v1', ],
['cursor-shape-v1', 'private', ],
['drm-lease', 'staging', 'v1', ],
Expand Down
82 changes: 44 additions & 38 deletions src/tests/wayland-test-clients/color-management.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ wait_for_configure (WaylandDisplay *display)
wayland_display_dispatch (display);
}

static uint32_t
float_to_scaled_uint32_chromaticity (float value)
{
return (uint32_t) (value * 1000000);
}

static uint32_t
float_to_scaled_uint32 (float value)
{
Expand All @@ -98,7 +104,7 @@ float_to_scaled_uint32 (float value)

static void
handle_image_description_failed (void *data,
struct xx_image_description_v4 *image_description_v4,
struct wp_image_description_v1 *image_description_v4,
uint32_t cause,
const char *msg)

Expand All @@ -110,15 +116,15 @@ handle_image_description_failed (void *data,

static void
handle_image_description_ready (void *data,
struct xx_image_description_v4 *image_description_v4,
struct wp_image_description_v1 *image_description_v4,
uint32_t identity)
{
ImageDescriptionContext *image_description_context = data;

image_description_context->image_description_id = identity;
}

static const struct xx_image_description_v4_listener image_description_listener = {
static const struct wp_image_description_v1_listener image_description_listener = {
handle_image_description_failed,
handle_image_description_ready,
};
Expand All @@ -134,7 +140,7 @@ wait_for_image_description_ready (ImageDescriptionContext *image_description,

static void
create_image_description_from_params (WaylandDisplay *display,
struct xx_image_description_v4 **image_description,
struct wp_image_description_v1 **image_description,
int primaries_named,
Primaries *primaries,
int tf_named,
Expand All @@ -144,41 +150,41 @@ create_image_description_from_params (WaylandDisplay *display,
float ref_lum)

{
struct xx_image_description_creator_params_v4 *creator_params;
struct wp_image_description_creator_params_v1 *creator_params;
ImageDescriptionContext image_description_context;

creator_params =
xx_color_manager_v4_new_parametric_creator (display->color_management_mgr);
wp_color_manager_v1_create_parametric_creator (display->color_management_mgr);

if (primaries_named != -1)
xx_image_description_creator_params_v4_set_primaries_named (
wp_image_description_creator_params_v1_set_primaries_named (
creator_params,
primaries_named);

if (primaries)
xx_image_description_creator_params_v4_set_primaries (
wp_image_description_creator_params_v1_set_primaries (
creator_params,
float_to_scaled_uint32 (primaries->r_x),
float_to_scaled_uint32 (primaries->r_y),
float_to_scaled_uint32 (primaries->g_x),
float_to_scaled_uint32 (primaries->g_y),
float_to_scaled_uint32 (primaries->b_x),
float_to_scaled_uint32 (primaries->b_y),
float_to_scaled_uint32 (primaries->w_x),
float_to_scaled_uint32 (primaries->w_y));
float_to_scaled_uint32_chromaticity (primaries->r_x),
float_to_scaled_uint32_chromaticity (primaries->r_y),
float_to_scaled_uint32_chromaticity (primaries->g_x),
float_to_scaled_uint32_chromaticity (primaries->g_y),
float_to_scaled_uint32_chromaticity (primaries->b_x),
float_to_scaled_uint32_chromaticity (primaries->b_y),
float_to_scaled_uint32_chromaticity (primaries->w_x),
float_to_scaled_uint32_chromaticity (primaries->w_y));

if (tf_named != -1)
xx_image_description_creator_params_v4_set_tf_named (
wp_image_description_creator_params_v1_set_tf_named (
creator_params,
tf_named);

if (tf_power >= 1.0f)
xx_image_description_creator_params_v4_set_tf_power (
wp_image_description_creator_params_v1_set_tf_power (
creator_params,
float_to_scaled_uint32 (tf_power));

if (min_lum >= 0.0f && max_lum > 0.0f && ref_lum >= 0.0f)
xx_image_description_creator_params_v4_set_luminances (
wp_image_description_creator_params_v1_set_luminances (
creator_params,
float_to_scaled_uint32 (min_lum),
(uint32_t) max_lum,
Expand All @@ -188,8 +194,8 @@ create_image_description_from_params (WaylandDisplay *display,
image_description_context.creation_failed = FALSE;

*image_description =
xx_image_description_creator_params_v4_create (creator_params);
xx_image_description_v4_add_listener (
wp_image_description_creator_params_v1_create (creator_params);
wp_image_description_v1_add_listener (
*image_description,
&image_description_listener,
&image_description_context);
Expand All @@ -208,8 +214,8 @@ main (int argc,
struct xdg_toplevel *xdg_toplevel;
struct xdg_surface *xdg_surface;
struct wl_surface *surface;
struct xx_color_management_surface_v4 *color_surface;
struct xx_image_description_v4 *image_description;
struct wp_color_management_surface_v1 *color_surface;
struct wp_image_description_v1 *image_description;

display = wayland_display_new (WAYLAND_DISPLAY_CAPABILITY_TEST_DRIVER);

Expand All @@ -220,7 +226,7 @@ main (int argc,
xdg_toplevel_add_listener (xdg_toplevel, &xdg_toplevel_listener, NULL);
xdg_toplevel_set_title (xdg_toplevel, "color-management");
color_surface =
xx_color_manager_v4_get_surface (display->color_management_mgr, surface);
wp_color_manager_v1_get_surface (display->color_management_mgr, surface);

wl_surface_commit (surface);
wait_for_configure (display);
Expand All @@ -230,42 +236,42 @@ main (int argc,

create_image_description_from_params (display,
&image_description,
XX_COLOR_MANAGER_V4_PRIMARIES_BT2020,
WP_COLOR_MANAGER_V1_PRIMARIES_BT2020,
NULL,
XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_ST2084_PQ,
WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST2084_PQ,
-1.0f,
0.005f,
10000.0f,
303.0f);
xx_color_management_surface_v4_set_image_description (
wp_color_management_surface_v1_set_image_description (
color_surface,
image_description,
XX_COLOR_MANAGER_V4_RENDER_INTENT_PERCEPTUAL);
WP_COLOR_MANAGER_V1_RENDER_INTENT_PERCEPTUAL);

wl_surface_commit (surface);

xx_image_description_v4_destroy (image_description);
wp_image_description_v1_destroy (image_description);

test_driver_sync_point (display->test_driver, 1, NULL);
wait_for_sync_event (display, 1);

create_image_description_from_params (display,
&image_description,
XX_COLOR_MANAGER_V4_PRIMARIES_SRGB,
WP_COLOR_MANAGER_V1_PRIMARIES_SRGB,
NULL,
XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB,
WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB,
-1.0f,
0.2f,
80.0f,
70.0f);
xx_color_management_surface_v4_set_image_description (
wp_color_management_surface_v1_set_image_description (
color_surface,
image_description,
XX_COLOR_MANAGER_V4_RENDER_INTENT_PERCEPTUAL);
WP_COLOR_MANAGER_V1_RENDER_INTENT_PERCEPTUAL);

wl_surface_commit (surface);

xx_image_description_v4_destroy (image_description);
wp_image_description_v1_destroy (image_description);

test_driver_sync_point (display->test_driver, 2, NULL);
wait_for_sync_event (display, 2);
Expand All @@ -279,19 +285,19 @@ main (int argc,
-1.0f,
-1.0f,
-1.0f);
xx_color_management_surface_v4_set_image_description (
wp_color_management_surface_v1_set_image_description (
color_surface,
image_description,
XX_COLOR_MANAGER_V4_RENDER_INTENT_PERCEPTUAL);
WP_COLOR_MANAGER_V1_RENDER_INTENT_PERCEPTUAL);

wl_surface_commit (surface);

xx_image_description_v4_destroy (image_description);
wp_image_description_v1_destroy (image_description);

test_driver_sync_point (display->test_driver, 3, NULL);
wait_for_sync_event (display, 3);

xx_color_management_surface_v4_destroy (color_surface);
wp_color_management_surface_v1_destroy (color_surface);

return EXIT_SUCCESS;
}
4 changes: 2 additions & 2 deletions src/tests/wayland-test-clients/wayland-test-client-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,11 @@ handle_registry_global (void *user_data,
wl_registry_bind (registry, id,
&wp_single_pixel_buffer_manager_v1_interface, 1);
}
else if (strcmp (interface, xx_color_manager_v4_interface.name) == 0)
else if (strcmp (interface, wp_color_manager_v1_interface.name) == 0)
{
display->color_management_mgr =
wl_registry_bind (registry, id,
&xx_color_manager_v4_interface, 1);
&wp_color_manager_v1_interface, 1);
}
else if (strcmp (interface, wp_viewporter_interface.name) == 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/tests/wayland-test-clients/wayland-test-client-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ typedef struct _WaylandDisplay
struct zwp_linux_dmabuf_v1 *linux_dmabuf;
struct wp_fractional_scale_manager_v1 *fractional_scale_mgr;
struct wp_single_pixel_buffer_manager_v1 *single_pixel_mgr;
struct xx_color_manager_v4 *color_management_mgr;
struct wp_color_manager_v1 *color_management_mgr;
struct wp_viewporter *viewporter;
struct xdg_wm_base *xdg_wm_base;
struct wl_seat *wl_seat;
Expand Down
Loading

0 comments on commit 4fe1e41

Please sign in to comment.