This removes the API impedance mismatch between
weston_color_curve_sample() and weston_color_curve_to_3x1D_LUT() that
was temporarily introduced in the previous commit. That mismatch is now
limited to gl_color_curve_lut_3x1d().
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Allow dictating which color format we'd like to use. This introduces the
front-end side and the core parts, leaving the EDID parsing and DRM
connector property for later patches.
Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
As it should have been. Found, when I temporarily needed to print
'static const struct weston_color_profile_params'.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
It is nice to see the numbers of a parametric color profile when created
from CTA or EDID or just to cross-check with weston.ini.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
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>
This was never used, and I happened to write a slightly different
version of it in color-lcms.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Output color effects are applied to the whole output scenegraph. It
depends on color-management being disabled, as the color effects are
applied in sRGB content.
For now we added only a few accessibility options: color inversion,
deuteranopia, protanopia and tritanopia CVD correction.
Note that surfaces presented on outputs that contains a color effect
can't be used for direct scanout (i.e. bypass composition and offloading
to KMS overlay planes). The color effect is applied in our GL-renderer.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
At this point, the DRM/KMS API supports offloading post-blend color
xform only through LUT's. This is not ideal, and an API to improve that
should be proposed in the future.
But we still want to experiment with offloading pre-blend (not post)
color transformation through the colorop API, which is close to being
accepted upstream. But this requires us to offload post-blend as well.
weston_color_curve_to_3x1D_LUT() currently fails if we detect that
crafting a LUT from the color curve may result in bad precision.
Instead, let's add a boolean param to control if we forbid or not bad
precision. This should allow us to offload post-blend xform through
LUT's.
This also improves the error messages in this function.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Since "color: do not use color steps for non-optimized pipelines",
WESTON_COLOR_MAPPING_TYPE_3D_LUT became unused. So drop it from our
code.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
For non-optimized pipelines, stop using the color steps (pre curve,
color mapping and post curve). Instead, make use of the
xform->to_shaper_plus_3dlut() vfunc.
In this patch we add a bool to signalize that the steps are valid (for
optimized pipelines) or not. If not (non-optimized ones), the vfunc must
be used.
This brings flexibility for the renderer/backend implementing the xform.
For now we only implement xform's in the GL-renderer, and this has no
behavior changes. It should be relevant when we implement the xform in
our DRM-backend, see commit "color: add to_shaper_plus_3dlut() vfunc to
struct weston_color_transform".
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
This function allow us to get a shaper (3x1D LUT) + 3D LUT that is
equivalent to a certain xform.
With that, we allow backend/renderer that are not capable of handling
the color steps of the xform to fallback to something else.
E.g. when we introduce the code to offload color xform to KMS using the
DRM-backend, we'll depend on the driver/hardware implementing the color
steps. With this patch, DRM-backend should be able to fallback to a
shaper (3x1D LUT) + 3DLUT, color operations that should be commonly
supported by drivers/hardwares.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Replace a plain array with a type-safe documented structure.
This will get more wide use later.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
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>
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>
When we create a parametric color profile (we still do not fully
support, but plan to), a struct weston_color_tf_info is created.
So add a new function weston_color_curve_from_tf_info() to create a
color curve given a transfer function.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Not all color curves comes from parameters. For instance, with the
CM&HDR protocol users can set color curves from tf_info.
So let's add a new curve type to accommodate that.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
This just makes the code more readable and should help us to avoid
mistakes in the future. No behavior changes.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Up to now we were using 10 as the max number of params for color curves
and transfer functions. But this came from LittleCMS, whose parametric
curves may contain up to 10 params.
But out color curves and tf's are not tied to LittleCMS, so let's define
constants to help avoid confusion.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Start to print the parameters from struct cmlcms_color_profile::params
in cmlcms_color_profile_print(). This will be useful for the next
commit, in which we add tests that craft parametric color profiles.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
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>
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>
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>
Add function to color managers to create color profiles from parameters.
This will be used by the parametric color profile builder that we'll add
in the next commit.
WARNING: 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.
Co-authored-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
In the next commits we'll start support clients that want to create
image descriptions through params using the CM&HDR protocol extension.
In order to do that, we'll have to expose the primaries and transfer
functions that the color manager supports. So keep track of that.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Based on KMS "Colorspace" connector property, populate the mask of
supported colorimetry modes on a head.
EDID should be checked too, but it is currently ignored.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This API is mostly for use by the DRM-backend. Colorimetry mode is is
the KMS connector property "Colorspace" which defines the video signal
encoding colorimetry. A video sink indicates the supported modes in EDID
or DisplayID.
This patch adds the libweston API that allows backends to indicate the
supported modes for the frontends, and frontends to set the mode to be
used by backends. Colorimetry mode does not directly affect color
management inside Weston, it is only metadata for the video sink. It is
the frontend's responsibility to set up an output color profile that
agrees with the colorimetry mode. (That API has not been implemented
yet.) eotf_mode will be the same.
There is only one reason to make this a libweston core API instead of
a backend-drm API: when wayland-backend gains color-management protocol
support, meaning it can forward WCG and HDR content correctly to a
host compositor, the supported colorimetry modes can be determined from
the host compositor's supported color-management features, allowing the
guest Weston to pick some other output image description than the host
compositor's preferred image description. This likely allows only a few
other choices from standard colorspaces, so it's possible this isn't
sufficient for that use case.
Either way, it is easy to just copy the eotf_mode API design, and since
colorimetry_mode and eotf_mode go together, let both have the same API
design. It is possible to convert this to backend-drm API later.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Turns out these structures do not need to be in the public header, so
move them into a private header.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Until now, all the curves would be represented with 3x1D LUT's. Now we
support LINPOW and POWLIN curves (arbitrary names that we've picked).
We can use these curves to represent LittleCMS curves type 1, 4 and
their inverses -1, -4. The reason why we want that is because we gain
precision using the parametric curves (compared to the LUT's);
Surprisingly we had to increase the tolerance of the sRGB->adobeRGB MAT
test. Our analysis is that the inverse EOTF power-law curve with
exponent 1.0 / 2.2 amplifies errors more than the LUT, specially for
input (optical) values closer to zero.
That makes sense, because this curve is more sensible to input values
closer to zero (i.e. little input variation results in lots of output
variation). And this model makes sense, as humans are more capable of
perceiving changes of light intensity in the dark.
But the downside of all that is that for input values closer to zero, a
little bit of noise increases significantly the error.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Just like with color profiles, generate an ID for color transformations
as well. This is not needed by protocol or anything, it is just for
debugging purposes. A small ID is easier for humans than a long pointer
value.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This reverts commit 188a3ebd5e.
Call weston_compositor_enable_color_management_protocol() after
compositor->color_manager has been set, and so allows to check if the
color manager supports the features mandatory in protocol. The check is
added in the next patch.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This makes it more explicit that this indeed is increasing the reference
count, rather than just returning a pointer.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
In this patch we enable the color-management protocol support, as long
as the color-manager plugin in use supports it.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
In this MR we add support to the majority of the interfaces from the
color-management protocol.
That means that we are able to advertise output's images descriptions to
clients, preferred surface images descriptions, and so on. We also
support clients that wants to create ICC-based images descriptions and
set such descriptions for surfaces.
We still don't support the interface to allow clients to create
image descriptions from parameters, but that should be addressed
in the near future.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
This is preparation for the CM&HDR protocol implementation. It requires
us to give a unique id to each color-profile, so let's do that.
In this commit we introduce a generic id generator to libweston, and
its first user: the color-profile.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
In the next commit we'll stop using NULL as the stock sRGB color
profile, so add a function to the color manager to allow libweston core
to have access to the stock sRGB profile.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
It prints the existent color transformations for new subscribers. Also
prints any creation/destruction of color transformations.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Add matrix in color.h
Matrix is used as an optimized method for
color mapping vs 3DLUT.
Nothing sets color mapping to matrix yet.
Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
Add post-curve support in color.h.
Pre-curve and post-curve describe color pipeline components
in a single GL shader invocation.The GL shader is supposed
to match struct weston_color_transform exactly.
We have the following color pipeline:
shader A -> blending -> shader B -> KMS. Both A and B shaders
using the same source file :fragment.glsl.
Each shader has pre and post curve.
The typical color pipeline with 3DLUT:
Shader A: pre-curve identity->3DLUT->blending->post-curve identity
Shader B: pre-curve->3DLUT identity->post-curve identity->KMS
The typical color pipeline with matrix (in next commits):
Shader A: pre-curve->matrix->blending->post-curve identity
Shader B: pre-curve->matrix identity->post-curve identity->KMS
The pre-curve plays role of EOTF (shader A) or INV_EOTF
(shader B) becouse we are stiching the shaders.
We assume that someone in the future may use both pre-curve
and post-curve, for example, when it is not possible to combine
these curves into 3DLUT and we will do mapping elements based on
their location in ICC profile.
Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
I am going to need to add yet another output property to be set by a
color manager: HDR Static Metadata Type 1. With the old color manager
API design, I would have needed to add the fourth function pointer to be
called always in the same group as the previous three. This seemed more
convoluted than it needs to be.
Therefore collapse the three existing function pointers in the API into
just one that is resposible for setting up all three things.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
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>
Check whether HDR_OUTPUT_METADATA property exists on a KMS connector. If
yes, pretend that EDID claims support for all EOTF modes and update the
head supported EOTFs mask accordingly. If not, then only SDR is
possible.
Parsing EDID to take monitor capabilities into account is left for
later.
HDR mode cannot be set without HDR_OUTPUT_METADATA.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This is the switch to turn HDR mode on.
The values in the enumeration come straight from CTA-861-G standard.
Monitors advertise support for some of the HDR modes in their EDID, and
I am not aware of any other way to detect if a HDR mode actually works
or not. Different monitors may support different and multiple modes.
Different modes may look different. Therefore the high-level choice of
how to drive a HDR video sink is left for the Weston frontend to decide.
All the details like what HDR metadata to use are left for the color
manager.
This commit adds the libweston API for backends to advertise support and
for frontends to choose a mode. Backend and frontend implementations
follow in other commits.
The frontend API does not limit the EOTF mode to the supported ones to
allow experimentation and overriding EDID.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Introduce 3D LUT definition as part of Weston
color transform struct. A 3D LUT is a LUT containing
entries for each possible RGB triplets.
Co-authored-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>