wayland: update xx color management to version 4

This commit is contained in:
Xaver Hugl 2024-07-17 17:25:05 +02:00
parent 01d9393e80
commit 1d3e3faf7b
9 changed files with 379 additions and 301 deletions

View file

@ -228,8 +228,8 @@ ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml
BASENAME security-context-v1
)
ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml
PROTOCOL ${PROJECT_SOURCE_DIR}/src/wayland/protocols/xx-color-management-v3.xml
BASENAME xx-color-management-v3
PROTOCOL ${PROJECT_SOURCE_DIR}/src/wayland/protocols/xx-color-management-v4.xml
BASENAME xx-color-management-v4
)
if (WaylandProtocols_VERSION VERSION_LESS 1.36)
ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml
@ -340,7 +340,7 @@ target_sources(kwin PRIVATE
xdgtopleveldrag_v1.cpp
xwaylandkeyboardgrab_v1.cpp
xwaylandshell_v1.cpp
xx_colormanagement_v3.cpp
xx_colormanagement_v4.cpp
)
install(FILES
@ -417,19 +417,19 @@ install(FILES
xdgshell.h
xwaylandkeyboardgrab_v1.h
xwaylandshell_v1.h
xx_colormanagement_v3.h
xx_colormanagement_v4.h
${CMAKE_CURRENT_BINARY_DIR}/qwayland-server-content-type-v1.h
${CMAKE_CURRENT_BINARY_DIR}/qwayland-server-frog-color-management-v1.h
${CMAKE_CURRENT_BINARY_DIR}/qwayland-server-kde-external-brightness-v1.h
${CMAKE_CURRENT_BINARY_DIR}/qwayland-server-linux-drm-syncobj-v1.h
${CMAKE_CURRENT_BINARY_DIR}/qwayland-server-presentation-time.h
${CMAKE_CURRENT_BINARY_DIR}/qwayland-server-xx-color-management-v3.h
${CMAKE_CURRENT_BINARY_DIR}/qwayland-server-xx-color-management-v4.h
${CMAKE_CURRENT_BINARY_DIR}/wayland-content-type-v1-server-protocol.h
${CMAKE_CURRENT_BINARY_DIR}/wayland-frog-color-management-v1-server-protocol.h
${CMAKE_CURRENT_BINARY_DIR}/wayland-kde-external-brightness-v1-server-protocol.h
${CMAKE_CURRENT_BINARY_DIR}/wayland-linux-drm-syncobj-v1-server-protocol.h
${CMAKE_CURRENT_BINARY_DIR}/wayland-presentation-time-server-protocol.h
${CMAKE_CURRENT_BINARY_DIR}/wayland-xx-color-management-v3-server-protocol.h
${CMAKE_CURRENT_BINARY_DIR}/wayland-xx-color-management-v4-server-protocol.h
DESTINATION ${KDE_INSTALL_INCLUDEDIR}/kwin/wayland COMPONENT Devel)

View file

@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="xx_color_management_v3">
<protocol name="xx_color_management_v4">
<copyright>
Copyright 2019 Sebastian Wick
Copyright 2019 Erwin Burema
Copyright 2020 AMD
Copyright 2020-2024 Collabora, Ltd.
Copyright 2024 Xaver Hugl
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
@ -64,7 +65,7 @@
protocol.
</description>
<interface name="xx_color_manager_v3" version="1">
<interface name="xx_color_manager_v4" version="1">
<description summary="color manager singleton">
A global interface used for getting color management extensions for
wl_surface and wl_output objects, and for creating client defined image
@ -75,7 +76,7 @@
<request name="destroy" type="destructor">
<description summary="destroy the color manager">
Destroy the xx_color_manager_v3 object. This does not affect any other
Destroy the xx_color_manager_v4 object. This does not affect any other
objects in any way.
</description>
</request>
@ -371,28 +372,42 @@
<request name="get_output">
<description summary="create a color management interface for a wl_output">
This creates a new xx_color_management_output_v3 object for the
This creates a new xx_color_management_output_v4 object for the
given wl_output.
See the xx_color_management_output_v3 interface for more details.
See the xx_color_management_output_v4 interface for more details.
</description>
<arg name="id" type="new_id" interface="xx_color_management_output_v3"/>
<arg name="id" type="new_id" interface="xx_color_management_output_v4"/>
<arg name="output" type="object" interface="wl_output"/>
</request>
<request name="get_surface">
<description summary="create a color management interface for a wl_surface">
If a xx_color_management_surface_v3 object already exists for the given
If a xx_color_management_surface_v4 object already exists for the given
wl_surface, the protocol error surface_exists is raised.
This creates a new color xx_color_management_surface_v3 object for the
This creates a new color xx_color_management_surface_v4 object for the
given wl_surface.
See the xx_color_management_surface_v3 interface for more details.
See the xx_color_management_surface_v4 interface for more details.
</description>
<arg name="id" type="new_id" interface="xx_color_management_surface_v3"/>
<arg name="id" type="new_id" interface="xx_color_management_surface_v4"/>
<arg name="surface" type="object" interface="wl_surface"/>
</request>
<request name="get_feedback_surface">
<description summary="create a color management feedback interface">
This creates a new color xx_color_management_feedback_surface_v4 object
for the given wl_surface.
See the xx_color_management_feedback_surface_v4 interface for more
details.
</description>
<arg name="id" type="new_id"
interface="xx_color_management_feedback_surface_v4"/>
<arg name="surface" type="object" interface="wl_surface"/>
</request>
@ -401,15 +416,15 @@
Makes a new ICC-based image description creator object with all
properties initially unset. The client can then use the object's
interface to define all the required properties for an image description
and finally create a xx_image_description_v3 object.
and finally create a xx_image_description_v4 object.
This request can be used when the compositor advertises
xx_color_manager_v3.feature.icc_v2_v4.
xx_color_manager_v4.feature.icc_v2_v4.
Otherwise this request raises the protocol error unsupported_feature.
</description>
<arg name="obj"
type="new_id" interface="xx_image_description_creator_icc_v3"
type="new_id" interface="xx_image_description_creator_icc_v4"
summary="the new creator object"/>
</request>
@ -418,15 +433,15 @@
Makes a new parametric image description creator object with all
properties initially unset. The client can then use the object's
interface to define all the required properties for an image description
and finally create a xx_image_description_v3 object.
and finally create a xx_image_description_v4 object.
This request can be used when the compositor advertises
xx_color_manager_v3.feature.parametric.
xx_color_manager_v4.feature.parametric.
Otherwise this request raises the protocol error unsupported_feature.
</description>
<arg name="obj"
type="new_id" interface="xx_image_description_creator_params_v3"
type="new_id" interface="xx_image_description_creator_params_v4"
summary="the new creator object"/>
</request>
@ -473,20 +488,20 @@
</event>
</interface>
<interface name="xx_color_management_output_v3" version="1">
<interface name="xx_color_management_output_v4" version="1">
<description summary="output color properties">
A xx_color_management_output_v3 describes the color properties of an
A xx_color_management_output_v4 describes the color properties of an
output.
The xx_color_management_output_v3 is associated with the wl_output global
The xx_color_management_output_v4 is associated with the wl_output global
underlying the wl_output object. Therefore the client destroying the
wl_output object has no impact, but the compositor removing the output
global makes the xx_color_management_output_v3 object inert.
global makes the xx_color_management_output_v4 object inert.
</description>
<request name="destroy" type="destructor">
<description summary="destroy the color management output">
Destroy the color xx_color_management_output_v3 object. This does not
Destroy the color xx_color_management_output_v4 object. This does not
affect any remaining protocol objects.
</description>
</request>
@ -505,12 +520,12 @@
<request name="get_image_description">
<description summary="get the image description of the output">
This creates a new xx_image_description_v3 object for the current image
This creates a new xx_image_description_v4 object for the current image
description of the output. There always is exactly one image description
active for an output so the client should destroy the image description
created by earlier invocations of this request. This request is usually
sent as a reaction to the image_description_changed event or when
creating a xx_color_management_output_v3 object.
creating a xx_color_management_output_v4 object.
The image description of an output represents the color encoding the
output expects. There might be performance and power advantages, as well
@ -520,53 +535,50 @@
of, then the color reproduction on those outputs might be considerably
worse.
The created xx_image_description_v3 object preserves the image
The created xx_image_description_v4 object preserves the image
description of the output from the time the object was created.
The resulting image description object allows get_information request.
If this protocol object is inert, the resulting image description object
shall immediately deliver the xx_image_description_v3.failed event with
shall immediately deliver the xx_image_description_v4.failed event with
the no_output cause.
If the interface version is inadequate for the output's image
description, meaning that the client does not support all the events
needed to deliver the crucial information, the resulting image
description object shall immediately deliver the
xx_image_description_v3.failed event with the low_version cause.
xx_image_description_v4.failed event with the low_version cause.
Otherwise the object shall immediately deliver the ready event.
</description>
<arg name="image_description"
type="new_id" interface="xx_image_description_v3"/>
type="new_id" interface="xx_image_description_v4"/>
</request>
</interface>
<interface name="xx_color_management_surface_v3" version="1">
<interface name="xx_color_management_surface_v4" version="1">
<description summary="color management extension to a surface">
A xx_color_management_surface_v3 allows the client to set the color
A xx_color_management_surface_v4 allows the client to set the color
space and HDR properties of a surface.
If the wl_surface associated with the xx_color_management_surface_v3 is
destroyed, the xx_color_management_surface_v3 object becomes inert.
If the wl_surface associated with the xx_color_management_surface_v4 is
destroyed, the xx_color_management_surface_v4 object becomes inert.
</description>
<request name="destroy" type="destructor">
<description summary="destroy the color management interface for a surface">
Destroy the xx_color_management_surface_v3 object and do the same as
Destroy the xx_color_management_surface_v4 object and do the same as
unset_image_description.
</description>
</request>
<enum name="error">
<description summary="protocol errors"/>
<entry name="inert" value="0"
summary="forbidden request on inert object"/>
<entry name="render_intent" value="1"
<entry name="render_intent" value="0"
summary="unsupported rendering intent"/>
<entry name="image_description" value="2"
<entry name="image_description" value="1"
summary="invalid image description"/>
</enum>
@ -582,17 +594,17 @@
other image descriptions.
Image description whose creation gracefully failed (received
xx_image_description_v3.failed) are forbidden in this request, and in
xx_image_description_v4.failed) are forbidden in this request, and in
such case the protocol error image_description is raised.
All image descriptions whose creation succeeded (received
xx_image_description_v3.ready) are allowed and must always be accepted
xx_image_description_v4.ready) are allowed and must always be accepted
by the compositor.
A rendering intent provides the client's preference on how content
colors should be mapped to each output. The render_intent value must
be one advertised by the compositor with
xx_color_manager_v3.render_intent event, otherwise the protocol error
xx_color_manager_v4.render_intent event, otherwise the protocol error
render_intent is raised.
By default, a surface does not have an associated image description
@ -603,9 +615,9 @@
</description>
<arg name="image_description"
type="object" interface="xx_image_description_v3"/>
type="object" interface="xx_image_description_v4"/>
<arg name="render_intent"
type="uint" enum="xx_color_manager_v3.render_intent"
type="uint" enum="xx_color_manager_v4.render_intent"
summary="rendering intent"/>
</request>
@ -617,16 +629,36 @@
wl_surface.commit.
</description>
</request>
</interface>
<interface name="xx_color_management_feedback_surface_v4" version="1">
<description summary="color management extension to a surface">
A xx_color_management_feedback_surface_v4 allows the client to get the
preferred color description of a surface.
If the wl_surface associated with this object is destroyed, the
xx_color_management_feedback_surface_v4 object becomes inert.
</description>
<request name="destroy" type="destructor">
<description summary="destroy the color management interface for a surface">
Destroy the xx_color_management_feedback_surface_v4 object.
</description>
</request>
<enum name="error">
<description summary="protocol errors"/>
<entry name="inert" value="0"
summary="forbidden request on inert object"/>
</enum>
<event name="preferred_changed">
<description summary="compositor's preferred image description for the surface">
<description summary="the preferred image description changed">
The preferred image description is the one which likely has the most
performance and/or quality benefits for the compositor if used by the
client for its wl_surface contents. This event is sent whenever the
compositor changes the wl_surface's preferred image description.
This is not an initial event.
This event is merely a notification. When the client wants to know
what the preferred image description is, it shall use the get_preferred
request.
@ -650,15 +682,15 @@
reproduction, if the image description of a content update matches the
preferred image description.
This creates a new xx_image_description_v3 object for the currently
This creates a new xx_image_description_v4 object for the currently
preferred image description for the wl_surface. The client should
stop using and destroy the image descriptions created by earlier
invocations of this request for the associated wl_surface.
This request is usually sent as a reaction to the preferred_changed
event or when creating a xx_color_management_surface_v3 object if
the client is capable of adapting to image descriptions.
event or when creating a xx_color_management_feedback_surface_v4 object
if the client is capable of adapting to image descriptions.
The created xx_image_description_v3 object preserves the preferred image
The created xx_image_description_v4 object preserves the preferred image
description of the wl_surface from the time the object was created.
The resulting image description object allows get_information request.
@ -667,19 +699,19 @@
description, meaning that the client does not support all the
events needed to deliver the crucial information, the resulting image
description object shall immediately deliver the
xx_image_description_v3.failed event with the low_version cause,
xx_image_description_v4.failed event with the low_version cause,
otherwise the object shall immediately deliver the ready event.
</description>
<arg name="image_description"
type="new_id" interface="xx_image_description_v3"/>
type="new_id" interface="xx_image_description_v4"/>
</request>
</interface>
<interface name="xx_image_description_creator_icc_v3" version="1">
<interface name="xx_image_description_creator_icc_v4" version="1">
<description summary="holder of image description ICC information">
This type of object is used for collecting all the information required
to create a xx_image_description_v3 object from an ICC file. A complete
to create a xx_image_description_v4 object from an ICC file. A complete
set of required parameters consists of these properties:
- ICC file
@ -721,19 +753,19 @@
If the particular combination of the information is not supported
by the compositor, the resulting image description object shall
immediately deliver the xx_image_description_v3.failed event with the
immediately deliver the xx_image_description_v4.failed event with the
'unsupported' cause. If a valid image description was created from the
information, the xx_image_description_v3.ready event will eventually
information, the xx_image_description_v4.ready event will eventually
be sent instead.
This request destroys the xx_image_description_creator_icc_v3 object.
This request destroys the xx_image_description_creator_icc_v4 object.
The resulting image description object does not allow get_information
request.
</description>
<arg name="image_description"
type="new_id" interface="xx_image_description_v3"/>
type="new_id" interface="xx_image_description_v4"/>
</request>
<request name="set_icc_file">
@ -746,8 +778,8 @@
requirements raises the bad_fd protocol error.
If reading the data fails due to an error independent of the client, the
compositor shall send the xx_image_description_v3.failed event on the
created xx_image_description_v3 with the 'operating_system' cause.
compositor shall send the xx_image_description_v4.failed event on the
created xx_image_description_v4 with the 'operating_system' cause.
The maximum size of the ICC profile is 4 MB. If length is greater than
that or zero, the protocol error bad_size is raised. If offset + length
@ -755,10 +787,10 @@
A compositor may read the file at any time starting from this request
and only until whichever happens first:
- If create request was issued, the xx_image_description_v3 object
- If create request was issued, the xx_image_description_v4 object
delivers either failed or ready event; or
- if create request was not issued, this
xx_image_description_creator_icc_v3 object is destroyed.
xx_image_description_creator_icc_v4 object is destroyed.
A compositor shall not modify the contents of the file, and the fd may
be sealed for writes and size changes. The client must ensure to its
@ -769,8 +801,8 @@
must be 2 or 4, it must be a 3 channel profile and the class must be
Display or ColorSpace. Violating these requirements will not result in a
protocol error but will eventually send the
xx_image_description_v3.failed event on the created
xx_image_description_v3 with the 'unsupported' cause.
xx_image_description_v4.failed event on the created
xx_image_description_v4 with the 'unsupported' cause.
See the International Color Consortium specification ICC.1:2022 for more
details about ICC profiles.
@ -788,10 +820,10 @@
</request>
</interface>
<interface name="xx_image_description_creator_params_v3" version="1">
<interface name="xx_image_description_creator_params_v4" version="1">
<description summary="holder of image description parameters">
This type of object is used for collecting all the parameters required
to create a xx_image_description_v3 object. A complete set of required
to create a xx_image_description_v4 object. A complete set of required
parameters consists of these properties:
- transfer characteristic function (tf)
- chromaticities of primaries and white point (primary color volume)
@ -851,12 +883,12 @@
If the particular combination of the parameter set is not supported
by the compositor, the resulting image description object shall
immediately deliver the xx_image_description_v3.failed event with the
immediately deliver the xx_image_description_v4.failed event with the
'unsupported' cause. If a valid image description was created from the
parameter set, the xx_image_description_v3.ready event will eventually
parameter set, the xx_image_description_v4.ready event will eventually
be sent instead.
This request destroys the xx_image_description_creator_params_v3
This request destroys the xx_image_description_creator_params_v4
object.
The resulting image description object does not allow get_information
@ -864,7 +896,7 @@
</description>
<arg name="image_description"
type="new_id" interface="xx_image_description_v3"/>
type="new_id" interface="xx_image_description_v4"/>
</request>
<request name="set_tf_named">
@ -876,14 +908,14 @@
content should be encoded and decoded according to the industry standard
practices for the transfer characteristic.
Only names advertised with xx_color_manager_v3 event supported_tf_named
Only names advertised with xx_color_manager_v4 event supported_tf_named
are allowed. Other values shall raise the protocol error invalid_tf.
If transfer characteristic has already been set on this object, the
protocol error already_set is raised.
</description>
<arg name="tf" type="uint" enum="xx_color_manager_v3.transfer_function"
<arg name="tf" type="uint" enum="xx_color_manager_v4.transfer_function"
summary="named transfer function"/>
</request>
@ -906,7 +938,7 @@
protocol error already_set is raised.
This request can be used when the compositor advertises
xx_color_manager_v3.feature.set_tf_power. Otherwise this request raises
xx_color_manager_v4.feature.set_tf_power. Otherwise this request raises
the protocol error unsupported_feature.
</description>
@ -919,7 +951,7 @@
This describes the primary color volume which is the basis for color
value encoding.
Only names advertised with xx_color_manager_v3 event
Only names advertised with xx_color_manager_v4 event
supported_primaries_named are allowed. Other values shall raise the
protocol error invalid_primaries.
@ -927,7 +959,7 @@
already_set is raised.
</description>
<arg name="primaries" type="uint" enum="xx_color_manager_v3.primaries"
<arg name="primaries" type="uint" enum="xx_color_manager_v4.primaries"
summary="named primaries"/>
</request>
@ -944,7 +976,7 @@
already_set is raised.
This request can be used if the compositor advertises
xx_color_manager_v3.feature.set_primaries. Otherwise this request raises
xx_color_manager_v4.feature.set_primaries. Otherwise this request raises
the protocol error unsupported_feature.
</description>
@ -999,7 +1031,7 @@
already_set is raised.
This request can be used if the compositor advertises
xx_color_manager_v3.feature.set_luminances. Otherwise this request
xx_color_manager_v4.feature.set_luminances. Otherwise this request
raises the protocol error unsupported_feature.
</description>
@ -1046,14 +1078,14 @@
protocol error already_set is raised.
This request can be used if the compositor advertises
xx_color_manager_v3.feature.set_mastering_display_primaries. Otherwise
xx_color_manager_v4.feature.set_mastering_display_primaries. Otherwise
this request raises the protocol error unsupported_feature. The
advertisement implies support only for target color volumes fully
contained within the primary color volume.
If a compositor additionally supports target color volume exceeding the
primary color volume, it must advertise
xx_color_manager_v3.feature.extended_target_volume. If a client uses
xx_color_manager_v4.feature.extended_target_volume. If a client uses
target color volume exceeding the primary color volume and the
compositor does not support it, the result is implementation defined.
Compositors are recommended to detect this case and fail the image
@ -1120,15 +1152,15 @@
</request>
</interface>
<interface name="xx_image_description_v3" version="1">
<interface name="xx_image_description_v4" version="1">
<description summary="Colorimetric image description">
An image description carries information about the color encoding used on
a surface when attached to a wl_surface via
xx_color_management_surface_v3.set_image_description. A compositor can use
xx_color_management_surface_v4.set_image_description. A compositor can use
this information to decode pixel values into colorimetrically meaningful
quantities.
Note, that the xx_image_description_v3 object is not ready to be used
Note, that the xx_image_description_v4 object is not ready to be used
immediately after creation. The object eventually delivers either the
'ready' or the 'failed' event, specified in all requests creating it. The
object is deemed "ready" after receiving the 'ready' event.
@ -1139,7 +1171,7 @@
interfaces shall raise protocol errors defined there.
Once created and regardless of how it was created, a
xx_image_description_v3 object always refers to one fixed image
xx_image_description_v4 object always refers to one fixed image
description. It cannot change after creation.
</description>
@ -1147,8 +1179,8 @@
<description summary="destroy the image description">
Destroy this object. It is safe to destroy an object which is not ready.
Destroying a xx_image_description_v3 object has no side-effects, not
even if a xx_color_management_surface_v3.set_image_description has not
Destroying a xx_image_description_v4 object has no side-effects, not
even if a xx_color_management_surface_v4.set_image_description has not
yet been followed by a wl_surface.commit.
</description>
</request>
@ -1177,7 +1209,7 @@
<event name="failed">
<description summary="graceful error on creating the image description">
If creating a xx_image_description_v3 object fails for a reason that is
If creating a xx_image_description_v4 object fails for a reason that is
not defined as a protocol error, this event is sent.
The requests that create image description objects define whether and
@ -1185,7 +1217,7 @@
This event cannot be triggered after the image description was
successfully formed.
Once this event has been sent, the xx_image_description_v3 object will
Once this event has been sent, the xx_image_description_v4 object will
never become ready and it can only be destroyed.
</description>
@ -1197,11 +1229,11 @@
<event name="ready">
<description summary="indication that the object is ready to be used">
Once this event has been sent, the xx_image_description_v3 object is
Once this event has been sent, the xx_image_description_v4 object is
deemed "ready". Ready objects can be used to send requests and can be
used through other interfaces.
Every ready xx_image_description_v3 protocol object refers to an
Every ready xx_image_description_v4 protocol object refers to an
underlying image description record in the compositor. Multiple protocol
objects may end up referring to the same record. Clients may identify
these "copies" by comparing their id numbers: if the numbers from two
@ -1230,7 +1262,7 @@
<request name="get_information">
<description summary="get information about the image description">
Creates a xx_image_description_info_v3 object which delivers the
Creates a xx_image_description_info_v4 object which delivers the
information that makes up the image description.
Not all image description protocol objects allow get_information
@ -1240,20 +1272,20 @@
</description>
<arg name="information"
type="new_id" interface="xx_image_description_info_v3"/>
type="new_id" interface="xx_image_description_info_v4"/>
</request>
</interface>
<interface name="xx_image_description_info_v3" version="1">
<interface name="xx_image_description_info_v4" version="1">
<description summary="Colorimetric image description information">
Sends all matching events describing an image description object exactly
once and finally sends the 'done' event.
Once a xx_image_description_info_v3 object has delivered a 'done' event it
Once a xx_image_description_info_v4 object has delivered a 'done' event it
is automatically destroyed.
Every xx_image_description_info_v3 created from the same
xx_image_description_v3 shall always return the exact same data.
Every xx_image_description_info_v4 created from the same
xx_image_description_v4 shall always return the exact same data.
</description>
<event name="done" type="destructor">
@ -1304,7 +1336,7 @@
explicitly enumerated named set.
</description>
<arg name="primaries" type="uint" enum="xx_color_manager_v3.primaries"
<arg name="primaries" type="uint" enum="xx_color_manager_v4.primaries"
summary="named primaries"/>
</event>
@ -1328,7 +1360,7 @@
named function.
</description>
<arg name="tf" type="uint" enum="xx_color_manager_v3.transfer_function"
<arg name="tf" type="uint" enum="xx_color_manager_v4.transfer_function"
summary="named transfer function"/>
</event>

