summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeandro Ribeiro <leandro.ribeiro@collabora.com>2023-03-06 17:25:49 -0300
committerPekka Paalanen <pq@iki.fi>2023-04-12 10:03:32 +0000
commita28e0c26e1e1995e0a05607715696bf4e13c813d (patch)
tree0372c8f33cd55823904760e6867c1fb72b9e67d0
parentd827bdd5d48efc5960f9218fd72e6866ad9ec6a7 (diff)
downloadweston-a28e0c26e1e1995e0a05607715696bf4e13c813d.tar.gz
color-lcms: add debug scope for color profiles
It prints the existent color profiles for new subscribers. Also prints any creation/destruction of color profiles. Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
-rw-r--r--libweston/color-lcms/color-lcms.c30
-rw-r--r--libweston/color-lcms/color-lcms.h4
-rw-r--r--libweston/color-lcms/color-profile.c26
3 files changed, 59 insertions, 1 deletions
diff --git a/libweston/color-lcms/color-lcms.c b/libweston/color-lcms/color-lcms.c
index fc1d5986..aa97f7f7 100644
--- a/libweston/color-lcms/color-lcms.c
+++ b/libweston/color-lcms/color-lcms.c
@@ -389,6 +389,7 @@ cmlcms_destroy(struct weston_color_manager *cm_base)
cmsDeleteContext(cm->lcms_ctx);
weston_log_scope_destroy(cm->transforms_scope);
+ weston_log_scope_destroy(cm->profiles_scope);
free(cm);
}
@@ -417,6 +418,26 @@ transforms_scope_new_sub(struct weston_log_subscription *subs, void *data)
}
}
+static void
+profiles_scope_new_sub(struct weston_log_subscription *subs, void *data)
+{
+ struct weston_color_manager_lcms *cm = data;
+ struct cmlcms_color_profile *cprof;
+ char *str;
+
+ if (wl_list_empty(&cm->color_profile_list))
+ return;
+
+ weston_log_subscription_printf(subs, "Existent:\n");
+ wl_list_for_each(cprof, &cm->color_profile_list, link) {
+ weston_log_subscription_printf(subs, "Color profile %p:\n", cprof);
+
+ str = cmlcms_color_profile_print(cprof);
+ weston_log_subscription_printf(subs, "%s", str);
+ free(str);
+ }
+}
+
WL_EXPORT struct weston_color_manager *
weston_color_manager_create(struct weston_compositor *compositor)
{
@@ -444,12 +465,19 @@ weston_color_manager_create(struct weston_compositor *compositor)
weston_compositor_add_log_scope(compositor, "color-lcms-transformations",
"Color transformation creation and destruction.\n",
transforms_scope_new_sub, NULL, cm);
- if (!cm->transforms_scope)
+ cm->profiles_scope =
+ weston_compositor_add_log_scope(compositor, "color-lcms-profiles",
+ "Color profile creation and destruction.\n",
+ profiles_scope_new_sub, NULL, cm);
+
+ if (!cm->profiles_scope || !cm->transforms_scope)
goto err;
return &cm->base;
err:
+ weston_log_scope_destroy(cm->transforms_scope);
+ weston_log_scope_destroy(cm->profiles_scope);
free(cm);
return NULL;
}
diff --git a/libweston/color-lcms/color-lcms.h b/libweston/color-lcms/color-lcms.h
index 834b0b26..bcaa6d26 100644
--- a/libweston/color-lcms/color-lcms.h
+++ b/libweston/color-lcms/color-lcms.h
@@ -36,6 +36,7 @@
struct weston_color_manager_lcms {
struct weston_color_manager base;
+ struct weston_log_scope *profiles_scope;
struct weston_log_scope *transforms_scope;
cmsContext lcms_ctx;
@@ -222,6 +223,9 @@ cmlcms_create_stock_profile(struct weston_color_manager_lcms *cm);
void
cmlcms_color_profile_destroy(struct cmlcms_color_profile *cprof);
+char *
+cmlcms_color_profile_print(const struct cmlcms_color_profile *cprof);
+
bool
retrieve_eotf_and_output_inv_eotf(cmsContext lcms_ctx,
cmsHPROFILE hProfile,
diff --git a/libweston/color-lcms/color-profile.c b/libweston/color-lcms/color-profile.c
index 431348b2..6fa9cd04 100644
--- a/libweston/color-lcms/color-profile.c
+++ b/libweston/color-lcms/color-profile.c
@@ -35,6 +35,7 @@
#include "color-lcms.h"
#include "shared/helpers.h"
#include "shared/string-helpers.h"
+#include "shared/xalloc.h"
struct xyz_arr_flt {
float v[3];
@@ -298,6 +299,17 @@ cmlcms_find_color_profile_by_md5(const struct weston_color_manager_lcms *cm,
return NULL;
}
+char *
+cmlcms_color_profile_print(const struct cmlcms_color_profile *cprof)
+{
+ char *str;
+
+ str_printf(&str, " description: %s\n", cprof->base.description);
+ abort_oom_if_null(str);
+
+ return str;
+}
+
static struct cmlcms_color_profile *
cmlcms_color_profile_create(struct weston_color_manager_lcms *cm,
cmsHPROFILE profile,
@@ -305,6 +317,7 @@ cmlcms_color_profile_create(struct weston_color_manager_lcms *cm,
char **errmsg)
{
struct cmlcms_color_profile *cprof;
+ char *str;
cprof = zalloc(sizeof *cprof);
if (!cprof)
@@ -316,17 +329,30 @@ cmlcms_color_profile_create(struct weston_color_manager_lcms *cm,
cmsGetHeaderProfileID(profile, cprof->md5sum.bytes);
wl_list_insert(&cm->color_profile_list, &cprof->link);
+ weston_log_scope_printf(cm->profiles_scope,
+ "New color profile: %p\n", cprof);
+
+ str = cmlcms_color_profile_print(cprof);
+ weston_log_scope_printf(cm->profiles_scope, "%s", str);
+ free(str);
+
return cprof;
}
void
cmlcms_color_profile_destroy(struct cmlcms_color_profile *cprof)
{
+ struct weston_color_manager_lcms *cm = get_cmlcms(cprof->base.cm);
+
wl_list_remove(&cprof->link);
cmsFreeToneCurveTriple(cprof->vcgt);
cmsFreeToneCurveTriple(cprof->eotf);
cmsFreeToneCurveTriple(cprof->output_inv_eotf_vcgt);
cmsCloseProfile(cprof->profile);
+
+ weston_log_scope_printf(cm->profiles_scope, "Destroyed color profile %p. " \
+ "Description: %s\n", cprof, cprof->base.description);
+
free(cprof->base.description);
free(cprof);
}