color-lcms: add translate_curve_element_LUT()

Currently in translate_curve_element() we always translate the curve
into a LUT. But in the future we'll be able to translate the curves to
parametric ones.

So move the current code to a new function
translate_curve_element_LUT(), so that in translate_curve_element() we
are able to call one of the two functions (_LUT() or _parametric()).

No behavior changes, just preparation for the upcoming patches.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
This commit is contained in:
Leandro Ribeiro 2024-03-07 17:32:19 -03:00 committed by Pekka Paalanen
parent 80d97db856
commit aff6029da2
2 changed files with 24 additions and 10 deletions

View File

@ -470,22 +470,15 @@ enum color_transform_step {
};
static bool
translate_curve_element(struct cmlcms_color_transform *xform,
cmsStage *elem, enum color_transform_step step)
translate_curve_element_LUT(struct cmlcms_color_transform *xform,
_cmsStageToneCurvesData *trc_data,
enum color_transform_step step)
{
struct weston_compositor *compositor = xform->base.cm->compositor;
struct weston_color_curve *curve;
cmsToneCurve **stash;
_cmsStageToneCurvesData *trc_data;
unsigned i;
weston_assert_uint64_eq(compositor, cmsStageType(elem),
cmsSigCurveSetElemType);
trc_data = cmsStageData(elem);
if (trc_data->nCurves != 3)
return false;
switch(step) {
case PRE_CURVE:
curve = &xform->base.pre_curve;
@ -505,6 +498,7 @@ translate_curve_element(struct cmlcms_color_transform *xform,
curve->type = WESTON_COLOR_CURVE_TYPE_LUT_3x1D;
curve->u.lut_3x1d.optimal_len = cmlcms_reasonable_1D_points();
weston_assert_uint32_eq(compositor, trc_data->nCurves, 3);
for (i = 0; i < 3; i++) {
stash[i] = cmsDupToneCurve(trc_data->TheCurves[i]);
abort_oom_if_null(stash[i]);
@ -513,6 +507,23 @@ translate_curve_element(struct cmlcms_color_transform *xform,
return true;
}
static bool
translate_curve_element(struct cmlcms_color_transform *xform,
cmsStage *elem, enum color_transform_step step)
{
struct weston_compositor *compositor = xform->base.cm->compositor;
_cmsStageToneCurvesData *trc_data;
weston_assert_uint64_eq(compositor, cmsStageType(elem),
cmsSigCurveSetElemType);
trc_data = cmsStageData(elem);
if (trc_data->nCurves != 3)
return false;
return translate_curve_element_LUT(xform, trc_data, step);
}
static bool
translate_matrix_element(struct weston_color_mapping *map, cmsStage *elem)
{

View File

@ -97,6 +97,9 @@ do { \
#define weston_assert_double_eq(compositor, a, b) \
weston_assert_(compositor, a, b, double, "%.10g", ==)
#define weston_assert_uint32_eq(compositor, a, b) \
weston_assert_(compositor, a, b, uint32_t, "%u", ==)
#define weston_assert_uint32_neq(compositor, a, b) \
weston_assert_(compositor, a, b, uint32_t, "%u", !=)