[gimp] app: add "Use OpenCL" toggle to Prefs -> Environment



commit 1cc9d7d7aae759b24ff72ea9a8a76e96f933e328
Author: Michael Natterer <mitch gimp org>
Date:   Sat Jun 1 23:02:42 2013 +0200

    app: add "Use OpenCL" toggle to Prefs -> Environment
    
    and configure GEGL accordingly. Let's see if it's really runtime
    switchable :)

 app/config/gimpgeglconfig.c      |   12 ++++++++++++
 app/config/gimpgeglconfig.h      |    1 +
 app/config/gimprc-blurbs.h       |    7 +++++--
 app/dialogs/preferences-dialog.c |    8 ++++++++
 app/gegl/gimp-gegl.c             |   16 +++++++++++++++-
 5 files changed, 41 insertions(+), 3 deletions(-)
---
diff --git a/app/config/gimpgeglconfig.c b/app/config/gimpgeglconfig.c
index 9d5f712..5d4a5c5 100644
--- a/app/config/gimpgeglconfig.c
+++ b/app/config/gimpgeglconfig.c
@@ -51,6 +51,7 @@ enum
   PROP_SWAP_PATH,
   PROP_NUM_PROCESSORS,
   PROP_TILE_CACHE_SIZE,
+  PROP_USE_OPENCL,
 
   /* ignored, only for backward compatibility: */
   PROP_STINGY_MEMORY_USE
@@ -158,6 +159,11 @@ gimp_gegl_config_class_init (GimpGeglConfigClass *klass)
                                     GIMP_PARAM_STATIC_STRINGS |
                                     GIMP_CONFIG_PARAM_CONFIRM);
 
+  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_USE_OPENCL,
+                                    "use-opencl", USE_OPENCL_BLURB,
+                                    TRUE,
+                                    GIMP_PARAM_STATIC_STRINGS);
+
   /*  only for backward compatibility:  */
   GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_STINGY_MEMORY_USE,
                                     "stingy-memory-use", NULL,
@@ -209,6 +215,9 @@ gimp_gegl_config_set_property (GObject      *object,
     case PROP_TILE_CACHE_SIZE:
       gegl_config->tile_cache_size = g_value_get_uint64 (value);
       break;
+    case PROP_USE_OPENCL:
+      gegl_config->use_opencl = g_value_get_boolean (value);
+      break;
 
     case PROP_STINGY_MEMORY_USE:
       /* ignored */
@@ -242,6 +251,9 @@ gimp_gegl_config_get_property (GObject    *object,
     case PROP_TILE_CACHE_SIZE:
       g_value_set_uint64 (value, gegl_config->tile_cache_size);
       break;
+    case PROP_USE_OPENCL:
+      g_value_set_boolean (value, gegl_config->use_opencl);
+      break;
 
     case PROP_STINGY_MEMORY_USE:
       /* ignored */
diff --git a/app/config/gimpgeglconfig.h b/app/config/gimpgeglconfig.h
index 4567da5..f9f3b39 100644
--- a/app/config/gimpgeglconfig.h
+++ b/app/config/gimpgeglconfig.h
@@ -39,6 +39,7 @@ struct _GimpGeglConfig
   gchar    *swap_path;
   guint     num_processors;
   guint64   tile_cache_size;
+  gboolean  use_opencl;
 };
 
 struct _GimpGeglConfigClass
diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h
index 6e89781..1c359a2 100644
--- a/app/config/gimprc-blurbs.h
+++ b/app/config/gimprc-blurbs.h
@@ -453,10 +453,13 @@ N_("Sets an upper limit to the memory that is used per image to keep " \
 #define UNDO_PREVIEW_SIZE_BLURB \
 N_("Sets the size of the previews in the Undo History.")
 
-#define USE_HELP_BLURB  \
+#define USE_HELP_BLURB \
 N_("When enabled, pressing F1 will open the help browser.")
 
-#define USER_MANUAL_ONLINE_BLURB  \
+#define USE_OPENCL_BLURB \
+N_("When enabled, uses OpenCL for some operations.")
+
+#define USER_MANUAL_ONLINE_BLURB \
 "When enabled, the online user manual will be used by the help system. " \
 "Otherwise the locally installed copy is used."
 
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index a935828..17258b0 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -1337,6 +1337,14 @@ prefs_dialog_new (Gimp       *gimp,
                          GTK_TABLE (table), 4, size_group);
 #endif /* ENABLE_MP */
 
+  /*  Hardware Acceleration  */
+  vbox2 = prefs_frame_new (_("Hardware Acceleration"), GTK_CONTAINER (vbox),
+                           FALSE);
+
+  prefs_check_button_add (object, "use-opencl",
+                          _("Use OpenCL"),
+                          GTK_BOX (vbox2));
+
   /*  Image Thumbnails  */
   vbox2 = prefs_frame_new (_("Image Thumbnails"), GTK_CONTAINER (vbox), FALSE);
 
diff --git a/app/gegl/gimp-gegl.c b/app/gegl/gimp-gegl.c
index d18c30d..88b53da 100644
--- a/app/gegl/gimp-gegl.c
+++ b/app/gegl/gimp-gegl.c
@@ -36,6 +36,7 @@
 
 static void  gimp_gegl_notify_tile_cache_size (GimpGeglConfig *config);
 static void  gimp_gegl_notify_num_processors  (GimpGeglConfig *config);
+static void  gimp_gegl_notify_use_opencl      (GimpGeglConfig *config);
 
 
 void
@@ -57,8 +58,9 @@ gimp_gegl_init (Gimp *gimp)
       g_object_set (gegl_config (),
                     "tile-cache-size", (guint64) config->tile_cache_size,
 #if 0
-                    "threads",    config->num_processors,
+                    "threads",         config->num_processors,
 #endif
+                    "use-opencl",      config->use_opencl,
                     NULL);
     }
   else
@@ -72,6 +74,7 @@ gimp_gegl_init (Gimp *gimp)
 #if 0
                     "threads",    config->num_processors,
 #endif
+                    "use-opencl", config->use_opencl,
                     NULL);
     }
 
@@ -89,6 +92,9 @@ gimp_gegl_init (Gimp *gimp)
   g_signal_connect (config, "notify::num-processors",
                     G_CALLBACK (gimp_gegl_notify_num_processors),
                     NULL);
+  g_signal_connect (config, "notify::use-opencl",
+                    G_CALLBACK (gimp_gegl_notify_use_opencl),
+                    NULL);
 
   gimp_babl_init ();
 
@@ -122,3 +128,11 @@ gimp_gegl_notify_num_processors (GimpGeglConfig *config)
                 NULL);
 #endif
 }
+
+static void
+gimp_gegl_notify_use_opencl (GimpGeglConfig *config)
+{
+  g_object_set (gegl_config (),
+                "use-opencl", config->use_opencl,
+                NULL);
+}


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