Commit graph

25 commits

Author SHA1 Message Date
Pekka Paalanen
360eef9663 color: add weston_color_profile_param_builder_set_target_primaries_named()
The protocol does not carry target primaries by enumeration, but in
weston.ini I want to be able to use a name rather than raw values.
Adding this API makes that possible.

main.c cannot look up the enumeration itself, because color-properties.h
is private. As it should be.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-09 16:17:57 +00:00
Pekka Paalanen
9b68277b77 libweston: export weston_color_profile_param_builder_set_primary_luminance()
All the others were already exported, this was forgotten.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-09 16:17:57 +00:00
Pekka Paalanen
e75873d376 color: improve primaries-named builder error
This error gets sent to clients or into the Weston log. Print the name
rather than the meaningless number.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-07 17:23:35 +03:00
Pekka Paalanen
b8ac69eef1 color: check maxCLL and maxFALL against target lum always
The target luminance range is implied when not explicitly set, so maxCLL
and maxFALL should be checked against target luminances regardless of
whether target luminances are explicit.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-07 17:23:35 +03:00
Pekka Paalanen
a17d5b4eb2 color: validate luminances more
Make sure the given values are finite, positive, and non-zero where
appropriate.

Because these validations are not mandated in the color-management
protocol, they are not immediate failures. They will fail the final
image description creation.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-07 17:23:35 +03:00
Pekka Paalanen
6fbc1376ee color: improve profile builder errors
Statements phrased positive are easier to understand than phrased
negative. Use "must" instead of "should".

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-07 17:23:35 +03:00
Pekka Paalanen
3f150b090b color: fix CIE value validation
The old code checked x for low limit and y for high limit, rather than
checking both for both limits. Fix this.

Check all value pairs rather than the first one four times. Don't stop
at the first error, record them all.

While at it, we might as well print exactly what value was the problem.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-07 17:23:35 +03:00
Pekka Paalanen
d180517ae4 color: move validate_color_gamut() up the file
This is a simple move of code, no changes. The next patch needs it here.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-07 17:23:35 +03:00
Pekka Paalanen
daec4a0994 color: print name of unsupported TF
Helps debugging when you have the name rather than a number.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-09-25 18:03:31 +03:00
Pekka Paalanen
f3badf2c2d color: introduce struct weston_color_tf
At first I wanted to wrap

	float tf_params[MAX_PARAMS_TF]

into a struct, so that it would become type-safe to pass into functions,
and it could be copied with a simple assignment. Then I noticed that for
tf_params to be operable, it must always be accompanied by struct
weston_color_tf_info. Hence, struct weston_color_tf was born.

The need for #define MAX_PARAMS_TF got eliminated.

Because struct weston_color_tf is a member of struct
weston_color_profile_params, now both need to not contain implicit
padding.

This patch makes the internal enumerated TF structures follow the
current protocol requests: all color channels use the same curve.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-09-25 18:03:31 +03:00
Leandro Ribeiro
39108501b3 libweston: make use of some of the new weston assert
We didn't have many Weston assert macros in place, but now we do.

Make use of a few of the newer macros where they make sense. No big
difference, but just to exercise using the correct ones now that they
exist.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-15 19:16:17 -03:00
Leandro Ribeiro
a4cefa69a2 shared: rename a few weston assert
Currently weston-test-assert.h has a better naming style than
weston-assert.h: more concise and standardized.

So let's copy the same style to weston-assert.h

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-09-15 19:13:04 -03:00
Leandro Ribeiro
d3ef4f9576 color: improve code that validates color gamut
First of all, we make it work for NaN CIE xy values.

We also improve the error message a bit. It was only printing that the
color gamut was invalid, but it didn't explain why. This adds the
explanation (out of valid range).

And finally, we make the code a bit shorter.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-04-03 17:49:53 +03:00
Leandro Ribeiro
25a10fa2cd color: add WL_EXPORT to param builder functions
The internal API to create parametric color profiles should be available
not only to libweston, but also to frontend. WL_EXPORT was missing from
the functions, so add that.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-04-03 17:49:40 +03:00
Loïc Molinari
9373e76655 shared: Rename NULL and not NULL pointer assertions
Make the NULL assertions more explicit.