View file

@ -25,7 +25,7 @@
#include "surface_p.h"
#include "transaction.h"
#include "utils/resource.h"
#include "xx_colormanagement_v3.h"
#include "xx_colormanagement_v4.h"
#include <wayland-server.h>
// std
@ -1116,8 +1116,8 @@ void SurfaceInterface::setPreferredColorDescription(const ColorDescription &desc
if (d->frogColorManagement) {
d->frogColorManagement->setPreferredColorDescription(descr);
}
if (d->xxColorSurface) {
d->xxColorSurface->setPreferredColorDescription(descr);
for (const auto feedbackSurface : std::as_const(d->xxColorFeedbacks)) {
feedbackSurface->setPreferredColorDescription(descr);
}
for (auto child : std::as_const(d->current->subsurface.below)) {
child->surface()->setPreferredColorDescription(descr);

View file

@ -27,7 +27,8 @@ class TearingControlV1Interface;
class FractionalScaleV1Interface;
class FrogColorManagementSurfaceV1;
class PresentationTimeFeedback;
class XXColorSurfaceV3;
class XXColorSurfaceV4;
class XXColorFeedbackSurfaceV4;
class LinuxDrmSyncObjSurfaceV1;
struct SurfaceState
@ -176,7 +177,8 @@ public:
ClientConnection *client = nullptr;
TearingControlV1Interface *tearing = nullptr;
FrogColorManagementSurfaceV1 *frogColorManagement = nullptr;
XXColorSurfaceV3 *xxColorSurface = nullptr;
XXColorSurfaceV4 *xxColorSurface = nullptr;
QList<XXColorFeedbackSurfaceV4 *> xxColorFeedbacks;
LinuxDrmSyncObjSurfaceV1 *syncObjV1 = nullptr;
struct

View file

@ -1,111 +0,0 @@
/*
SPDX-FileCopyrightText: 2024 Xaver Hugl <xaver.hugl@gmail.com>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#pragma once
#include "core/colorspace.h"
#include "wayland/qwayland-server-xx-color-management-v3.h"
#include <QObject>
#include <QPointer>
namespace KWin
{
class Display;
class SurfaceInterface;
class Output;
class XXColorManagerV3 : public QObject, private QtWaylandServer::xx_color_manager_v3
{
Q_OBJECT
public:
explicit XXColorManagerV3(Display *display, QObject *parent);
private:
void xx_color_manager_v3_bind_resource(Resource *resource) override;
void xx_color_manager_v3_destroy(Resource *resource) override;
void xx_color_manager_v3_get_output(Resource *resource, uint32_t id, struct ::wl_resource *output) override;
void xx_color_manager_v3_get_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface) override;
void xx_color_manager_v3_new_icc_creator(Resource *resource, uint32_t obj) override;
void xx_color_manager_v3_new_parametric_creator(Resource *resource, uint32_t obj) override;
};
class XXColorSurfaceV3 : private QtWaylandServer::xx_color_management_surface_v3
{
public:
explicit XXColorSurfaceV3(wl_client *client, uint32_t id, uint32_t version, SurfaceInterface *surface);
~XXColorSurfaceV3() override;
void setPreferredColorDescription(const ColorDescription &descr);
private:
void xx_color_management_surface_v3_destroy_resource(Resource *resource) override;
void xx_color_management_surface_v3_destroy(Resource *resource) override;
void xx_color_management_surface_v3_set_image_description(Resource *resource, struct ::wl_resource *image_description, uint32_t render_intent) override;
void xx_color_management_surface_v3_unset_image_description(Resource *resource) override;
void xx_color_management_surface_v3_get_preferred(Resource *resource, uint32_t image_description) override;
QPointer<SurfaceInterface> m_surface;
ColorDescription m_preferred;
};
class XXColorParametricCreatorV3 : private QtWaylandServer::xx_image_description_creator_params_v3
{
public:
explicit XXColorParametricCreatorV3(wl_client *client, uint32_t id, uint32_t version);
private:
void xx_image_description_creator_params_v3_destroy_resource(Resource *resource) override;
void xx_image_description_creator_params_v3_create(Resource *resource, uint32_t image_description) override;
void xx_image_description_creator_params_v3_set_tf_named(Resource *resource, uint32_t tf) override;
void xx_image_description_creator_params_v3_set_tf_power(Resource *resource, uint32_t eexp) override;
void xx_image_description_creator_params_v3_set_primaries_named(Resource *resource, uint32_t primaries) override;
void xx_image_description_creator_params_v3_set_primaries(Resource *resource, int32_t r_x, int32_t r_y, int32_t g_x, int32_t g_y, int32_t b_x, int32_t b_y, int32_t w_x, int32_t w_y) override;
void xx_image_description_creator_params_v3_set_mastering_display_primaries(Resource *resource, int32_t r_x, int32_t r_y, int32_t g_x, int32_t g_y, int32_t b_x, int32_t b_y, int32_t w_x, int32_t w_y) override;
void xx_image_description_creator_params_v3_set_mastering_luminance(Resource *resource, uint32_t min_lum, uint32_t max_lum) override;
void xx_image_description_creator_params_v3_set_max_cll(Resource *resource, uint32_t max_cll) override;
void xx_image_description_creator_params_v3_set_max_fall(Resource *resource, uint32_t max_fall) override;
void xx_image_description_creator_params_v3_set_luminances(Resource *resource, uint32_t min_lum, uint32_t max_lum, uint32_t reference_lum) override;
std::optional<Colorimetry> m_colorimetry;
std::optional<TransferFunction> m_transferFunction;
std::optional<double> m_maxAverageLuminance;
std::optional<double> m_maxPeakBrightness;
};
class XXImageDescriptionV3 : private QtWaylandServer::xx_image_description_v3
{
public:
explicit XXImageDescriptionV3(wl_client *client, uint32_t id, uint32_t version, const ColorDescription &color);
const ColorDescription &description() const;
static XXImageDescriptionV3 *get(wl_resource *resource);
private:
void xx_image_description_v3_destroy_resource(Resource *resource) override;
void xx_image_description_v3_destroy(Resource *resource) override;
void xx_image_description_v3_get_information(Resource *resource, uint32_t information) override;
const ColorDescription m_description;
};
class XXColorManagementOutputV3 : public QObject, private QtWaylandServer::xx_color_management_output_v3
{
Q_OBJECT
public:
explicit XXColorManagementOutputV3(wl_client *client, uint32_t id, uint32_t version, Output *output);
private:
void colorDescriptionChanged();
void xx_color_management_output_v3_destroy_resource(Resource *resource) override;
void xx_color_management_output_v3_destroy(Resource *resource) override;
void xx_color_management_output_v3_get_image_description(Resource *resource, uint32_t image_description) override;
Output *const m_output;
ColorDescription m_colorDescription;
};
}

View file

@ -3,7 +3,7 @@
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "xx_colormanagement_v3.h"
#include "xx_colormanagement_v4.h"
#include "display.h"
#include "surface.h"
#include "surface_p.h"
@ -13,13 +13,13 @@
namespace KWin
{
XXColorManagerV3::XXColorManagerV3(Display *display, QObject *parent)
XXColorManagerV4::XXColorManagerV4(Display *display, QObject *parent)
: QObject(parent)
, QtWaylandServer::xx_color_manager_v3(*display, 1)
, QtWaylandServer::xx_color_manager_v4(*display, 1)
{
}
void XXColorManagerV3::xx_color_manager_v3_bind_resource(Resource *resource)
void XXColorManagerV4::xx_color_manager_v4_bind_resource(Resource *resource)
{
send_supported_feature(resource->handle, feature::feature_parametric);
send_supported_feature(resource->handle, feature::feature_extended_target_volume);
@ -40,17 +40,17 @@ void XXColorManagerV3::xx_color_manager_v3_bind_resource(Resource *resource)
// TODO implement the other rendering intents
}
void XXColorManagerV3::xx_color_manager_v3_destroy(Resource *resource)
void XXColorManagerV4::xx_color_manager_v4_destroy(Resource *resource)
{
wl_resource_destroy(resource->handle);
}
void XXColorManagerV3::xx_color_manager_v3_get_output(Resource *resource, uint32_t id, struct ::wl_resource *output)
void XXColorManagerV4::xx_color_manager_v4_get_output(Resource *resource, uint32_t id, struct ::wl_resource *output)
{
new XXColorManagementOutputV3(resource->client(), id, resource->version(), OutputInterface::get(output)->handle());
new XXColorManagementOutputV4(resource->client(), id, resource->version(), OutputInterface::get(output)->handle());
}
void XXColorManagerV3::xx_color_manager_v3_get_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface)
void XXColorManagerV4::xx_color_manager_v4_get_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface)
{
const auto surf = SurfaceInterface::get(surface);
const auto priv = SurfaceInterfacePrivate::get(surf);
@ -58,27 +58,70 @@ void XXColorManagerV3::xx_color_manager_v3_get_surface(Resource *resource, uint3
wl_resource_post_error(resource->handle, 0, "there's already a color management surface for this wl_surface");
return;
}
priv->xxColorSurface = new XXColorSurfaceV3(resource->client(), id, resource->version(), surf);
priv->xxColorSurface = new XXColorSurfaceV4(resource->client(), id, resource->version(), surf);
}
void XXColorManagerV3::xx_color_manager_v3_new_icc_creator(Resource *resource, uint32_t obj)
void XXColorManagerV4::xx_color_manager_v4_get_feedback_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface)
{
const auto surf = SurfaceInterface::get(surface);
const auto priv = SurfaceInterfacePrivate::get(surf);
priv->xxColorFeedbacks.push_back(new XXColorFeedbackSurfaceV4(resource->client(), id, resource->version(), surf));
}
void XXColorManagerV4::xx_color_manager_v4_new_icc_creator(Resource *resource, uint32_t obj)
{
wl_resource_post_error(resource->handle, error::error_unsupported_feature, "ICC profiles are not supported");
}
void XXColorManagerV3::xx_color_manager_v3_new_parametric_creator(Resource *resource, uint32_t obj)
void XXColorManagerV4::xx_color_manager_v4_new_parametric_creator(Resource *resource, uint32_t obj)
{
new XXColorParametricCreatorV3(resource->client(), obj, resource->version());
new XXColorParametricCreatorV4(resource->client(), obj, resource->version());
}
XXColorSurfaceV3::XXColorSurfaceV3(wl_client *client, uint32_t id, uint32_t version, SurfaceInterface *surface)
: QtWaylandServer::xx_color_management_surface_v3(client, id, version)
XXColorFeedbackSurfaceV4::XXColorFeedbackSurfaceV4(wl_client *client, uint32_t id, uint32_t version, SurfaceInterface *surface)
: QtWaylandServer::xx_color_management_feedback_surface_v4(client, id, version)
, m_surface(surface)
, m_preferred(SurfaceInterfacePrivate::get(surface)->preferredColorDescription.value_or(ColorDescription::sRGB))
{
}
XXColorSurfaceV3::~XXColorSurfaceV3()
XXColorFeedbackSurfaceV4::~XXColorFeedbackSurfaceV4()
{
if (m_surface) {
SurfaceInterfacePrivate::get(m_surface)->xxColorFeedbacks.removeOne(this);
}
}
void XXColorFeedbackSurfaceV4::setPreferredColorDescription(const ColorDescription &descr)
{
if (m_preferred != descr) {
m_preferred = descr;
send_preferred_changed(resource()->handle);
}
}
void XXColorFeedbackSurfaceV4::xx_color_management_feedback_surface_v4_destroy_resource(Resource *resource)
{
delete this;
}
void XXColorFeedbackSurfaceV4::xx_color_management_feedback_surface_v4_destroy(Resource *resource)
{
wl_resource_destroy(resource->handle);
}
void XXColorFeedbackSurfaceV4::xx_color_management_feedback_surface_v4_get_preferred(Resource *resource, uint32_t image_description)
{
new XXImageDescriptionV4(resource->client(), image_description, resource->version(), m_preferred);
}
XXColorSurfaceV4::XXColorSurfaceV4(wl_client *client, uint32_t id, uint32_t version, SurfaceInterface *surface)
: QtWaylandServer::xx_color_management_surface_v4(client, id, version)
, m_surface(surface)
{
}
XXColorSurfaceV4::~XXColorSurfaceV4()
{
if (m_surface) {
const auto priv = SurfaceInterfacePrivate::get(m_surface);
@ -88,36 +131,28 @@ XXColorSurfaceV3::~XXColorSurfaceV3()
}
}
void XXColorSurfaceV3::setPreferredColorDescription(const ColorDescription &descr)
{
if (m_preferred != descr) {
m_preferred = descr;
send_preferred_changed(resource()->handle);
}
}
void XXColorSurfaceV3::xx_color_management_surface_v3_destroy_resource(Resource *resource)
void XXColorSurfaceV4::xx_color_management_surface_v4_destroy_resource(Resource *resource)
{
delete this;
}
void XXColorSurfaceV3::xx_color_management_surface_v3_destroy(Resource *resource)
void XXColorSurfaceV4::xx_color_management_surface_v4_destroy(Resource *resource)
{
wl_resource_destroy(resource->handle);
}
void XXColorSurfaceV3::xx_color_management_surface_v3_set_image_description(Resource *resource, struct ::wl_resource *image_description, uint32_t render_intent)
void XXColorSurfaceV4::xx_color_management_surface_v4_set_image_description(Resource *resource, struct ::wl_resource *image_description, uint32_t render_intent)
{
if (!m_surface) {
return;
}
const auto priv = SurfaceInterfacePrivate::get(m_surface);
priv->pending->colorDescription = XXImageDescriptionV3::get(image_description)->description();
priv->pending->colorDescription = XXImageDescriptionV4::get(image_description)->description();
priv->pending->colorDescriptionIsSet = true;
// TODO render_intent
}
void XXColorSurfaceV3::xx_color_management_surface_v3_unset_image_description(Resource *resource)
void XXColorSurfaceV4::xx_color_management_surface_v4_unset_image_description(Resource *resource)
{
if (!m_surface) {
return;
@ -127,22 +162,17 @@ void XXColorSurfaceV3::xx_color_management_surface_v3_unset_image_description(Re
priv->pending->colorDescriptionIsSet = true;
}
void XXColorSurfaceV3::xx_color_management_surface_v3_get_preferred(Resource *resource, uint32_t image_description)
{
new XXImageDescriptionV3(resource->client(), image_description, resource->version(), m_preferred);
}
XXColorParametricCreatorV3::XXColorParametricCreatorV3(wl_client *client, uint32_t id, uint32_t version)
: QtWaylandServer::xx_image_description_creator_params_v3(client, id, version)
XXColorParametricCreatorV4::XXColorParametricCreatorV4(wl_client *client, uint32_t id, uint32_t version)
: QtWaylandServer::xx_image_description_creator_params_v4(client, id, version)
{
}
void XXColorParametricCreatorV3::xx_image_description_creator_params_v3_destroy_resource(Resource *resource)
void XXColorParametricCreatorV4::xx_image_description_creator_params_v4_destroy_resource(Resource *resource)
{
delete this;
}
void XXColorParametricCreatorV3::xx_image_description_creator_params_v3_create(Resource *resource, uint32_t image_description)
void XXColorParametricCreatorV4::xx_image_description_creator_params_v4_create(Resource *resource, uint32_t image_description)
{
if (!m_colorimetry || !m_transferFunction) {
wl_resource_post_error(resource->handle, error::error_incomplete_set, "colorimetry or transfer function missing");
@ -152,23 +182,23 @@ void XXColorParametricCreatorV3::xx_image_description_creator_params_v3_create(R
wl_resource_post_error(resource->handle, error::error_inconsistent_set, "max_cll and max_fall must only be set with the PQ transfer function");
return;
}
new XXImageDescriptionV3(resource->client(), image_description, resource->version(), ColorDescription(*m_colorimetry, *m_transferFunction, m_maxAverageLuminance.value_or(100), 0, m_maxAverageLuminance.value_or(100), m_maxPeakBrightness.value_or(100)));
new XXImageDescriptionV4(resource->client(), image_description, resource->version(), ColorDescription(*m_colorimetry, *m_transferFunction, m_maxAverageLuminance.value_or(100), 0, m_maxAverageLuminance.value_or(100), m_maxPeakBrightness.value_or(100)));
wl_resource_destroy(resource->handle);
}
void XXColorParametricCreatorV3::xx_image_description_creator_params_v3_set_tf_named(Resource *resource, uint32_t tf)
void XXColorParametricCreatorV4::xx_image_description_creator_params_v4_set_tf_named(Resource *resource, uint32_t tf)
{
if (m_transferFunction) {
wl_resource_post_error(resource->handle, error::error_already_set, "transfer function is already set");
return;
}
switch (tf) {
case XX_COLOR_MANAGER_V3_TRANSFER_FUNCTION_SRGB:
case XX_COLOR_MANAGER_V3_TRANSFER_FUNCTION_BT709:
case XX_COLOR_MANAGER_V3_TRANSFER_FUNCTION_GAMMA22:
case XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB:
case XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_BT709:
case XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_GAMMA22:
m_transferFunction = TransferFunction::gamma22;
return;
case XX_COLOR_MANAGER_V3_TRANSFER_FUNCTION_ST2084_PQ:
case XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_ST2084_PQ:
m_transferFunction = TransferFunction::PerceptualQuantizer;
return;
default:
@ -177,22 +207,22 @@ void XXColorParametricCreatorV3::xx_image_description_creator_params_v3_set_tf_n
}
}
void XXColorParametricCreatorV3::xx_image_description_creator_params_v3_set_tf_power(Resource *resource, uint32_t eexp)
void XXColorParametricCreatorV4::xx_image_description_creator_params_v4_set_tf_power(Resource *resource, uint32_t eexp)
{
wl_resource_post_error(resource->handle, error::error_invalid_tf, "power transfer functions are not supported");
}
void XXColorParametricCreatorV3::xx_image_description_creator_params_v3_set_primaries_named(Resource *resource, uint32_t primaries)
void XXColorParametricCreatorV4::xx_image_description_creator_params_v4_set_primaries_named(Resource *resource, uint32_t primaries)
{
if (m_colorimetry) {
wl_resource_post_error(resource->handle, error::error_already_set, "primaries are already set");
return;
}
switch (primaries) {
case XX_COLOR_MANAGER_V3_PRIMARIES_SRGB:
case XX_COLOR_MANAGER_V4_PRIMARIES_SRGB:
m_colorimetry = Colorimetry::fromName(NamedColorimetry::BT709);
return;
case XX_COLOR_MANAGER_V3_PRIMARIES_BT2020:
case XX_COLOR_MANAGER_V4_PRIMARIES_BT2020:
m_colorimetry = Colorimetry::fromName(NamedColorimetry::BT2020);
return;
default:
@ -201,7 +231,7 @@ void XXColorParametricCreatorV3::xx_image_description_creator_params_v3_set_prim
}
}
void XXColorParametricCreatorV3::xx_image_description_creator_params_v3_set_primaries(Resource *resource, int32_t r_x, int32_t r_y, int32_t g_x, int32_t g_y, int32_t b_x, int32_t b_y, int32_t w_x, int32_t w_y)
void XXColorParametricCreatorV4::xx_image_description_creator_params_v4_set_primaries(Resource *resource, int32_t r_x, int32_t r_y, int32_t g_x, int32_t g_y, int32_t b_x, int32_t b_y, int32_t w_x, int32_t w_y)
{
if (m_colorimetry) {
wl_resource_post_error(resource->handle, error::error_already_set, "primaries are already set");
@ -218,33 +248,33 @@ void XXColorParametricCreatorV3::xx_image_description_creator_params_v3_set_prim
QVector2D(w_x / 10'000.0, w_y / 10'000.0)};
}
void XXColorParametricCreatorV3::xx_image_description_creator_params_v3_set_luminances(Resource *resource, uint32_t min_lum, uint32_t max_lum, uint32_t reference_lum)
void XXColorParametricCreatorV4::xx_image_description_creator_params_v4_set_luminances(Resource *resource, uint32_t min_lum, uint32_t max_lum, uint32_t reference_lum)
{
wl_resource_post_error(resource->handle, error::error_unsupported_feature, "set_luminances isn't supported yet");
}
void XXColorParametricCreatorV3::xx_image_description_creator_params_v3_set_mastering_display_primaries(Resource *resource, int32_t r_x, int32_t r_y, int32_t g_x, int32_t g_y, int32_t b_x, int32_t b_y, int32_t w_x, int32_t w_y)
void XXColorParametricCreatorV4::xx_image_description_creator_params_v4_set_mastering_display_primaries(Resource *resource, int32_t r_x, int32_t r_y, int32_t g_x, int32_t g_y, int32_t b_x, int32_t b_y, int32_t w_x, int32_t w_y)
{
// ignored (at least for now)
}
void XXColorParametricCreatorV3::xx_image_description_creator_params_v3_set_mastering_luminance(Resource *resource, uint32_t min_lum, uint32_t max_lum)
void XXColorParametricCreatorV4::xx_image_description_creator_params_v4_set_mastering_luminance(Resource *resource, uint32_t min_lum, uint32_t max_lum)
{
// ignored (at least for now)
}
void XXColorParametricCreatorV3::xx_image_description_creator_params_v3_set_max_cll(Resource *resource, uint32_t max_cll)
void XXColorParametricCreatorV4::xx_image_description_creator_params_v4_set_max_cll(Resource *resource, uint32_t max_cll)
{
m_maxPeakBrightness = max_cll;
}
void XXColorParametricCreatorV3::xx_image_description_creator_params_v3_set_max_fall(Resource *resource, uint32_t max_fall)
void XXColorParametricCreatorV4::xx_image_description_creator_params_v4_set_max_fall(Resource *resource, uint32_t max_fall)
{
m_maxAverageLuminance = max_fall;
}
XXImageDescriptionV3::XXImageDescriptionV3(wl_client *client, uint32_t id, uint32_t version, const ColorDescription &color)
: QtWaylandServer::xx_image_description_v3(client, id, version)
XXImageDescriptionV4::XXImageDescriptionV4(wl_client *client, uint32_t id, uint32_t version, const ColorDescription &color)
: QtWaylandServer::xx_image_description_v4(client, id, version)
, m_description(color)
{
// there's no need to track image description identities, as our descriptions are very lightweight
@ -252,12 +282,12 @@ XXImageDescriptionV3::XXImageDescriptionV3(wl_client *client, uint32_t id, uint3
send_ready(resource()->handle, s_identity++);
}
void XXImageDescriptionV3::xx_image_description_v3_destroy_resource(Resource *resource)
void XXImageDescriptionV4::xx_image_description_v4_destroy_resource(Resource *resource)
{
delete this;
}
void XXImageDescriptionV3::xx_image_description_v3_destroy(Resource *resource)
void XXImageDescriptionV4::xx_image_description_v4_destroy(Resource *resource)
{
wl_resource_destroy(resource->handle);
}
@ -266,74 +296,74 @@ static uint32_t kwinTFtoProtoTF(TransferFunction tf)
{
switch (tf.type) {
case TransferFunction::sRGB:
return xx_color_manager_v3_transfer_function::XX_COLOR_MANAGER_V3_TRANSFER_FUNCTION_SRGB;
return xx_color_manager_v4_transfer_function::XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_SRGB;
case TransferFunction::linear:
return xx_color_manager_v3_transfer_function::XX_COLOR_MANAGER_V3_TRANSFER_FUNCTION_LINEAR;
return xx_color_manager_v4_transfer_function::XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_LINEAR;
case TransferFunction::PerceptualQuantizer:
return xx_color_manager_v3_transfer_function::XX_COLOR_MANAGER_V3_TRANSFER_FUNCTION_ST2084_PQ;
return xx_color_manager_v4_transfer_function::XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_ST2084_PQ;
case TransferFunction::scRGB:
return xx_color_manager_v3_transfer_function::XX_COLOR_MANAGER_V3_TRANSFER_FUNCTION_LINEAR;
return xx_color_manager_v4_transfer_function::XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_LINEAR;
case TransferFunction::gamma22:
return xx_color_manager_v3_transfer_function::XX_COLOR_MANAGER_V3_TRANSFER_FUNCTION_GAMMA22;
return xx_color_manager_v4_transfer_function::XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_GAMMA22;
}
Q_UNREACHABLE();
}
void XXImageDescriptionV3::xx_image_description_v3_get_information(Resource *qtResource, uint32_t information)
void XXImageDescriptionV4::xx_image_description_v4_get_information(Resource *qtResource, uint32_t information)
{
auto resource = wl_resource_create(qtResource->client(), &xx_image_description_info_v3_interface, qtResource->version(), information);
auto resource = wl_resource_create(qtResource->client(), &xx_image_description_info_v4_interface, qtResource->version(), information);
const auto c = m_description.containerColorimetry();
const auto round = [](float f) {
return std::clamp(std::round(f * 10'000.0), 0.0, 1.0);
};
xx_image_description_info_v3_send_primaries(resource,
xx_image_description_info_v4_send_primaries(resource,
round(c.red().x()), round(c.red().y()),
round(c.green().x()), round(c.green().y()),
round(c.blue().x()), round(c.blue().y()),
round(c.white().x()), round(c.white().y()));
xx_image_description_info_v3_send_tf_named(resource, kwinTFtoProtoTF(m_description.transferFunction()));
xx_image_description_info_v3_send_done(resource);
xx_image_description_info_v4_send_tf_named(resource, kwinTFtoProtoTF(m_description.transferFunction()));
xx_image_description_info_v4_send_done(resource);
wl_resource_destroy(resource);
}
const ColorDescription &XXImageDescriptionV3::description() const
const ColorDescription &XXImageDescriptionV4::description() const
{
return m_description;
}
XXImageDescriptionV3 *XXImageDescriptionV3::get(wl_resource *resource)
XXImageDescriptionV4 *XXImageDescriptionV4::get(wl_resource *resource)
{
if (auto resourceContainer = Resource::fromResource(resource)) {
return static_cast<XXImageDescriptionV3 *>(resourceContainer->object());
return static_cast<XXImageDescriptionV4 *>(resourceContainer->object());
} else {
return nullptr;
}
}
XXColorManagementOutputV3::XXColorManagementOutputV3(wl_client *client, uint32_t id, uint32_t version, Output *output)
: QtWaylandServer::xx_color_management_output_v3(client, id, version)
XXColorManagementOutputV4::XXColorManagementOutputV4(wl_client *client, uint32_t id, uint32_t version, Output *output)
: QtWaylandServer::xx_color_management_output_v4(client, id, version)
, m_output(output)
, m_colorDescription(output->colorDescription())
{
connect(output, &Output::colorDescriptionChanged, this, &XXColorManagementOutputV3::colorDescriptionChanged);
connect(output, &Output::colorDescriptionChanged, this, &XXColorManagementOutputV4::colorDescriptionChanged);
}
void XXColorManagementOutputV3::xx_color_management_output_v3_destroy_resource(Resource *resource)
void XXColorManagementOutputV4::xx_color_management_output_v4_destroy_resource(Resource *resource)
{
delete this;
}
void XXColorManagementOutputV3::xx_color_management_output_v3_destroy(Resource *resource)
void XXColorManagementOutputV4::xx_color_management_output_v4_destroy(Resource *resource)
{
wl_resource_destroy(resource->handle);
}
void XXColorManagementOutputV3::xx_color_management_output_v3_get_image_description(Resource *resource, uint32_t image_description)
void XXColorManagementOutputV4::xx_color_management_output_v4_get_image_description(Resource *resource, uint32_t image_description)
{
new XXImageDescriptionV3(resource->client(), image_description, resource->version(), m_colorDescription);
new XXImageDescriptionV4(resource->client(), image_description, resource->version(), m_colorDescription);
}
void XXColorManagementOutputV3::colorDescriptionChanged()
void XXColorManagementOutputV4::colorDescriptionChanged()
{
m_colorDescription = m_output->colorDescription();
send_image_description_changed();
@ -341,4 +371,4 @@ void XXColorManagementOutputV3::colorDescriptionChanged()
}
#include "moc_xx_colormanagement_v3.cpp"
#include "moc_xx_colormanagement_v4.cpp"

View file

@ -0,0 +1,125 @@
/*
SPDX-FileCopyrightText: 2024 Xaver Hugl <xaver.hugl@gmail.com>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#pragma once
#include "core/colorspace.h"
#include "wayland/qwayland-server-xx-color-management-v4.h"
#include <QObject>
#include <QPointer>
namespace KWin
{
class Display;
class SurfaceInterface;
class Output;
class XXColorManagerV4 : public QObject, private QtWaylandServer::xx_color_manager_v4
{
Q_OBJECT
public:
explicit XXColorManagerV4(Display *display, QObject *parent);
private:
void xx_color_manager_v4_bind_resource(Resource *resource) override;
void xx_color_manager_v4_destroy(Resource *resource) override;
void xx_color_manager_v4_get_output(Resource *resource, uint32_t id, struct ::wl_resource *output) override;
void xx_color_manager_v4_get_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface) override;
void xx_color_manager_v4_get_feedback_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface) override;
void xx_color_manager_v4_new_icc_creator(Resource *resource, uint32_t obj) override;
void xx_color_manager_v4_new_parametric_creator(Resource *resource, uint32_t obj) override;
};
class XXColorFeedbackSurfaceV4 : private QtWaylandServer::xx_color_management_feedback_surface_v4
{
public:
explicit XXColorFeedbackSurfaceV4(wl_client *client, uint32_t id, uint32_t version, SurfaceInterface *surface);
~XXColorFeedbackSurfaceV4() override;
void setPreferredColorDescription(const ColorDescription &descr);
private:
void xx_color_management_feedback_surface_v4_destroy_resource(Resource *resource) override;
void xx_color_management_feedback_surface_v4_destroy(Resource *resource) override;
void xx_color_management_feedback_surface_v4_get_preferred(Resource *resource, uint32_t image_description) override;
QPointer<SurfaceInterface> m_surface;
ColorDescription m_preferred;
};
class XXColorSurfaceV4 : private QtWaylandServer::xx_color_management_surface_v4
{
public:
explicit XXColorSurfaceV4(wl_client *client, uint32_t id, uint32_t version, SurfaceInterface *surface);
~XXColorSurfaceV4() override;
private:
void xx_color_management_surface_v4_destroy_resource(Resource *resource) override;
void xx_color_management_surface_v4_destroy(Resource *resource) override;
void xx_color_management_surface_v4_set_image_description(Resource *resource, struct ::wl_resource *image_description, uint32_t render_intent) override;
void xx_color_management_surface_v4_unset_image_description(Resource *resource) override;
QPointer<SurfaceInterface> m_surface;
};
class XXColorParametricCreatorV4 : private QtWaylandServer::xx_image_description_creator_params_v4
{
public:
explicit XXColorParametricCreatorV4(wl_client *client, uint32_t id, uint32_t version);
private:
void xx_image_description_creator_params_v4_destroy_resource(Resource *resource) override;
void xx_image_description_creator_params_v4_create(Resource *resource, uint32_t image_description) override;
void xx_image_description_creator_params_v4_set_tf_named(Resource *resource, uint32_t tf) override;
void xx_image_description_creator_params_v4_set_tf_power(Resource *resource, uint32_t eexp) override;
void xx_image_description_creator_params_v4_set_primaries_named(Resource *resource, uint32_t primaries) override;
void xx_image_description_creator_params_v4_set_primaries(Resource *resource, int32_t r_x, int32_t r_y, int32_t g_x, int32_t g_y, int32_t b_x, int32_t b_y, int32_t w_x, int32_t w_y) override;
void xx_image_description_creator_params_v4_set_mastering_display_primaries(Resource *resource, int32_t r_x, int32_t r_y, int32_t g_x, int32_t g_y, int32_t b_x, int32_t b_y, int32_t w_x, int32_t w_y) override;
void xx_image_description_creator_params_v4_set_mastering_luminance(Resource *resource, uint32_t min_lum, uint32_t max_lum) override;
void xx_image_description_creator_params_v4_set_max_cll(Resource *resource, uint32_t max_cll) override;
void xx_image_description_creator_params_v4_set_max_fall(Resource *resource, uint32_t max_fall) override;
void xx_image_description_creator_params_v4_set_luminances(Resource *resource, uint32_t min_lum, uint32_t max_lum, uint32_t reference_lum) override;
std::optional<Colorimetry> m_colorimetry;
std::optional<TransferFunction> m_transferFunction;
std::optional<double> m_maxAverageLuminance;
std::optional<double> m_maxPeakBrightness;
};
class XXImageDescriptionV4 : private QtWaylandServer::xx_image_description_v4
{
public:
explicit XXImageDescriptionV4(wl_client *client, uint32_t id, uint32_t version, const ColorDescription &color);
const ColorDescription &description() const;
static XXImageDescriptionV4 *get(wl_resource *resource);
private:
void xx_image_description_v4_destroy_resource(Resource *resource) override;
void xx_image_description_v4_destroy(Resource *resource) override;
void xx_image_description_v4_get_information(Resource *resource, uint32_t information) override;
const ColorDescription m_description;
};
class XXColorManagementOutputV4 : public QObject, private QtWaylandServer::xx_color_management_output_v4
{
Q_OBJECT
public:
explicit XXColorManagementOutputV4(wl_client *client, uint32_t id, uint32_t version, Output *output);
private:
void colorDescriptionChanged();
void xx_color_management_output_v4_destroy_resource(Resource *resource) override;
void xx_color_management_output_v4_destroy(Resource *resource) override;
void xx_color_management_output_v4_get_image_description(Resource *resource, uint32_t image_description) override;
Output *const m_output;
ColorDescription m_colorDescription;
};
}

View file

@ -76,7 +76,7 @@
#include "wayland/xdgoutput_v1.h"
#include "wayland/xdgshell.h"
#include "wayland/xdgtopleveldrag_v1.h"
#include "wayland/xx_colormanagement_v3.h"
#include "wayland/xx_colormanagement_v4.h"
#include "workspace.h"
#include "xdgactivationv1.h"
#include "xdgshellintegration.h"
@ -515,7 +515,7 @@ bool WaylandServer::init()
new FrogColorManagementV1(m_display, m_display);
new PresentationTime(m_display, m_display);
if (qEnvironmentVariableIntValue("KWIN_ENABLE_XX_COLOR_MANAGEMENT")) {
m_xxColorManager = new XXColorManagerV3(m_display, m_display);
m_xxColorManager = new XXColorManagerV4(m_display, m_display);
}
m_xdgDialogWm = new KWin::XdgDialogWmV1Interface(m_display, m_display);
connect(m_xdgDialogWm, &KWin::XdgDialogWmV1Interface::dialogCreated, this, [this](KWin::XdgDialogV1Interface *dialog) {

View file

@ -60,7 +60,7 @@ class XdgPopupWindow;
class XdgSurfaceWindow;
class XdgToplevelWindow;
class PresentationTime;
class XXColorManagerV3;
class XXColorManagerV4;
class LinuxDrmSyncObjV1Interface;
class RenderBackend;
@ -288,7 +288,7 @@ private:
QHash<Output *, OutputDeviceV2Interface *> m_waylandOutputDevices;
DrmLeaseManagerV1 *m_leaseManager = nullptr;
OutputOrderV1Interface *m_outputOrder = nullptr;
XXColorManagerV3 *m_xxColorManager = nullptr;
XXColorManagerV4 *m_xxColorManager = nullptr;
XdgDialogWmV1Interface *m_xdgDialogWm = nullptr;
ExternalBrightnessV1 *m_externalBrightness = nullptr;
KWIN_SINGLETON(WaylandServer)