gegl r2019 - in trunk: . gegl gegl/buffer
- From: ok svn gnome org
- To: svn-commits-list gnome org
- Subject: gegl r2019 - in trunk: . gegl gegl/buffer
- Date: Wed, 13 Feb 2008 23:28:41 +0000 (GMT)
Author: ok
Date: Wed Feb 13 23:28:41 2008
New Revision: 2019
URL: http://svn.gnome.org/viewvc/gegl?rev=2019&view=rev
Log:
* gegl/buffer/gegl-buffer-allocator.c: (gegl_buffer_alloc),
(gegl_swap_dir): added swapdir lookup function, with empty GEGL_SWAP
~/.gegl-0.0/swap is now used, set up a symlink to /tmp or /var/tmp if
you want that kind of behavior. GEGL_SWAP=RAM causes gegl to use
the old behavior of swapping to RAM.
* gegl/gegl-init.c: (gegl_init)
(gegl_exit): use gegl_swap_dir() to get at swap location for cleanup.
(gegl_post_parse_hook): modified default module search path to
include ~/.gegl-0.0/plug-ins/, also add a dummy Makefile to this dir
if none exist.
Modified:
trunk/ChangeLog
trunk/gegl/buffer/gegl-buffer-allocator.c
trunk/gegl/gegl-init.c
Modified: trunk/gegl/buffer/gegl-buffer-allocator.c
==============================================================================
--- trunk/gegl/buffer/gegl-buffer-allocator.c (original)
+++ trunk/gegl/buffer/gegl-buffer-allocator.c Wed Feb 13 23:28:41 2008
@@ -128,6 +128,35 @@
static GHashTable *allocators = NULL;
+/* if this function is made to return NULL swapping is disabled */
+const gchar *gegl_swap_dir (void)
+{
+ static gchar swapdir[1024]="";
+ if (swapdir[0]=='\0')
+ {
+ if (g_getenv ("GEGL_SWAP"))
+ {
+ if (g_str_equal (g_getenv ("GEGL_SWAP"), "RAM"))
+ return NULL;
+ g_sprintf (swapdir, "%s", g_getenv ("GEGL_SWAP"));
+ }
+ else
+ {
+ g_sprintf (swapdir, "%s/.%s/swap", g_get_home_dir(), GEGL_LIBRARY);
+ }
+
+ /* Fall back to "swapping to RAM" if not able to make
+ * sure swapping dir exist
+ */
+ if (g_mkdir_with_parents (swapdir, S_IRUSR | S_IWUSR | S_IXUSR)!=0)
+ {
+ g_warning ("unable to make sure swapdir %s exist", swapdir);
+ return NULL;
+ }
+ }
+ return swapdir;
+};
+
GeglBuffer *
gegl_buffer_new_from_format (const void *babl_format,
gint x,
@@ -146,13 +175,11 @@
/* if no match, create new */
if (allocator == NULL)
{
- const gchar *gegl_swap = g_getenv ("GEGL_SWAP");
-
- if (gegl_swap != NULL)
+ if (gegl_swap_dir () != NULL)
{
GeglStorage *storage;
gchar *path;
- path = g_strdup_printf ("%s/GEGL-%i-%s.swap", gegl_swap,
+ path = g_strdup_printf ("%s/GEGL-%i-%s.swap", gegl_swap_dir (),
getpid (), babl_name (babl_format));
storage = g_object_new (GEGL_TYPE_STORAGE,
"format", babl_format,
Modified: trunk/gegl/gegl-init.c
==============================================================================
--- trunk/gegl/gegl-init.c (original)
+++ trunk/gegl/gegl-init.c Wed Feb 13 23:28:41 2008
@@ -49,21 +49,21 @@
static glong global_time = 0;
+static const gchar *makefile (void);
/**
* gegl_init:
* @argc: a pointer to the number of command line arguments.
* @argv: a pointer to the array of command line arguments.
*
- * Call this function before using any other GEGL functions. It will
- * initialize everything needed to operate GEGL and parses some
- * standard command line options. @argc and @argv are adjusted
- * accordingly so your own code will never see those standard
- * arguments.
+ * Call this function before using any other GEGL functions. It will initialize
+ * everything needed to operate GEGL and parses some standard command line
+ * options. @argc and @argv are adjusted accordingly so your own code will
+ * never see those standard arguments.
*
- * Note that there is an alternative ways to initialize GEGL: if you
- * are calling g_option_context_parse() with the option group returned
- * by gegl_get_option_group(), you don't have to call gegl_init().
+ * Note that there is an alternative ways to initialize GEGL: if you are
+ * calling g_option_context_parse() with the option group returned by
+ * gegl_get_option_group(), you don't have to call gegl_init().
**/
void
gegl_init (gint *argc,
@@ -74,9 +74,9 @@
if (!g_thread_supported())
g_thread_init (NULL);
- /* If any command-line actions are ever added to GEGL, then the
- * commented out code below should be used. Until then, we simply
- * call the parse hook directly.
+ /* If any command-line actions are ever added to GEGL, then the commented
+ * out code below should be used. Until then, we simply call the parse hook
+ * directly.
*/
gegl_post_parse_hook (NULL, NULL, NULL, NULL);
@@ -124,6 +124,9 @@
void gegl_tile_mem_stats (void);
+
+const gchar *gegl_swap_dir (void);
+
void
gegl_exit (void)
{
@@ -161,13 +164,12 @@
if (gegl_buffer_leaks ())
g_print (" buffer-leaks: %i", gegl_buffer_leaks ());
- if (g_getenv ("GEGL_SWAP"))
+ if (gegl_swap_dir())
{
/* remove all files matching <$GEGL_SWAP>/GEGL-<pid>-*.swap */
- const gchar *swapdir = g_getenv ("GEGL_SWAP");
guint pid = getpid ();
- GDir *dir = g_dir_open (swapdir, 0, NULL);
+ GDir *dir = g_dir_open (gegl_swap_dir (), 0, NULL);
gchar *glob = g_strdup_printf ("GEGL-%i-*.swap", pid);
GPatternSpec *pattern = g_pattern_spec_new (glob);
@@ -181,7 +183,7 @@
{
if (g_pattern_match_string (pattern, name))
{
- gchar *fname = g_strdup_printf ("%s/%s", swapdir, name);
+ gchar *fname = g_strdup_printf ("%s/%s", gegl_swap_dir (), name);
g_unlink (fname);
g_free (fname);
}
@@ -196,6 +198,7 @@
g_print ("\n");
}
+
static void
gegl_init_i18n (void)
{
@@ -231,14 +234,19 @@
time = gegl_ticks ();
if (!module_db)
{
- gchar *module_path;
+
+ module_db = gegl_module_db_new (FALSE);
if (g_getenv ("GEGL_PATH"))
{
+ gchar *module_path;
module_path = g_strdup (g_getenv ("GEGL_PATH"));
+ gegl_module_db_load (module_db, module_path);
+ g_free (module_path);
}
else
{
+ gchar *module_path;
#ifdef G_OS_WIN32
module_path =
g_win32_get_package_installation_subdirectory (NULL,
@@ -247,13 +255,26 @@
#else
module_path = g_build_filename (LIBDIR, GEGL_LIBRARY, NULL);
#endif
+ gegl_module_db_load (module_db, module_path);
+
+ /* also load plug-ins from ~/.gegl-0.0/plug-ins */
+ g_free (module_path);
+ module_path = g_build_filename (g_get_home_dir (), "." GEGL_LIBRARY, "plug-ins", NULL);
+ if (g_mkdir_with_parents (module_path, S_IRUSR | S_IWUSR | S_IXUSR)==0)
+ {
+ gchar *makefile_path = g_malloc (strlen (module_path) + 20);
+ g_sprintf (makefile_path, "%s/Makefile", module_path);
+ g_printf ("%s\n", makefile_path);
+ if (!g_file_test (makefile_path, G_FILE_TEST_EXISTS))
+ g_file_set_contents (makefile_path, makefile (), -1, NULL);
+ g_free (makefile_path);
+ }
+ gegl_module_db_load (module_db, module_path);
+ g_free (module_path);
}
- module_db = gegl_module_db_new (FALSE);
- gegl_module_db_load (module_db, module_path);
- g_free (module_path);
gegl_instrument ("gegl_init", "load modules", gegl_ticks () - time);
}
@@ -263,3 +284,24 @@
return TRUE;
}
+
+static const gchar *makefile (void)
+{
+ return
+ "# This is a generic makefile for GEGL operations. Just add .c files,\n"
+ "# rename mentions of the filename and opname to the new name, and it should \n"
+ "# compile. Operations in this dir should be loaded by GEGL by default\n"
+ "# If the operation being written depends on extra libraries, you'd better\n"
+ "# add a dedicated target with the extra bits linked in.\n"
+ "\n\n"
+ "CFLAGS += `pkg-config gegl --cflags` -I. -fPIC\n"
+ "LDFLAGS += `pkg-config --libs` -shared\n"
+ "SHREXT=.so\n"
+ "CFILES = $(wildcard ./*.c)\n"
+ "SOBJS = $(subst ./,,$(CFILES:.c=$(SHREXT)))\n"
+ "all: $(SOBJS)\n"
+ "%$(SHREXT): %.c $(GEGLHEADERS)\n"
+ " @echo $@; $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDADD)\n"
+ "clean:\n"
+ " rm -f *$(SHREXT) $(OFILES)\n";
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]