[gegl] gegl: Add gegl_tile_set_data() and more
- From: Martin Nordholts <martinn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] gegl: Add gegl_tile_set_data() and more
- Date: Sun, 2 Oct 2011 16:24:44 +0000 (UTC)
commit 6586652f5eab6aaadc58cc82bf0033876e05cae0
Author: Martin Nordholts <martinn src gnome org>
Date: Sun Oct 2 18:18:33 2011 +0200
gegl: Add gegl_tile_set_data() and more
Add gegl_tile_set_data(), gegl_tile_set_data_full() and
GeglDestroyNotify to better support custom tile backends.
gegl/buffer/gegl-buffer-linear.c | 9 ++++---
gegl/buffer/gegl-buffer-private.h | 6 ++--
gegl/buffer/gegl-tile.c | 20 +++++++++++++++++++
gegl/buffer/gegl-tile.h | 39 ++++++++++++++++++++++--------------
gegl/gegl-types.h | 5 ++++
5 files changed, 57 insertions(+), 22 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-linear.c b/gegl/buffer/gegl-buffer-linear.c
index 55475f3..2263b73 100644
--- a/gegl/buffer/gegl-buffer-linear.c
+++ b/gegl/buffer/gegl-buffer-linear.c
@@ -88,12 +88,13 @@ gegl_buffer_linear_new_from_data (const gpointer data,
tile->x = 0;
tile->y = 0;
tile->z = 0;
- tile->data = (gpointer)data;
- tile->size = babl_format_get_bytes_per_pixel (format) * rowstride * extent->height;
tile->next_shared = tile;
tile->prev_shared = tile;
- tile->destroy_notify = (void (*) (gpointer, gpointer)) destroy_fn;
- tile->destroy_notify_data = destroy_fn_data;
+ gegl_tile_set_data_full (tile,
+ (gpointer) data,
+ babl_format_get_bytes_per_pixel (format) * rowstride * extent->height,
+ (GeglDestroyNotify) destroy_fn,
+ destroy_fn_data);
if (buffer->tile_storage->cache)
gegl_tile_handler_cache_insert (buffer->tile_storage->cache, tile, 0, 0, 0);
diff --git a/gegl/buffer/gegl-buffer-private.h b/gegl/buffer/gegl-buffer-private.h
index 2966c2b..f3c55fa 100644
--- a/gegl/buffer/gegl-buffer-private.h
+++ b/gegl/buffer/gegl-buffer-private.h
@@ -163,9 +163,9 @@ struct _GeglTile
GeglTile *next_shared;
GeglTile *prev_shared;
- void (*destroy_notify) (gpointer pixels,
- gpointer data);
- gpointer destroy_notify_data;
+ /* called when the tile is about to be destroyed */
+ GeglDestroyNotify destroy_notify;
+ gpointer destroy_notify_data;
};
#ifndef __GEGL_TILE_C
diff --git a/gegl/buffer/gegl-tile.c b/gegl/buffer/gegl-tile.c
index 5de2f1e..b85e8cf 100644
--- a/gegl/buffer/gegl-tile.c
+++ b/gegl/buffer/gegl-tile.c
@@ -288,6 +288,26 @@ guchar *gegl_tile_get_data (GeglTile *tile)
return tile->data;
}
+void gegl_tile_set_data (GeglTile *tile,
+ gpointer pixel_data,
+ gint pixel_data_size)
+{
+ tile->data = pixel_data;
+ tile->size = pixel_data_size;
+}
+
+void gegl_tile_set_data_full (GeglTile *tile,
+ gpointer pixel_data,
+ gint pixel_data_size,
+ GeglDestroyNotify destroy_notify,
+ gpointer destroy_notify_data)
+{
+ tile->data = pixel_data;
+ tile->size = pixel_data_size;
+ tile->destroy_notify = destroy_notify;
+ tile->destroy_notify_data = destroy_notify_data;
+}
+
void gegl_tile_set_rev (GeglTile *tile,
guint rev)
diff --git a/gegl/buffer/gegl-tile.h b/gegl/buffer/gegl-tile.h
index 05d5469..5af5e33 100644
--- a/gegl/buffer/gegl-tile.h
+++ b/gegl/buffer/gegl-tile.h
@@ -22,32 +22,41 @@
#include <glib-object.h>
#include "gegl-buffer-backend.h"
-GeglTile * gegl_tile_new (gint size);
-GeglTile * gegl_tile_new_bare (void); /* special hack for linear bufs */
-GeglTile * gegl_tile_ref (GeglTile *tile);
-void gegl_tile_unref (GeglTile *tile);
+GeglTile * gegl_tile_new (gint size);
+GeglTile * gegl_tile_new_bare (void);
+GeglTile * gegl_tile_ref (GeglTile *tile);
+void gegl_tile_unref (GeglTile *tile);
/* lock a tile for writing, this would allow writing to buffers
* later gotten with get_data()
*/
-void gegl_tile_lock (GeglTile *tile);
+void gegl_tile_lock (GeglTile *tile);
/* unlock the tile notifying the tile that we're done manipulating
* the data.
*/
-void gegl_tile_unlock (GeglTile *tile);
+void gegl_tile_unlock (GeglTile *tile);
-void gegl_tile_mark_as_stored (GeglTile *tile);
-gboolean gegl_tile_is_stored (GeglTile *tile);
-gboolean gegl_tile_store (GeglTile *tile);
-void gegl_tile_void (GeglTile *tile);
-GeglTile *gegl_tile_dup (GeglTile *tile);
+void gegl_tile_mark_as_stored (GeglTile *tile);
+gboolean gegl_tile_is_stored (GeglTile *tile);
+gboolean gegl_tile_store (GeglTile *tile);
+void gegl_tile_void (GeglTile *tile);
+GeglTile *gegl_tile_dup (GeglTile *tile);
-void gegl_tile_set_rev (GeglTile *tile,
- guint rev);
-guint gegl_tile_get_rev (GeglTile *tile);
+void gegl_tile_set_rev (GeglTile *tile,
+ guint rev);
+guint gegl_tile_get_rev (GeglTile *tile);
+
+guchar *gegl_tile_get_data (GeglTile *tile);
+void gegl_tile_set_data (GeglTile *tile,
+ gpointer pixel_data,
+ gint pixel_data_size);
+void gegl_tile_set_data_full (GeglTile *tile,
+ gpointer pixel_data,
+ gint pixel_data_size,
+ GeglDestroyNotify destroy_notify,
+ gpointer destroy_notify_data);
-guchar *gegl_tile_get_data (GeglTile *tile);
#endif
diff --git a/gegl/gegl-types.h b/gegl/gegl-types.h
index 8ff5048..9726daa 100644
--- a/gegl/gegl-types.h
+++ b/gegl/gegl-types.h
@@ -66,6 +66,11 @@ GType gegl_processor_get_type (void) G_GNUC_CONST;
#define GEGL_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEGL_TYPE_PROCESSOR, GeglProcessor))
#define GEGL_IS_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEGL_TYPE_PROCESSOR))
+
+typedef void (*GeglDestroyNotify) (gpointer pixel_data,
+ gpointer user_data);
+
+
G_END_DECLS
#endif /* __GEGL_TYPES_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]