color-lcms: move output-only fields from cmlcms_color_profile

Refactoring to allow the next patch, no functional changes.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
Pekka Paalanen 2024-02-22 14:59:06 +02:00 committed by Pekka Paalanen
parent 5d6e7115a9
commit 7ccb9736b3
3 changed files with 41 additions and 41 deletions

View file

@ -57,6 +57,31 @@ struct cmlcms_md5_sum {
uint8_t bytes[16];
};
struct cmlcms_output_profile_extract {
/** The curves to decode an electrical signal
*
* For ICC profiles, if the profile type is matrix-shaper, then eotf
* contains the TRC, otherwise eotf contains an approximated EOTF.
*/
cmsToneCurve *eotf[3];
/**
* This field represents a concatenation of inverse EOTF + VCGT,
* if the tag exists and it can not be null.
* VCGT is part of monitor calibration which means: even though we must
* apply VCGT in the compositor, we pretend that it happens inside the
* monitor. This is how the classic color management and ICC profiles work.
* The ICC profile (ignoring the VCGT tag) characterizes the output which
* is VCGT + monitor behavior.
*/
cmsToneCurve *output_inv_eotf_vcgt[3];
/**
* VCGT tag cached from output profile, it could be null if not exist
*/
cmsToneCurve *vcgt[3];
};
struct cmlcms_color_profile {
struct weston_color_profile base;
@ -69,33 +94,8 @@ struct cmlcms_color_profile {
/* Only for profiles created from an ICC file. */
struct ro_anonymous_file *prof_rofile;
/** The curves to decode an electrical signal
*
* For ICC profiles, if the profile type is matrix-shaper, then eotf
* contains the TRC, otherwise eotf contains an approximated EOTF if the
* profile is used for output.
* The field may be populated on demand.
*/
cmsToneCurve *eotf[3];
/**
* If the profile does support being an output profile and it is used as an
* output then this field represents a concatenation of inverse EOTF + VCGT,
* if the tag exists and it can not be null.
* VCGT is part of monitor calibration which means: even though we must
* apply VCGT in the compositor, we pretend that it happens inside the
* monitor. This is how the classic color management and ICC profiles work.
* The ICC profile (ignoring the VCGT tag) characterizes the output which
* is VCGT + monitor behavior. The field is null only if the profile is not
* usable as an output profile. The field is set when cmlcms_color_profile
* is created.
*/
cmsToneCurve *output_inv_eotf_vcgt[3];
/**
* VCGT tag cached from output profile, it could be null if not exist
*/
cmsToneCurve *vcgt[3];
/* Populated only when profile used as output profile */
struct cmlcms_output_profile_extract extract;
};
/**

View file

@ -346,9 +346,9 @@ cmlcms_color_profile_destroy(struct cmlcms_color_profile *cprof)
struct weston_color_manager_lcms *cm = to_cmlcms(cprof->base.cm);
wl_list_remove(&cprof->link);
cmsFreeToneCurveTriple(cprof->vcgt);
cmsFreeToneCurveTriple(cprof->eotf);
cmsFreeToneCurveTriple(cprof->output_inv_eotf_vcgt);
cmsFreeToneCurveTriple(cprof->extract.vcgt);
cmsFreeToneCurveTriple(cprof->extract.eotf);
cmsFreeToneCurveTriple(cprof->extract.output_inv_eotf_vcgt);
cmsCloseProfile(cprof->profile);
/* Only profiles created from ICC files have these. */
@ -433,9 +433,9 @@ cmlcms_create_stock_profile(struct weston_color_manager_lcms *cm)
if (!retrieve_eotf_and_output_inv_eotf(cm->lcms_ctx,
cm->sRGB_profile->profile,
cm->sRGB_profile->eotf,
cm->sRGB_profile->output_inv_eotf_vcgt,
cm->sRGB_profile->vcgt,
cm->sRGB_profile->extract.eotf,
cm->sRGB_profile->extract.output_inv_eotf_vcgt,
cm->sRGB_profile->extract.vcgt,
cmlcms_reasonable_1D_points()))
goto err_close;

View file

@ -96,7 +96,7 @@ cmlcms_fill_in_output_inv_eotf_vcgt(struct weston_color_transform *xform_base,
struct cmlcms_color_profile *p = xform->search_key.output_profile;
assert(p && "output_profile");
fill_in_curves(p->output_inv_eotf_vcgt, values, len);
fill_in_curves(p->extract.output_inv_eotf_vcgt, values, len);
}
static void
@ -894,14 +894,14 @@ xform_realize_chain(struct cmlcms_color_transform *xform)
switch (xform->search_key.category) {
case CMLCMS_CATEGORY_INPUT_TO_BLEND:
/* Add linearization step to make blending well-defined. */
extra = profile_from_rgb_curves(cm->lcms_ctx, output_profile->eotf);
extra = profile_from_rgb_curves(cm->lcms_ctx, output_profile->extract.eotf);
chain[chain_len++] = extra;
break;
case CMLCMS_CATEGORY_INPUT_TO_OUTPUT:
/* Just add VCGT if it is provided. */
if (output_profile->vcgt[0]) {
if (output_profile->extract.vcgt[0]) {
extra = profile_from_rgb_curves(cm->lcms_ctx,
output_profile->vcgt);
output_profile->extract.vcgt);
chain[chain_len++] = extra;
}
break;
@ -1012,12 +1012,12 @@ cmlcms_color_transform_create(struct weston_color_manager_lcms *cm,
free(str);
/* Ensure the linearization etc. have been extracted. */
if (!search_param->output_profile->eotf[0]) {
if (!search_param->output_profile->extract.eotf[0]) {
if (!retrieve_eotf_and_output_inv_eotf(cm->lcms_ctx,
search_param->output_profile->profile,
search_param->output_profile->eotf,
search_param->output_profile->output_inv_eotf_vcgt,
search_param->output_profile->vcgt,
search_param->output_profile->extract.eotf,
search_param->output_profile->extract.output_inv_eotf_vcgt,
search_param->output_profile->extract.vcgt,
cmlcms_reasonable_1D_points())) {
err_msg = "retrieve_eotf_and_output_inv_eotf failed";
goto error;