[gimp/metadata-browser] app: default to half the physical memory for the tile-cache-size setting



commit b7f71ff8bcfc43ee8c85ea1b71dacb90c3e25fa6
Author: Michael Natterer <mitch gimp org>
Date:   Sun May 13 20:19:40 2012 +0200

    app: default to half the physical memory for the tile-cache-size setting
    
    Wanted to do this for ages but forgot...
    (cherry picked from commit 36bb8a625bdb561b8eb13ba12d3148416e11aa0e)
    
    Additionally, set the default undo memory size to 1/8th of the
    physical memory.

 app/config/gimpbaseconfig.c |   11 ++++++++++-
 app/config/gimpcoreconfig.c |   12 +++++++++++-
 2 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/app/config/gimpbaseconfig.c b/app/config/gimpbaseconfig.c
index 972a5c2..55cade7 100644
--- a/app/config/gimpbaseconfig.c
+++ b/app/config/gimpbaseconfig.c
@@ -106,6 +106,7 @@ gimp_base_config_class_init (GimpBaseConfigClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
   gint          num_processors;
+  guint64       memory_size;
 
   parent_class = g_type_class_peek_parent (klass);
 
@@ -138,10 +139,18 @@ gimp_base_config_class_init (GimpBaseConfigClass *klass)
                                  "num-processors", NUM_PROCESSORS_BLURB,
                                  1, GIMP_MAX_NUM_THREADS, num_processors,
                                  GIMP_PARAM_STATIC_STRINGS);
+
+  memory_size = gimp_get_physical_memory_size ();
+
+  if (memory_size > 0)
+    memory_size = memory_size / 2; /* half the memory */
+  else
+    memory_size = 1 << 30; /* 1GB */
+
   GIMP_CONFIG_INSTALL_PROP_MEMSIZE (object_class, PROP_TILE_CACHE_SIZE,
                                     "tile-cache-size", TILE_CACHE_SIZE_BLURB,
                                     0, MIN (G_MAXSIZE, GIMP_MAX_MEMSIZE),
-                                    1 << 30, /* 1GB */
+                                    memory_size,
                                     GIMP_PARAM_STATIC_STRINGS |
                                     GIMP_CONFIG_PARAM_CONFIRM);
 
diff --git a/app/config/gimpcoreconfig.c b/app/config/gimpcoreconfig.c
index 676e705..30b0872 100644
--- a/app/config/gimpcoreconfig.c
+++ b/app/config/gimpcoreconfig.c
@@ -31,6 +31,7 @@
 #include "config-types.h"
 
 #include "core/core-types.h"
+#include "core/gimp-utils.h"
 #include "core/gimpgrid.h"
 #include "core/gimptemplate.h"
 
@@ -141,6 +142,7 @@ gimp_core_config_class_init (GimpCoreConfigClass *klass)
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
   gchar        *path;
   GimpRGB       red          = { 1.0, 0, 0, 0.5 };
+  guint64       undo_size;
 
   object_class->finalize     = gimp_core_config_finalize;
   object_class->set_property = gimp_core_config_set_property;
@@ -376,9 +378,17 @@ gimp_core_config_class_init (GimpCoreConfigClass *klass)
                                 0, 1 << 20, 5,
                                 GIMP_PARAM_STATIC_STRINGS |
                                 GIMP_CONFIG_PARAM_CONFIRM);
+
+  undo_size = gimp_get_physical_memory_size ();
+
+  if (undo_size > 0)
+    undo_size = undo_size / 8; /* 1/8th of the memory */
+  else
+    undo_size = 1 << 26; /* 64GB */
+
   GIMP_CONFIG_INSTALL_PROP_MEMSIZE (object_class, PROP_UNDO_SIZE,
                                     "undo-size", UNDO_SIZE_BLURB,
-                                    0, GIMP_MAX_MEMSIZE, 1 << 26, /* 64MB */
+                                    0, GIMP_MAX_MEMSIZE, undo_size,
                                     GIMP_PARAM_STATIC_STRINGS |
                                     GIMP_CONFIG_PARAM_CONFIRM);
   GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_UNDO_PREVIEW_SIZE,



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