18 , QtWaylandServer::xx_color_manager_v2(*display, 1)
22void XXColorManagerV2::xx_color_manager_v2_bind_resource(Resource *resource)
24 send_supported_feature(resource->handle, feature::feature_parametric);
25 send_supported_feature(resource->handle, feature::feature_extended_target_volume);
26 send_supported_feature(resource->handle, feature::feature_set_mastering_display_primaries);
27 send_supported_feature(resource->handle, feature::feature_set_primaries);
29 send_supported_primaries_named(resource->handle, primaries::primaries_srgb);
30 send_supported_primaries_named(resource->handle, primaries::primaries_bt2020);
32 send_supported_tf_named(resource->handle, transfer_function::transfer_function_bt709);
33 send_supported_tf_named(resource->handle, transfer_function::transfer_function_gamma22);
34 send_supported_tf_named(resource->handle, transfer_function::transfer_function_srgb);
35 send_supported_tf_named(resource->handle, transfer_function::transfer_function_st2084_pq);
38 send_supported_intent(resource->handle, render_intent::render_intent_perceptual);
39 send_supported_intent(resource->handle, render_intent::render_intent_relative);
43void XXColorManagerV2::xx_color_manager_v2_destroy(Resource *resource)
45 wl_resource_destroy(resource->handle);
48void XXColorManagerV2::xx_color_manager_v2_get_output(Resource *resource, uint32_t
id, struct ::wl_resource *output)
53void XXColorManagerV2::xx_color_manager_v2_get_surface(Resource *resource, uint32_t
id, struct ::wl_resource *surface)
57 if (priv->frogColorManagement || priv->xxColorSurface) {
58 wl_resource_post_error(resource->handle, 0,
"there's already a color management surface for this wl_surface");
61 priv->xxColorSurface =
new XXColorSurfaceV2(resource->client(),
id, resource->version(), surf);
64void XXColorManagerV2::xx_color_manager_v2_new_icc_creator(Resource *resource, uint32_t obj)
66 wl_resource_post_error(resource->handle, error::error_unsupported_feature,
"ICC profiles are not supported");
69void XXColorManagerV2::xx_color_manager_v2_new_parametric_creator(Resource *resource, uint32_t obj)
71 new XXColorParametricCreatorV2(resource->client(), obj, resource->version());
75 : QtWaylandServer::xx_color_management_surface_v2(client, id,
version)
86 priv->pending->colorDescriptionIsSet =
true;
87 priv->xxColorSurface =
nullptr;
93 if (m_preferred != descr) {
95 send_preferred_changed(resource()->handle);
99void XXColorSurfaceV2::xx_color_management_surface_v2_destroy_resource(Resource *resource)
104void XXColorSurfaceV2::xx_color_management_surface_v2_destroy(Resource *resource)
106 wl_resource_destroy(resource->handle);
109void XXColorSurfaceV2::xx_color_management_surface_v2_set_image_description(Resource *resource, struct ::wl_resource *image_description, uint32_t render_intent)
116 priv->pending->colorDescriptionIsSet =
true;
120void XXColorSurfaceV2::xx_color_management_surface_v2_unset_image_description(Resource *resource)
127 priv->pending->colorDescriptionIsSet =
true;
130void XXColorSurfaceV2::xx_color_management_surface_v2_get_preferred(Resource *resource, uint32_t image_description)
132 new XXImageDescriptionV2(resource->client(), image_description, resource->version(), m_preferred);
136 : QtWaylandServer::xx_image_description_creator_params_v2(client, id,
version)
140void XXColorParametricCreatorV2::xx_image_description_creator_params_v2_destroy_resource(Resource *resource)
145void XXColorParametricCreatorV2::xx_image_description_creator_params_v2_create(Resource *resource, uint32_t image_description)
147 if (!m_colorimetry || !m_transferFunction) {
148 wl_resource_post_error(resource->handle, error::error_incomplete_set,
"colorimetry or transfer function missing");
152 wl_resource_post_error(resource->handle, error::error_inconsistent_set,
"max_cll and max_fall must only be set with the PQ transfer function");
155 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)));
156 wl_resource_destroy(resource->handle);
159void XXColorParametricCreatorV2::xx_image_description_creator_params_v2_set_tf_named(Resource *resource, uint32_t tf)
161 if (m_transferFunction) {
162 wl_resource_post_error(resource->handle, error::error_already_set,
"transfer function is already set");
166 case XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_SRGB:
167 case XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_BT709:
168 case XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_GAMMA22:
171 case XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_ST2084_PQ:
176 wl_resource_post_error(resource->handle, error::error_invalid_tf,
"unsupported named transfer function");
180void XXColorParametricCreatorV2::xx_image_description_creator_params_v2_set_tf_power(Resource *resource, uint32_t eexp)
182 wl_resource_post_error(resource->handle, error::error_invalid_tf,
"power transfer functions are not supported");
185void XXColorParametricCreatorV2::xx_image_description_creator_params_v2_set_primaries_named(Resource *resource, uint32_t primaries)
188 wl_resource_post_error(resource->handle, error::error_already_set,
"primaries are already set");
192 case XX_COLOR_MANAGER_V2_PRIMARIES_SRGB:
195 case XX_COLOR_MANAGER_V2_PRIMARIES_BT2020:
200 wl_resource_post_error(resource->handle, error::error_invalid_primaries,
"unsupported named primaries");
204void 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)
207 wl_resource_post_error(resource->handle, error::error_already_set,
"primaries are already set");
210 if (w_x == 0 || w_y == 0) {
211 wl_resource_post_error(resource->handle, error::error_invalid_primaries,
"whitepoint must not be zero");
214 m_colorimetry = Colorimetry{
215 QVector2D(r_x / 10'000.0, r_y / 10'000.0),
216 QVector2D(g_x / 10'000.0, g_y / 10'000.0),
217 QVector2D(b_x / 10'000.0, b_y / 10'000.0),
218 QVector2D(w_x / 10'000.0, w_y / 10'000.0)};
221void 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)
226void XXColorParametricCreatorV2::xx_image_description_creator_params_v2_set_mastering_luminance(Resource *resource, uint32_t min_lum, uint32_t max_lum)
231void XXColorParametricCreatorV2::xx_image_description_creator_params_v2_set_max_cll(Resource *resource, uint32_t max_cll)
233 m_maxPeakBrightness = max_cll;
236void XXColorParametricCreatorV2::xx_image_description_creator_params_v2_set_max_fall(Resource *resource, uint32_t max_fall)
238 m_maxFrameAverageBrightness = max_fall;
242 : QtWaylandServer::xx_image_description_v2(client, id,
version)
243 , m_description(color)
246 static uint32_t s_identity = 1;
247 send_ready(resource()->handle, s_identity++);
250void XXImageDescriptionV2::xx_image_description_v2_destroy_resource(Resource *resource)
255void XXImageDescriptionV2::xx_image_description_v2_destroy(Resource *resource)
257 wl_resource_destroy(resource->handle);
264 return xx_color_manager_v2_transfer_function::XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_SRGB;
266 return xx_color_manager_v2_transfer_function::XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_LINEAR;
268 return xx_color_manager_v2_transfer_function::XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_ST2084_PQ;
270 return xx_color_manager_v2_transfer_function::XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_LINEAR;
272 return xx_color_manager_v2_transfer_function::XX_COLOR_MANAGER_V2_TRANSFER_FUNCTION_GAMMA22;
277void XXImageDescriptionV2::xx_image_description_v2_get_information(Resource *qtResource, uint32_t information)
279 auto resource = wl_resource_create(qtResource->client(), &xx_image_description_info_v2_interface, qtResource->version(), information);
281 const auto round = [](
float f) {
282 return std::clamp(std::round(f * 10'000.0), 0.0, 1.0);
284 xx_image_description_info_v2_send_primaries(resource,
285 round(c.red().x()), round(c.red().y()),
286 round(c.green().x()), round(c.green().y()),
287 round(c.blue().x()), round(c.blue().y()),
288 round(c.white().x()), round(c.white().y()));
289 xx_image_description_info_v2_send_tf_named(resource, kwinTFtoProtoTF(m_description.
transferFunction()));
290 xx_image_description_info_v2_send_done(resource);
291 wl_resource_destroy(resource);
296 return m_description;
301 if (
auto resourceContainer = Resource::fromResource(resource)) {
309 : QtWaylandServer::xx_color_management_output_v2(client, id,
version)
311 , m_colorDescription(output->colorDescription())
316void XXColorManagementOutputV2::xx_color_management_output_v2_destroy_resource(Resource *resource)
321void XXColorManagementOutputV2::xx_color_management_output_v2_destroy(Resource *resource)
323 wl_resource_destroy(resource->handle);
326void XXColorManagementOutputV2::xx_color_management_output_v2_get_image_description(Resource *resource, uint32_t image_description)
328 new XXImageDescriptionV2(resource->client(), image_description, resource->version(), m_colorDescription);
331void XXColorManagementOutputV2::colorDescriptionChanged()
334 send_image_description_changed();
339#include "moc_xx_colormanagement_v2.cpp"
NamedTransferFunction transferFunction() const
static const ColorDescription sRGB
const Colorimetry & colorimetry() const
static const Colorimetry & fromName(NamedColorimetry name)
Class holding the Wayland server display loop.
void colorDescriptionChanged()
const ColorDescription & colorDescription() const
static OutputInterface * get(wl_resource *native)
Resource representing a wl_surface.
static SurfaceInterface * get(wl_resource *native)
static SurfaceInterfacePrivate * get(SurfaceInterface *surface)
XXColorManagementOutputV2(wl_client *client, uint32_t id, uint32_t version, Output *output)
XXColorManagerV2(Display *display, QObject *parent)
XXColorParametricCreatorV2(wl_client *client, uint32_t id, uint32_t version)
~XXColorSurfaceV2() override
XXColorSurfaceV2(wl_client *client, uint32_t id, uint32_t version, SurfaceInterface *surface)
void setPreferredColorDescription(const ColorDescription &descr)
const ColorDescription & description() const
XXImageDescriptionV2(wl_client *client, uint32_t id, uint32_t version, const ColorDescription &color)
static XXImageDescriptionV2 * get(wl_resource *resource)