wayland: update xx-color-management to v2

This commit is contained in:
Xaver Hugl 2024-02-07 18:54:50 +01:00 committed by Vlad Zahorodnii
parent cd43199e70
commit a5726e19fd
9 changed files with 306 additions and 344 deletions

View file

@ -228,8 +228,8 @@ ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml
BASENAME security-context-v1 BASENAME security-context-v1
) )
ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml
PROTOCOL ${PROJECT_SOURCE_DIR}/src/wayland/protocols/xx-color-management-v1.xml PROTOCOL ${PROJECT_SOURCE_DIR}/src/wayland/protocols/xx-color-management-v2.xml
BASENAME xx-color-management-v1 BASENAME xx-color-management-v2
) )
target_sources(kwin PRIVATE target_sources(kwin PRIVATE
@ -312,7 +312,7 @@ target_sources(kwin PRIVATE
xdgtopleveldrag_v1.cpp xdgtopleveldrag_v1.cpp
xwaylandkeyboardgrab_v1.cpp xwaylandkeyboardgrab_v1.cpp
xwaylandshell_v1.cpp xwaylandshell_v1.cpp
xx_colormanagement_v1.cpp xx_colormanagement_v2.cpp
) )
install(FILES install(FILES
@ -385,15 +385,15 @@ install(FILES
xdgshell.h xdgshell.h
xwaylandkeyboardgrab_v1.h xwaylandkeyboardgrab_v1.h
xwaylandshell_v1.h xwaylandshell_v1.h
xx_colormanagement_v1.h xx_colormanagement_v2.h
${CMAKE_CURRENT_BINARY_DIR}/qwayland-server-content-type-v1.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-frog-color-management-v1.h
${CMAKE_CURRENT_BINARY_DIR}/qwayland-server-presentation-time.h ${CMAKE_CURRENT_BINARY_DIR}/qwayland-server-presentation-time.h
${CMAKE_CURRENT_BINARY_DIR}/qwayland-server-xx-color-management-v1.h ${CMAKE_CURRENT_BINARY_DIR}/qwayland-server-xx-color-management-v2.h
${CMAKE_CURRENT_BINARY_DIR}/wayland-content-type-v1-server-protocol.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-frog-color-management-v1-server-protocol.h
${CMAKE_CURRENT_BINARY_DIR}/wayland-presentation-time-server-protocol.h ${CMAKE_CURRENT_BINARY_DIR}/wayland-presentation-time-server-protocol.h
${CMAKE_CURRENT_BINARY_DIR}/wayland-xx-color-management-v1-server-protocol.h ${CMAKE_CURRENT_BINARY_DIR}/wayland-xx-color-management-v2-server-protocol.h
DESTINATION ${KDE_INSTALL_INCLUDEDIR}/kwin/wayland COMPONENT Devel) DESTINATION ${KDE_INSTALL_INCLUDEDIR}/kwin/wayland COMPONENT Devel)

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<protocol name="xx_color_management_v1"> <protocol name="xx_color_management_v2">
<copyright> <copyright>
Copyright 2019 Sebastian Wick Copyright 2019 Sebastian Wick
Copyright 2019 Erwin Burema Copyright 2019 Erwin Burema
@ -64,7 +64,7 @@
protocol. protocol.
</description> </description>
<interface name="xx_color_manager_v1" version="1"> <interface name="xx_color_manager_v2" version="1">
<description summary="color manager singleton"> <description summary="color manager singleton">
A global interface used for getting color management extensions for A global interface used for getting color management extensions for
wl_surface and wl_output objects, and for creating client defined image wl_surface and wl_output objects, and for creating client defined image
@ -75,7 +75,7 @@
<request name="destroy" type="destructor"> <request name="destroy" type="destructor">
<description summary="destroy the color manager"> <description summary="destroy the color manager">
Destroy the xx_color_manager_v1 object. This does not affect any other Destroy the xx_color_manager_v2 object. This does not affect any other
objects in any way. objects in any way.
</description> </description>
</request> </request>
@ -148,7 +148,7 @@
</description> </description>
</entry> </entry>
<entry name="pal_m" value="1"> <entry name="pal_m" value="1">
<description summary="Color primaries for PAL-M as defined by the BT.407 standard"> <description summary="Color primaries for PAL-M as defined by the BT.470 standard">
Color primaries as defined by Color primaries as defined by
- Rec. ITU-R BT.470-6 System M (historical) - Rec. ITU-R BT.470-6 System M (historical)
- United States National Television System Committee 1953 Recommendation for transmission standards for color television - United States National Television System Committee 1953 Recommendation for transmission standards for color television
@ -280,7 +280,7 @@
</description> </description>
</entry> </entry>
<entry name="bt1361" value="8"> <entry name="bt1361" value="8">
<description summary="BT.1361 transfer function"> <description summary="BT.1361 extended transfer function">
Transfer characteristics as defined by Transfer characteristics as defined by
- Rec. ITU-R BT.1361-0 extended colour gamut system (historical) - Rec. ITU-R BT.1361-0 extended colour gamut system (historical)
Equivalent to H.273 TransferCharacteristics code point 12. Equivalent to H.273 TransferCharacteristics code point 12.
@ -327,25 +327,25 @@
<request name="get_output"> <request name="get_output">
<description summary="create a color management interface for a wl_output"> <description summary="create a color management interface for a wl_output">
This creates a new xx_color_management_output_v1 object for the This creates a new xx_color_management_output_v2 object for the
given wl_output. given wl_output.
See the xx_color_management_output_v1 interface for more details. See the xx_color_management_output_v2 interface for more details.
</description> </description>
<arg name="id" type="new_id" interface="xx_color_management_output_v1"/> <arg name="id" type="new_id" interface="xx_color_management_output_v2"/>
<arg name="output" type="object" interface="wl_output"/> <arg name="output" type="object" interface="wl_output"/>
</request> </request>
<request name="get_surface"> <request name="get_surface">
<description summary="create a color management interface for a wl_surface"> <description summary="create a color management interface for a wl_surface">
This creates a new color xx_color_management_surface_v1 object for the This creates a new color xx_color_management_surface_v2 object for the
given wl_surface. given wl_surface.
See the xx_color_management_surface_v1 interface for more details. See the xx_color_management_surface_v2 interface for more details.
</description> </description>
<arg name="id" type="new_id" interface="xx_color_management_surface_v1"/> <arg name="id" type="new_id" interface="xx_color_management_surface_v2"/>
<arg name="surface" type="object" interface="wl_surface"/> <arg name="surface" type="object" interface="wl_surface"/>
</request> </request>
@ -354,15 +354,15 @@
Makes a new ICC-based image description creator object with all Makes a new ICC-based image description creator object with all
properties initially unset. The client can then use the object's properties initially unset. The client can then use the object's
interface to define all the required properties for an image description interface to define all the required properties for an image description
and finally create a xx_image_description_v1 object. and finally create a xx_image_description_v2 object.
This request can be used when the compositor advertises This request can be used when the compositor advertises
xx_color_manager_v1.feature.icc_v2_v4. xx_color_manager_v2.feature.icc_v2_v4.
Otherwise this request raises the protocol error unsupported_feature. Otherwise this request raises the protocol error unsupported_feature.
</description> </description>
<arg name="obj" type="new_id" <arg name="obj" type="new_id"
interface="xx_image_description_creator_icc_v1" interface="xx_image_description_creator_icc_v2"
summary="the new creator object"/> summary="the new creator object"/>
</request> </request>
@ -371,15 +371,15 @@
Makes a new parametric image description creator object with all Makes a new parametric image description creator object with all
properties initially unset. The client can then use the object's properties initially unset. The client can then use the object's
interface to define all the required properties for an image description interface to define all the required properties for an image description
and finally create a xx_image_description_v1 object. and finally create a xx_image_description_v2 object.
This request can be used when the compositor advertises This request can be used when the compositor advertises
xx_color_manager_v1.feature.parametric. xx_color_manager_v2.feature.parametric.
Otherwise this request raises the protocol error unsupported_feature. Otherwise this request raises the protocol error unsupported_feature.
</description> </description>
<arg name="obj" type="new_id" <arg name="obj" type="new_id"
interface="xx_image_description_creator_params_v1" interface="xx_image_description_creator_params_v2"
summary="the new creator object"/> summary="the new creator object"/>
</request> </request>
@ -423,30 +423,20 @@
</event> </event>
</interface> </interface>
<interface name="xx_color_management_output_v1" version="1"> <interface name="xx_color_management_output_v2" version="1">
<description summary="output color properties"> <description summary="output color properties">
A xx_color_management_output_v1 describes the color properties of an A xx_color_management_output_v2 describes the color properties of an
output. output.
When xx_color_management_output_v1 object is created, it will send The xx_color_management_output_v2 is associated with the wl_output global
its initial events followed by a wl_output.done event. When creating underlying the wl_output object. Therefore the client destroying the
wl_output and its extension objects, use a final wl_display.sync to wl_output object has no impact, but the compositor removing the output
guarantee that all output events have been received across all global makes the xx_color_management_output_v2 object inert.
extensions.
If the wl_output associated with the xx_color_management_output_v1 is
destroyed, the xx_color_management_output_v1 object becomes inert.
</description> </description>
<enum name="error">
<description summary="protocol errors"/>
<entry name="inert" value="0" summary="forbidden request on inert object"/>
</enum>
<request name="destroy" type="destructor"> <request name="destroy" type="destructor">
<description summary="destroy the color management output"> <description summary="destroy the color management output">
Destroy the color xx_color_management_output_v1 object. This does not Destroy the color xx_color_management_output_v2 object. This does not
affect any remaining protocol objects. affect any remaining protocol objects.
</description> </description>
</request> </request>
@ -457,8 +447,6 @@
output changed, followed by one wl_output.done event common to output changed, followed by one wl_output.done event common to
output events across all extensions. output events across all extensions.
This is not an initial event.
If the client wants to use the updated image description, it needs If the client wants to use the updated image description, it needs
to do get_image_description again, because image description objects to do get_image_description again, because image description objects
are immutable. are immutable.
@ -467,52 +455,50 @@
<request name="get_image_description"> <request name="get_image_description">
<description summary="get the image description of the output"> <description summary="get the image description of the output">
If this protocol object is inert, the protocol error inert is raised. This creates a new xx_image_description_v2 object for the current image description
This creates a new xx_image_description_v1 object for the current image description
of the output. There always is exactly one image description active for an 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 output so the client should destroy the image description created by earlier
invocations of this request. This request is usually sent as a reaction invocations of this request. This request is usually sent as a reaction
to the image_description_changed event or when creating a to the image_description_changed event or when creating a
xx_color_management_output_v1 object. xx_color_management_output_v2 object.
The created xx_image_description_v1 object preserves the image description The created xx_image_description_v2 object preserves the image description
of the output from the time the object was created. of the output from the time the object was created.
The resulting image description object allows get_information request. The resulting image description object allows get_information request.
If the output no longer exists in the compositor, the resulting image If this protocol object is inert, the resulting image
description object shall immediately deliver the description object shall immediately deliver the
xx_image_description_v1.failed event with the no_output cause. xx_image_description_v2.failed event with the no_output cause.
If the interface version is inadequate for the output's image If the interface version is inadequate for the output's image
description, meaning that the client does not support all the description, meaning that the client does not support all the
events needed to deliver the crucial information, the resulting image events needed to deliver the crucial information, the resulting image
description object shall immediately deliver the description object shall immediately deliver the
xx_image_description_v1.failed event with the low_version cause. xx_image_description_v2.failed event with the low_version cause.
Otherwise the object shall immediately deliver the ready event. Otherwise the object shall immediately deliver the ready event.
</description> </description>
<arg name="image_description" type="new_id" interface="xx_image_description_v1"/> <arg name="image_description" type="new_id" interface="xx_image_description_v2"/>
</request> </request>
</interface> </interface>
<interface name="xx_color_management_surface_v1" version="1"> <interface name="xx_color_management_surface_v2" version="1">
<description summary="color management extension to a surface"> <description summary="color management extension to a surface">
A xx_color_management_surface_v1 allows the client to set the color A xx_color_management_surface_v2 allows the client to set the color
space and HDR properties of a surface. space and HDR properties of a surface.
If the wl_surface associated with the xx_color_management_surface_v1 is If the wl_surface associated with the xx_color_management_surface_v2 is
destroyed, the xx_color_management_surface_v1 object becomes inert. destroyed, the xx_color_management_surface_v2 object becomes inert.
</description> </description>
<request name="destroy" type="destructor"> <request name="destroy" type="destructor">
<description summary="destroy the color management interface for a surface"> <description summary="destroy the color management interface for a surface">
Destroy the xx_color_management_surface_v1 object. Destroy the xx_color_management_surface_v2 object.
When the last xx_color_management_surface_v1 object for a wl_surface When the last xx_color_management_surface_v2 object for a wl_surface
is destroyed, it does the same as set_default_image_description. is destroyed, it does the same as unset_image_description.
</description> </description>
</request> </request>
@ -536,7 +522,7 @@
A rendering intent provides the client's preference on how content A rendering intent provides the client's preference on how content
colors should be mapped to each output. The render_intent value must colors should be mapped to each output. The render_intent value must
be one advertised by the compositor with be one advertised by the compositor with
xx_color_manager_v1.render_intent event, otherwise the protocol error xx_color_manager_v2.render_intent event, otherwise the protocol error
render_intent is raised. render_intent is raised.
By default, a surface does not have an associated image description By default, a surface does not have an associated image description
@ -546,15 +532,16 @@
requirements. requirements.
</description> </description>
<arg name="image_description" type="object" interface="xx_image_description_v1"/> <arg name="image_description" type="object" interface="xx_image_description_v2"/>
<arg name="render_intent" type="uint" enum="xx_color_manager_v1.render_intent" <arg name="render_intent" type="uint" enum="xx_color_manager_v2.render_intent"
summary="rendering intent"/> summary="rendering intent"/>
</request> </request>
<request name="set_default_image_description"> <request name="unset_image_description">
<description summary="set the surface image description to default"> <description summary="remove the surface image description">
This request sets the surface image description to the defaults, see This request removes any image description from the surface. See
set_image_description. This is double-buffered state, see set_image_description for how a compositor handles a surface without
an image description. This is double-buffered state, see
wl_surface.commit. wl_surface.commit.
</description> </description>
</request> </request>
@ -585,15 +572,15 @@
<description summary="get the preferred image description"> <description summary="get the preferred image description">
If this protocol object is inert, the protocol error inert is raised. If this protocol object is inert, the protocol error inert is raised.
This creates a new xx_image_description_v1 object for the currently This creates a new xx_image_description_v2 object for the currently
preferred image description for the wl_surface. The client should preferred image description for the wl_surface. The client should
stop using and destroy the image descriptions created by earlier stop using and destroy the image descriptions created by earlier
invocations of this request for the associated wl_surface. invocations of this request for the associated wl_surface.
This request is usually sent as a reaction to the preferred_changed This request is usually sent as a reaction to the preferred_changed
event or when creating a xx_color_management_surface_v1 object if event or when creating a xx_color_management_surface_v2 object if
the client is capable of adapting to image descriptions. the client is capable of adapting to image descriptions.
The created xx_image_description_v1 object preserves the preferred image The created xx_image_description_v2 object preserves the preferred image
description of the wl_surface from the time the object was created. description of the wl_surface from the time the object was created.
The resulting image description object allows get_information request. The resulting image description object allows get_information request.
@ -602,18 +589,18 @@
description, meaning that the client does not support all the description, meaning that the client does not support all the
events needed to deliver the crucial information, the resulting image events needed to deliver the crucial information, the resulting image
description object shall immediately deliver the description object shall immediately deliver the
xx_image_description_v1.failed event with the low_version cause, xx_image_description_v2.failed event with the low_version cause,
otherwise the object shall immediately deliver the ready event. otherwise the object shall immediately deliver the ready event.
</description> </description>
<arg name="image_description" type="new_id" interface="xx_image_description_v1"/> <arg name="image_description" type="new_id" interface="xx_image_description_v2"/>
</request> </request>
</interface> </interface>
<interface name="xx_image_description_creator_icc_v1" version="1"> <interface name="xx_image_description_creator_icc_v2" version="1">
<description summary="holder of image description ICC information"> <description summary="holder of image description ICC information">
This type of object is used for collecting all the information required This type of object is used for collecting all the information required
to create a xx_image_description_v1 object from an ICC file. A complete to create a xx_image_description_v2 object from an ICC file. A complete
set of required parameters consists of these properties: set of required parameters consists of these properties:
- ICC file - ICC file
@ -623,28 +610,22 @@
set. There may be several alternative requests for setting each property, set. There may be several alternative requests for setting each property,
and in that case the client must choose one of them. and in that case the client must choose one of them.
Once all properties have been set, the create request can be used to Once all properties have been set, the create request must be used to
create the image description object. Finally, the params object should create the image description object, destroying the creator in the
be destroyed. process.
</description> </description>
<request name="destroy" type="destructor">
<description summary="destroy">
Destroys this object. No other object is affected.
</description>
</request>
<enum name="error"> <enum name="error">
<description summary="protocol errors"/> <description summary="protocol errors"/>
<entry name="incomplete_set" value="0" summary="incomplete parameter set"/> <entry name="incomplete_set" value="0" summary="incomplete parameter set"/>
<entry name="already_used" value="1" summary="create request already done"/> <entry name="already_set" value="1" summary="property already set"/>
<entry name="already_set" value="2" summary="property already set"/> <entry name="bad_fd" value="2" summary="fd not seekable and readable"/>
<entry name="bad_fd" value="3" summary="fd not seekable and readable"/> <entry name="bad_size" value="3" summary="no or too much data"/>
<entry name="bad_size" value="4" summary="no or too much data"/> <entry name="out_of_file" value="4" summary="offset + length exceeds file size"/>
</enum> </enum>
<request name="create"> <request name="create" type="destructor">
<description summary="Create the image description object from ICC data"> <description summary="Create the image description object from ICC data">
Create an image description object based on the ICC information Create an image description object based on the ICC information
previously set on this object. A compositor must parse the ICC data in previously set on this object. A compositor must parse the ICC data in
@ -656,23 +637,18 @@
If the particular combination of the information is not supported If the particular combination of the information is not supported
by the compositor, the resulting image description object shall by the compositor, the resulting image description object shall
immediately deliver the xx_image_description_v1.failed event with the immediately deliver the xx_image_description_v2.failed event with the
'unsupported' cause. If a valid image description was created from the 'unsupported' cause. If a valid image description was created from the
information, the xx_image_description_v1.ready event will eventually information, the xx_image_description_v2.ready event will eventually
be sent instead. be sent instead.
This request can be issued at most once during the lifetime of the This request destroys the xx_image_description_creator_icc_v2 object.
xx_image_description_creator_icc_v1 object, after which the only
legal request is destroy. Otherwise the protocol error already_used
is raised.
A client should destroy this object immediately after this request.
The resulting image description object does not allow get_information The resulting image description object does not allow get_information
request. request.
</description> </description>
<arg name="image_description" type="new_id" interface="xx_image_description_v1"/> <arg name="image_description" type="new_id" interface="xx_image_description_v2"/>
</request> </request>
<request name="set_icc_file"> <request name="set_icc_file">
@ -685,18 +661,20 @@
these requirements raises the bad_fd protocol error. these requirements raises the bad_fd protocol error.
If reading the data fails due to an error independent of the client, the If reading the data fails due to an error independent of the client, the
compositor shall send the xx_image_description_v1.failed event on the compositor shall send the xx_image_description_v2.failed event on the
created xx_image_description_v1 with the 'operating_system' cause. created xx_image_description_v2 with the 'operating_system' cause.
The maximum size of the ICC profile is 4 MB. If length is greater 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. than that or zero, the protocol error bad_size is raised.
If offset + length exceeds the file size, the protocol error
out_of_file is raised.
A compositor may read the file at any time starting from this request A compositor may read the file at any time starting from this request
and only until whichever happens first: and only until whichever happens first:
- If create request was issued, the xx_image_description_v1 object - If create request was issued, the xx_image_description_v2 object
delivers either failed or ready event; or delivers either failed or ready event; or
- if create request was not issued, this - if create request was not issued, this
xx_image_description_creator_icc_v1 object is destroyed. xx_image_description_creator_icc_v2 object is destroyed.
A compositor shall not modify the contents of the file, and the fd may 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 be sealed for writes and size changes. The client must ensure to its
@ -707,8 +685,8 @@
The ICC profile version must be 2 or 4, it must be a 3 channel profile The ICC profile version must be 2 or 4, it must be a 3 channel profile
and the class must be 'display'. and the class must be 'display'.
Violating these requirements will not result in a protocol error but Violating these requirements will not result in a protocol error but
will eventually send the xx_image_description_v1.failed event on the will eventually send the xx_image_description_v2.failed event on the
created xx_image_description_v1 with the 'unsupported' cause. created xx_image_description_v2 with the 'unsupported' cause.
See the International Color Consortium specification ICC.1:2022 for more See the International Color Consortium specification ICC.1:2022 for more
details about ICC profiles. details about ICC profiles.
@ -723,10 +701,10 @@
</request> </request>
</interface> </interface>
<interface name="xx_image_description_creator_params_v1" version="1"> <interface name="xx_image_description_creator_params_v2" version="1">
<description summary="holder of image description parameters"> <description summary="holder of image description parameters">
This type of object is used for collecting all the parameters required This type of object is used for collecting all the parameters required
to create a xx_image_description_v1 object. A complete set of required to create a xx_image_description_v2 object. A complete set of required
parameters consists of these properties: parameters consists of these properties:
- transfer characteristic function (tf) - transfer characteristic function (tf)
- chromaticities of primaries and white point (primary color volume) - chromaticities of primaries and white point (primary color volume)
@ -744,31 +722,24 @@
set. There may be several alternative requests for setting each property, set. There may be several alternative requests for setting each property,
and in that case the client must choose one of them. and in that case the client must choose one of them.
Once all properties have been set, the create request can be used to Once all properties have been set, the create request must be used to
create the image description object. Finally, the params object should create the image description object, destroying the creator in the
be destroyed. process.
</description> </description>
<request name="destroy" type="destructor">
<description summary="destroy">
Destroys this object. No other object is affected.
</description>
</request>
<enum name="error"> <enum name="error">
<description summary="protocol errors"/> <description summary="protocol errors"/>
<entry name="incomplete_set" value="0" summary="incomplete parameter set"/> <entry name="incomplete_set" value="0" summary="incomplete parameter set"/>
<entry name="inconsistent_set" value="1" summary="invalid combination of parameters"/> <entry name="inconsistent_set" value="1" summary="invalid combination of parameters"/>
<entry name="already_used" value="2" summary="create request already done"/> <entry name="already_set" value="2" summary="property already set"/>
<entry name="already_set" value="3" summary="property already set"/> <entry name="invalid_tf" value="3" summary="invalid transfer characteristic"/>
<entry name="invalid_tf" value="4" summary="invalid transfer characteristic"/> <entry name="invalid_primaries" value="4" summary="invalid primaries or white point"/>
<entry name="invalid_primaries" value="5" summary="invalid primaries or white point"/> <entry name="invalid_luminance" value="5" summary="invalid luminance value or range"/>
<entry name="invalid_luminance" value="6" summary="invalid luminance value or range"/> <entry name="invalid_mastering" value="6" summary="invalid mastering information"/>
<entry name="invalid_mastering" value="7" summary="invalid mastering information"/>
</enum> </enum>
<request name="create"> <request name="create" type="destructor">
<description summary="Create the image description object using params"> <description summary="Create the image description object using params">
Create an image description object based on the parameters previously Create an image description object based on the parameters previously
set on this object. set on this object.
@ -779,30 +750,26 @@
If the particular combination of the parameter set is not supported If the particular combination of the parameter set is not supported
by the compositor, the resulting image description object shall by the compositor, the resulting image description object shall
immediately deliver the xx_image_description_v1.failed event with the immediately deliver the xx_image_description_v2.failed event with the
'unsupported' cause. If a valid image description was created from the 'unsupported' cause. If a valid image description was created from the
parameter set, the xx_image_description_v1.ready event will eventually parameter set, the xx_image_description_v2.ready event will eventually
be sent instead. be sent instead.
This request can be issued at most once during the lifetime of the This request destroys the xx_image_description_creator_params_v2
xx_image_description_creator_params_v1 object, after which the only object.
legal request is destroy. Otherwise the protocol error already_used
is raised.
A client should destroy this object immediately after this request.
The resulting image description object does not allow get_information The resulting image description object does not allow get_information
request. request.
</description> </description>
<arg name="image_description" type="new_id" interface="xx_image_description_v1"/> <arg name="image_description" type="new_id" interface="xx_image_description_v2"/>
</request> </request>
<request name="set_tf_named"> <request name="set_tf_named">
<description summary="named transfer characteristic"> <description summary="named transfer characteristic">
Sets the transfer characteristic using explicitly enumerated named functions. Sets the transfer characteristic using explicitly enumerated named functions.
Only names advertised with xx_color_manager_v1 Only names advertised with xx_color_manager_v2
event supported_tf_named are allowed. Other values shall raise the event supported_tf_named are allowed. Other values shall raise the
protocol error invalid_tf. protocol error invalid_tf.
@ -829,7 +796,7 @@
protocol error already_set is raised. protocol error already_set is raised.
This request can be used when the compositor advertises This request can be used when the compositor advertises
xx_color_manager_v1.feature.set_tf_power. Otherwise this request raises xx_color_manager_v2.feature.set_tf_power. Otherwise this request raises
the protocol error invalid_tf. the protocol error invalid_tf.
</description> </description>
@ -842,7 +809,7 @@
This describes the primary color volume which is the basis This describes the primary color volume which is the basis
for color value encoding. for color value encoding.
Only names advertised with xx_color_manager_v1 Only names advertised with xx_color_manager_v2
event supported_primaries_named are allowed. Other values shall raise the event supported_primaries_named are allowed. Other values shall raise the
protocol error invalid_primaries. protocol error invalid_primaries.
@ -866,7 +833,7 @@
already_set is raised. already_set is raised.
This request can be used if the compositor advertises This request can be used if the compositor advertises
xx_color_manager_v1.feature.set_primaries. Otherwise this request xx_color_manager_v2.feature.set_primaries. Otherwise this request
raises the protocol error invalid_primaries. raises the protocol error invalid_primaries.
</description> </description>
@ -915,14 +882,14 @@
the protocol error already_set is raised. the protocol error already_set is raised.
This request can be used if the compositor advertises This request can be used if the compositor advertises
xx_color_manager_v1.feature.set_mastering_display_primaries. xx_color_manager_v2.feature.set_mastering_display_primaries.
Otherwise this request raises the protocol error invalid_mastering. Otherwise this request raises the protocol error invalid_mastering.
The advertisement implies support only for target color The advertisement implies support only for target color
volumes fully contained within the primary color volume. volumes fully contained within the primary color volume.
If a compositor additionally supports target color volume exceeding If a compositor additionally supports target color volume exceeding
the primary color volume, it must advertise the primary color volume, it must advertise
xx_color_manager_v1.feature.extended_target_volume. xx_color_manager_v2.feature.extended_target_volume.
If a client uses target color volume exceeding the primary color volume If a client uses target color volume exceeding the primary color volume
and the compositor does not support it, the result is implementation and the compositor does not support it, the result is implementation
defined. Compositors are recommended to detect this case and fail the defined. Compositors are recommended to detect this case and fail the
@ -996,15 +963,15 @@
</request> </request>
</interface> </interface>
<interface name="xx_image_description_v1" version="1"> <interface name="xx_image_description_v2" version="1">
<description summary="Colorimetric image description"> <description summary="Colorimetric image description">
An image description carries information about the color encoding used An image description carries information about the color encoding used
on a surface when attached to a wl_surface via on a surface when attached to a wl_surface via
xx_color_management_surface_v1.set_image_description. A compositor can xx_color_management_surface_v2.set_image_description. A compositor can
use this information to decode pixel values into colorimetrically use this information to decode pixel values into colorimetrically
meaningful quantities. meaningful quantities.
Note, that the xx_image_description_v1 object is not ready to be used Note, that the xx_image_description_v2 object is not ready to be used
immediately after creation. The object eventually delivers either the immediately after creation. The object eventually delivers either the
'ready' or the 'failed' event, specified in all requests creating it. The 'ready' or the 'failed' event, specified in all requests creating it. The
object is deemed "ready" after receiving the 'ready' event. object is deemed "ready" after receiving the 'ready' event.
@ -1014,7 +981,7 @@
protocol error. Attempts to use an object which is not ready through other protocol error. Attempts to use an object which is not ready through other
interfaces shall raise protocol errors defined there. interfaces shall raise protocol errors defined there.
Once created and regardless of how it was created, a xx_image_description_v1 Once created and regardless of how it was created, a xx_image_description_v2
object always refers to one fixed image description. It cannot change object always refers to one fixed image description. It cannot change
after creation. after creation.
</description> </description>
@ -1023,8 +990,8 @@
<description summary="destroy the image description"> <description summary="destroy the image description">
Destroy this object. It is safe to destroy an object which is not ready. Destroy this object. It is safe to destroy an object which is not ready.
Destroying a xx_image_description_v1 object has no side-effects, not Destroying a xx_image_description_v2 object has no side-effects, not
even if a xx_color_management_surface_v1.set_image_description has even if a xx_color_management_surface_v2.set_image_description has
not yet been followed by a wl_surface.commit. not yet been followed by a wl_surface.commit.
</description> </description>
</request> </request>
@ -1047,14 +1014,14 @@
<event name="failed"> <event name="failed">
<description summary="graceful error on creating the image description"> <description summary="graceful error on creating the image description">
If creating a xx_image_description_v1 object fails for a reason that If creating a xx_image_description_v2 object fails for a reason that
is not defined as a protocol error, this event is sent. is not defined as a protocol error, this event is sent.
The requests that create image description objects define whether The requests that create image description objects define whether
and when this can occur. Only such creation requests can trigger this and when this can occur. Only such creation requests can trigger this
event. This event cannot be triggered after the image description was event. This event cannot be triggered after the image description was
successfully formed. successfully formed.
Once this event has been sent, the xx_image_description_v1 object will Once this event has been sent, the xx_image_description_v2 object will
never become ready and it can only be destroyed. never become ready and it can only be destroyed.
</description> </description>
@ -1064,11 +1031,11 @@
<event name="ready"> <event name="ready">
<description summary="indication that the object is ready to be used"> <description summary="indication that the object is ready to be used">
Once this event has been sent, the xx_image_description_v1 object is Once this event has been sent, the xx_image_description_v2 object is
deemed "ready". Ready objects can be used to send requests and can be deemed "ready". Ready objects can be used to send requests and can be
used through other interfaces. used through other interfaces.
Every ready xx_image_description_v1 protocol object refers to an Every ready xx_image_description_v2 protocol object refers to an
underlying image description record in the compositor. Multiple protocol underlying image description record in the compositor. Multiple protocol
objects may end up referring to the same record. Clients may identify objects may end up referring to the same record. Clients may identify
these "copies" by comparing their id numbers: if the numbers from two these "copies" by comparing their id numbers: if the numbers from two
@ -1097,7 +1064,7 @@
<request name="get_information"> <request name="get_information">
<description summary="get information about the image description"> <description summary="get information about the image description">
Creates a xx_image_description_info_v1 object which delivers the Creates a xx_image_description_info_v2 object which delivers the
information that makes up the image description. information that makes up the image description.
Not all image description protocol objects allow get_information Not all image description protocol objects allow get_information
@ -1106,20 +1073,20 @@
error no_information is raised. error no_information is raised.
</description> </description>
<arg name="information" type="new_id" interface="xx_image_description_info_v1"/> <arg name="information" type="new_id" interface="xx_image_description_info_v2"/>
</request> </request>
</interface> </interface>
<interface name="xx_image_description_info_v1" version="1"> <interface name="xx_image_description_info_v2" version="1">
<description summary="Colorimetric image description information"> <description summary="Colorimetric image description information">
Sends all matching events describing an image description object exactly Sends all matching events describing an image description object exactly
once and finally sends the 'done' event. once and finally sends the 'done' event.
Once a xx_image_description_info_v1 object has delivered a 'done' event Once a xx_image_description_info_v2 object has delivered a 'done' event
it is automatically destroyed. it is automatically destroyed.
Every xx_image_description_info_v1 created from the same Every xx_image_description_info_v2 created from the same
xx_image_description_v1 shall always return the exact same data. xx_image_description_v2 shall always return the exact same data.
</description> </description>
<event name="done" type="destructor"> <event name="done" type="destructor">
@ -1170,7 +1137,7 @@
explicitly enumerated named set. explicitly enumerated named set.
</description> </description>
<arg name="primaries" type="uint" enum="xx_color_manager_v1.primaries" summary="named primaries"/> <arg name="primaries" type="uint" enum="xx_color_manager_v2.primaries" summary="named primaries"/>
</event> </event>
<event name="tf_power"> <event name="tf_power">
@ -1193,7 +1160,7 @@
named function. named function.
</description> </description>
<arg name="tf" type="uint" enum="xx_color_manager_v1.transfer_function" summary="named transfer function"/> <arg name="tf" type="uint" enum="xx_color_manager_v2.transfer_function" summary="named transfer function"/>
</event> </event>
<event name="target_primaries"> <event name="target_primaries">

View file

@ -24,7 +24,7 @@
#include "surface_p.h" #include "surface_p.h"
#include "transaction.h" #include "transaction.h"
#include "utils/resource.h" #include "utils/resource.h"
#include "xx_colormanagement_v1.h" #include "xx_colormanagement_v2.h"
#include <wayland-server.h> #include <wayland-server.h>
// std // std

View file

@ -27,7 +27,7 @@ class TearingControlV1Interface;
class FractionalScaleV1Interface; class FractionalScaleV1Interface;
class FrogColorManagementSurfaceV1; class FrogColorManagementSurfaceV1;
class PresentationTimeFeedback; class PresentationTimeFeedback;
class XXColorSurfaceV1; class XXColorSurfaceV2;
struct SurfaceState struct SurfaceState
{ {
@ -168,7 +168,7 @@ public:
ClientConnection *client = nullptr; ClientConnection *client = nullptr;
TearingControlV1Interface *tearing = nullptr; TearingControlV1Interface *tearing = nullptr;
FrogColorManagementSurfaceV1 *frogColorManagement = nullptr; FrogColorManagementSurfaceV1 *frogColorManagement = nullptr;
XXColorSurfaceV1 *xxColorSurface = nullptr; XXColorSurfaceV2 *xxColorSurface = nullptr;
struct struct
{ {

View file

@ -1,111 +0,0 @@
/*
SPDX-FileCopyrightText: 2023 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-v1.h"
#include <QObject>
#include <QPointer>
namespace KWin
{
class Display;
class SurfaceInterface;
class Output;
class XXColorManagerV1 : public QObject, private QtWaylandServer::xx_color_manager_v1
{
Q_OBJECT
public:
explicit XXColorManagerV1(Display *display, QObject *parent);
private:
void xx_color_manager_v1_bind_resource(Resource *resource) override;
void xx_color_manager_v1_destroy(Resource *resource) override;
void xx_color_manager_v1_get_output(Resource *resource, uint32_t id, struct ::wl_resource *output) override;
void xx_color_manager_v1_get_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface) override;
void xx_color_manager_v1_new_icc_creator(Resource *resource, uint32_t obj) override;
void xx_color_manager_v1_new_parametric_creator(Resource *resource, uint32_t obj) override;
};
class XXColorSurfaceV1 : private QtWaylandServer::xx_color_management_surface_v1
{
public:
explicit XXColorSurfaceV1(wl_client *client, uint32_t id, uint32_t version, SurfaceInterface *surface);
~XXColorSurfaceV1() override;
void setPreferredColorDescription(const ColorDescription &descr);
private:
void xx_color_management_surface_v1_destroy_resource(Resource *resource) override;
void xx_color_management_surface_v1_destroy(Resource *resource) override;
void xx_color_management_surface_v1_set_image_description(Resource *resource, struct ::wl_resource *image_description, uint32_t render_intent) override;
void xx_color_management_surface_v1_set_default_image_description(Resource *resource) override;
void xx_color_management_surface_v1_get_preferred(Resource *resource, uint32_t image_description) override;
QPointer<SurfaceInterface> m_surface;
ColorDescription m_preferred;
};
class XXColorParametricCreatorV1 : private QtWaylandServer::xx_image_description_creator_params_v1
{
public:
explicit XXColorParametricCreatorV1(wl_client *client, uint32_t id, uint32_t version);
private:
void xx_image_description_creator_params_v1_destroy_resource(Resource *resource) override;
void xx_image_description_creator_params_v1_destroy(Resource *resource) override;
void xx_image_description_creator_params_v1_create(Resource *resource, uint32_t image_description) override;
void xx_image_description_creator_params_v1_set_tf_named(Resource *resource, uint32_t tf) override;
void xx_image_description_creator_params_v1_set_tf_power(Resource *resource, uint32_t eexp) override;
void xx_image_description_creator_params_v1_set_primaries_named(Resource *resource, uint32_t primaries) override;
void xx_image_description_creator_params_v1_set_primaries(Resource *resource, uint32_t r_x, uint32_t r_y, uint32_t g_x, uint32_t g_y, uint32_t b_x, uint32_t b_y, uint32_t w_x, uint32_t w_y) override;
void xx_image_description_creator_params_v1_set_mastering_display_primaries(Resource *resource, uint32_t r_x, uint32_t r_y, uint32_t g_x, uint32_t g_y, uint32_t b_x, uint32_t b_y, uint32_t w_x, uint32_t w_y) override;
void xx_image_description_creator_params_v1_set_mastering_luminance(Resource *resource, uint32_t min_lum, uint32_t max_lum) override;
void xx_image_description_creator_params_v1_set_max_cll(Resource *resource, uint32_t max_cll) override;
void xx_image_description_creator_params_v1_set_max_fall(Resource *resource, uint32_t max_fall) override;
std::optional<Colorimetry> m_colorimetry;
std::optional<NamedTransferFunction> m_transferFunction;
std::optional<double> m_maxFrameAverageBrightness;
std::optional<double> m_maxPeakBrightness;
};
class XXImageDescriptionV1 : private QtWaylandServer::xx_image_description_v1
{
public:
explicit XXImageDescriptionV1(wl_client *client, uint32_t id, uint32_t version, const ColorDescription &color);
const ColorDescription &description() const;
static XXImageDescriptionV1 *get(wl_resource *resource);
private:
void xx_image_description_v1_destroy_resource(Resource *resource) override;
void xx_image_description_v1_destroy(Resource *resource) override;
void xx_image_description_v1_get_information(Resource *resource, uint32_t information) override;
const ColorDescription m_description;
};
class XXColorManagementOutputV1 : public QObject, private QtWaylandServer::xx_color_management_output_v1
{
Q_OBJECT
public:
explicit XXColorManagementOutputV1(wl_client *client, uint32_t id, uint32_t version, Output *output);
private:
void colorDescriptionChanged();
void xx_color_management_output_v1_destroy_resource(Resource *resource) override;
void xx_color_management_output_v1_destroy(Resource *resource) override;
void xx_color_management_output_v1_get_image_description(Resource *resource, uint32_t image_description) override;
Output *const m_output;
ColorDescription m_colorDescription;
};
}

View file

@ -1,9 +1,9 @@
/* /*
SPDX-FileCopyrightText: 2023 Xaver Hugl <xaver.hugl@gmail.com> 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 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/ */
#include "xx_colormanagement_v1.h" #include "xx_colormanagement_v2.h"
#include "display.h" #include "display.h"
#include "surface.h" #include "surface.h"
#include "surface_p.h" #include "surface_p.h"
@ -13,13 +13,13 @@
namespace KWin namespace KWin
{ {
XXColorManagerV1::XXColorManagerV1(Display *display, QObject *parent) XXColorManagerV2::XXColorManagerV2(Display *display, QObject *parent)
: QObject(parent) : QObject(parent)
, QtWaylandServer::xx_color_manager_v1(*display, 1) , QtWaylandServer::xx_color_manager_v2(*display, 1)
{ {
} }
void XXColorManagerV1::xx_color_manager_v1_bind_resource(Resource *resource) void XXColorManagerV2::xx_color_manager_v2_bind_resource(Resource *resource)
{ {
send_supported_feature(resource->handle, feature::feature_parametric); send_supported_feature(resource->handle, feature::feature_parametric);
send_supported_feature(resource->handle, feature::feature_extended_target_volume); send_supported_feature(resource->handle, feature::feature_extended_target_volume);
@ -40,17 +40,17 @@ void XXColorManagerV1::xx_color_manager_v1_bind_resource(Resource *resource)
// TODO implement the other rendering intents // TODO implement the other rendering intents
} }
void XXColorManagerV1::xx_color_manager_v1_destroy(Resource *resource) void XXColorManagerV2::xx_color_manager_v2_destroy(Resource *resource)
{ {
wl_resource_destroy(resource->handle); wl_resource_destroy(resource->handle);
} }
void XXColorManagerV1::xx_color_manager_v1_get_output(Resource *resource, uint32_t id, struct ::wl_resource *output) void XXColorManagerV2::xx_color_manager_v2_get_output(Resource *resource, uint32_t id, struct ::wl_resource *output)
{ {
new XXColorManagementOutputV1(resource->client(), id, resource->version(), OutputInterface::get(output)->handle()); new XXColorManagementOutputV2(resource->client(), id, resource->version(), OutputInterface::get(output)->handle());
} }
void XXColorManagerV1::xx_color_manager_v1_get_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface) void XXColorManagerV2::xx_color_manager_v2_get_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface)
{ {
const auto surf = SurfaceInterface::get(surface); const auto surf = SurfaceInterface::get(surface);
const auto priv = SurfaceInterfacePrivate::get(surf); const auto priv = SurfaceInterfacePrivate::get(surf);
@ -58,27 +58,27 @@ void XXColorManagerV1::xx_color_manager_v1_get_surface(Resource *resource, uint3
wl_resource_post_error(resource->handle, 0, "there's already a color management surface for this wl_surface"); wl_resource_post_error(resource->handle, 0, "there's already a color management surface for this wl_surface");
return; return;
} }
priv->xxColorSurface = new XXColorSurfaceV1(resource->client(), id, resource->version(), surf); priv->xxColorSurface = new XXColorSurfaceV2(resource->client(), id, resource->version(), surf);
} }
void XXColorManagerV1::xx_color_manager_v1_new_icc_creator(Resource *resource, uint32_t obj) void XXColorManagerV2::xx_color_manager_v2_new_icc_creator(Resource *resource, uint32_t obj)
{ {
wl_resource_post_error(resource->handle, error::error_unsupported_feature, "ICC profiles are not supported"); wl_resource_post_error(resource->handle, error::error_unsupported_feature, "ICC profiles are not supported");
} }
void XXColorManagerV1::xx_color_manager_v1_new_parametric_creator(Resource *resource, uint32_t obj) void XXColorManagerV2::xx_color_manager_v2_new_parametric_creator(Resource *resource, uint32_t obj)
{ {
new XXColorParametricCreatorV1(resource->client(), obj, resource->version()); new XXColorParametricCreatorV2(resource->client(), obj, resource->version());
} }
XXColorSurfaceV1::XXColorSurfaceV1(wl_client *client, uint32_t id, uint32_t version, SurfaceInterface *surface) XXColorSurfaceV2::XXColorSurfaceV2(wl_client *client, uint32_t id, uint32_t version, SurfaceInterface *surface)
: QtWaylandServer::xx_color_management_surface_v1(client, id, version) : QtWaylandServer::xx_color_management_surface_v2(client, id, version)
, m_surface(surface) , m_surface(surface)
, m_preferred(SurfaceInterfacePrivate::get(surface)->preferredColorDescription.value_or(ColorDescription::sRGB)) , m_preferred(SurfaceInterfacePrivate::get(surface)->preferredColorDescription.value_or(ColorDescription::sRGB))
{ {
} }
XXColorSurfaceV1::~XXColorSurfaceV1() XXColorSurfaceV2::~XXColorSurfaceV2()
{ {
if (m_surface) { if (m_surface) {
const auto priv = SurfaceInterfacePrivate::get(m_surface); const auto priv = SurfaceInterfacePrivate::get(m_surface);
@ -88,7 +88,7 @@ XXColorSurfaceV1::~XXColorSurfaceV1()
} }
} }
void XXColorSurfaceV1::setPreferredColorDescription(const ColorDescription &descr) void XXColorSurfaceV2::setPreferredColorDescription(const ColorDescription &descr)
{ {
if (m_preferred != descr) { if (m_preferred != descr) {
m_preferred = descr; m_preferred = descr;
@ -96,28 +96,28 @@ void XXColorSurfaceV1::setPreferredColorDescription(const ColorDescription &desc
} }
} }
void XXColorSurfaceV1::xx_color_management_surface_v1_destroy_resource(Resource *resource) void XXColorSurfaceV2::xx_color_management_surface_v2_destroy_resource(Resource *resource)
{ {
delete this; delete this;
} }
void XXColorSurfaceV1::xx_color_management_surface_v1_destroy(Resource *resource) void XXColorSurfaceV2::xx_color_management_surface_v2_destroy(Resource *resource)
{ {
wl_resource_destroy(resource->handle); wl_resource_destroy(resource->handle);
} }
void XXColorSurfaceV1::xx_color_management_surface_v1_set_image_description(Resource *resource, struct ::wl_resource *image_description, uint32_t render_intent) void XXColorSurfaceV2::xx_color_management_surface_v2_set_image_description(Resource *resource, struct ::wl_resource *image_description, uint32_t render_intent)
{ {
if (!m_surface) { if (!m_surface) {
return; return;
} }
const auto priv = SurfaceInterfacePrivate::get(m_surface); const auto priv = SurfaceInterfacePrivate::get(m_surface);
priv->pending->colorDescription = XXImageDescriptionV1::get(image_description)->description(); priv->pending->colorDescription = XXImageDescriptionV2::get(image_description)->description();
priv->pending->colorDescriptionIsSet = true; priv->pending->colorDescriptionIsSet = true;
// TODO render_intent // TODO render_intent
} }
void XXColorSurfaceV1::xx_color_management_surface_v1_set_default_image_description(Resource *resource) void XXColorSurfaceV2::xx_color_management_surface_v2_unset_image_description(Resource *resource)
{ {
if (!m_surface) { if (!m_surface) {
return; return;
@ -127,27 +127,22 @@ void XXColorSurfaceV1::xx_color_management_surface_v1_set_default_image_descript
priv->pending->colorDescriptionIsSet = true; priv->pending->colorDescriptionIsSet = true;
} }
void XXColorSurfaceV1::xx_color_management_surface_v1_get_preferred(Resource *resource, uint32_t image_description) void XXColorSurfaceV2::xx_color_management_surface_v2_get_preferred(Resource *resource, uint32_t image_description)
{ {
new XXImageDescriptionV1(resource->client(), image_description, resource->version(), m_preferred); new XXImageDescriptionV2(resource->client(), image_description, resource->version(), m_preferred);
} }
XXColorParametricCreatorV1::XXColorParametricCreatorV1(wl_client *client, uint32_t id, uint32_t version) XXColorParametricCreatorV2::XXColorParametricCreatorV2(wl_client *client, uint32_t id, uint32_t version)
: QtWaylandServer::xx_image_description_creator_params_v1(client, id, version) : QtWaylandServer::xx_image_description_creator_params_v2(client, id, version)
{ {
} }
void XXColorParametricCreatorV1::xx_image_description_creator_params_v1_destroy_resource(Resource *resource) void XXColorParametricCreatorV2::xx_image_description_creator_params_v2_destroy_resource(Resource *resource)
{ {
delete this; delete this;
} }
void XXColorParametricCreatorV1::xx_image_description_creator_params_v1_destroy(Resource *resource) void XXColorParametricCreatorV2::xx_image_description_creator_params_v2_create(Resource *resource, uint32_t image_description)
{
wl_resource_destroy(resource->handle);
}
void XXColorParametricCreatorV1::xx_image_description_creator_params_v1_create(Resource *resource, uint32_t image_description)
{ {
if (!m_colorimetry || !m_transferFunction) { if (!m_colorimetry || !m_transferFunction) {
wl_resource_post_error(resource->handle, error::error_incomplete_set, "colorimetry or transfer function missing"); wl_resource_post_error(resource->handle, error::error_incomplete_set, "colorimetry or transfer function missing");
@ -157,22 +152,23 @@ void XXColorParametricCreatorV1::xx_image_description_creator_params_v1_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"); 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; return;
} }
new XXImageDescriptionV1(resource->client(), image_description, resource->version(), ColorDescription(*m_colorimetry, *m_transferFunction, 100, 0, m_maxFrameAverageBrightness.value_or(100), m_maxPeakBrightness.value_or(100))); new XXImageDescriptionV2(resource->client(), image_description, resource->version(), ColorDescription(*m_colorimetry, *m_transferFunction, 100, 0, m_maxFrameAverageBrightness.value_or(100), m_maxPeakBrightness.value_or(100)));
wl_resource_destroy(resource->handle);
} }
void XXColorParametricCreatorV1::xx_image_description_creator_params_v1_set_tf_named(Resource *resource, uint32_t tf) void XXColorParametricCreatorV2::xx_image_description_creator_params_v2_set_tf_named(Resource *resource, uint32_t tf)
{ {
if (m_transferFunction) { if (m_transferFunction) {
wl_resource_post_error(resource->handle, error::error_already_set, "transfer function is already set"); wl_resource_post_error(resource->handle, error::error_already_set, "transfer function is already set");
return; return;
} }
switch (tf) { switch (tf) {
case XX_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB: case XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_SRGB:
case XX_COLOR_MANAGER_V1_TRANSFER_FUNCTION_BT709: case XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_BT709:
case XX_COLOR_MANAGER_V1_TRANSFER_FUNCTION_GAMMA22: case XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_GAMMA22:
m_transferFunction = NamedTransferFunction::gamma22; m_transferFunction = NamedTransferFunction::gamma22;
return; return;
case XX_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST2084_PQ: case XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_ST2084_PQ:
m_transferFunction = NamedTransferFunction::PerceptualQuantizer; m_transferFunction = NamedTransferFunction::PerceptualQuantizer;
return; return;
default: default:
@ -181,22 +177,22 @@ void XXColorParametricCreatorV1::xx_image_description_creator_params_v1_set_tf_n
} }
} }
void XXColorParametricCreatorV1::xx_image_description_creator_params_v1_set_tf_power(Resource *resource, uint32_t eexp) void XXColorParametricCreatorV2::xx_image_description_creator_params_v2_set_tf_power(Resource *resource, uint32_t eexp)
{ {
wl_resource_post_error(resource->handle, error::error_invalid_tf, "power transfer functions are not supported"); wl_resource_post_error(resource->handle, error::error_invalid_tf, "power transfer functions are not supported");
} }
void XXColorParametricCreatorV1::xx_image_description_creator_params_v1_set_primaries_named(Resource *resource, uint32_t primaries) void XXColorParametricCreatorV2::xx_image_description_creator_params_v2_set_primaries_named(Resource *resource, uint32_t primaries)
{ {
if (m_colorimetry) { if (m_colorimetry) {
wl_resource_post_error(resource->handle, error::error_already_set, "primaries are already set"); wl_resource_post_error(resource->handle, error::error_already_set, "primaries are already set");
return; return;
} }
switch (primaries) { switch (primaries) {
case XX_COLOR_MANAGER_V1_PRIMARIES_SRGB: case XX_COLOR_MANAGER_V2_PRIMARIES_SRGB:
m_colorimetry = Colorimetry::fromName(NamedColorimetry::BT709); m_colorimetry = Colorimetry::fromName(NamedColorimetry::BT709);
return; return;
case XX_COLOR_MANAGER_V1_PRIMARIES_BT2020: case XX_COLOR_MANAGER_V2_PRIMARIES_BT2020:
m_colorimetry = Colorimetry::fromName(NamedColorimetry::BT2020); m_colorimetry = Colorimetry::fromName(NamedColorimetry::BT2020);
return; return;
default: default:
@ -205,7 +201,7 @@ void XXColorParametricCreatorV1::xx_image_description_creator_params_v1_set_prim
} }
} }
void XXColorParametricCreatorV1::xx_image_description_creator_params_v1_set_primaries(Resource *resource, uint32_t r_x, uint32_t r_y, uint32_t g_x, uint32_t g_y, uint32_t b_x, uint32_t b_y, uint32_t w_x, uint32_t w_y) void XXColorParametricCreatorV2::xx_image_description_creator_params_v2_set_primaries(Resource *resource, uint32_t r_x, uint32_t r_y, uint32_t g_x, uint32_t g_y, uint32_t b_x, uint32_t b_y, uint32_t w_x, uint32_t w_y)
{ {
if (m_colorimetry) { if (m_colorimetry) {
wl_resource_post_error(resource->handle, error::error_already_set, "primaries are already set"); wl_resource_post_error(resource->handle, error::error_already_set, "primaries are already set");
@ -222,28 +218,28 @@ void XXColorParametricCreatorV1::xx_image_description_creator_params_v1_set_prim
QVector2D(w_x / 10'000.0, w_y / 10'000.0)}; QVector2D(w_x / 10'000.0, w_y / 10'000.0)};
} }
void XXColorParametricCreatorV1::xx_image_description_creator_params_v1_set_mastering_display_primaries(Resource *resource, uint32_t r_x, uint32_t r_y, uint32_t g_x, uint32_t g_y, uint32_t b_x, uint32_t b_y, uint32_t w_x, uint32_t w_y) void XXColorParametricCreatorV2::xx_image_description_creator_params_v2_set_mastering_display_primaries(Resource *resource, uint32_t r_x, uint32_t r_y, uint32_t g_x, uint32_t g_y, uint32_t b_x, uint32_t b_y, uint32_t w_x, uint32_t w_y)
{ {
// ignored (at least for now) // ignored (at least for now)
} }
void XXColorParametricCreatorV1::xx_image_description_creator_params_v1_set_mastering_luminance(Resource *resource, uint32_t min_lum, uint32_t max_lum) void XXColorParametricCreatorV2::xx_image_description_creator_params_v2_set_mastering_luminance(Resource *resource, uint32_t min_lum, uint32_t max_lum)
{ {
// ignored (at least for now) // ignored (at least for now)
} }
void XXColorParametricCreatorV1::xx_image_description_creator_params_v1_set_max_cll(Resource *resource, uint32_t max_cll) void XXColorParametricCreatorV2::xx_image_description_creator_params_v2_set_max_cll(Resource *resource, uint32_t max_cll)
{ {
m_maxPeakBrightness = max_cll; m_maxPeakBrightness = max_cll;
} }
void XXColorParametricCreatorV1::xx_image_description_creator_params_v1_set_max_fall(Resource *resource, uint32_t max_fall) void XXColorParametricCreatorV2::xx_image_description_creator_params_v2_set_max_fall(Resource *resource, uint32_t max_fall)
{ {
m_maxFrameAverageBrightness = max_fall; m_maxFrameAverageBrightness = max_fall;
} }
XXImageDescriptionV1::XXImageDescriptionV1(wl_client *client, uint32_t id, uint32_t version, const ColorDescription &color) XXImageDescriptionV2::XXImageDescriptionV2(wl_client *client, uint32_t id, uint32_t version, const ColorDescription &color)
: QtWaylandServer::xx_image_description_v1(client, id, version) : QtWaylandServer::xx_image_description_v2(client, id, version)
, m_description(color) , m_description(color)
{ {
// there's no need to track image description identities, as our descriptions are very lightweight // there's no need to track image description identities, as our descriptions are very lightweight
@ -251,12 +247,12 @@ XXImageDescriptionV1::XXImageDescriptionV1(wl_client *client, uint32_t id, uint3
send_ready(resource()->handle, s_identity++); send_ready(resource()->handle, s_identity++);
} }
void XXImageDescriptionV1::xx_image_description_v1_destroy_resource(Resource *resource) void XXImageDescriptionV2::xx_image_description_v2_destroy_resource(Resource *resource)
{ {
delete this; delete this;
} }
void XXImageDescriptionV1::xx_image_description_v1_destroy(Resource *resource) void XXImageDescriptionV2::xx_image_description_v2_destroy(Resource *resource)
{ {
wl_resource_destroy(resource->handle); wl_resource_destroy(resource->handle);
} }
@ -265,74 +261,74 @@ static uint32_t kwinTFtoProtoTF(NamedTransferFunction tf)
{ {
switch (tf) { switch (tf) {
case NamedTransferFunction::sRGB: case NamedTransferFunction::sRGB:
return xx_color_manager_v1_transfer_function::XX_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB; return xx_color_manager_v2_transfer_function::XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_SRGB;
case NamedTransferFunction::linear: case NamedTransferFunction::linear:
return xx_color_manager_v1_transfer_function::XX_COLOR_MANAGER_V1_TRANSFER_FUNCTION_LINEAR; return xx_color_manager_v2_transfer_function::XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_LINEAR;
case NamedTransferFunction::PerceptualQuantizer: case NamedTransferFunction::PerceptualQuantizer:
return xx_color_manager_v1_transfer_function::XX_COLOR_MANAGER_V1_TRANSFER_FUNCTION_ST2084_PQ; return xx_color_manager_v2_transfer_function::XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_ST2084_PQ;
case NamedTransferFunction::scRGB: case NamedTransferFunction::scRGB:
return xx_color_manager_v1_transfer_function::XX_COLOR_MANAGER_V1_TRANSFER_FUNCTION_LINEAR; return xx_color_manager_v2_transfer_function::XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_LINEAR;
case NamedTransferFunction::gamma22: case NamedTransferFunction::gamma22:
return xx_color_manager_v1_transfer_function::XX_COLOR_MANAGER_V1_TRANSFER_FUNCTION_GAMMA22; return xx_color_manager_v2_transfer_function::XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_GAMMA22;
} }
Q_UNREACHABLE(); Q_UNREACHABLE();
} }
void XXImageDescriptionV1::xx_image_description_v1_get_information(Resource *qtResource, uint32_t information) void XXImageDescriptionV2::xx_image_description_v2_get_information(Resource *qtResource, uint32_t information)
{ {
auto resource = wl_resource_create(qtResource->client(), &xx_image_description_info_v1_interface, qtResource->version(), information); auto resource = wl_resource_create(qtResource->client(), &xx_image_description_info_v2_interface, qtResource->version(), information);
const auto c = m_description.colorimetry(); const auto c = m_description.colorimetry();
const auto round = [](float f) { const auto round = [](float f) {
return std::clamp(std::round(f * 10'000.0), 0.0, 1.0); return std::clamp(std::round(f * 10'000.0), 0.0, 1.0);
}; };
xx_image_description_info_v1_send_primaries(resource, xx_image_description_info_v2_send_primaries(resource,
round(c.red().x()), round(c.red().y()), round(c.red().x()), round(c.red().y()),
round(c.green().x()), round(c.green().y()), round(c.green().x()), round(c.green().y()),
round(c.blue().x()), round(c.blue().y()), round(c.blue().x()), round(c.blue().y()),
round(c.white().x()), round(c.white().y())); round(c.white().x()), round(c.white().y()));
xx_image_description_info_v1_send_tf_named(resource, kwinTFtoProtoTF(m_description.transferFunction())); xx_image_description_info_v2_send_tf_named(resource, kwinTFtoProtoTF(m_description.transferFunction()));
xx_image_description_info_v1_send_done(resource); xx_image_description_info_v2_send_done(resource);
wl_resource_destroy(resource); wl_resource_destroy(resource);
} }
const ColorDescription &XXImageDescriptionV1::description() const const ColorDescription &XXImageDescriptionV2::description() const
{ {
return m_description; return m_description;
} }
XXImageDescriptionV1 *XXImageDescriptionV1::get(wl_resource *resource) XXImageDescriptionV2 *XXImageDescriptionV2::get(wl_resource *resource)
{ {
if (auto resourceContainer = Resource::fromResource(resource)) { if (auto resourceContainer = Resource::fromResource(resource)) {
return static_cast<XXImageDescriptionV1 *>(resourceContainer->object()); return static_cast<XXImageDescriptionV2 *>(resourceContainer->object());
} else { } else {
return nullptr; return nullptr;
} }
} }
XXColorManagementOutputV1::XXColorManagementOutputV1(wl_client *client, uint32_t id, uint32_t version, Output *output) XXColorManagementOutputV2::XXColorManagementOutputV2(wl_client *client, uint32_t id, uint32_t version, Output *output)
: QtWaylandServer::xx_color_management_output_v1(client, id, version) : QtWaylandServer::xx_color_management_output_v2(client, id, version)
, m_output(output) , m_output(output)
, m_colorDescription(output->colorDescription()) , m_colorDescription(output->colorDescription())
{ {
connect(output, &Output::colorDescriptionChanged, this, &XXColorManagementOutputV1::colorDescriptionChanged); connect(output, &Output::colorDescriptionChanged, this, &XXColorManagementOutputV2::colorDescriptionChanged);
} }
void XXColorManagementOutputV1::xx_color_management_output_v1_destroy_resource(Resource *resource) void XXColorManagementOutputV2::xx_color_management_output_v2_destroy_resource(Resource *resource)
{ {
delete this; delete this;
} }
void XXColorManagementOutputV1::xx_color_management_output_v1_destroy(Resource *resource) void XXColorManagementOutputV2::xx_color_management_output_v2_destroy(Resource *resource)
{ {
wl_resource_destroy(resource->handle); wl_resource_destroy(resource->handle);
} }
void XXColorManagementOutputV1::xx_color_management_output_v1_get_image_description(Resource *resource, uint32_t image_description) void XXColorManagementOutputV2::xx_color_management_output_v2_get_image_description(Resource *resource, uint32_t image_description)
{ {
new XXImageDescriptionV1(resource->client(), image_description, resource->version(), m_colorDescription); new XXImageDescriptionV2(resource->client(), image_description, resource->version(), m_colorDescription);
} }
void XXColorManagementOutputV1::colorDescriptionChanged() void XXColorManagementOutputV2::colorDescriptionChanged()
{ {
m_colorDescription = m_output->colorDescription(); m_colorDescription = m_output->colorDescription();
send_image_description_changed(); send_image_description_changed();
@ -340,4 +336,4 @@ void XXColorManagementOutputV1::colorDescriptionChanged()
} }
#include "moc_xx_colormanagement_v1.cpp" #include "moc_xx_colormanagement_v2.cpp"

View file

@ -0,0 +1,110 @@
/*
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-v2.h"
#include <QObject>
#include <QPointer>
namespace KWin
{
class Display;
class SurfaceInterface;
class Output;
class XXColorManagerV2 : public QObject, private QtWaylandServer::xx_color_manager_v2
{
Q_OBJECT
public:
explicit XXColorManagerV2(Display *display, QObject *parent);
private:
void xx_color_manager_v2_bind_resource(Resource *resource) override;
void xx_color_manager_v2_destroy(Resource *resource) override;
void xx_color_manager_v2_get_output(Resource *resource, uint32_t id, struct ::wl_resource *output) override;
void xx_color_manager_v2_get_surface(Resource *resource, uint32_t id, struct ::wl_resource *surface) override;
void xx_color_manager_v2_new_icc_creator(Resource *resource, uint32_t obj) override;
void xx_color_manager_v2_new_parametric_creator(Resource *resource, uint32_t obj) override;
};
class XXColorSurfaceV2 : private QtWaylandServer::xx_color_management_surface_v2
{
public:
explicit XXColorSurfaceV2(wl_client *client, uint32_t id, uint32_t version, SurfaceInterface *surface);
~XXColorSurfaceV2() override;
void setPreferredColorDescription(const ColorDescription &descr);
private:
void xx_color_management_surface_v2_destroy_resource(Resource *resource) override;
void xx_color_management_surface_v2_destroy(Resource *resource) override;
void xx_color_management_surface_v2_set_image_description(Resource *resource, struct ::wl_resource *image_description, uint32_t render_intent) override;
void xx_color_management_surface_v2_unset_image_description(Resource *resource) override;
void xx_color_management_surface_v2_get_preferred(Resource *resource, uint32_t image_description) override;
QPointer<SurfaceInterface> m_surface;
ColorDescription m_preferred;
};
class XXColorParametricCreatorV2 : private QtWaylandServer::xx_image_description_creator_params_v2
{
public:
explicit XXColorParametricCreatorV2(wl_client *client, uint32_t id, uint32_t version);
private:
void xx_image_description_creator_params_v2_destroy_resource(Resource *resource) override;
void xx_image_description_creator_params_v2_create(Resource *resource, uint32_t image_description) override;
void xx_image_description_creator_params_v2_set_tf_named(Resource *resource, uint32_t tf) override;
void xx_image_description_creator_params_v2_set_tf_power(Resource *resource, uint32_t eexp) override;
void xx_image_description_creator_params_v2_set_primaries_named(Resource *resource, uint32_t primaries) override;
void xx_image_description_creator_params_v2_set_primaries(Resource *resource, uint32_t r_x, uint32_t r_y, uint32_t g_x, uint32_t g_y, uint32_t b_x, uint32_t b_y, uint32_t w_x, uint32_t w_y) override;
void xx_image_description_creator_params_v2_set_mastering_display_primaries(Resource *resource, uint32_t r_x, uint32_t r_y, uint32_t g_x, uint32_t g_y, uint32_t b_x, uint32_t b_y, uint32_t w_x, uint32_t w_y) override;
void xx_image_description_creator_params_v2_set_mastering_luminance(Resource *resource, uint32_t min_lum, uint32_t max_lum) override;
void xx_image_description_creator_params_v2_set_max_cll(Resource *resource, uint32_t max_cll) override;
void xx_image_description_creator_params_v2_set_max_fall(Resource *resource, uint32_t max_fall) override;
std::optional<Colorimetry> m_colorimetry;
std::optional<NamedTransferFunction> m_transferFunction;
std::optional<double> m_maxFrameAverageBrightness;
std::optional<double> m_maxPeakBrightness;
};
class XXImageDescriptionV2 : private QtWaylandServer::xx_image_description_v2
{
public:
explicit XXImageDescriptionV2(wl_client *client, uint32_t id, uint32_t version, const ColorDescription &color);
const ColorDescription &description() const;
static XXImageDescriptionV2 *get(wl_resource *resource);
private:
void xx_image_description_v2_destroy_resource(Resource *resource) override;
void xx_image_description_v2_destroy(Resource *resource) override;
void xx_image_description_v2_get_information(Resource *resource, uint32_t information) override;
const ColorDescription m_description;
};
class XXColorManagementOutputV2 : public QObject, private QtWaylandServer::xx_color_management_output_v2
{
Q_OBJECT
public:
explicit XXColorManagementOutputV2(wl_client *client, uint32_t id, uint32_t version, Output *output);
private:
void colorDescriptionChanged();
void xx_color_management_output_v2_destroy_resource(Resource *resource) override;
void xx_color_management_output_v2_destroy(Resource *resource) override;
void xx_color_management_output_v2_get_image_description(Resource *resource, uint32_t image_description) override;
Output *const m_output;
ColorDescription m_colorDescription;
};
}

View file

@ -73,7 +73,7 @@
#include "wayland/xdgtopleveldrag_v1.h" #include "wayland/xdgtopleveldrag_v1.h"
#include "wayland/xwaylandkeyboardgrab_v1.h" #include "wayland/xwaylandkeyboardgrab_v1.h"
#include "wayland/xwaylandshell_v1.h" #include "wayland/xwaylandshell_v1.h"
#include "wayland/xx_colormanagement_v1.h" #include "wayland/xx_colormanagement_v2.h"
#include "workspace.h" #include "workspace.h"
#include "x11window.h" #include "x11window.h"
#include "xdgactivationv1.h" #include "xdgactivationv1.h"
@ -490,7 +490,7 @@ bool WaylandServer::init(InitializationFlags flags)
new FrogColorManagementV1(m_display, m_display); new FrogColorManagementV1(m_display, m_display);
new PresentationTime(m_display, m_display); new PresentationTime(m_display, m_display);
if (qEnvironmentVariableIntValue("KWIN_ENABLE_XX_COLOR_MANAGEMENT")) { if (qEnvironmentVariableIntValue("KWIN_ENABLE_XX_COLOR_MANAGEMENT")) {
m_xxColorManager = new XXColorManagerV1(m_display, m_display); m_xxColorManager = new XXColorManagerV2(m_display, m_display);
} }
return true; return true;
} }

View file

@ -57,7 +57,7 @@ class XdgPopupWindow;
class XdgSurfaceWindow; class XdgSurfaceWindow;
class XdgToplevelWindow; class XdgToplevelWindow;
class PresentationTime; class PresentationTime;
class XXColorManagerV1; class XXColorManagerV2;
class KWIN_EXPORT WaylandServer : public QObject class KWIN_EXPORT WaylandServer : public QObject
{ {
@ -290,7 +290,7 @@ private:
QHash<Output *, OutputDeviceV2Interface *> m_waylandOutputDevices; QHash<Output *, OutputDeviceV2Interface *> m_waylandOutputDevices;
DrmLeaseManagerV1 *m_leaseManager = nullptr; DrmLeaseManagerV1 *m_leaseManager = nullptr;
OutputOrderV1Interface *m_outputOrder = nullptr; OutputOrderV1Interface *m_outputOrder = nullptr;
XXColorManagerV1 *m_xxColorManager = nullptr; XXColorManagerV2 *m_xxColorManager = nullptr;
KWIN_SINGLETON(WaylandServer) KWIN_SINGLETON(WaylandServer)
}; };