libweston: add struct weston_output_color_outcome

This new struct collects all the things that a color manager needs to
set up when any colorimetry aspect of an output changes. The intention
is to make the color manager API less verbose.

In this first step, the new struct is added and replaces the fields in
weston_output.

The intention is for the following color manager API changes to
dynamically allocate this structure. Unfortunately, until that actually
happens, we need a temporary way to allocate it. That is
weston_output::colorout_, which will be removed in the next patch. This
keeps the patches more palatable for review at the cost of some
back-and-forth in code changes.

This is a pure refactoring, no functional changes.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
Pekka Paalanen
2022-04-28 15:25:00 +03:00
committed by Pekka Paalanen
parent 6122765203
commit 6c0524fd80
5 changed files with 72 additions and 26 deletions
+15 -8
View File
@@ -740,6 +740,7 @@ triangle_fan_debug(struct gl_renderer *gr,
static int color_idx = 0;
struct gl_shader_config alt;
const GLfloat *col;
struct weston_color_transform *ctransf;
static const GLfloat color[][4] = {
{ 1.0, 0.0, 0.0, 1.0 },
{ 0.0, 1.0, 0.0, 1.0 },
@@ -758,8 +759,8 @@ triangle_fan_debug(struct gl_renderer *gr,
.unicolor = { col[0], col[1], col[2], col[3] },
};
if (!gl_shader_config_set_color_transform(&alt,
output->from_sRGB_to_blend)) {
ctransf = output->color_outcome->from_sRGB_to_blend;
if (!gl_shader_config_set_color_transform(&alt, ctransf)) {
weston_log("GL-renderer: %s failed to generate a color transformation.\n",
__func__);
return;
@@ -932,6 +933,7 @@ static void
censor_override(struct gl_shader_config *sconf,
struct weston_output *output)
{
struct weston_color_transform *ctransf;
struct gl_shader_config alt = {
.req = {
.variant = SHADER_VARIANT_SOLID,
@@ -942,8 +944,8 @@ censor_override(struct gl_shader_config *sconf,
.unicolor = { 0.40, 0.0, 0.0, 1.0 },
};
if (!gl_shader_config_set_color_transform(&alt,
output->from_sRGB_to_blend)) {
ctransf = output->color_outcome->from_sRGB_to_blend;
if (!gl_shader_config_set_color_transform(&alt, ctransf)) {
weston_log("GL-renderer: %s failed to generate a color transformation.\n",
__func__);
}
@@ -1307,6 +1309,7 @@ draw_output_borders(struct weston_output *output,
},
.view_alpha = 1.0f,
};
struct weston_color_transform *ctransf;
struct gl_output_state *go = get_output_state(output);
struct gl_renderer *gr = get_renderer(output->compositor);
struct gl_border_image *top, *bottom, *left, *right;
@@ -1315,7 +1318,8 @@ draw_output_borders(struct weston_output *output,
if (border_status == BORDER_STATUS_CLEAN)
return; /* Clean. Nothing to do. */
if (!gl_shader_config_set_color_transform(&sconf, output->from_sRGB_to_output)) {
ctransf = output->color_outcome->from_sRGB_to_output;
if (!gl_shader_config_set_color_transform(&sconf, ctransf)) {
weston_log("GL-renderer: %s failed to generate a color transformation.\n", __func__);
return;
}
@@ -1550,13 +1554,15 @@ blit_shadow_to_output(struct weston_output *output,
struct gl_renderer *gr = get_renderer(output->compositor);
double width = output->current_mode->width;
double height = output->current_mode->height;
struct weston_color_transform *ctransf;
pixman_box32_t *rects;
int n_rects;
int i;
pixman_region32_t translated_damage;
GLfloat verts[4 * 2];
if (!gl_shader_config_set_color_transform(&sconf, output->from_blend_to_output)) {
ctransf = output->color_outcome->from_blend_to_output;
if (!gl_shader_config_set_color_transform(&sconf, ctransf)) {
weston_log("GL-renderer: %s failed to generate a color transformation.\n", __func__);
return;
}
@@ -1624,7 +1630,8 @@ gl_renderer_repaint_output(struct weston_output *output,
struct weston_paint_node *pnode;
assert(output->from_blend_to_output_by_backend ||
output->from_blend_to_output == NULL || shadow_exists(go));
output->color_outcome->from_blend_to_output == NULL ||
shadow_exists(go));
if (use_output(output) < 0)
return;
@@ -3439,7 +3446,7 @@ gl_renderer_output_create(struct weston_output *output,
go->begin_render_sync = EGL_NO_SYNC_KHR;
go->end_render_sync = EGL_NO_SYNC_KHR;
if ((output->from_blend_to_output != NULL &&
if ((output->color_outcome->from_blend_to_output != NULL &&
output->from_blend_to_output_by_backend == false) ||
quirks->gl_force_full_redraw_of_shadow_fb) {
assert(gr->gl_supports_color_transforms);