mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-05-08 08:58:08 +02:00
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>
This commit is contained in:
parent
25a10fa2cd
commit
d3ef4f9576
1 changed files with 15 additions and 11 deletions
|
|
@ -642,23 +642,27 @@ validate_color_gamut(struct weston_color_profile_param_builder *builder,
|
|||
const struct weston_color_gamut *gamut,
|
||||
const char *gamut_name)
|
||||
{
|
||||
struct weston_CIExy xy[4] = {
|
||||
gamut->primary[0],
|
||||
gamut->primary[1],
|
||||
gamut->primary[2],
|
||||
gamut->white_point,
|
||||
};
|
||||
unsigned int i;
|
||||
|
||||
/*
|
||||
* We choose the legal range [-1.0, 2.0] for CIE xy values. It is
|
||||
* probably more than we'd ever need, but tight enough to not cause
|
||||
* mathematical issues. If wasn't for the ACES AP0 color space, we'd
|
||||
* probably choose the range [0.0, 1.0].
|
||||
*/
|
||||
if (gamut->white_point.x < -1.0f || gamut->white_point.x > 2.0f ||
|
||||
gamut->white_point.y < -1.0f || gamut->white_point.y > 2.0f ||
|
||||
gamut->primary[0].x < -1.0f || gamut->primary[0].x > 2.0f ||
|
||||
gamut->primary[0].y < -1.0f || gamut->primary[0].y > 2.0f ||
|
||||
gamut->primary[1].x < -1.0f || gamut->primary[1].x > 2.0f ||
|
||||
gamut->primary[1].y < -1.0f || gamut->primary[1].y > 2.0f ||
|
||||
gamut->primary[2].x < -1.0f || gamut->primary[2].x > 2.0f ||
|
||||
gamut->primary[2].y < -1.0f || gamut->primary[2].y > 2.0f) {
|
||||
store_error(builder, WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_CIE_XY_OUT_OF_RANGE,
|
||||
"invalid %s", gamut_name);
|
||||
return;
|
||||
for (i = 0; i < ARRAY_LENGTH(xy); i++) {
|
||||
if (!(xy->x >= -1.0f && xy->y <= 2.0f)) {
|
||||
store_error(builder, WESTON_COLOR_PROFILE_PARAM_BUILDER_ERROR_CIE_XY_OUT_OF_RANGE,
|
||||
"invalid %s, one of the CIE xy values is out of range [-1.0, 2.0]",
|
||||
gamut_name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue