summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeandro Ribeiro <leandro.ribeiro@collabora.com>2023-10-06 14:03:03 -0300
committerPekka Paalanen <pq@iki.fi>2023-10-30 11:47:35 +0000
commitcab1992b812d3f60733eead9748372e24f0ae006 (patch)
tree0695f5a806f0607d07a65fd9aa624fe2b4dc34c8
parent0c1ab2ad76402dbf32cdf59917bb8e517efdecb9 (diff)
color: do not use NULL as stock sRGB color profile
Stop assuming that NULL represents the stock sRGB color profile. From now on, query the stock sRGB color profile from the color manager. This should be internal to libweston (core and the color plugins), and users of the libweston public API should not be affected by this. They are still allowed to set an output color profile to the stock sRGB using NULL. Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
-rw-r--r--libweston/color-lcms/color-lcms.c8
-rw-r--r--libweston/color-noop.c12
-rw-r--r--libweston/color.c3
-rw-r--r--libweston/compositor.c22
4 files changed, 32 insertions, 13 deletions
diff --git a/libweston/color-lcms/color-lcms.c b/libweston/color-lcms/color-lcms.c
index 923ae262..d5fe847c 100644
--- a/libweston/color-lcms/color-lcms.c
+++ b/libweston/color-lcms/color-lcms.c
@@ -304,13 +304,7 @@ cmlcms_create_output_color_outcome(struct weston_color_manager *cm_base,
if (!cmlcms_get_hdr_meta(output, &co->hdr_meta))
goto out_fail;
- /*
- * TODO: if output->color_profile is NULL, maybe manufacture a
- * profile from weston_color_characteristics if it has enough
- * information?
- * Or let the frontend decide to call a "create a profile from
- * characteristics" API?
- */
+ assert(output->color_profile);
/* TODO: take container color space into account */
diff --git a/libweston/color-noop.c b/libweston/color-noop.c
index b7236e88..182af750 100644
--- a/libweston/color-noop.c
+++ b/libweston/color-noop.c
@@ -146,8 +146,12 @@ cmnoop_get_surface_color_transform(struct weston_color_manager *cm_base,
struct weston_output *output,
struct weston_surface_color_transform *surf_xform)
{
- /* TODO: Assert surface has no colorspace set */
- assert(output->color_profile == NULL);
+ struct weston_color_manager_noop *cmnoop = get_cmnoop(cm_base);
+
+ /* TODO: Assert that, if the surface has a cprof, it is the stock one */
+
+ assert(output->color_profile &&
+ get_cprof(output->color_profile) == cmnoop->stock_cprof);
if (!check_output_eotf_mode(output))
return false;
@@ -163,9 +167,11 @@ static struct weston_output_color_outcome *
cmnoop_create_output_color_outcome(struct weston_color_manager *cm_base,
struct weston_output *output)
{
+ struct weston_color_manager_noop *cmnoop = get_cmnoop(cm_base);
struct weston_output_color_outcome *co;
- assert(output->color_profile == NULL);
+ assert(output->color_profile &&
+ get_cprof(output->color_profile) == cmnoop->stock_cprof);
if (!check_output_eotf_mode(output))
return NULL;
diff --git a/libweston/color.c b/libweston/color.c
index 2834d797..2f322e94 100644
--- a/libweston/color.c
+++ b/libweston/color.c
@@ -50,7 +50,6 @@
WL_EXPORT struct weston_color_profile *
weston_color_profile_ref(struct weston_color_profile *cprof)
{
- /* NULL is a valid color space: sRGB */
if (!cprof)
return NULL;
@@ -92,7 +91,7 @@ weston_color_profile_get_description(struct weston_color_profile *cprof)
if (cprof)
return cprof->description;
else
- return "built-in default sRGB SDR profile";
+ return "(untagged)";
}
/**
diff --git a/libweston/compositor.c b/libweston/compositor.c
index a767cecf..f9c72144 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -7170,6 +7170,8 @@ weston_output_set_color_outcome(struct weston_output *output)
struct weston_color_manager *cm = output->compositor->color_manager;
struct weston_output_color_outcome *colorout;
+ assert(output->color_profile);
+
colorout = cm->create_output_color_outcome(cm, output);
if (!colorout) {
weston_log("Creating color transformation for output \"%s\" failed.\n",
@@ -7412,11 +7414,17 @@ WL_EXPORT bool
weston_output_set_color_profile(struct weston_output *output,
struct weston_color_profile *cprof)
{
+ struct weston_color_manager *cm = output->compositor->color_manager;
struct weston_color_profile *old;
struct weston_paint_node *pnode;
old = output->color_profile;
- output->color_profile = weston_color_profile_ref(cprof);
+
+ if (!cprof) {
+ output->color_profile = cm->get_stock_sRGB_color_profile(cm);
+ } else {
+ output->color_profile = weston_color_profile_ref(cprof);
+ }
if (output->enabled) {
if (!weston_output_set_color_outcome(output)) {
@@ -7603,6 +7611,8 @@ weston_output_init(struct weston_output *output,
struct weston_compositor *compositor,
const char *name)
{
+ struct weston_color_manager *cm;
+
output->pos.c = weston_coord(0, 0);
output->compositor = compositor;
output->destroying = 0;
@@ -7636,6 +7646,11 @@ weston_output_init(struct weston_output *output,
weston_plane_init(&output->primary_plane, compositor);
weston_compositor_stack_plane(compositor,
&output->primary_plane, NULL);
+
+ /* Set the stock sRGB color profile for the output. Libweston users are
+ * free to set the color profile to whatever they want later on. */
+ cm = compositor->color_manager;
+ output->color_profile = cm->get_stock_sRGB_color_profile(cm);
}
/** Adds weston_output object to pending output list.
@@ -7949,7 +7964,12 @@ weston_output_release(struct weston_output *output)
if (output->enabled)
weston_compositor_remove_output(output);
+ /* We always have a color profile set, as weston_output_init() sets the
+ * output cprof to the stock sRGB one. */
+ assert(output->color_profile);
weston_color_profile_unref(output->color_profile);
+ output->color_profile = NULL;
+
assert(output->color_outcome == NULL);
pixman_region32_fini(&output->region);