[mutter] color-manager: Maintain a lcms context



commit 083b788c74737465fcc9f0fab229186fbbb1c851
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Wed Jul 27 13:30:15 2022 +0200

    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>

 meson.build                               |  2 ++
 src/backends/meta-color-manager-private.h |  3 +++
 src/backends/meta-color-manager.c         | 14 ++++++++++++++
 src/meson.build                           |  1 +
 4 files changed, 20 insertions(+)
---
diff --git a/meson.build b/meson.build
index e383be77c1..cbfc8946a6 100644
--- a/meson.build
+++ b/meson.build
@@ -13,6 +13,7 @@ mutter_srcdir = meson.current_source_dir()
 mutter_builddir = meson.current_build_dir()
 
 # generic version requirements
+lcms2_req = '>= 2.6'
 colord_req = '>= 1.4.5'
 fribidi_req = '>= 1.0.0'
 glib_req = '>= 2.69.0'
@@ -126,6 +127,7 @@ atk_dep = dependency('atk', version: atk_req)
 libcanberra_dep = dependency('libcanberra', version: libcanberra_req)
 dbus_dep = dependency('dbus-1')
 colord_dep = dependency('colord', version: colord_req)
+lcms2_dep = dependency('lcms2', version: lcms2_req)
 
 have_wayland = get_option('wayland')
 # For now always require X11 support
diff --git a/src/backends/meta-color-manager-private.h b/src/backends/meta-color-manager-private.h
index ae33ae1ca0..b358a359ad 100644
--- a/src/backends/meta-color-manager-private.h
+++ b/src/backends/meta-color-manager-private.h
@@ -19,6 +19,7 @@
 #define META_COLOR_MANAGER_PRIVATE_H
 
 #include <colord.h>
+#include <lcms2.h>
 
 #include "backends/meta-color-manager.h"
 
@@ -35,4 +36,6 @@ gboolean meta_color_manager_is_ready (MetaColorManager *color_manager);
 META_EXPORT_TEST
 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 */
diff --git a/src/backends/meta-color-manager.c b/src/backends/meta-color-manager.c
index 696c2b3374..cae3d923c9 100644
--- a/src/backends/meta-color-manager.c
+++ b/src/backends/meta-color-manager.c
@@ -68,6 +68,8 @@ typedef struct _MetaColorManagerPrivate
 {
   MetaBackend *backend;
 
+  cmsContext lcms_context;
+
   CdClient *cd_client;
   GCancellable *cancellable;
 
@@ -243,6 +245,8 @@ meta_color_manager_constructed (GObject *object)
   MetaColorManagerPrivate *priv =
     meta_color_manager_get_instance_private (color_manager);
 
+  priv->lcms_context = cmsCreateContext (NULL, NULL);
+
   priv->cancellable = g_cancellable_new ();
 
   priv->cd_client = cd_client_new ();
@@ -270,6 +274,7 @@ meta_color_manager_finalize (GObject *object)
   g_clear_object (&priv->cancellable);
   g_clear_pointer (&priv->devices, g_hash_table_unref);
   g_clear_object (&priv->gsd_color);
+  g_clear_pointer (&priv->lcms_context, cmsDeleteContext);
 
   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);
 }
+
+cmsContext
+meta_color_manager_get_lcms_context (MetaColorManager *color_manager)
+{
+  MetaColorManagerPrivate *priv =
+    meta_color_manager_get_instance_private (color_manager);
+
+  return priv->lcms_context;
+}
diff --git a/src/meson.build b/src/meson.build
index adcfbad957..0b5d6c4fc0 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -23,6 +23,7 @@ mutter_pkg_deps = [
 
 mutter_pkg_private_deps = [
   colord_dep,
+  lcms2_dep,
   gmodule_no_export_dep,
   gnome_settings_daemon_dep,
   json_glib_dep,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]