[gegl] buffer: use a separate config object for gegl buffer
- From: Øyvind "pippin" Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] buffer: use a separate config object for gegl buffer
- Date: Mon, 24 Sep 2018 13:35:15 +0000 (UTC)
commit d6dcdd6617afc9f29391932bf38005f960b14664
Author: Øyvind Kolås <pippin gimp org>
Date: Thu Sep 20 23:15:21 2018 +0200
buffer: use a separate config object for gegl buffer
A config object similar to GEGLs GeglConfig has been added for
gegl-buffer, making the files in the buffer directory more
independent of the rest of the GEGL code base. All properties
of GeglBufferConfig are bi-directionally bound to their
counterparts in GeglConfig
gegl/buffer/Makefile.am | 2 ++
gegl/buffer/gegl-buffer.c | 8 ++++----
gegl/buffer/gegl-tile-backend-file-async.c | 6 +++---
gegl/buffer/gegl-tile-backend-swap.c | 10 +++++-----
gegl/buffer/gegl-tile-backend.c | 4 ++--
gegl/buffer/gegl-tile-handler-cache.c | 22 +++++++++++-----------
gegl/gegl-config.c | 11 +++++++++++
7 files changed, 38 insertions(+), 25 deletions(-)
---
diff --git a/gegl/buffer/Makefile.am b/gegl/buffer/Makefile.am
index 270f563bf..175b7b4d9 100644
--- a/gegl/buffer/Makefile.am
+++ b/gegl/buffer/Makefile.am
@@ -27,6 +27,8 @@ libbuffer_la_SOURCES = \
gegl-algorithms.h \
gegl-buffer.c \
gegl-buffer-access.c \
+ gegl-buffer-config.c \
+ gegl-buffer-config.h \
gegl-buffer-index.h \
gegl-buffer-iterator.c \
gegl-buffer-iterator2.c \
diff --git a/gegl/buffer/gegl-buffer.c b/gegl/buffer/gegl-buffer.c
index c13d28361..2e722b2ad 100644
--- a/gegl/buffer/gegl-buffer.c
+++ b/gegl/buffer/gegl-buffer.c
@@ -38,7 +38,7 @@
#include "gegl-buffer-types.h"
#include "gegl-buffer.h"
-#include "gegl-config.h" // XXX should be removed
+#include "gegl-buffer-config.h"
#include "gegl-buffer-private.h"
#include "gegl-debug.h"
#include "gegl-tile-storage.h"
@@ -534,7 +534,7 @@ gegl_buffer_constructor (GType type,
if (buffer->path)
maybe_path = buffer->path;
else
- maybe_path = gegl_config ()->swap;
+ maybe_path = gegl_buffer_config ()->swap;
if (maybe_path)
use_ram = g_ascii_strcasecmp (maybe_path, "ram") == 0;
@@ -850,13 +850,13 @@ gegl_buffer_class_init (GeglBufferClass *class)
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,
+ -1, G_MAXINT, gegl_buffer_config()->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, gegl_config()->tile_width,
+ -1, G_MAXINT, gegl_buffer_config()->tile_width,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
diff --git a/gegl/buffer/gegl-tile-backend-file-async.c b/gegl/buffer/gegl-tile-backend-file-async.c
index 995965eb4..82d1a4bf1 100644
--- a/gegl/buffer/gegl-tile-backend-file-async.c
+++ b/gegl/buffer/gegl-tile-backend-file-async.c
@@ -51,7 +51,7 @@
#include "gegl-buffer-index.h"
#include "gegl-buffer-types.h"
#include "gegl-debug.h"
-#include "gegl-config.h"
+#include "gegl-buffer-config.h"
#ifndef HAVE_FSYNC
@@ -177,7 +177,7 @@ gegl_tile_backend_file_push_queue (GeglFileBackendThreadParams *params)
g_mutex_lock (&mutex);
/* block if the queue has gotten too big */
- while (queue_size > gegl_config ()->queue_size)
+ while (queue_size > gegl_buffer_config ()->queue_size)
g_cond_wait (&max_cond, &mutex);
params->file->pending_ops += 1;
@@ -294,7 +294,7 @@ gegl_tile_backend_file_writer_thread (gpointer ignored)
g_free (params->source);
/* unblock the main thread if the queue had gotten too big */
- if (queue_size < gegl_config ()->queue_size)
+ if (queue_size < gegl_buffer_config ()->queue_size)
g_cond_signal (&max_cond);
}
diff --git a/gegl/buffer/gegl-tile-backend-swap.c b/gegl/buffer/gegl-tile-backend-swap.c
index fb38800dd..94b670682 100644
--- a/gegl/buffer/gegl-tile-backend-swap.c
+++ b/gegl/buffer/gegl-tile-backend-swap.c
@@ -42,7 +42,7 @@
#include "gegl-tile-backend.h"
#include "gegl-tile-backend-swap.h"
#include "gegl-debug.h"
-#include "gegl-config.h"
+#include "gegl-buffer-config.h"
#ifndef HAVE_FSYNC
@@ -1097,7 +1097,7 @@ gegl_tile_backend_swap_ensure_exist (void)
if (in_fd == -1 || out_fd == -1)
{
gchar *filename = g_strdup_printf ("%i-shared.swap", getpid ());
- path = g_build_filename (gegl_config ()->swap, filename, NULL);
+ path = g_build_filename (gegl_buffer_config ()->swap, filename, NULL);
g_free (filename);
GEGL_NOTE (GEGL_DEBUG_TILE_BACKEND, "creating swapfile %s", path);
@@ -1143,11 +1143,11 @@ gegl_tile_backend_swap_class_init (GeglTileBackendSwapClass *klass)
gegl_tile_backend_swap_writer_thread,
NULL);
- g_signal_connect (gegl_config (), "notify::tile-cache-size",
+ g_signal_connect (gegl_buffer_config (), "notify::tile-cache-size",
G_CALLBACK (gegl_tile_backend_swap_tile_cache_size_notify),
NULL);
- gegl_tile_backend_swap_tile_cache_size_notify (G_OBJECT (gegl_config ()),
+ gegl_tile_backend_swap_tile_cache_size_notify (G_OBJECT (gegl_buffer_config ()),
NULL, NULL);
}
@@ -1158,7 +1158,7 @@ gegl_tile_backend_swap_cleanup (void)
return;
g_signal_handlers_disconnect_by_func (
- gegl_config (),
+ gegl_buffer_config (),
gegl_tile_backend_swap_tile_cache_size_notify,
NULL);
diff --git a/gegl/buffer/gegl-tile-backend.c b/gegl/buffer/gegl-tile-backend.c
index 0f70dda1c..fc8b0554e 100644
--- a/gegl/buffer/gegl-tile-backend.c
+++ b/gegl/buffer/gegl-tile-backend.c
@@ -26,7 +26,7 @@
#include "gegl-buffer-private.h"
#include "gegl-tile-source.h"
#include "gegl-tile-backend.h"
-#include "gegl-config.h"
+#include "gegl-buffer-config.h"
G_DEFINE_TYPE_WITH_PRIVATE (GeglTileBackend, gegl_tile_backend,
GEGL_TYPE_TILE_SOURCE)
@@ -354,7 +354,7 @@ gegl_tile_backend_unlink_swap (gchar *path)
/* Ensure we delete only files in our known swap directory for safety. */
if (g_file_test (path, G_FILE_TEST_EXISTS) &&
- g_strcmp0 (dirname, gegl_config()->swap) == 0)
+ g_strcmp0 (dirname, gegl_buffer_config()->swap) == 0)
g_unlink (path);
g_free (dirname);
diff --git a/gegl/buffer/gegl-tile-handler-cache.c b/gegl/buffer/gegl-tile-handler-cache.c
index 97fbad15a..f57e5b65b 100644
--- a/gegl/buffer/gegl-tile-handler-cache.c
+++ b/gegl/buffer/gegl-tile-handler-cache.c
@@ -21,7 +21,7 @@
#include <glib.h>
#include <glib-object.h>
-#include "gegl-config.h"
+#include "gegl-buffer-config.h"
#include "gegl-buffer.h"
#include "gegl-buffer-private.h"
#include "gegl-tile.h"
@@ -521,14 +521,14 @@ gegl_tile_handler_cache_trim (GeglTileHandlerCache *cache)
g_mutex_lock (&mutex);
while ((guintptr) g_atomic_pointer_get (&cache_total) >
- gegl_config ()->tile_cache_size)
+ gegl_buffer_config ()->tile_cache_size)
{
CacheItem *last_writable;
GeglTile *tile;
GList *prev_link;
#ifdef GEGL_DEBUG_CACHE_HITS
- GEGL_NOTE(GEGL_DEBUG_CACHE, "cache_total:"G_GUINT64_FORMAT" > cache_size:"G_GUINT64_FORMAT,
cache_total, gegl_config()->tile_cache_size);
+ GEGL_NOTE(GEGL_DEBUG_CACHE, "cache_total:"G_GUINT64_FORMAT" > cache_size:"G_GUINT64_FORMAT,
cache_total, gegl_buffer_config()->tile_cache_size);
GEGL_NOTE(GEGL_DEBUG_CACHE, "%f%% hit:%i miss:%i %i]", cache_hits*100.0/(cache_hits+cache_misses),
cache_hits, cache_misses, g_queue_get_length (&cache_queue));
#endif
@@ -833,7 +833,7 @@ gegl_tile_handler_cache_tile_uncloned (GeglTileHandlerCache *cache,
total = (guintptr) g_atomic_pointer_add (&cache_total, tile->size) +
tile->size;
- if (total > gegl_config ()->tile_cache_size)
+ if (total > gegl_buffer_config ()->tile_cache_size)
gegl_tile_handler_cache_trim (cache);
cache_total_max = MAX (cache_total_max, total);
@@ -953,9 +953,9 @@ gegl_tile_handler_cache_equalfunc (gconstpointer a,
}
static void
-gegl_config_tile_cache_size_notify (GObject *gobject,
- GParamSpec *pspec,
- gpointer user_data)
+gegl_buffer_config_tile_cache_size_notify (GObject *gobject,
+ GParamSpec *pspec,
+ gpointer user_data)
{
gegl_tile_handler_cache_trim (NULL);
}
@@ -963,15 +963,15 @@ gegl_config_tile_cache_size_notify (GObject *gobject,
void
gegl_tile_cache_init (void)
{
- g_signal_connect (gegl_config (), "notify::tile-cache-size",
- G_CALLBACK (gegl_config_tile_cache_size_notify), NULL);
+ g_signal_connect (gegl_buffer_config (), "notify::tile-cache-size",
+ G_CALLBACK (gegl_buffer_config_tile_cache_size_notify), NULL);
}
void
gegl_tile_cache_destroy (void)
{
- g_signal_handlers_disconnect_by_func (gegl_config(),
- gegl_config_tile_cache_size_notify,
+ g_signal_handlers_disconnect_by_func (gegl_buffer_config(),
+ gegl_buffer_config_tile_cache_size_notify,
NULL);
g_warn_if_fail (g_queue_is_empty (&cache_queue));
diff --git a/gegl/gegl-config.c b/gegl/gegl-config.c
index f34b416c7..0a5043690 100644
--- a/gegl/gegl-config.c
+++ b/gegl/gegl-config.c
@@ -26,6 +26,7 @@
#include "gegl.h"
#include "gegl-types-internal.h"
#include "gegl-config.h"
+#include "gegl-buffer-config.h"
#include "opencl/gegl-cl.h"
@@ -264,6 +265,16 @@ gegl_config_class_init (GeglConfigClass *klass)
static void
gegl_config_init (GeglConfig *self)
{
+ char *forward_props[]={"swap",
+ "queue-size",
+ "tile-width",
+ "tile-height",
+ "tile-cache-size",
+ NULL};
+ GeglBufferConfig *bconf = gegl_buffer_config ();
+ for (int i = 0; forward_props[i]; i++)
+ g_object_bind_property (bconf, forward_props[i],
+ self, forward_props[i], G_BINDING_BIDIRECTIONAL);
}
#undef gegl_config_threads
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]