weston_assert_ptr_is_null() -> weston_assert_ptr_null()
weston_assert_ptr()         -> weston_assert_ptr_not_null()

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-02-26 23:50:45 +01:00
Robert Mader
9124a98aec color: update color-management protocol to wp-v1
For a list of changes that got squashed into this commit see
https://gitlab.freedesktop.org/rmader/weston/-/commits/color-management-protocol-wp-v1-bkp

Co-authored-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Signed-off-by: Robert Mader <robert.mader@collabora.com>
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-02-26 10:09:43 -03:00
Leandro Ribeiro
277082dbd9 color: change has_parameters to count_parameters
A counter instead of a boolean should be useful when we add code
printing the parameters. This should help us to avoid printing unused
parameters.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-01-20 09:30:46 +00:00
Leandro Ribeiro
9dcc5f20f8 color: adjust a few error codes in our parametric creator API
If a certain feature is unsupported, return UNSUPPORTED instead of
BAD_TF, BAD_PRIMARIES, etc.

Also, up to now cm->get_color_profile_from_params() would return
UNSUPPORTED. But this is different from the other UNSUPPORTED usages, so
return a new error.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-01-20 09:30:46 +00:00
Leandro Ribeiro
b852744977 color: prioritize protocol error instead of graceful failure
In the parametric builder API, which is used by our color management
protocol implementation, we have errors that may be translated to
protocol errors or graceful failures. As we return a single err code
to the protocol implementation, let's prioritize the protocol error.

We do that by inverting the order of checks, as the first error code
caught is the one prioritized.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-01-20 09:30:46 +00:00
Leandro Ribeiro
0ed8294881 color: add weston_color_profile_param_builder_set_primary_luminance()
This follows a recent change in the CM&HDR protocol (more specifically,
v4 of the experimental version). Now users of the API can set luminance
parameters for the primary color volume.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-01-20 09:30:46 +00:00
Leandro Ribeiro
9ae0a7ec05 color: accept max_fall and max_cll even for tf different from PQ
The CM&HDR protocol extension spec relaxed the requirements for the
max_fall and max_cll setters. Now we accept such values even when the
transfer function is not PQ.

This also fixes an issue in which we'd not accept target_luminance
for transfer function different from PQ, which was not on the spec.

INCONSISTENT_SET is not being used in any other errors, so remove that
from enum weston_color_profile_param_builder_error.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-01-20 09:30:46 +00:00
Leandro Ribeiro
1082ef328a color: rename luminance to target luminance
In the experimental color-management protocol v3
(xx-color-management-v3), we had only the luminance parameters that were
defining the luminance range targeted by the image description. But in
v4 a way to specify luminance parameters for the primary color volume
has been added.

In order to avoid confusion, rename existent luminance variables to
target luminance.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-01-20 09:30:46 +00:00
Marius Vlad
207fed2710 Revert "shared/helpers.h: Migrate helpers.h to libweston"
This is problematic as we don't have namespacing for these and some of
the macros can interfere with other defines.

This reverts commit 8634c7e349.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2025-01-17 10:18:26 +02:00
Marius Vlad
8634c7e349 shared/helpers.h: Migrate helpers.h to libweston
As weston_windowed_output_get_api needs ARRAY_LENGTH() move helpers to a
libweston/ so other users can re-use that instead of re-defining these
all over. Easier for other front-ends to make use of them.

With this change windowed-output-api.h also includes the helpers header.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-11-25 11:26:35 +00:00
Leandro Ribeiro
2c44a4ea4a color: introduce API to create color profile from parameters
Add API to create color profiles from parameters. It is a public API
that should be used by the frontend and also by the color management
protocol implementation.

Currently our protocol implementation does not support clients that want
to create color profiles from parameters, and this is a step towards
supporting that.

As warned in "color: add get_color_profile_from_params() to color
managers", we still do not fully support creating color profiles from
parameters. This just creates a boilerplate color profile that we're
planning to extend later.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-06-17 11:50:41 -03:00