color: add from sRGB to output color transformation

This is needed when drawing anything internal directly to an output,
like the borders/decorations in a nested compositor setup. This makes
the assumption that the internal stuff starts in sRGB, which should be
safe. As borders are never blended with other content, this should also
be sufficient.

This patch is a reminder that that path exists, rather than a real
implementation. To be implemented when someone needs it.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
Pekka Paalanen 2021-03-22 17:32:07 +02:00 committed by Pekka Paalanen
parent 1d2eee208c
commit cda3951a9a
5 changed files with 38 additions and 0 deletions

View File

@ -374,6 +374,7 @@ struct weston_output {
int scale;
bool use_renderer_shadow_buffer;
struct weston_color_transform *from_sRGB_to_output;
struct weston_color_transform *from_blend_to_output;
bool from_blend_to_output_by_backend;

View File

@ -75,6 +75,19 @@ cmnoop_get_output_color_transform(struct weston_color_manager *cm_base,
return true;
}
static bool
cmnoop_get_sRGB_to_output_color_transform(struct weston_color_manager *cm_base,
struct weston_output *output,
struct weston_color_transform **xform_out)
{
/* TODO: Assert output has no colorspace set */
/* Identity transform */
*xform_out = NULL;
return true;
}
static bool
cmnoop_init(struct weston_color_manager *cm_base)
{
@ -109,6 +122,8 @@ weston_color_manager_noop_create(struct weston_compositor *compositor)
cm->base.get_surface_color_transform =
cmnoop_get_surface_color_transform;
cm->base.get_output_color_transform = cmnoop_get_output_color_transform;
cm->base.get_sRGB_to_output_color_transform =
cmnoop_get_sRGB_to_output_color_transform;
return &cm->base;
}

View File

@ -176,6 +176,22 @@ struct weston_color_manager {
(*get_output_color_transform)(struct weston_color_manager *cm,
struct weston_output *output,
struct weston_color_transform **xform_out);
/** Get sRGB to output transformation
*
* \param cm The color manager.
* \param output The output for the destination color space.
* \param xform_out Pointer for storing the weston_color_transform.
* \return True on success, false on failure.
*
* The callee is responsible for increasing the reference count on the
* weston_color_transform it stores via xform_out. On failure, xform_out
* is untouched.
*/
bool
(*get_sRGB_to_output_color_transform)(struct weston_color_manager *cm,
struct weston_output *output,
struct weston_color_transform **xform_out);
};
struct weston_color_transform *

View File

@ -6272,6 +6272,8 @@ weston_output_transform_coordinate(struct weston_output *output,
static void
weston_output_reset_color_transforms(struct weston_output *output)
{
weston_color_transform_unref(output->from_sRGB_to_output);
output->from_sRGB_to_output = NULL;
weston_color_transform_unref(output->from_blend_to_output);
output->from_blend_to_output = NULL;
}
@ -6687,6 +6689,8 @@ weston_output_enable(struct weston_output *output)
ok = cm->get_output_color_transform(cm, output,
&output->from_blend_to_output);
ok = ok && cm->get_sRGB_to_output_color_transform(cm, output,
&output->from_sRGB_to_output);
if (!ok) {
weston_log("Creating color transformation for output \"%s\" failed.\n",
output->name);

View File

@ -1272,6 +1272,8 @@ draw_output_borders(struct weston_output *output,
if (border_status == BORDER_STATUS_CLEAN)
return; /* Clean. Nothing to do. */
assert(output->from_sRGB_to_output == NULL);
top = &go->borders[GL_RENDERER_BORDER_TOP];
bottom = &go->borders[GL_RENDERER_BORDER_BOTTOM];
left = &go->borders[GL_RENDERER_BORDER_LEFT];