[gimp/gimp-2-10] libgimpbase, libgimp, app: pass misc. GEGL config to plug-ins



commit 0a39f362b52c8c12646a134f74daf6f66456e92c
Author: Ell <ell_se yahoo com>
Date:   Mon Nov 19 16:13:07 2018 -0500

    libgimpbase, libgimp, app: pass misc. GEGL config to plug-ins
    
    Pass the GEGL tile-cache size, swap path, and thread-count to plug-
    ins as part of their config, and have libgimp set the plug-in's
    GeglConfig accordingly upon initialization.

 app/plug-in/gimppluginmanager-call.c |  3 +++
 libgimp/gimp.c                       |  3 +++
 libgimpbase/gimpprotocol.c           | 30 ++++++++++++++++++++++++++++++
 libgimpbase/gimpprotocol.h           |  7 ++++++-
 4 files changed, 42 insertions(+), 1 deletion(-)
---
diff --git a/app/plug-in/gimppluginmanager-call.c b/app/plug-in/gimppluginmanager-call.c
index ee6497b135..26f9bea4a9 100644
--- a/app/plug-in/gimppluginmanager-call.c
+++ b/app/plug-in/gimppluginmanager-call.c
@@ -226,6 +226,9 @@ gimp_plug_in_manager_call_run (GimpPlugInManager   *manager,
       config.icon_theme_dir   = icon_theme_dir ?
                                   g_file_get_path (icon_theme_dir) :
                                   NULL;
+      config.tile_cache_size  = gegl_config->tile_cache_size;
+      config.swap_path        = gegl_config->swap_path;
+      config.num_processors   = gegl_config->num_processors;
 
       proc_run.name    = GIMP_PROCEDURE (procedure)->original_name;
       proc_run.nparams = gimp_value_array_length (args);
diff --git a/libgimp/gimp.c b/libgimp/gimp.c
index 9b34362c53..85acc60636 100644
--- a/libgimp/gimp.c
+++ b/libgimp/gimp.c
@@ -2338,6 +2338,9 @@ gimp_config (GPConfig *config)
   gimp_cpu_accel_set_use (config->use_cpu_accel);
 
   g_object_set (gegl_config (),
+                "tile-cache-size",     config->tile_cache_size,
+                "swap",                config->swap_path,
+                "threads",             (gint) config->num_processors,
                 "use-opencl",          config->use_opencl,
                 "application-license", "GPL3",
                 NULL);
diff --git a/libgimpbase/gimpprotocol.c b/libgimpbase/gimpprotocol.c
index 9142c70869..ffb9194f17 100644
--- a/libgimpbase/gimpprotocol.c
+++ b/libgimpbase/gimpprotocol.c
@@ -553,6 +553,20 @@ _gp_config_read (GIOChannel      *channel,
                                 &config->icon_theme_dir, 1, user_data))
     goto cleanup;
 
+  if (config->version < 0x0019)
+    goto end;
+
+  if (! _gimp_wire_read_int64 (channel,
+                               &config->tile_cache_size, 1, user_data))
+    goto cleanup;
+  if (! _gimp_wire_read_string (channel,
+                                &config->swap_path, 1, user_data))
+    goto cleanup;
+  if (! _gimp_wire_read_int32 (channel,
+                               (guint32 *) &config->num_processors, 1,
+                               user_data))
+    goto cleanup;
+
  end:
   msg->data = config;
   return;
@@ -562,6 +576,7 @@ _gp_config_read (GIOChannel      *channel,
   g_free (config->wm_class);
   g_free (config->display_name);
   g_free (config->icon_theme_dir);
+  g_free (config->swap_path);
   g_slice_free (GPConfig, config);
 }
 
@@ -657,6 +672,20 @@ _gp_config_write (GIOChannel      *channel,
   if (! _gimp_wire_write_string (channel,
                                  &config->icon_theme_dir, 1, user_data))
     return;
+
+  if (config->version < 0x0019)
+    return;
+
+  if (! _gimp_wire_write_int64 (channel,
+                                &config->tile_cache_size, 1, user_data))
+    return;
+  if (! _gimp_wire_write_string (channel,
+                                 &config->swap_path, 1, user_data))
+    return;
+  if (! _gimp_wire_write_int32 (channel,
+                                (const guint32 *) &config->num_processors, 1,
+                                user_data))
+    return;
 }
 
 static void
@@ -670,6 +699,7 @@ _gp_config_destroy (GimpWireMessage *msg)
       g_free (config->wm_class);
       g_free (config->display_name);
       g_free (config->icon_theme_dir);
+      g_free (config->swap_path);
       g_slice_free (GPConfig, config);
     }
 }
diff --git a/libgimpbase/gimpprotocol.h b/libgimpbase/gimpprotocol.h
index 29c00819be..0481b85e4d 100644
--- a/libgimpbase/gimpprotocol.h
+++ b/libgimpbase/gimpprotocol.h
@@ -26,7 +26,7 @@ G_BEGIN_DECLS
 
 /* Increment every time the protocol changes
  */
-#define GIMP_PROTOCOL_VERSION  0x0018
+#define GIMP_PROTOCOL_VERSION  0x0019
 
 
 enum
@@ -85,6 +85,11 @@ struct _GPConfig
 
   /* since protocol version 0x0017: */
   gchar   *icon_theme_dir;
+
+  /* since protocol version 0x0019: */
+  guint64  tile_cache_size;
+  gchar   *swap_path;
+  gint32   num_processors;
 };
 
 struct _GPTileReq


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