libweston: begin color-lcms plugin

This creates the color-lcms plugin that in the future will be using
Little CMS as the color matching module, processing ICC profiles, and
producing HDR tone mappings.

Right now, this new plugin is functionally equivalent to the no-op color
manager, except it already links to lcms2 and checks that the renderer
supports color operations.

Color-lcms is a libweston plugin that is loaded with explicit
weston_compositor API. This does not currently allow loading alternative
color manager plugins. External color manager plugins might be
considered in the future when the libweston APIs around color management
stabilize.

This libweston plugin uses the same build option as the old cms-static
Weston plugins, as they both need lcms2. The minimum version for lcms2
was chosen by what Debian Buster provides today and for no other reason.

This plugin intends to support the Wayland CM&HDR protocol extension and
hence sets supports_client_protocol to true. This will expose the
protocol extension to clients when it gets implemented.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
dev
Pekka Paalanen 4 years ago committed by Pekka Paalanen
parent 8fb23ed110
commit 5e79dd4892
  1. 3
      include/libweston/libweston.h
  2. 130
      libweston/color-lcms/color-lcms.c
  3. 44
      libweston/color-lcms/color-lcms.h
  4. 29
      libweston/color-lcms/meson.build
  5. 4
      libweston/color.h
  6. 35
      libweston/compositor.c
  7. 1
      libweston/meson.build
  8. 2
      meson_options.txt

@ -2001,6 +2001,9 @@ weston_keyboard_send_keymap(struct weston_keyboard *kbd,
int
weston_compositor_load_xwayland(struct weston_compositor *compositor);
int
weston_compositor_load_color_manager(struct weston_compositor *compositor);
bool
weston_head_is_connected(struct weston_head *head);

@ -0,0 +1,130 @@
/*
* Copyright 2021 Collabora, Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "config.h"
#include <lcms2.h>
#include <libweston/libweston.h>
#include "color.h"
#include "color-lcms.h"
#include "shared/helpers.h"
static void
cmlcms_destroy_color_transform(struct weston_color_transform *xform_base)
{
}
static bool
cmlcms_get_surface_color_transform(struct weston_color_manager *cm_base,
struct weston_surface *surface,
struct weston_output *output,
struct weston_surface_color_transform *surf_xform)
{
/* Identity transform */
surf_xform->transform = NULL;
surf_xform->identity_pipeline = true;
return true;
}
static bool
cmlcms_get_output_color_transform(struct weston_color_manager *cm_base,
struct weston_output *output,
struct weston_color_transform **xform_out)
{
/* Identity transform */
*xform_out = NULL;
return true;
}
static bool
cmlcms_get_sRGB_to_output_color_transform(struct weston_color_manager *cm_base,
struct weston_output *output,
struct weston_color_transform **xform_out)
{
/* Identity transform */
*xform_out = NULL;
return true;
}
static bool
cmlcms_get_sRGB_to_blend_color_transform(struct weston_color_manager *cm_base,
struct weston_output *output,
struct weston_color_transform **xform_out)
{
/* Identity transform */
*xform_out = NULL;
return true;
}
static bool
cmlcms_init(struct weston_color_manager *cm_base)
{
if (!(cm_base->compositor->capabilities & WESTON_CAP_COLOR_OPS)) {
weston_log("color-lcms: error: color operations capability missing. Is GL-renderer not in use?\n");
return false;
}
return true;
}
static void
cmlcms_destroy(struct weston_color_manager *cm_base)
{
struct weston_color_manager_lcms *cmlcms = get_cmlcms(cm_base);
free(cmlcms);
}
WL_EXPORT struct weston_color_manager *
weston_color_manager_create(struct weston_compositor *compositor)
{
struct weston_color_manager_lcms *cm;
cm = zalloc(sizeof *cm);
if (!cm)
return NULL;
cm->base.name = "work-in-progress";
cm->base.compositor = compositor;
cm->base.supports_client_protocol = true;
cm->base.init = cmlcms_init;
cm->base.destroy = cmlcms_destroy;
cm->base.destroy_color_transform = cmlcms_destroy_color_transform;
cm->base.get_surface_color_transform =
cmlcms_get_surface_color_transform;
cm->base.get_output_color_transform = cmlcms_get_output_color_transform;
cm->base.get_sRGB_to_output_color_transform =
cmlcms_get_sRGB_to_output_color_transform;
cm->base.get_sRGB_to_blend_color_transform =
cmlcms_get_sRGB_to_blend_color_transform;
return &cm->base;
}

