color-lcms: create log scopes in cmlcms_init()
This does not change any behaviour, but creating complex dynamic things was intended to be done in init() rather than color_manager_create(). Create is called from weston_compositor_load_color_manager() before loading backends, and init is called from weston_compositor_backends_loaded() after loading backends. Now we assert instead of check that scope creation succeeded, because the only way it could fail is to have small memory allocations fail, or internal code error. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
parent
3e9f8402ad
commit
80c0d5e643
@ -394,27 +394,57 @@ static bool
|
||||
cmlcms_init(struct weston_color_manager *cm_base)
|
||||
{
|
||||
struct weston_color_manager_lcms *cm = to_cmlcms(cm_base);
|
||||
struct weston_compositor *compositor = cm->base.compositor;
|
||||
|
||||
if (!(cm->base.compositor->capabilities & WESTON_CAP_COLOR_OPS)) {
|
||||
if (!(compositor->capabilities & WESTON_CAP_COLOR_OPS)) {
|
||||
weston_log("color-lcms: error: color operations capability missing. Is GL-renderer not in use?\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
cm->transforms_scope =
|
||||
weston_compositor_add_log_scope(compositor, "color-lcms-transformations",
|
||||
"Color transformation creation and destruction.\n",
|
||||
transforms_scope_new_sub, NULL, cm);
|
||||
weston_assert_ptr(compositor, cm->transforms_scope);
|
||||
|
||||
cm->optimizer_scope =
|
||||
weston_compositor_add_log_scope(compositor, "color-lcms-optimizer",
|
||||
"Color transformation pipeline optimizer. It's best " \
|
||||
"used together with the color-lcms-transformations " \
|
||||
"log scope.\n", NULL, NULL, NULL);
|
||||
weston_assert_ptr(compositor, cm->optimizer_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);
|
||||
weston_assert_ptr(compositor, cm->profiles_scope);
|
||||
|
||||
cm->lcms_ctx = cmsCreateContext(NULL, cm);
|
||||
if (!cm->lcms_ctx) {
|
||||
weston_log("color-lcms error: creating LittCMS context failed.\n");
|
||||
return false;
|
||||
goto out_err;
|
||||
}
|
||||
|
||||
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;
|
||||
goto out_err;
|
||||
}
|
||||
weston_log("LittleCMS %d initialized.\n", cmsGetEncodedCMMversion());
|
||||
|
||||
return true;
|
||||
|
||||
out_err:
|
||||
weston_log_scope_destroy(cm->transforms_scope);
|
||||
cm->transforms_scope = NULL;
|
||||
weston_log_scope_destroy(cm->optimizer_scope);
|
||||
cm->optimizer_scope = NULL;
|
||||
weston_log_scope_destroy(cm->profiles_scope);
|
||||
cm->profiles_scope = NULL;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -494,29 +524,5 @@ weston_color_manager_create(struct weston_compositor *compositor)
|
||||
wl_list_init(&cm->color_transform_list);
|
||||
wl_list_init(&cm->color_profile_list);
|
||||
|
||||
cm->transforms_scope =
|
||||
weston_compositor_add_log_scope(compositor, "color-lcms-transformations",
|
||||
"Color transformation creation and destruction.\n",
|
||||
transforms_scope_new_sub, NULL, cm);
|
||||
cm->optimizer_scope =
|
||||
weston_compositor_add_log_scope(compositor, "color-lcms-optimizer",
|
||||
"Color transformation pipeline optimizer. It's best " \
|
||||
"used together with the color-lcms-transformations " \
|
||||
"log scope.\n", NULL, NULL, NULL);
|
||||
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 || !cm->optimizer_scope)
|
||||
goto err;
|
||||
|
||||
return &cm->base;
|
||||
|
||||
err:
|
||||
weston_log_scope_destroy(cm->transforms_scope);
|
||||
weston_log_scope_destroy(cm->optimizer_scope);
|
||||
weston_log_scope_destroy(cm->profiles_scope);
|
||||
free(cm);
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user