gegl r2320 - in branches/branch_zhangjb: . examples examples/data gegl gegl/buffer gegl/graph gegl/process
- From: zhangjb svn gnome org
- To: svn-commits-list gnome org
- Subject: gegl r2320 - in branches/branch_zhangjb: . examples examples/data gegl gegl/buffer gegl/graph gegl/process
- Date: Tue, 20 May 2008 08:16:42 +0000 (UTC)
Author: zhangjb
Date: Tue May 20 08:16:41 2008
New Revision: 2320
URL: http://svn.gnome.org/viewvc/gegl?rev=2320&view=rev
Log:
Merge from HEAD trunk.
Added:
branches/branch_zhangjb/examples/2geglbuffer.c
- copied unchanged from r2319, /trunk/examples/2geglbuffer.c
branches/branch_zhangjb/examples/data/
- copied from r2319, /trunk/examples/data/
branches/branch_zhangjb/examples/geglbuffer-add-image.c
- copied unchanged from r2319, /trunk/examples/geglbuffer-add-image.c
branches/branch_zhangjb/examples/geglbuffer-clock.c
- copied unchanged from r2319, /trunk/examples/geglbuffer-clock.c
Removed:
branches/branch_zhangjb/examples/2gegl.c
branches/branch_zhangjb/examples/clock.c
Modified:
branches/branch_zhangjb/AUTHORS
branches/branch_zhangjb/ChangeLog
branches/branch_zhangjb/NEWS
branches/branch_zhangjb/configure.ac
branches/branch_zhangjb/examples/Makefile.am
branches/branch_zhangjb/examples/multiplayer-paint.sh
branches/branch_zhangjb/gegl/buffer/Makefile.am
branches/branch_zhangjb/gegl/buffer/gegl-buffer-access.c
branches/branch_zhangjb/gegl/buffer/gegl-buffer-index.h
branches/branch_zhangjb/gegl/buffer/gegl-buffer-load.c
branches/branch_zhangjb/gegl/buffer/gegl-buffer-save.c
branches/branch_zhangjb/gegl/buffer/gegl-buffer.c
branches/branch_zhangjb/gegl/buffer/gegl-tile-backend-file.c
branches/branch_zhangjb/gegl/buffer/gegl-tile-storage.c
branches/branch_zhangjb/gegl/gegl-config.c
branches/branch_zhangjb/gegl/gegl-config.h
branches/branch_zhangjb/gegl/gegl-init.c
branches/branch_zhangjb/gegl/graph/gegl-node-context.c
branches/branch_zhangjb/gegl/graph/gegl-node.c
branches/branch_zhangjb/gegl/process/gegl-eval-mgr.c
branches/branch_zhangjb/gegl/process/gegl-processor.c
Modified: branches/branch_zhangjb/AUTHORS
==============================================================================
--- branches/branch_zhangjb/AUTHORS (original)
+++ branches/branch_zhangjb/AUTHORS Tue May 20 08:16:41 2008
@@ -6,7 +6,8 @@
Richard Kralovic, Kevin Cozens, Victor Bogado, Martin Nordholts, Geert
Jordaens, Michael Schumacher, John Marshall, Ãtienne Bersac, Mark Probst, HÃkon
Hitland, Tor Lillqvist, Hans Breuer, Deji Akingunola and Bradley Broom,
-Hans Petter Jansson, Jan Heller.
+Hans Petter Jansson, Jan Heller, dmacks netscpace org, Sven Anders and
+Hubert Figuiere.
Documentation:
^^^^^^^^^^^^^^
Modified: branches/branch_zhangjb/NEWS
==============================================================================
--- branches/branch_zhangjb/NEWS (original)
+++ branches/branch_zhangjb/NEWS Tue May 20 08:16:41 2008
@@ -13,6 +13,8 @@
â Fileformat compatible with swap format.
â Tunable cache size.
â Operations
+ â Optimized iteration over buffer in pointer filters when possible using a
+ scan iterator.
â Handle variant implementations of GeglOperations.
â Optimized variants of some point and compositing operations reimplemented
using a new data type /g4float/ that allows writing cpu agnostic vectorized
@@ -21,7 +23,8 @@
Contributions from:
Ãyvind KolÃs, Kevin Cozens, Sven Neumann, Manish Singh, Martin Nordholts,
- Ãtienne Bersac, Hans Petter Jansson, Jan Heller.
+ Ãtienne Bersac, Hans Petter Jansson, Jan Heller, dmacs netspace org,
+ Sven Anders and Hubert Figuiere.
Changes in GEGL 0.0.16
ââââââââââââââââââââââ
Modified: branches/branch_zhangjb/configure.ac
==============================================================================
--- branches/branch_zhangjb/configure.ac (original)
+++ branches/branch_zhangjb/configure.ac Tue May 20 08:16:41 2008
@@ -39,7 +39,7 @@
# required versions of external libraries
m4_define([babl_required_version], [0.0.20])
-m4_define([glib_required_version], [2.16.1])
+m4_define([glib_required_version], [2.12.0])
m4_define([gtk_required_version], [2.8.6])
m4_define([lua_required_version], [5.1.0])
m4_define([cairo_required_version], [0.0.0])
@@ -333,21 +333,6 @@
#AC_PROG_YACC
#AM_PROG_LEX
-#############################
-# Threads and multi processor
-#############################
-
-AC_ARG_ENABLE(mp, [ --enable-mp enable experimental support for multiple processors], ,
-enable_mp=no
-)
-
-if test "x$enable_mp" != "xno"; then
- AC_DEFINE(ENABLE_MP, 1,
- [Define to 1 to enable support for multiple processors.])
-fi
-
-
-
########################
# Check for MMX assembly
@@ -435,7 +420,7 @@
PKG_CHECK_MODULES(BABL, babl >= babl_required_version)
-GLIB_PACKAGES="gobject-2.0 gmodule-2.0 gio-2.0"
+GLIB_PACKAGES="gobject-2.0 gmodule-2.0 "
AC_SUBST(GLIB_PACKAGES)
dnl This PATH_GLIB is somewhat redundant, but does a sanity compile and
@@ -454,6 +439,13 @@
*** Errors follow:
$DEP_PKG_ERRORS]))
+PKG_CHECK_MODULES(GIO, gio-2.0,
+ have_gio="yes"
+ AC_DEFINE(HAVE_GIO, 1, [Define to 1 to compile with gio support.])
+ GLIB_PACKAGES="$GLIB_PACKAGES gio-2.0",
+ have_gio="no (gio not found)")
+AM_CONDITIONAL(HAVE_GIO, test "x$have_gio" = "xyes")
+
# Rerun PKG_CONFIG to add gthread-2.0 cflags and libs
DEP_CFLAGS=`$PKG_CONFIG --cflags $GLIB_PACKAGES gthread-2.0`
DEP_LIBS=`$PKG_CONFIG --libs $GLIB_PACKAGES gthread-2.0`
@@ -846,6 +838,7 @@
docs/gallery/Makefile
docs/gallery/data/Makefile
examples/Makefile
+examples/data/Makefile
gegl.pc
gegl-uninstalled.pc
])
@@ -858,11 +851,11 @@
GEGL docs: $enable_docs
Build workshop: $enable_workshop
Build website: $have_asciidoc
- Multiprocessor: $enable_mp
SIMD: sse:$enable_sse mmx:$enable_mmx
Optional dependencies:
GTK+: $have_gtk
+ GIO: $have_gio
Ruby: $have_ruby
Lua: $have_lua
Cairo: $have_cairo
Modified: branches/branch_zhangjb/examples/Makefile.am
==============================================================================
--- branches/branch_zhangjb/examples/Makefile.am (original)
+++ branches/branch_zhangjb/examples/Makefile.am Tue May 20 08:16:41 2008
@@ -1,5 +1,6 @@
#include $(top_srcdir)/operations/Makefile-common.am
+SUBDIRS = data
CFILES = $(wildcard $(srcdir)/*.c)
bins = $(subst $(srcdir)/,,$(CFILES:.c=))
EXTRA_DIST = $(wildcard *.c)
Modified: branches/branch_zhangjb/examples/multiplayer-paint.sh
==============================================================================
--- branches/branch_zhangjb/examples/multiplayer-paint.sh (original)
+++ branches/branch_zhangjb/examples/multiplayer-paint.sh Tue May 20 08:16:41 2008
@@ -1,11 +1,12 @@
#!/bin/sh
-./2gegl data/car-stack.jpg test.gegl
-./clock test.gegl &
+./2geglbuffer data/surfer.png test.gegl
+./geglbuffer-add-image test.gegl data/surfer.png 64 64
+./geglbuffer-clock test.gegl &
+
./gegl-paint test.gegl &
./gegl-paint test.gegl &
-gegl -x '<gegl><open-buffer path="test.gegl"/></gegl>'
-
-killall -9 clock gegl-paint lt-clock lt-gegl-paint
+gegl -x '<gegl><open-buffer path="test.gegl"/></gegl>'
+killall -9 geglbuffer-clock gegl-paint lt-geglbuffer-clock lt-gegl-paint
Modified: branches/branch_zhangjb/gegl/buffer/Makefile.am
==============================================================================
--- branches/branch_zhangjb/gegl/buffer/Makefile.am (original)
+++ branches/branch_zhangjb/gegl/buffer/Makefile.am Tue May 20 08:16:41 2008
@@ -1,6 +1,13 @@
noinst_LTLIBRARIES = libbuffer.la
+if HAVE_GIO
+GIO_SUPPORT_SOURCES=\
+ gegl-tile-backend-tiledir.c \
+ $(null__)
+endif
+
BUFFER_sources = \
+ $(GIO_SUPPORT_SOURCES) \
gegl-buffer.c \
gegl-buffer-access.c \
gegl-buffer-share.c \
@@ -19,7 +26,6 @@
gegl-tile-storage.c \
gegl-tile-backend.c \
gegl-tile-backend-file.c \
- gegl-tile-backend-tiledir.c \
gegl-tile-backend-ram.c \
gegl-tile-handler.c \
gegl-tile-handler-cache.c \
Modified: branches/branch_zhangjb/gegl/buffer/gegl-buffer-access.c
==============================================================================
--- branches/branch_zhangjb/gegl/buffer/gegl-buffer-access.c (original)
+++ branches/branch_zhangjb/gegl/buffer/gegl-buffer-access.c Tue May 20 08:16:41 2008
@@ -22,7 +22,9 @@
#include <glib-object.h>
#include <glib/gprintf.h>
+#if HAVE_GIO
#include <gio/gio.h>
+#endif
#include "gegl-types.h"
#include "gegl-buffer-types.h"
Modified: branches/branch_zhangjb/gegl/buffer/gegl-buffer-index.h
==============================================================================
--- branches/branch_zhangjb/gegl/buffer/gegl-buffer-index.h (original)
+++ branches/branch_zhangjb/gegl/buffer/gegl-buffer-index.h Tue May 20 08:16:41 2008
@@ -122,10 +122,17 @@
void gegl_tile_entry_destroy (GeglBufferTile *entry);
+#if HAVE_GIO
GeglBufferItem *gegl_buffer_read_header(GInputStream *i,
goffset *offset);
GList *gegl_buffer_read_index (GInputStream *i,
goffset *offset);
+#else
+GeglBufferItem *gegl_buffer_read_header(int i,
+ goffset *offset);
+GList *gegl_buffer_read_index (int i,
+ goffset *offset);
+#endif
#define struct_check_padding(type, size) \
if (sizeof (type) != size) \
Modified: branches/branch_zhangjb/gegl/buffer/gegl-buffer-load.c
==============================================================================
--- branches/branch_zhangjb/gegl/buffer/gegl-buffer-load.c (original)
+++ branches/branch_zhangjb/gegl/buffer/gegl-buffer-load.c Tue May 20 08:16:41 2008
@@ -21,7 +21,14 @@
#include <string.h>
#include <errno.h>
+#if HAVE_GIO
#include <gio/gio.h>
+#else
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#endif
#include <glib-object.h>
#include "gegl-types.h"
@@ -49,8 +56,12 @@
GeglBufferHeader header;
GList *tiles;
gchar *path;
+#if HAVE_GIO
GFile *file;
GInputStream *i;
+#else
+ int i;
+#endif
gint tile_size;
Babl *format;
goffset offset;
@@ -62,7 +73,11 @@
{
info->offset = offset;
GEGL_NOTE (BUFFER_LOAD, "seek to %i", offset);
+#if HAVE_GIO
if(!g_seekable_seek (G_SEEKABLE (info->i), info->offset, G_SEEK_SET, NULL, NULL))
+#else
+ if(lseek (info->i, info->offset, SEEK_SET) == -1)
+#endif
{
g_warning ("failed seeking");
}
@@ -75,11 +90,15 @@
return;
if (info->path)
g_free (info->path);
+#if HAVE_GIO
if (info->i)
g_object_unref (info->i);
if (info->file)
g_object_unref (info->file);
-
+#else
+ if (info->i != -1)
+ close (info->i);
+#endif
if (info->tiles != NULL)
{
GList *iter;
@@ -93,24 +112,42 @@
g_slice_free (LoadInfo, info);
}
+#if HAVE_GIO
GeglBufferItem *
gegl_buffer_read_header (GInputStream *i,
goffset *offset)
+#else
+GeglBufferItem *
+gegl_buffer_read_header (int i,
+ goffset *offset)
+#endif
{
goffset placeholder;
GeglBufferItem *ret;
if (offset==0)
offset = &placeholder;
+#if HAVE_GIO
if(!g_seekable_seek (G_SEEKABLE (i), 0, G_SEEK_SET, NULL, NULL))
- g_warning ("failed seeking to %i", 0);
+#else
+ if(lseek(i, 0, SEEK_SET) == -1)
+#endif
+ g_warning ("failed seeking to %i", 0);
*offset = 0;
ret = g_malloc (sizeof (GeglBufferHeader));
+#if HAVE_GIO
*offset += g_input_stream_read (i,
((gchar*)ret),
sizeof(GeglBufferHeader),
NULL, NULL);
+#else
+ {
+ ssize_t sz_read = read(i, ret, sizeof(GeglBufferHeader));
+ if (sz_read != -1)
+ *offset += sz_read;
+ }
+#endif
GEGL_NOTE (BUFFER_LOAD, "read header: tile-width: %i tile-height: %i next:%i %ix%i\n",
ret->header.tile_width,
@@ -135,22 +172,39 @@
* is passed in the offset stored at the location is used as the initial seeking
* point and will be updated with the offset after the read is completed.
*/
+#if HAVE_GIO
static GeglBufferItem *read_block (GInputStream *i,
goffset *offset)
+#else
+static GeglBufferItem *read_block (int i,
+ goffset *offset)
+#endif
{
GeglBufferBlock block;
GeglBufferItem *ret;
- gsize read = 0;
+ gsize byte_read = 0;
gint own_size=0;
if (*offset==0)
return NULL;
if (offset)
+#if HAVE_GIO
if(!g_seekable_seek (G_SEEKABLE (i), *offset, G_SEEK_SET, NULL, NULL))
+#else
+ if(lseek(i, *offset, SEEK_SET) == -1)
+#endif
g_warning ("failed seeking to %i", (gint)*offset);
- read += g_input_stream_read (i, &block, sizeof (GeglBufferBlock), NULL, NULL);
+#if HAVE_GIO
+ byte_read += g_input_stream_read (i, &block, sizeof (GeglBufferBlock), NULL, NULL);
+#else
+ {
+ ssize_t sz_read = read (i, &block, sizeof (GeglBufferBlock));
+ if(sz_read != -1)
+ byte_read += sz_read;
+ }
+#endif
GEGL_NOTE (BUFFER_LOAD, "read block: length:%i next:%i",
block.length, (guint)block.next);
@@ -179,18 +233,36 @@
*/
ret = g_malloc (own_size);
memcpy (ret, &block, sizeof (GeglBufferBlock));
- read += g_input_stream_read (i, ((gchar*)ret) + sizeof(GeglBufferBlock),
+#if HAVE_GIO
+ byte_read += g_input_stream_read (i, ((gchar*)ret) + sizeof(GeglBufferBlock),
own_size - sizeof(GeglBufferBlock),
NULL, NULL);
+#else
+ {
+ ssize_t sz_read = read (i, ((gchar*)ret) + sizeof(GeglBufferBlock),
+ own_size - sizeof(GeglBufferBlock));
+ if(sz_read != -1)
+ byte_read += sz_read;
+ }
+#endif
ret->block.length = own_size;
}
else if (block.length < own_size)
{
ret = g_malloc (own_size);
memcpy (ret, &block, sizeof (GeglBufferBlock));
- read += g_input_stream_read (i, ((gchar*)ret) + sizeof(GeglBufferBlock),
+#if HAVE_GIO
+ byte_read += g_input_stream_read (i, ((gchar*)ret) + sizeof(GeglBufferBlock),
block.length - sizeof (GeglBufferBlock),
NULL, NULL);
+#else
+ {
+ ssize_t sz_read = read (i, ret + sizeof(GeglBufferBlock),
+ block.length - sizeof (GeglBufferBlock));
+ if(sz_read != -1)
+ byte_read += sz_read;
+ }
+#endif
ret->block.length = own_size;
}
else
@@ -199,13 +271,19 @@
g_warning ("skipping block : of flags:%i\n", block.flags);
}
- *offset += read;
+ *offset += byte_read;
return ret;
}
+#if HAVE_GIO
GList *
gegl_buffer_read_index (GInputStream *i,
goffset *offset)
+#else
+GList *
+gegl_buffer_read_index (int i,
+ goffset *offset)
+#endif
/* load the index */
{
GList *ret = NULL;
@@ -247,14 +325,23 @@
info->path = g_strdup (path);
+#if HAVE_GIO
info->file = g_file_new_for_commandline_arg (info->path);
info->i = G_INPUT_STREAM (g_file_read (info->file, NULL, NULL));
-
+#else
+ info->i = open (info->path, O_RDONLY);
+#endif
GEGL_NOTE (BUFFER_LOAD, "starting to load buffer %s", path);
+#if HAVE_GIO
if (!info->i)
+#else
+ if (info->i == -1)
+#endif
{
GEGL_NOTE (BUFFER_LOAD, "failed top open %s for reading", path);
+#if HAVE_GIO
g_object_unref (info->file);
+#endif
return NULL;
}
@@ -318,9 +405,16 @@
data = gegl_tile_get_data (tile);
g_assert (data);
+#if HAVE_GIO
info->offset += g_input_stream_read (info->i, data, info->tile_size,
NULL, NULL);
-
+#else
+ {
+ ssize_t sz_read = read (info->i, data, info->tile_size);
+ if(sz_read != -1)
+ info->offset += sz_read;
+ }
+#endif
/*g_assert (info->offset == entry->offset + info->tile_size);*/
gegl_tile_unlock (tile);
Modified: branches/branch_zhangjb/gegl/buffer/gegl-buffer-save.c
==============================================================================
--- branches/branch_zhangjb/gegl/buffer/gegl-buffer-save.c (original)
+++ branches/branch_zhangjb/gegl/buffer/gegl-buffer-save.c Tue May 20 08:16:41 2008
@@ -20,7 +20,15 @@
#include <string.h>
+#if HAVE_GIO
#include <gio/gio.h>
+#else
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#endif
+
#include <glib-object.h>
#include "gegl-types.h"
@@ -45,8 +53,12 @@
GeglBufferHeader header;
GList *tiles;
gchar *path;
+#if HAVE_GIO
GFile *file;
GOutputStream *o;
+#else
+ int o;
+#endif
gint tile_size;
gint offset;
@@ -93,7 +105,13 @@
if (block == NULL)
info->in_holding->next = 0;
+#if HAVE_GIO
ret = g_output_stream_write (info->o, info->in_holding, info->in_holding->length, NULL, NULL);
+#else
+ ret = write (info->o, info->in_holding, info->in_holding->length);
+ if (ret == -1)
+ ret = 0;
+#endif
info->offset += ret;
g_assert (allocated_pos == info->offset);
}
@@ -111,10 +129,15 @@
return;
if (info->path)
g_free (info->path);
+#if HAVE_GIO
if (info->o)
g_object_unref (info->o);
if (info->file)
g_object_unref (info->file);
+#else
+ if (info->o != -1)
+ close (info->o);
+#endif
if (info->tiles != NULL)
{
GList *iter;
@@ -209,9 +232,12 @@
*/
info->path = g_strdup (path);
+#if HAVE_GIO
info->file = g_file_new_for_commandline_arg (info->path);
info->o = G_OUTPUT_STREAM (g_file_replace (info->file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, NULL));
-
+#else
+ info->o = open (info->path, O_RDWR|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
+#endif
g_object_get (buffer, "px-size", &bpp, NULL);
info->header.x = buffer->extent.x;
info->header.y = buffer->extent.y;
@@ -312,7 +338,15 @@
}
/* save the header */
+#if HAVE_GIO
info->offset += g_output_stream_write (info->o, &info->header, sizeof (GeglBufferHeader), NULL, NULL);
+#else
+ {
+ ssize_t ret = write (info->o, &info->header, sizeof (GeglBufferHeader));
+ if (ret != -1)
+ info->offset += ret;
+ }
+#endif
g_assert (info->offset == info->header.next);
/* save the index */
@@ -351,7 +385,15 @@
g_assert (data);
g_assert (info->offset == entry->offset);
+#if HAVE_GIO
info->offset += g_output_stream_write (info->o, data, info->tile_size, NULL, NULL);
+#else
+ {
+ ssize_t ret = write (info->o, data, info->tile_size);
+ if (ret != -1)
+ info->offset += ret;
+ }
+#endif
g_object_unref (G_OBJECT (tile));
i++;
}
Modified: branches/branch_zhangjb/gegl/buffer/gegl-buffer.c
==============================================================================
--- branches/branch_zhangjb/gegl/buffer/gegl-buffer.c (original)
+++ branches/branch_zhangjb/gegl/buffer/gegl-buffer.c Tue May 20 08:16:41 2008
@@ -41,7 +41,9 @@
#include <glib-object.h>
#include <glib/gstdio.h>
#include <glib/gprintf.h>
+#if HAVE_GIO
#include <gio/gio.h>
+#endif
#include "gegl-types.h"
Modified: branches/branch_zhangjb/gegl/buffer/gegl-tile-backend-file.c
==============================================================================
--- branches/branch_zhangjb/gegl/buffer/gegl-tile-backend-file.c (original)
+++ branches/branch_zhangjb/gegl/buffer/gegl-tile-backend-file.c Tue May 20 08:16:41 2008
@@ -18,7 +18,14 @@
#include "config.h"
+#if HAVE_GIO
#include <gio/gio.h>
+#else
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#endif
#include <string.h>
#include <errno.h>
@@ -36,9 +43,14 @@
GeglTileBackend parent_instance;
gchar *path; /* the path to our buffer */
+#if HAVE_GIO
GFile *file; /* gfile refering to our buffer */
GOutputStream *o; /* for writing */
GInputStream *i; /* for reading */
+#else
+ int o;
+ int i;
+#endif
gboolean exist; /* the file exist (and we've thus been able
* to initialize i and o, the utility_call ensure_exist
* should be called before any code using i and o)
@@ -78,11 +90,12 @@
GList *tiles;
/* cooperative sharing of file */
-
+#if HAVE_GIO
GFileMonitor *monitor; /* Before using mmap we'll use GIO's infrastructure
* for monitoring the file for changes, this should
* also be more portable.
*/
+#endif
guint32 rev; /* revision of last index sync */
};
@@ -107,9 +120,13 @@
ensure_exist (self);
+#if HAVE_GIO
success = g_seekable_seek (G_SEEKABLE (self->i),
offset, G_SEEK_SET,
NULL, NULL);
+#else
+ success = (lseek (self->i, offset, SEEK_SET) >= 0);
+#endif
if (success == FALSE)
{
g_warning ("unable to seek to tile in buffer: %s", g_strerror (errno));
@@ -119,19 +136,23 @@
while (to_be_read > 0)
{
- gint read;
+ gint byte_read;
- read = g_input_stream_read (G_INPUT_STREAM (self->i),
+#if HAVE_GIO
+ byte_read = g_input_stream_read (G_INPUT_STREAM (self->i),
dest + tile_size - to_be_read, to_be_read,
NULL, NULL);
- if (read <= 0)
+#else
+ byte_read = read (self->i, dest + tile_size - to_be_read, to_be_read);
+#endif
+ if (byte_read <= 0)
{
g_message ("unable to read tile data from self: "
"%s (%d/%d bytes read)",
- g_strerror (errno), read, to_be_read);
+ g_strerror (errno), byte_read, to_be_read);
return;
}
- to_be_read -= read;
+ to_be_read -= byte_read;
}
@@ -150,9 +171,13 @@
ensure_exist (self);
+#if HAVE_GIO
success = g_seekable_seek (G_SEEKABLE (self->o),
offset, G_SEEK_SET,
NULL, NULL);
+#else
+ success = (lseek (self->o, offset, SEEK_SET) >= 0);
+#endif
if (success == FALSE)
{
g_warning ("unable to seek to tile in buffer: %s", g_strerror (errno));
@@ -163,10 +188,14 @@
while (to_be_written > 0)
{
gint wrote;
+#if HAVE_GIO
wrote = g_output_stream_write (self->o,
source + tile_size - to_be_written,
to_be_written, NULL, NULL);
-
+#else
+ wrote = write (self->o, source + tile_size - to_be_written,
+ to_be_written);
+#endif
if (wrote <= 0)
{
g_message ("unable to write tile data to self: "
@@ -211,8 +240,12 @@
GEGL_NOTE (TILE_BACKEND, "growing file to %i bytes", (gint)self->total);
+#if HAVE_GIO
g_assert (g_seekable_truncate (G_SEEKABLE (self->o),
self->total, NULL,NULL));
+#else
+ g_assert (ftruncate (self->o, self->total) == 0);
+#endif
}
}
dbg_alloc (GEGL_TILE_BACKEND (self)->tile_size);
@@ -240,14 +273,22 @@
ensure_exist (self);
+#if HAVE_GIO
success = g_seekable_seek (G_SEEKABLE (self->o), 0, G_SEEK_SET,
NULL, NULL);
+#else
+ success = (lseek (self->o, 0, SEEK_SET) != -1);
+#endif
if (success == FALSE)
{
g_warning ("unable to seek in buffer");
return FALSE;
}
+#if HAVE_GIO
g_output_stream_write (self->o, &(self->header), 256, NULL, NULL);
+#else
+ write (self->o, &(self->header), 256);
+#endif
GEGL_NOTE (TILE_BACKEND, "Wrote header, next=%i", (gint)self->header.next);
return TRUE;
}
@@ -269,9 +310,13 @@
self->in_holding->next = 0;
}
+#if HAVE_GIO
if(!g_seekable_seek (G_SEEKABLE (self->o),
self->offset, G_SEEK_SET,
NULL, NULL))
+#else
+ if(lseek (self->o, self->offset, G_SEEK_SET) == -1)
+#endif
goto fail;
GEGL_NOTE (TILE_BACKEND, "Wrote block: length:%i flags:%i next:%i at offset %i",
@@ -279,9 +324,18 @@
self->in_holding->flags,
(gint)self->in_holding->next,
(gint)self->offset);
+#if HAVE_GIO
self->offset += g_output_stream_write (self->o, self->in_holding,
self->in_holding->length,
NULL, NULL);
+#else
+ {
+ ssize_t written = write (self->o, self->in_holding,
+ self->in_holding->length);
+ if(written != -1)
+ self->offset += written;
+ }
+#endif
g_assert (next_allocation == self->offset); /* true as long as
the simple allocation
@@ -297,10 +351,13 @@
* of file, worry about writing
* header inside free list later
*/
-
+#if HAVE_GIO
if(!g_seekable_seek (G_SEEKABLE (self->o),
(goffset) self->offset, G_SEEK_SET,
NULL, NULL))
+#else
+ if(lseek (self->o, self->offset, G_SEEK_SET) == -1)
+#endif
goto fail;
}
self->in_holding = block;
@@ -506,7 +563,11 @@
}
write_header (self);
+#if HAVE_GIO
g_output_stream_flush (self->o, NULL, NULL);
+#else
+ fsync (self->o);
+#endif
GEGL_NOTE (TILE_BACKEND, "flushed %s", self->path);
@@ -609,6 +670,7 @@
{
GEGL_NOTE (TILE_BACKEND, "finalizing buffer %s", self->path);
+#if HAVE_GIO
if (self->i)
g_object_unref (self->i);
if (self->o)
@@ -619,13 +681,27 @@
g_file_delete (self->file, NULL, NULL);
g_object_unref (self->file);
}
+#else
+ if (self->i != -1)
+ {
+ close(self->i);
+ self->i = -1;
+ }
+ if (self->o != -1)
+ {
+ close(self->o);
+ self->o = -1;
+ }
+#endif
}
if (self->path)
g_free (self->path);
+#if HAVE_GIO
if (self->monitor)
g_object_unref (self->monitor);
+#endif
(*G_OBJECT_CLASS (parent_class)->finalize)(object);
}
@@ -760,6 +836,7 @@
self->tiles = NULL;
}
+#if HAVE_GIO
static void
file_changed (GFileMonitor *monitor,
GFile *file,
@@ -773,6 +850,8 @@
load_index (self, TRUE);
}
}
+#endif
+
static GObject *
gegl_tile_backend_file_constructor (GType type,
guint n_params,
@@ -787,15 +866,23 @@
backend = GEGL_TILE_BACKEND (object);
GEGL_NOTE (TILE_BACKEND, "constructing file backend: %s", self->path);
+#if HAVE_GIO
self->file = g_file_new_for_commandline_arg (self->path);
-
+#else
+ self->i = self->o = -1;
+#endif
self->index = g_hash_table_new (hashfunc, equalfunc);
/* If the file already exists open it, assuming it is a GeglBuffer. */
+#if HAVE_GIO
if (g_file_query_exists (self->file, NULL))
+#else
+ if (access (self->path, F_OK) != -1)
+#endif
{
goffset offset = 0;
+#if HAVE_GIO
/* Install a monitor for changes to the file in case other applications
* might be writing to the buffer
*/
@@ -818,6 +905,10 @@
NULL, NULL));
self->i = g_object_get_data (G_OBJECT (self->o), "istream");
#endif
+#else
+ self->o = open (self->path, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
+ self->i = self->o;
+#endif
/*self->i = G_INPUT_STREAM (g_file_read (self->file, NULL, NULL));*/
self->header = gegl_buffer_read_header (self->i, &offset)->header;
self->header.rev = self->header.rev -1;
@@ -843,7 +934,9 @@
self->exist = FALSE; /* this is also the default, the file will be created on demand */
}
+#if HAVE_GIO
g_assert (self->file);
+#endif
backend->header = &self->header;
@@ -876,13 +969,19 @@
g_output_stream_flush (self->o, NULL, NULL);
self->i = g_object_get_data (G_OBJECT (self->o), "istream");
#else
+
+#if HAVE_GIO
self->o = G_OUTPUT_STREAM (g_file_replace (self->file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, NULL));
g_output_stream_flush (self->o, NULL, NULL);
+#else
+ self->o = open (self->path, O_RDWR);
+#endif
self->next_pre_alloc = 256; /* reserved space for header */
self->total = 256; /* reserved space for header */
+#if HAVE_GIO
g_assert(g_seekable_seek (G_SEEKABLE (self->o), 256, G_SEEK_SET, NULL, NULL));
-
+#endif
gegl_buffer_header_init (&self->header,
backend->tile_width,
backend->tile_height,
@@ -890,14 +989,25 @@
backend->format
);
write_header (self);
+#if HAVE_GIO
g_output_stream_flush (self->o, NULL, NULL);
self->i = G_INPUT_STREAM (g_file_read (self->file, NULL, NULL));
+#else
+ fsync (self->o);
+ self->i = open (self->path, O_RDONLY);
+#endif
+
#endif
/*self->i = G_INPUT_STREAM (g_file_read (self->file, NULL, NULL));*/
self->next_pre_alloc = 256; /* reserved space for header */
self->total = 256; /* reserved space for header */
+#if HAVE_GIO
g_assert (self->i);
g_assert (self->o);
+#else
+ g_assert (self->i != -1);
+ g_assert (self->o != -1);
+#endif
}
}
@@ -931,9 +1041,14 @@
gegl_tile_backend_file_init (GeglTileBackendFile *self)
{
self->path = NULL;
+#if HAVE_GIO
self->file = NULL;
self->i = NULL;
self->o = NULL;
+#else
+ self->i = -1;
+ self->o = -1;
+#endif
self->index = NULL;
self->free_list = NULL;
self->next_pre_alloc = 256; /* reserved space for header */
@@ -951,7 +1066,11 @@
}
self->header.flags += GEGL_FLAG_LOCKED;
write_header (self);
+#if HAVE_GIO
g_output_stream_flush (self->o, NULL, NULL);
+#else
+ fsync (self->o);
+#endif
return TRUE;
}
@@ -964,6 +1083,10 @@
}
self->header.flags -= GEGL_FLAG_LOCKED;
write_header (self);
+#if HAVE_GIO
g_output_stream_flush (self->o, NULL, NULL);
+#else
+ fsync (self->o);
+#endif
return TRUE;
}
Modified: branches/branch_zhangjb/gegl/buffer/gegl-tile-storage.c
==============================================================================
--- branches/branch_zhangjb/gegl/buffer/gegl-tile-storage.c (original)
+++ branches/branch_zhangjb/gegl/buffer/gegl-tile-storage.c Tue May 20 08:16:41 2008
@@ -24,7 +24,9 @@
#include "gegl-tile.h"
#include "gegl-tile-backend-file.h"
#include "gegl-tile-backend-ram.h"
+#if HAVE_GIO
#include "gegl-tile-backend-tiledir.h"
+#endif
#include "gegl-tile-handler-empty.h"
#include "gegl-tile-handler-zoom.h"
#include "gegl-tile-handler-cache.h"
Modified: branches/branch_zhangjb/gegl/gegl-config.c
==============================================================================
--- branches/branch_zhangjb/gegl/gegl-config.c (original)
+++ branches/branch_zhangjb/gegl/gegl-config.c Tue May 20 08:16:41 2008
@@ -31,8 +31,7 @@
PROP_QUALITY,
PROP_CACHE_SIZE,
PROP_SWAP,
- PROP_BABL_ERROR,
- PROP_NODE_CACHES
+ PROP_BABL_ERROR
};
static void
@@ -61,10 +60,6 @@
g_value_set_string (value, config->swap);
break;
- case PROP_NODE_CACHES:
- g_value_set_boolean (value, config->node_caches);
- break;
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, property_id, pspec);
break;
@@ -104,9 +99,6 @@
g_free (config->swap);
config->swap = g_value_dup_string (value);
break;
- case PROP_NODE_CACHES:
- config->node_caches = g_value_get_boolean (value);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, property_id, pspec);
break;
@@ -135,10 +127,6 @@
gobject_class->get_property = get_property;
gobject_class->finalize = finalize;
- g_object_class_install_property (gobject_class, PROP_NODE_CACHES,
- g_param_spec_boolean ("node-caches", "Node caches", "Whether GEGL caches the results at each node in the graph.", TRUE,
- G_PARAM_READWRITE));
-
g_object_class_install_property (gobject_class, PROP_CACHE_SIZE,
g_param_spec_double ("cachei-size", "Cache size", "size of cache in bytes",
0.0, 1.0, 1.0,
@@ -165,5 +153,4 @@
self->swap = NULL;
self->quality = 1.0;
self->cache_size = 256*1024*1024;
- self->node_caches = TRUE;
}
Modified: branches/branch_zhangjb/gegl/gegl-config.h
==============================================================================
--- branches/branch_zhangjb/gegl/gegl-config.h (original)
+++ branches/branch_zhangjb/gegl/gegl-config.h Tue May 20 08:16:41 2008
@@ -42,7 +42,6 @@
gint cache_size;
gdouble quality;
gdouble babl_error;
- gboolean node_caches;
};
struct _GeglConfigClass
Modified: branches/branch_zhangjb/gegl/gegl-init.c
==============================================================================
--- branches/branch_zhangjb/gegl/gegl-init.c (original)
+++ branches/branch_zhangjb/gegl/gegl-init.c Tue May 20 08:16:41 2008
@@ -132,11 +132,6 @@
if (config)
return;
-#if ENABLE_MP
- if (!g_thread_supported())
- g_thread_init (NULL);
-#endif
-
/* 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.
@@ -164,7 +159,6 @@
static gchar *cmd_gegl_cache_size=NULL;
static gchar *cmd_gegl_quality=NULL;
static gchar *cmd_babl_error=NULL;
-static gboolean cmd_no_node_caches=FALSE;
static const GOptionEntry cmd_entries[]=
{
@@ -184,11 +178,6 @@
N_("How much memory to (approximately) use for caching imagery"), "<megabytes>"
},
{
- "gegl-no-node-caches", 0, 0,
- G_OPTION_ARG_NONE, &cmd_no_node_caches,
- N_("Don't use per node caches to speed up _re_evaluation of the graph"),
- },
- {
"gegl-quality", 0, 0,
G_OPTION_ARG_STRING, &cmd_gegl_quality,
N_("The quality of rendering a value between 0.0(fast) and 1.0(reference)"), "<quality>"
@@ -227,7 +216,9 @@
}
void gegl_tile_backend_ram_stats (void);
+#if HAVE_GIO
void gegl_tile_backend_tiledir_stats (void);
+#endif
void gegl_tile_backend_file_stats (void);
void
@@ -256,7 +247,9 @@
gegl_buffer_stats ();
gegl_tile_backend_ram_stats ();
gegl_tile_backend_file_stats ();
+#if HAVE_GIO
gegl_tile_backend_tiledir_stats ();
+#endif
}
global_time = gegl_ticks () - global_time;
gegl_instrument ("gegl", "gegl", global_time);
@@ -356,9 +349,6 @@
if (g_getenv ("GEGL_CACHE_SIZE"))
config->cache_size = atoi(g_getenv("GEGL_CACHE_SIZE"))* 1024*1024;
- config->node_caches = !cmd_no_node_caches;
- if (g_getenv ("GEGL_NO_NODE_CACHES"))
- g_object_set (config, "node-caches", FALSE, NULL);
if (gegl_swap_dir())
config->swap = g_strdup(gegl_swap_dir ());
if (cmd_gegl_swap)
Modified: branches/branch_zhangjb/gegl/graph/gegl-node-context.c
==============================================================================
--- branches/branch_zhangjb/gegl/graph/gegl-node-context.c (original)
+++ branches/branch_zhangjb/gegl/graph/gegl-node-context.c Tue May 20 08:16:41 2008
@@ -204,15 +204,15 @@
{
Property *property = NULL;
- {
- GSList *found;
- found = g_slist_find_custom (self->property, property_name, lookup_property);
- if (found)
- property = found->data;
- }
+ GSList *found;
+ found = g_slist_find_custom (self->property, property_name, lookup_property);
+ if (found)
+ property = found->data;
+
if (!property)
{
- g_warning ("didn't find context %p for %s", property_name, gegl_node_get_debug_name (self->node));
+ g_warning ("didn't find context %p for %s", property_name,
+ gegl_node_get_debug_name (self->node));
return;
}
self->property = g_slist_remove (self->property, property);
@@ -224,7 +224,9 @@
const gchar *property_name)
{
Property *property = NULL;
- GSList *found = g_slist_find_custom (self->property, property_name, lookup_property);
+ GSList *found;
+
+ found = g_slist_find_custom (self->property, property_name, lookup_property);
if (found)
property = found->data;
@@ -333,7 +335,8 @@
if (format == NULL)
{
- g_warning ("no format for %s presuming RGBA float\n", gegl_node_get_debug_name (node));
+ g_warning ("no format for %s presuming RGBA float\n",
+ gegl_node_get_debug_name (node));
format = babl_format ("RGBA float");
}
g_assert (format != NULL);
@@ -341,8 +344,7 @@
result = &context->result_rect;
- if (gegl_config()->node_caches &&
- node->dont_cache == FALSE &&
+ if (node->dont_cache == FALSE &&
! GEGL_OPERATION_CLASS (G_OBJECT_GET_CLASS (operation))->no_cache)
{
GeglBuffer *cache;
Modified: branches/branch_zhangjb/gegl/graph/gegl-node.c
==============================================================================
--- branches/branch_zhangjb/gegl/graph/gegl-node.c (original)
+++ branches/branch_zhangjb/gegl/graph/gegl-node.c Tue May 20 08:16:41 2008
@@ -40,10 +40,6 @@
#include "process/gegl-eval-mgr.h"
#include "process/gegl-have-visitor.h"
-#if ENABLE_MP
-#include "process/gegl-lock-visitor.h"
-#include "process/gegl-unlock-visitor.h"
-#endif
#include "process/gegl-prepare-visitor.h"
#include "process/gegl-finish-visitor.h"
#include "process/gegl-processor.h"
@@ -196,10 +192,6 @@
GEGL_TYPE_NODE,
GeglNodePrivate);
-#if ENABLE_MP
- self->mutex = g_mutex_new ();
-#endif
-
priv = GEGL_NODE_GET_PRIVATE (self);
self->pads = NULL;
@@ -287,14 +279,6 @@
g_free (priv->name);
}
-#if ENABLE_MP
- if (self->mutex)
- {
- g_mutex_free (self->mutex);
- self->mutex = NULL;
- }
-#endif
-
G_OBJECT_CLASS (gegl_node_parent_class)->finalize (gobject);
}
@@ -538,7 +522,6 @@
g_return_if_fail (GEGL_IS_NODE (node));
g_return_if_fail (rect != NULL);
- gegl_node_lock (node);
if (node->cache)
{
gegl_cache_invalidate (node->cache, rect);
@@ -546,7 +529,6 @@
g_signal_emit (node, gegl_node_signals[INVALIDATED], 0,
rect, NULL);
- gegl_node_unlock (node);
}
static void
@@ -1500,10 +1482,6 @@
GeglVisitor *prepare_visitor;
GeglVisitor *have_visitor;
GeglVisitor *finish_visitor;
-#if ENABLE_MP
- GeglVisitor *lock_visitor;
- GeglVisitor *unlock_visitor;
-#endif
guchar *id;
gint i;
@@ -1523,12 +1501,6 @@
id = g_malloc (1);
-#if ENABLE_MP
- lock_visitor = g_object_new (GEGL_TYPE_LOCK_VISITOR, "id", id, NULL);
- gegl_visitor_dfs_traverse (lock_visitor, GEGL_VISITABLE (root));
- g_object_unref (lock_visitor);
-#endif
-
for (i = 0; i < 2; i++)
{
prepare_visitor = g_object_new (GEGL_TYPE_PREPARE_VISITOR, "id", id, NULL);
@@ -1544,12 +1516,6 @@
gegl_visitor_dfs_traverse (finish_visitor, GEGL_VISITABLE (root));
g_object_unref (finish_visitor);
-#if ENABLE_MP
- unlock_visitor = g_object_new (GEGL_TYPE_UNLOCK_VISITOR, "id", id, NULL);
- gegl_visitor_dfs_traverse (unlock_visitor, GEGL_VISITABLE (root));
- g_object_unref (unlock_visitor);
-#endif
-
g_object_unref (root);
g_free (id);
@@ -2161,23 +2127,3 @@
{
return g_object_new (GEGL_TYPE_NODE, NULL);
}
-
-void
-gegl_node_lock (GeglNode *node)
-{
-#if ENABLE_MP
- g_return_if_fail (GEGL_IS_NODE (node));
- g_print ("locking %s %p\n", gegl_node_get_debug_name (node), node->mutex);
- g_mutex_lock (node->mutex);
-#endif
-}
-
-void
-gegl_node_unlock (GeglNode *node)
-{
-#if ENABLE_MP
- g_return_if_fail (GEGL_IS_NODE (node));
- g_print ("unlocking %s %p\n", gegl_node_get_debug_name (node), node->mutex);
- g_mutex_unlock (node->mutex);
-#endif
-}
Modified: branches/branch_zhangjb/gegl/process/gegl-eval-mgr.c
==============================================================================
--- branches/branch_zhangjb/gegl/process/gegl-eval-mgr.c (original)
+++ branches/branch_zhangjb/gegl/process/gegl-eval-mgr.c Tue May 20 08:16:41 2008
@@ -29,10 +29,6 @@
#include "gegl-cr-visitor.h"
#include "gegl-have-visitor.h"
#include "gegl-need-visitor.h"
-#if ENABLE_MP
-#include "gegl-lock-visitor.h"
-#include "gegl-unlock-visitor.h"
-#endif
#include "gegl-instrument.h"
#include "graph/gegl-node.h"
#include "gegl-prepare-visitor.h"
@@ -103,12 +99,6 @@
root = pad->node;
g_object_ref (root);
-#if ENABLE_MP
- GeglVisitor *lock_visitor = g_object_new (GEGL_TYPE_LOCK_VISITOR, "id", context_id, NULL);
- gegl_visitor_dfs_traverse (lock_visitor, GEGL_VISITABLE (root));
- g_object_unref (lock_visitor);
-#endif
-
for (i = 0; i < 2; i++)
{
prepare_visitor = g_object_new (GEGL_TYPE_PREPARE_VISITOR, "id", context_id, NULL);
@@ -120,13 +110,6 @@
gegl_visitor_dfs_traverse (have_visitor, GEGL_VISITABLE (root));
g_object_unref (have_visitor);
-#if ENABLE_MP
- GeglVisitor *unlock_visitor = g_object_new (GEGL_TYPE_UNLOCK_VISITOR, "id", context_id, NULL);
- gegl_visitor_dfs_traverse (unlock_visitor, GEGL_VISITABLE (root));
- g_object_unref (unlock_visitor);
-#endif
-
-
g_assert (root);
if (self->roi.width == -1 &&
@@ -210,4 +193,3 @@
}
return buffer;
}
-
Modified: branches/branch_zhangjb/gegl/process/gegl-processor.c
==============================================================================
--- branches/branch_zhangjb/gegl/process/gegl-processor.c (original)
+++ branches/branch_zhangjb/gegl/process/gegl-processor.c Tue May 20 08:16:41 2008
@@ -587,86 +587,6 @@
return !gegl_processor_is_rendered (processor);
}
-
-#if ENABLE_MP
-
-gpointer render_thread (gpointer data)
-{
- GeglProcessor *processor = data;
-
- while (gegl_processor_render (processor, &processor->rectangle, &processor->progress));
- processor->thread_done = TRUE;
- return NULL;
-}
-
-gboolean
-gegl_processor_work (GeglProcessor *processor,
- gdouble *progress)
-{
- gboolean more_work = FALSE;
- GeglCache *cache;
-
- if (!processor->thread)
- {
- processor->thread = g_thread_create (render_thread,
- processor,
- FALSE,
- NULL);
- processor->thread_done = FALSE;
- if (progress)
- *progress = processor->progress;
- more_work = !processor->thread_done;
- }
- else
- {
- if (progress)
- *progress = processor->progress;
- if (processor->thread_done)
- {
- processor->thread = NULL;
- }
- more_work = !processor->thread_done;
- }
-
- /*more_work = gegl_processor_render (processor, &processor->rectangle, progress);*/
-
- if (more_work)
- {
- return TRUE;
- }
-
- if (GEGL_IS_OPERATION_SINK (processor->node->operation) &&
- !gegl_operation_sink_needs_full (processor->node->operation))
- {
- if (progress)
- *progress = 1.0;
- return FALSE;
- }
-
- cache = gegl_node_get_cache (processor->input);
-
- if (processor->context)
- {
- gegl_operation_process (processor->node->operation,
- processor->context,
- "output" /* ignored output_pad */,
- &processor->context->result_rect
- );
- gegl_node_remove_context (processor->node, cache);
- processor->context = NULL;
- if (progress)
- *progress = 1.0;
- return TRUE;
- }
-
- if (progress)
- *progress = 1.0;
-
- return FALSE;
-}
-
-#else
-
gboolean
gegl_processor_work (GeglProcessor *processor,
gdouble *progress)
@@ -700,7 +620,6 @@
return FALSE;
}
-#endif
void
gegl_processor_destroy (GeglProcessor *processor)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]