@ -0,0 +1,44 @@
/*
* Copyright 2021 Collabora, Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef WESTON_COLOR_LCMS_H
#define WESTON_COLOR_LCMS_H
#include <libweston/libweston.h>
#include "color.h"
#include "shared/helpers.h"
struct weston_color_manager_lcms {
struct weston_color_manager base;
};
static inline struct weston_color_manager_lcms *
get_cmlcms(struct weston_color_manager *cm_base)
{
return container_of(cm_base, struct weston_color_manager_lcms, base);
}
#endif /* WESTON_COLOR_LCMS_H */

@ -0,0 +1,29 @@
if not get_option('color-management-lcms')
subdir_done()
endif
dep_lcms2 = dependency('lcms2', version: '>= 2.9', required: false)
if not dep_lcms2.found()
error('color-lcms plugin requires lcms2 which was not found. Or, you can use \'-Dcolor-management-lcms=false\'.')
endif
srcs_color_lcms = [
'color-lcms.c',
]
deps_color_lcms = [
dep_libm,
dep_libweston_private,
dep_lcms2,
]
plugin_color_lcms = shared_library(
'color-lcms',
srcs_color_lcms,
include_directories: common_inc,
dependencies: deps_color_lcms,
name_prefix: '',
install: true,
install_dir: dir_module_libweston
)
env_modmap += 'color-lcms.so=@0@;'.format(plugin_color_lcms.full_path())

@ -235,4 +235,8 @@ weston_paint_node_ensure_color_transform(struct weston_paint_node *pnode);
struct weston_color_manager *
weston_color_manager_noop_create(struct weston_compositor *compositor);
/* DSO module entrypoint */
struct weston_color_manager *
weston_color_manager_create(struct weston_compositor *compositor);
#endif /* WESTON_COLOR_H */

@ -8267,6 +8267,41 @@ weston_compositor_load_xwayland(struct weston_compositor *compositor)
return 0;
}
/** Load Little CMS color manager plugin
*
* Calling this function before loading any backend sets Little CMS
* as the active color matching module (CMM) instead of the default no-op
* color manager.
*
* \ingroup compositor
*/
WL_EXPORT int
weston_compositor_load_color_manager(struct weston_compositor *compositor)
{
struct weston_color_manager *
(*cm_create)(struct weston_compositor *compositor);
if (compositor->color_manager) {
weston_log("Error: Color manager '%s' is loaded, cannot load another.\n",
compositor->color_manager->name);
return -1;
}
cm_create = weston_load_module("color-lcms.so", "weston_color_manager_create");
if (!cm_create) {
weston_log("Error: Could not load color-lcms.so.\n");
return -1;
}
compositor->color_manager = cm_create(compositor);
if (!compositor->color_manager) {
weston_log("Error: loading color-lcms.so failed.\n");
return -1;
}
return 0;
}
/** Resolve an internal compositor error by disconnecting the client.
*
* This function is used in cases when the wl_buffer turns out

@ -246,6 +246,7 @@ if get_option('weston-launch')
meson.add_install_script('echo', 'REMINDER: You are installing weston-launch, please make it setuid-root.')
endif
subdir('color-lcms')
subdir('renderer-gl')
subdir('backend-drm')
subdir('backend-fbdev')

@ -142,7 +142,7 @@ option(
'color-management-lcms',
type: 'boolean',
value: true,
description: 'Compositor color management: lcms'
description: 'Compositor color management: Little CMS'
)
option(
'color-management-colord',

Loading…
Cancel
Save