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
parent
8fb23ed110
commit
5e79dd4892
@ -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()) |
Loading…
Reference in new issue