[gegl] Revert "gegl-config: remove tile_width/tile_height"



commit d315fe35b34ba835119e10d2a21542668359f958
Author: Øyvind Kolås <pippin gimp org>
Date:   Thu Sep 20 22:55:00 2018 +0200

    Revert "gegl-config: remove tile_width/tile_height"
    
    This reverts commit 628887b53b6811eaf3e47b122e1b69424fe174ad.
    
    Will do this in a different manner, using a config object for gegl-buffer.

 gegl/buffer/gegl-buffer.c | 33 ++++++++++-----------------------
 gegl/gegl-config.c        | 33 +++++++++++++++++++++++++++++++++
 gegl/gegl-config.h        |  2 ++
 gegl/gegl-init.c          | 23 +++++++++++++++++++++++
 4 files changed, 68 insertions(+), 23 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer.c b/gegl/buffer/gegl-buffer.c
index cd4e9618b..c13d28361 100644
--- a/gegl/buffer/gegl-buffer.c
+++ b/gegl/buffer/gegl-buffer.c
@@ -848,30 +848,17 @@ gegl_buffer_class_init (GeglBufferClass *class)
                                                         G_PARAM_READWRITE |
                                                         G_PARAM_CONSTRUCT_ONLY));
 
-  {
-    gint tile_height = 128;
-    gint tile_width = 128;
-    if (g_getenv ("GEGL_TILE_SIZE"))
-    {
-      const gchar *str = g_getenv ("GEGL_TILE_SIZE");
-      tile_width = atoi(str);
-      str = strchr (str, 'x');
-      if (str)
-        tile_height = atoi(str+1);
-    }
+  g_object_class_install_property (gobject_class, PROP_TILE_HEIGHT,
+                                   g_param_spec_int ("tile-height", "tile-height", "height of a tile",
+                                                     -1, G_MAXINT, gegl_config()->tile_height,
+                                                     G_PARAM_READWRITE |
+                                                     G_PARAM_CONSTRUCT_ONLY));
 
-    g_object_class_install_property (gobject_class, PROP_TILE_HEIGHT,
-                                     g_param_spec_int ("tile-height", "tile-height", "height of a tile",
-                                                       -1, G_MAXINT, tile_height,
-                                                       G_PARAM_READWRITE |
-                                                       G_PARAM_CONSTRUCT_ONLY));
-
-    g_object_class_install_property (gobject_class, PROP_TILE_WIDTH,
-                                     g_param_spec_int ("tile-width", "tile-width", "width of a tile",
-                                                       -1, G_MAXINT, tile_width,
-                                                       G_PARAM_READWRITE |
-                                                       G_PARAM_CONSTRUCT_ONLY));
-  }
+  g_object_class_install_property (gobject_class, PROP_TILE_WIDTH,
+                                   g_param_spec_int ("tile-width", "tile-width", "width of a tile",
+                                                     -1, G_MAXINT, gegl_config()->tile_width,
+                                                     G_PARAM_READWRITE |
+                                                     G_PARAM_CONSTRUCT_ONLY));
 
   g_object_class_install_property (gobject_class, PROP_PATH,
                                    g_param_spec_string ("path", "Path",
diff --git a/gegl/gegl-config.c b/gegl/gegl-config.c
index 12f3dc4cf..f34b416c7 100644
--- a/gegl/gegl-config.c
+++ b/gegl/gegl-config.c
@@ -40,6 +40,8 @@ enum
   PROP_TILE_CACHE_SIZE,
   PROP_CHUNK_SIZE,
   PROP_SWAP,
+  PROP_TILE_WIDTH,
+  PROP_TILE_HEIGHT,
   PROP_THREADS,
   PROP_USE_OPENCL,
   PROP_QUEUE_SIZE,
@@ -66,6 +68,14 @@ gegl_config_get_property (GObject    *gobject,
         g_value_set_int (value, config->chunk_size);
         break;
 
+      case PROP_TILE_WIDTH:
+        g_value_set_int (value, config->tile_width);
+        break;
+
+      case PROP_TILE_HEIGHT:
+        g_value_set_int (value, config->tile_height);
+        break;
+
       case PROP_QUALITY:
         g_value_set_double (value, config->quality);
         break;
@@ -112,6 +122,12 @@ gegl_config_set_property (GObject      *gobject,
       case PROP_CHUNK_SIZE:
         config->chunk_size = g_value_get_int (value);
         break;
+      case PROP_TILE_WIDTH:
+        config->tile_width = g_value_get_int (value);
+        break;
+      case PROP_TILE_HEIGHT:
+        config->tile_height = g_value_get_int (value);
+        break;
       case PROP_QUALITY:
         config->quality = g_value_get_double (value);
         return;
@@ -160,6 +176,23 @@ gegl_config_class_init (GeglConfigClass *klass)
   gobject_class->get_property = gegl_config_get_property;
   gobject_class->finalize     = gegl_config_finalize;
 
+
+  g_object_class_install_property (gobject_class, PROP_TILE_WIDTH,
+                                   g_param_spec_int ("tile-width",
+                                                     "Tile width",
+                                                     "default tile width for created buffers.",
+                                                     0, G_MAXINT, 128,
+                                                     G_PARAM_READWRITE |
+                                                     G_PARAM_CONSTRUCT));
+
+  g_object_class_install_property (gobject_class, PROP_TILE_HEIGHT,
+                                   g_param_spec_int ("tile-height",
+                                                     "Tile height",
+                                                     "default tile height for created buffers.",
+                                                     0, G_MAXINT, 128,
+                                                     G_PARAM_READWRITE |
+                                                     G_PARAM_CONSTRUCT));
+
   g_object_class_install_property (gobject_class, PROP_TILE_CACHE_SIZE,
                                    g_param_spec_uint64 ("tile-cache-size",
                                                         "Tile Cache size",
diff --git a/gegl/gegl-config.h b/gegl/gegl-config.h
index f4c3626d7..f830390a5 100644
--- a/gegl/gegl-config.h
+++ b/gegl/gegl-config.h
@@ -39,6 +39,8 @@ struct _GeglConfig
   guint64  tile_cache_size;
   gint     chunk_size; /* The size of elements being processed at once */
   gdouble  quality;
+  gint     tile_width;
+  gint     tile_height;
   gboolean use_opencl;
   gint     queue_size;
   gchar   *application_license;
diff --git a/gegl/gegl-init.c b/gegl/gegl-init.c
index e9d8dcdd1..39bb6c323 100644
--- a/gegl/gegl-init.c
+++ b/gegl/gegl-init.c
@@ -273,6 +273,7 @@ static gchar    *cmd_gegl_swap           = NULL;
 static gchar    *cmd_gegl_cache_size     = NULL;
 static gchar    *cmd_gegl_chunk_size     = NULL;
 static gchar    *cmd_gegl_quality        = NULL;
+static gchar    *cmd_gegl_tile_size      = NULL;
 static gchar    *cmd_gegl_threads        = NULL;
 static gboolean *cmd_gegl_disable_opencl = NULL;
 
@@ -288,6 +289,11 @@ static const GOptionEntry cmd_entries[]=
      G_OPTION_ARG_STRING, &cmd_gegl_cache_size,
      N_("How much memory to (approximately) use for caching imagery"), "<megabytes>"
     },
+    {
+     "gegl-tile-size", 0, 0,
+     G_OPTION_ARG_STRING, &cmd_gegl_tile_size,
+     N_("Default size of tiles in GeglBuffers"), "<widthxheight>"
+    },
     {
      "gegl-chunk-size", 0, 0,
      G_OPTION_ARG_STRING, &cmd_gegl_chunk_size,
@@ -362,6 +368,15 @@ static void gegl_config_parse_env (GeglConfig *config)
   if (g_getenv ("GEGL_CHUNK_SIZE"))
     config->chunk_size = atoi(g_getenv("GEGL_CHUNK_SIZE"));
 
+  if (g_getenv ("GEGL_TILE_SIZE"))
+    {
+      const gchar *str = g_getenv ("GEGL_TILE_SIZE");
+      config->tile_width = atoi(str);
+      str = strchr (str, 'x');
+      if (str)
+        config->tile_height = atoi(str+1);
+    }
+
   if (g_getenv ("GEGL_THREADS"))
     {
       _gegl_threads = atoi(g_getenv("GEGL_THREADS"));
@@ -662,6 +677,14 @@ gegl_post_parse_hook (GOptionContext *context,
     config->tile_cache_size = atoll (cmd_gegl_cache_size)*1024*1024;
   if (cmd_gegl_chunk_size)
     config->chunk_size = atoi (cmd_gegl_chunk_size);
+  if (cmd_gegl_tile_size)
+    {
+      const gchar *str = cmd_gegl_tile_size;
+      config->tile_width = atoi(str);
+      str = strchr (str, 'x');
+      if (str)
+        config->tile_height = atoi(str+1);
+    }
   if (cmd_gegl_threads)
     {
       _gegl_threads = atoi (cmd_gegl_threads);


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