[gegl] gegl: make mipmap rendering a GeglConfig property



commit 7e1a74e59dd12aacd2881baf51067a344f423d8f
Author: Øyvind Kolås <pippin gimp org>
Date:   Sun Jan 13 21:34:23 2019 +0100

    gegl: make mipmap rendering a GeglConfig property
    
    This makes is possible to switch between mipmap preview rendering and
    not at runtime, the same environment variable as before
    controls overriding the default.

 gegl/gegl-config.c     | 18 +++++++++++++++++-
 gegl/gegl-config.h     |  1 +
 gegl/gegl-init.c       | 12 ++++++++++++
 gegl/graph/gegl-node.c |  5 +----
 4 files changed, 31 insertions(+), 5 deletions(-)
---
diff --git a/gegl/gegl-config.c b/gegl/gegl-config.c
index 30e7af1e7..c781e3ed0 100644
--- a/gegl/gegl-config.c
+++ b/gegl/gegl-config.c
@@ -47,7 +47,8 @@ enum
   PROP_THREADS,
   PROP_USE_OPENCL,
   PROP_QUEUE_SIZE,
-  PROP_APPLICATION_LICENSE
+  PROP_APPLICATION_LICENSE,
+  PROP_MIPMAP_RENDERING
 };
 
 gint _gegl_threads = 1;
@@ -106,6 +107,10 @@ gegl_config_get_property (GObject    *gobject,
         g_value_set_string (value, config->application_license);
         break;
 
+      case PROP_MIPMAP_RENDERING:
+        g_value_set_boolean (value, config->mipmap_rendering);
+        break;
+
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, property_id, pspec);
         break;
@@ -151,6 +156,9 @@ gegl_config_set_property (GObject      *gobject,
       case PROP_USE_OPENCL:
         config->use_opencl = g_value_get_boolean (value);
         break;
+      case PROP_MIPMAP_RENDERING:
+        config->mipmap_rendering = g_value_get_boolean (value);
+        break;
       case PROP_QUEUE_SIZE:
         config->queue_size = g_value_get_int (value);
         break;
@@ -250,6 +258,14 @@ gegl_config_class_init (GeglConfigClass *klass)
                                                      G_PARAM_READWRITE |
                                                      G_PARAM_CONSTRUCT));
 
+  g_object_class_install_property (gobject_class, PROP_MIPMAP_RENDERING,
+                                   g_param_spec_boolean ("mipmap-rendering",
+                                                         "mipmap rendering",
+                                                         "Enable code paths for mipmap preview rendering, 
uses approximations for 50% 25% etc zoom factors to reduce processing.",
+                                                         FALSE,
+                                                         G_PARAM_READWRITE |
+                                                         G_PARAM_CONSTRUCT));
+
   g_object_class_install_property (gobject_class, PROP_USE_OPENCL,
                                    g_param_spec_boolean ("use-opencl",
                                                          "Use OpenCL",
diff --git a/gegl/gegl-config.h b/gegl/gegl-config.h
index 7ebb7f85b..78c5fc302 100644
--- a/gegl/gegl-config.h
+++ b/gegl/gegl-config.h
@@ -44,6 +44,7 @@ struct _GeglConfig
   gint     tile_height;
   gboolean use_opencl;
   gint     queue_size;
+  gboolean mipmap_rendering;
   gchar   *application_license;
 };
 
diff --git a/gegl/gegl-init.c b/gegl/gegl-init.c
index 1b42cc2c2..bf5b367c8 100644
--- a/gegl/gegl-init.c
+++ b/gegl/gegl-init.c
@@ -269,6 +269,18 @@ gegl_get_option_group (void)
 
 static void gegl_config_parse_env (GeglConfig *config)
 {
+  if (g_getenv ("GEGL_MIPMAP_RENDERING"))
+    {
+      const gchar *value = g_getenv ("GEGL_MIPMAP_RENDERING");
+      if (!strcmp (value, "1")||
+          !strcmp (value, "true")||
+          !strcmp (value, "yes"))
+        g_object_set (config, "mipmap-rendering", TRUE, NULL);
+      else
+        g_object_set (config, "mipmap-rendering", TRUE, NULL);
+    }
+
+
   if (g_getenv ("GEGL_QUALITY"))
     {
       const gchar *quality = g_getenv ("GEGL_QUALITY");
diff --git a/gegl/graph/gegl-node.c b/gegl/graph/gegl-node.c
index 1d8cb263b..58ac8b00b 100644
--- a/gegl/graph/gegl-node.c
+++ b/gegl/graph/gegl-node.c
@@ -1118,10 +1118,7 @@ gegl_node_blit_buffer (GeglNode            *self,
 
 static inline gboolean gegl_mipmap_rendering_enabled (void)
 {
-  static int enabled = -1;
-  if (enabled == -1)
-    enabled = g_getenv("GEGL_MIPMAP_RENDERING")!=NULL;
-  return enabled;
+  return gegl_config()->mipmap_rendering;
 }
 
 void


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