color-lcms: introduce sRGB stock profile

The stock profile would be used when client or output
do not provide any profile or unaware of color management.

Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
dev
Vitaly Prosyak 3 years ago
parent a92fa34d1d
commit 19f318692e
  1. 6
      libweston/color-lcms/color-lcms.c
  2. 7
      libweston/color-lcms/color-lcms.h
  3. 40
      libweston/color-lcms/color-profile.c

@ -165,6 +165,10 @@ cmlcms_init(struct weston_color_manager *cm_base)
cmsSetLogErrorHandlerTHR(cm->lcms_ctx, lcms_error_logger); cmsSetLogErrorHandlerTHR(cm->lcms_ctx, lcms_error_logger);
if (!cmlcms_create_stock_profile(cm)) {
weston_log("color-lcms: error: cmlcms_create_stock_profile failed\n");
return false;
}
weston_log("LittleCMS %d initialized.\n", cmsGetEncodedCMMversion()); weston_log("LittleCMS %d initialized.\n", cmsGetEncodedCMMversion());
return true; return true;
@ -175,6 +179,8 @@ cmlcms_destroy(struct weston_color_manager *cm_base)
{ {
struct weston_color_manager_lcms *cm = get_cmlcms(cm_base); struct weston_color_manager_lcms *cm = get_cmlcms(cm_base);
if (cm->sRGB_profile)
cmlcms_color_profile_destroy(cm->sRGB_profile);
assert(wl_list_empty(&cm->color_transform_list)); assert(wl_list_empty(&cm->color_transform_list));
assert(wl_list_empty(&cm->color_profile_list)); assert(wl_list_empty(&cm->color_profile_list));

@ -39,6 +39,7 @@ struct weston_color_manager_lcms {
struct wl_list color_transform_list; /* cmlcms_color_transform::link */ struct wl_list color_transform_list; /* cmlcms_color_transform::link */
struct wl_list color_profile_list; /* cmlcms_color_profile::link */ struct wl_list color_profile_list; /* cmlcms_color_profile::link */
struct cmlcms_color_profile *sRGB_profile; /* stock profile */
}; };
static inline struct weston_color_manager_lcms * static inline struct weston_color_manager_lcms *
@ -186,4 +187,10 @@ ref_cprof(struct cmlcms_color_profile *cprof);
void void
unref_cprof(struct cmlcms_color_profile *cprof); unref_cprof(struct cmlcms_color_profile *cprof);
bool
cmlcms_create_stock_profile(struct weston_color_manager_lcms *cm);
void
cmlcms_color_profile_destroy(struct cmlcms_color_profile *cprof);
#endif /* WESTON_COLOR_LCMS_H */ #endif /* WESTON_COLOR_LCMS_H */

@ -102,7 +102,7 @@ cmlcms_color_profile_create(struct weston_color_manager_lcms *cm,
return cprof; return cprof;
} }
static void void
cmlcms_color_profile_destroy(struct cmlcms_color_profile *cprof) cmlcms_color_profile_destroy(struct cmlcms_color_profile *cprof)
{ {
wl_list_remove(&cprof->link); wl_list_remove(&cprof->link);
@ -153,6 +153,44 @@ make_icc_file_description(cmsHPROFILE profile,
return desc; return desc;
} }
/**
*
* Build stock profile which available for clients unaware of color management
*/
bool
cmlcms_create_stock_profile(struct weston_color_manager_lcms *cm)
{
cmsHPROFILE profile;
struct cmlcms_md5_sum md5sum;
char *desc = NULL;
profile = cmsCreate_sRGBProfileTHR(cm->lcms_ctx);
if (!profile) {
weston_log("color-lcms: error: cmsCreate_sRGBProfileTHR failed\n");
return false;
}
if (!cmsMD5computeID(profile)) {
weston_log("Failed to compute MD5 for ICC profile\n");
goto err_close;
}
cmsGetHeaderProfileID(profile, md5sum.bytes);
desc = make_icc_file_description(profile, &md5sum, "sRGB stock");
if (!desc)
goto err_close;
cm->sRGB_profile = cmlcms_color_profile_create(cm, profile, desc, NULL);
if (!cm->sRGB_profile)
goto err_close;
return true;
err_close:
free(desc);
cmsCloseProfile(profile);
return false;
}
bool bool
cmlcms_get_color_profile_from_icc(struct weston_color_manager *cm_base, cmlcms_get_color_profile_from_icc(struct weston_color_manager *cm_base,
const void *icc_data, const void *icc_data,

Loading…
Cancel
Save