color-manager: Maintain a lcms context

Will be used from other color related units later on. This also adds an
explicit dependency on LCMS2.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
This commit is contained in:
Jonas Ådahl 2022-07-27 13:30:15 +02:00
parent 508d3fe021
commit 083b788c74
4 changed files with 20 additions and 0 deletions

View File

@ -13,6 +13,7 @@ mutter_srcdir = meson.current_source_dir()
mutter_builddir = meson.current_build_dir() mutter_builddir = meson.current_build_dir()
# generic version requirements # generic version requirements
lcms2_req = '>= 2.6'
colord_req = '>= 1.4.5' colord_req = '>= 1.4.5'
fribidi_req = '>= 1.0.0' fribidi_req = '>= 1.0.0'
glib_req = '>= 2.69.0' glib_req = '>= 2.69.0'
@ -126,6 +127,7 @@ atk_dep = dependency('atk', version: atk_req)
libcanberra_dep = dependency('libcanberra', version: libcanberra_req) libcanberra_dep = dependency('libcanberra', version: libcanberra_req)
dbus_dep = dependency('dbus-1') dbus_dep = dependency('dbus-1')
colord_dep = dependency('colord', version: colord_req) colord_dep = dependency('colord', version: colord_req)
lcms2_dep = dependency('lcms2', version: lcms2_req)
have_wayland = get_option('wayland') have_wayland = get_option('wayland')
# For now always require X11 support # For now always require X11 support

View File

@ -19,6 +19,7 @@
#define META_COLOR_MANAGER_PRIVATE_H #define META_COLOR_MANAGER_PRIVATE_H
#include <colord.h> #include <colord.h>
#include <lcms2.h>
#include "backends/meta-color-manager.h" #include "backends/meta-color-manager.h"
@ -35,4 +36,6 @@ gboolean meta_color_manager_is_ready (MetaColorManager *color_manager);
META_EXPORT_TEST META_EXPORT_TEST
int meta_color_manager_get_num_color_devices (MetaColorManager *color_manager); int meta_color_manager_get_num_color_devices (MetaColorManager *color_manager);
cmsContext meta_color_manager_get_lcms_context (MetaColorManager *color_manager);
#endif /* META_COLOR_MANAGER_PRIVATE_H */ #endif /* META_COLOR_MANAGER_PRIVATE_H */

View File

@ -68,6 +68,8 @@ typedef struct _MetaColorManagerPrivate
{ {
MetaBackend *backend; MetaBackend *backend;
cmsContext lcms_context;
CdClient *cd_client; CdClient *cd_client;
GCancellable *cancellable; GCancellable *cancellable;
@ -243,6 +245,8 @@ meta_color_manager_constructed (GObject *object)
MetaColorManagerPrivate *priv = MetaColorManagerPrivate *priv =
meta_color_manager_get_instance_private (color_manager); meta_color_manager_get_instance_private (color_manager);
priv->lcms_context = cmsCreateContext (NULL, NULL);
priv->cancellable = g_cancellable_new (); priv->cancellable = g_cancellable_new ();
priv->cd_client = cd_client_new (); priv->cd_client = cd_client_new ();
@ -270,6 +274,7 @@ meta_color_manager_finalize (GObject *object)
g_clear_object (&priv->cancellable); g_clear_object (&priv->cancellable);
g_clear_pointer (&priv->devices, g_hash_table_unref); g_clear_pointer (&priv->devices, g_hash_table_unref);
g_clear_object (&priv->gsd_color); g_clear_object (&priv->gsd_color);
g_clear_pointer (&priv->lcms_context, cmsDeleteContext);
G_OBJECT_CLASS (meta_color_manager_parent_class)->finalize (object); G_OBJECT_CLASS (meta_color_manager_parent_class)->finalize (object);
} }
@ -389,3 +394,12 @@ meta_color_manager_get_num_color_devices (MetaColorManager *color_manager)
return g_hash_table_size (priv->devices); return g_hash_table_size (priv->devices);
} }
cmsContext
meta_color_manager_get_lcms_context (MetaColorManager *color_manager)
{
MetaColorManagerPrivate *priv =
meta_color_manager_get_instance_private (color_manager);
return priv->lcms_context;
}

View File

@ -23,6 +23,7 @@ mutter_pkg_deps = [
mutter_pkg_private_deps = [ mutter_pkg_private_deps = [
colord_dep, colord_dep,
lcms2_dep,
gmodule_no_export_dep, gmodule_no_export_dep,
gnome_settings_daemon_dep, gnome_settings_daemon_dep,
json_glib_dep, json_glib_dep,