gegl r2270 - in trunk: . gegl/buffer
- From: ok svn gnome org
- To: svn-commits-list gnome org
- Subject: gegl r2270 - in trunk: . gegl/buffer
- Date: Fri, 2 May 2008 23:29:31 +0100 (BST)
Author: ok
Date: Fri May 2 22:29:30 2008
New Revision: 2270
URL: http://svn.gnome.org/viewvc/gegl?rev=2270&view=rev
Log:
Added some documentation to internal tile level interface to
GeglBuffer, renamed the invalidated command to refetch.
* gegl/buffer/gegl-tile-source.h: added fake funcction calls to be
documented in lieu of the macros.
* gegl/buffer/gegl-buffer-access.c: (gegl_buffer_set):
* gegl/buffer/gegl-buffer-private.h:
* gegl/buffer/gegl-buffer-share.c:
* gegl/buffer/gegl-buffer.c: (get_tile), (gegl_buffer_try_lock),
(gegl_buffer_unlock):
* gegl/buffer/gegl-tile-backend-file.c: (load_index),
(file_changed), (gegl_tile_backend_file_constructor):
* gegl/buffer/gegl-tile-handler-cache.c: (command):
* gegl/buffer/gegl-tile-handler-log.c:
* gegl/buffer/gegl-tile.h:
* gegl/buffer/gegl-buffer.h:
Modified:
trunk/ChangeLog
trunk/gegl/buffer/gegl-buffer-access.c
trunk/gegl/buffer/gegl-buffer-private.h
trunk/gegl/buffer/gegl-buffer-share.c
trunk/gegl/buffer/gegl-buffer.c
trunk/gegl/buffer/gegl-buffer.h
trunk/gegl/buffer/gegl-tile-backend-file.c
trunk/gegl/buffer/gegl-tile-handler-cache.c
trunk/gegl/buffer/gegl-tile-handler-log.c
trunk/gegl/buffer/gegl-tile-source.h
trunk/gegl/buffer/gegl-tile.h
Modified: trunk/gegl/buffer/gegl-buffer-access.c
==============================================================================
--- trunk/gegl/buffer/gegl-buffer-access.c (original)
+++ trunk/gegl/buffer/gegl-buffer-access.c Fri May 2 22:29:30 2008
@@ -583,8 +583,8 @@
{
while (gegl_buffer_try_lock (buffer)==FALSE)
{
- g_print ("failed to aquire lock sleeping 1s");
- g_usleep (1000000);
+ g_print ("failed to aquire lock sleeping 100ms");
+ g_usleep (100000);
}
}
Modified: trunk/gegl/buffer/gegl-buffer-private.h
==============================================================================
--- trunk/gegl/buffer/gegl-buffer-private.h (original)
+++ trunk/gegl/buffer/gegl-buffer-private.h Fri May 2 22:29:30 2008
@@ -63,6 +63,8 @@
gint tile_width;
gint tile_height;
gchar *path;
+
+ gint lock_count;
};
struct _GeglBufferClass
Modified: trunk/gegl/buffer/gegl-buffer-share.c
==============================================================================
--- trunk/gegl/buffer/gegl-buffer-share.c (original)
+++ trunk/gegl/buffer/gegl-buffer-share.c Fri May 2 22:29:30 2008
@@ -28,6 +28,7 @@
#include "gegl-buffer-private.h"
#include "gegl-id-pool.h"
+#if 0
static GeglIDPool *pool = NULL;
guint
@@ -43,7 +44,6 @@
return id;
}
-#if 0
GeglBuffer*
gegl_buffer_open (const gchar *uri)
{
Modified: trunk/gegl/buffer/gegl-buffer.c
==============================================================================
--- trunk/gegl/buffer/gegl-buffer.c (original)
+++ trunk/gegl/buffer/gegl-buffer.c Fri May 2 22:29:30 2008
@@ -635,6 +635,8 @@
if (tile)
{
GeglBuffer *buffer = GEGL_BUFFER (handler);
+
+ /* not sure if this plays well with shifting */
tile->x = x;
tile->y = y;
tile->z = z;
@@ -655,7 +657,7 @@
* coordinates.
*/
{
- tile->tile_storage = buffer->tile_storage;
+ tile->tile_storage = buffer->tile_storage;
tile->x = x;
tile->y = y;
tile->z = z;
@@ -1019,14 +1021,28 @@
gboolean gegl_buffer_try_lock (GeglBuffer *buffer)
{
GeglTileBackend *backend = gegl_buffer_backend (buffer);
+ gboolean ret;
if (!backend->shared)
return FALSE;
- return gegl_tile_backend_file_try_lock (GEGL_TILE_BACKEND_FILE (backend));
+ if (buffer->lock_count>0)
+ {
+ buffer->lock_count++;
+ return TRUE;
+ }
+ ret =gegl_tile_backend_file_try_lock (GEGL_TILE_BACKEND_FILE (backend));
+ if (ret)
+ buffer->lock_count++;
+ return TRUE;
}
gboolean gegl_buffer_unlock (GeglBuffer *buffer)
{
GeglTileBackend *backend = gegl_buffer_backend (buffer);
if (!backend->shared)
return FALSE;
- return gegl_tile_backend_file_unlock (GEGL_TILE_BACKEND_FILE (backend));
+ g_assert (buffer->lock_count>=0);
+ buffer->lock_count--;
+ g_assert (buffer->lock_count>=0);
+ if (buffer->lock_count==0)
+ return gegl_tile_backend_file_unlock (GEGL_TILE_BACKEND_FILE (backend));
+ return TRUE;
}
Modified: trunk/gegl/buffer/gegl-buffer.h
==============================================================================
--- trunk/gegl/buffer/gegl-buffer.h (original)
+++ trunk/gegl/buffer/gegl-buffer.h Fri May 2 22:29:30 2008
@@ -56,19 +56,6 @@
const Babl *format);
-/**
- * gegl_buffer_share:
- * @buffer: a #GeglBuffer.
- *
- * return a integer handle or 0 upon error, the handle returned is
- * unique for this process on this host,
- *
- * An uri for this buffer can be constructed by gegl_buffer_make_uri.
- *
- * Returns: an integer handle for referring to this buffer.
- */
-guint gegl_buffer_share (GeglBuffer *buffer);
-
/**
* gegl_buffer_open:
* @path: the path to a gegl buffer on disk.
Modified: trunk/gegl/buffer/gegl-tile-backend-file.c
==============================================================================
--- trunk/gegl/buffer/gegl-tile-backend-file.c (original)
+++ trunk/gegl/buffer/gegl-tile-backend-file.c Fri May 2 22:29:30 2008
@@ -675,7 +675,8 @@
static void
-load_index (GeglTileBackendFile *self)
+load_index (GeglTileBackendFile *self,
+ gboolean block)
{
GeglBufferHeader new_header;
GList *iter;
@@ -691,7 +692,7 @@
while (new_header.flags & GEGL_FLAG_LOCKED)
{
- g_usleep (500000);
+ g_usleep (50000);
new_header = gegl_buffer_read_header (self->i, &offset)->header;
}
@@ -733,7 +734,7 @@
{
GeglRectangle rect;
g_hash_table_remove (self->index, existing);
- gegl_tile_source_invalidated (GEGL_TILE_SOURCE (backend->storage),
+ gegl_tile_source_refetch (GEGL_TILE_SOURCE (backend->storage),
existing->tile.x,
existing->tile.y,
existing->tile.z);
@@ -766,10 +767,10 @@
GFileMonitorEvent event_type,
GeglTileBackendFile *self)
{
- /*if (event_type == G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT)*/
if (event_type == G_FILE_MONITOR_EVENT_CHANGED)
+ /*if (event_type == G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT)*/
{
- load_index (self);
+ load_index (self, TRUE);
}
}
static GObject *
@@ -829,7 +830,7 @@
backend->tile_size = backend->tile_width * backend->tile_height * backend->px_size;
/* insert each of the entries into the hash table */
- load_index (self);
+ load_index (self, TRUE);
self->exist = TRUE;
g_assert (self->i);
g_assert (self->o);
Modified: trunk/gegl/buffer/gegl-tile-handler-cache.c
==============================================================================
--- trunk/gegl/buffer/gegl-tile-handler-cache.c (original)
+++ trunk/gegl/buffer/gegl-tile-handler-cache.c Fri May 2 22:29:30 2008
@@ -185,9 +185,6 @@
/* FIXME: replace with switch */
switch (command)
{
- case GEGL_TILE_SET:
- /* nothing to do */
- break; /* chain up */
case GEGL_TILE_FLUSH:
{
GList *link;
@@ -204,7 +201,7 @@
}
}
}
- break; /* chain up */
+ break;
case GEGL_TILE_GET:
/* XXX: we should perhaps store a NIL result, and place the empty
* generator after the cache, this would have to be possible to disable
@@ -219,7 +216,7 @@
if (exist)
return (gpointer)TRUE;
}
- break; /* chain up */
+ break;
case GEGL_TILE_IDLE:
{
gboolean action = gegl_tile_handler_cache_wash (cache);
@@ -227,7 +224,7 @@
return (gpointer)action;
break;
}
- case GEGL_TILE_INVALIDATED:
+ case GEGL_TILE_REFETCH:
gegl_tile_handler_cache_invalidate (cache, x, y, z);
break;
case GEGL_TILE_VOID:
@@ -236,6 +233,7 @@
default:
break;
}
+
return gegl_tile_handler_chain_up (handler, command, x, y, z, data);
}
Modified: trunk/gegl/buffer/gegl-tile-handler-log.c
==============================================================================
--- trunk/gegl/buffer/gegl-tile-handler-log.c (original)
+++ trunk/gegl/buffer/gegl-tile-handler-log.c Fri May 2 22:29:30 2008
@@ -34,7 +34,7 @@
"exist",
"-", /*void*/
"flush",
- "invalidated",
+ "refetch",
"last command",
"eeek",
NULL
Modified: trunk/gegl/buffer/gegl-tile-source.h
==============================================================================
--- trunk/gegl/buffer/gegl-tile-source.h (original)
+++ trunk/gegl/buffer/gegl-tile-source.h Fri May 2 22:29:30 2008
@@ -26,7 +26,7 @@
G_BEGIN_DECLS
-#define GEGL_TYPE_TILE_SOURCE (gegl_tile_source_get_type ())
+#define GEGL_TYPE_TILE_SOURCE (gegl_tile_source_get_type ())
#define GEGL_TILE_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEGL_TYPE_TILE_SOURCE, GeglTileSource))
#define GEGL_TILE_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEGL_TYPE_TILE_SOURCE, GeglTileSourceClass))
#define GEGL_IS_TILE_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEGL_TYPE_TILE_SOURCE))
@@ -35,19 +35,6 @@
typedef gint GeglTileCommand;
-enum _GeglTileCommand
-{
- GEGL_TILE_IDLE = 0,
- GEGL_TILE_SET,
- GEGL_TILE_GET,
- GEGL_TILE_IS_CACHED,
- GEGL_TILE_EXIST,
- GEGL_TILE_VOID,
- GEGL_TILE_FLUSH,
- GEGL_TILE_INVALIDATED, /* command sent by some backends through storage*/
- GEGL_TILE_LAST_COMMAND
-};
-
struct _GeglTileSource
{
GObject parent_instance;
@@ -67,35 +54,152 @@
GType gegl_tile_source_get_type (void) G_GNUC_CONST;
+gpointer gegl_tile_source_command (GeglTileSource *tile_source,
+ GeglTileCommand command,
+ gint x,
+ gint y,
+ gint z,
+ gpointer data);
-gpointer gegl_tile_source_command (GeglTileSource *gegl_tile_source,
- GeglTileCommand command,
- gint x,
- gint y,
- gint z,
- gpointer data);
-#define gegl_tile_source_idle(source) \
- gegl_tile_source_command(source,GEGL_TILE_IDLE,0,0,0,NULL)
+/* All commands have the ability to pass commands to all tiles the handlers
+ * add abstraction to the commands the documentaiton given here is valid
+ * when the commands are issued to a full blown GeglBuffer instance.
+ */
+
+enum _GeglTileCommand
+{
+ GEGL_TILE_IDLE = 0,
+ GEGL_TILE_SET,
+ GEGL_TILE_GET,
+ GEGL_TILE_IS_CACHED,
+ GEGL_TILE_EXIST,
+ GEGL_TILE_VOID,
+ GEGL_TILE_FLUSH,
+ GEGL_TILE_REFETCH,
+ GEGL_TILE_LAST_COMMAND
+};
+
+#ifdef NOT_REALLY_COS_THIS_IS_MACROS
+
+/**
+ * gegl_tile_source_get_tile:
+ * @source: a GeglTileSource *
+ * @x: x coordinate
+ * @y: y coordinate
+ * @z: tile zoom level
+ *
+ * Get a GeglTile *from the buffer.
+ *
+ * Returns: the tile at x,y,z or NULL if the tile could not be provided.
+ */
+GeglTile *gegl_tile_source_get_tile (GegTileSource *source,
+ gint x,
+ gint y,
+ gint z);
+
+/**
+ * gegl_tile_source_set_tile:
+ * @source: a GeglTileSource *
+ * @x: x coordinate
+ * @y: y coordinate
+ * @z: tile zoom level
+ * @tile: a #GeglTile
+ *
+ * Get a GeglTile *from the buffer.
+ *
+ * Returns: the TRUE if the set was successful.
+ */
+gboolean gegl_tile_source_set_tile (GegTileSource *source,
+ gint x,
+ gint y,
+ gint z,
+ GeglTile *tile);
+/**
+ * gegl_tile_source_is_cached:
+ * @source: a GeglTileSource *
+ * @x: tile x coordinate
+ * @y: tile y coordinate
+ * @z: tile zoom level
+ *
+ * Checks if a tile is in cache and easily retrieved.
+ */
+gboolean gegl_tile_source_is_cached (GegTileSource *source,
+ gint x,
+ gint y,
+ gint z);
+/**
+ * gegl_tile_source_exist:
+ * @source: a GeglTileSource *
+ * @x: x coordinate
+ * @y: y coordinate
+ * @z: tile zoom level
+ *
+ * Checks if a tile exists, this check would not cause the tile to be swapped
+ * in.
+ */
+gboolean gegl_tile_source_exist (GegTileSource *source,
+ gint x,
+ gint y,
+ gint z);
+/**
+ * gegl_tile_source_void:
+ * @source: a GeglTileSource *
+ * @x: x coordinate
+ * @y: y coordinate
+ * @z: tile zoom level
+ *
+ * Checks if a tile exists, this check would not cause the tile to be swapped
+ * in.
+ */
+void gegl_tile_source_void (GegTileSource *source,
+ gint x,
+ gint y,
+ gint z);
+/* INTERNAL API
+ * gegl_tile_source_refetch:
+ * @source: a GeglTileSource *
+ * @x: x coordinate
+ * @y: y coordinate
+ * @z: tile zoom level
+ *
+ * A message used internally when watching external buffers to indicate that
+ * a refresh of all data relating to the coordinates needs to be refetched.
+ * Subsequent get calls should get new and valid data for the tile coordinates.
+ */
+void gegl_tile_source_refetch (GegTileSource *source,
+ gint x,
+ gint y,
+ gint z);
+/* INTERNAL API
+ * gegl_tile_source_idle:
+ * @source: a GeglTileSource *
+ *
+ * Allow different parts of the buffer to do idle work (saving cached
+ * data lazily, perhaps prefetching in the future?), monitoring for
+ * changes or other tasks. Used internally by the buffer object.
+ *
+ * Returns: the TRUE if some work was done.
+ */
+gboolean gegl_tile_source_idle (GegTileSource *source);
+
+#endif
#define gegl_tile_source_set_tile(source,x,y,z,tile) \
(gboolean)gegl_tile_source_command(source,GEGL_TILE_SET,x,y,z,tile)
-
#define gegl_tile_source_get_tile(source,x,y,z) \
(GeglTile*)gegl_tile_source_command(source,GEGL_TILE_GET,x,y,z,NULL)
-
#define gegl_tile_source_is_cached(source,x,y,z) \
(gboolean)gegl_tile_source_command(source,GEGL_TILE_IS_CACHED,x,y,z,NULL)
-
#define gegl_tile_source_exist(source,x,y,z) \
(gboolean)gegl_tile_source_command(source,GEGL_TILE_EXIST,x,y,z,NULL)
-
#define gegl_tile_source_void(source,x,y,z) \
gegl_tile_source_command(source,GEGL_TILE_VOID,x,y,z,NULL)
-
-#define gegl_tile_source_invalidated(source,x,y,z) \
- gegl_tile_source_command(source,GEGL_TILE_INVALIDATED,x,y,z,NULL)
+#define gegl_tile_source_refetch(source,x,y,z) \
+ gegl_tile_source_command(source,GEGL_TILE_REFETCH,x,y,z,NULL)
+#define gegl_tile_source_idle(source) \
+ (gboolean)gegl_tile_source_command(source,GEGL_TILE_IDLE,0,0,0,NULL)
G_END_DECLS
Modified: trunk/gegl/buffer/gegl-tile.h
==============================================================================
--- trunk/gegl/buffer/gegl-tile.h (original)
+++ trunk/gegl/buffer/gegl-tile.h Fri May 2 22:29:30 2008
@@ -73,9 +73,22 @@
GeglTile * gegl_tile_new (gint size);
void * gegl_tile_get_format (GeglTile *tile);
+
+
+/* lock a tile for writing, this would allow writing to buffers
+ * later gotten with get_data()
+ */
void gegl_tile_lock (GeglTile *tile);
+/* get a pointer to the linear buffer of the tile.
+ */
guchar * gegl_tile_get_data (GeglTile *tile);
+/* unlock the tile notifying the tile that we're done manipulating
+ * the data.
+ */
void gegl_tile_unlock (GeglTile *tile);
+
+
+
gboolean gegl_tile_is_stored (GeglTile *tile);
gboolean gegl_tile_store (GeglTile *tile);
void gegl_tile_void (GeglTile *tile);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]