Commit graph

6 commits

Author SHA1 Message Date
Pekka Paalanen
120b88aa0a color: run vec3 through weston_color_curve_sample()
Future development will need to evaluate pipelines with curves and
matrices. Such pipelines naturally operate on vec3, as matrices cannot
be operated one channel at a time. Make weston_color_curve_sample()
operate on arrays of vec3.

Its currently only caller, weston_color_curve_to_3x1D_LUT(), is modified
to employ a temporary array for the API impedance mismatch. This
workaround will be removed later as weston_color_curve_to_3x1D_LUT()
itself will be converted to operate on vec3 arrays.

weston_v3f_array_to_planar() documentation was generated with AI.

weston_color_curve_sample() is restructured a little bit, attempting to
make it simpler to read.

color-operations.h gets the #includes needed to make it self-standing.

Assisted-by: Github Copilot (Claude Sonnet 3.5)
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-21 14:23:37 +03:00
Pekka Paalanen
e87eb19877 color,gl-renderer: handle neg. in linpow/powlin
We can handle the mirroring for negative input without conditional this
way. Maybe it's faster, maybe it's not, but I like this style better.

In color-operations we need only one call to the elementary function
rather than two. This helps a lot with code clarity, when we get a vec3
at a time to handle in the future, doing three trivial calls instead of
six with an if-else hassle.

fragment.glsl sheds one layer of function wrapping, which is nice.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-10-21 14:23:37 +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
Pekka Paalanen
98ec0d9b6c color: structurize parametric curve data
Rather than using a two-dimensional array, provide names to the fields.
The fields are primarily used by their names, but we also need the data
as a flat array of floats, so use unions to achieve that: two different
views into the same data.

This makes the code more self-explanatory. In color-operations.c it
removes a handful of temporaries. Comparison in color-properties.c is
simplified. ARRAY_COPY() turns into an assignment.

MAX_PARAMS_PARAM_CURVE is eliminated. Instead of having to maintain a
copy in fragment.glsl, the definition there is automated.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-04-14 11:00:21 +00:00
Leandro Ribeiro
8762c3bab5 color: implement perceptual quantizer transfer function
This implements WESTON_TF_ST2084_PQ.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-04-10 12:43:00 +00:00
Leandro Ribeiro
0af48f0415 color: add function to create 3x1D LUT from color curve
Some external API's (e.g. DRM/KMS) are not capable of dealing with
enumerated color curves. In such cases, we may need to create LUT's that
correspond to such curves and give them to such API's

So add function weston_color_curve_to_3x1D_LUT() to craft 3x1D LUT from
a color curve.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2025-04-10 12:43:00 +00:00