[gegl/gsoc2009-gpu: 5/15] Add GPU support to GeglTile
- From: Martin Nordholts <martinn src gnome org>
- To: svn-commits-list gnome org
- Subject: [gegl/gsoc2009-gpu: 5/15] Add GPU support to GeglTile
- Date: Wed, 24 Jun 2009 05:38:24 +0000 (UTC)
commit 23f7de625133b7e9407c186ecbc1a48d63f84763
Author: Jerson Michael Perpetua <jersonperpetua gmail com>
Date: Wed Jun 17 00:55:13 2009 +0800
Add GPU support to GeglTile
* Add gpu_data (type: GeglGpuTexture) to gegl/buffer/gegl-tile.h and
adjust destroy_notify to also free gpu_data
* Adjust method implementations in gegl/buffer/gegl-tile.c to properly
initialize, free and use the latter addition
* Adjust gegl/buffer/Makefile.am to include the header files in gegl/gpu
gegl/buffer/Makefile.am | 4 ++-
gegl/buffer/gegl-tile.c | 52 ++++++++++++++++++++++++++++++++--------------
gegl/buffer/gegl-tile.h | 17 ++++++++++----
3 files changed, 51 insertions(+), 22 deletions(-)
---
diff --git a/gegl/buffer/Makefile.am b/gegl/buffer/Makefile.am
index 21c44a6..99c9356 100644
--- a/gegl/buffer/Makefile.am
+++ b/gegl/buffer/Makefile.am
@@ -5,7 +5,9 @@ AM_CPPFLAGS = \
-I$(top_builddir)/gegl/property-types \
-I$(top_srcdir)/gegl/property-types \
-I$(top_builddir)/gegl/buffer \
- -I$(top_srcdir)/gegl/buffer
+ -I$(top_srcdir)/gegl/buffer \
+ -I$(top_builddir)/gegl/gpu \
+ -I$(top_srcdir)/gegl/gpu
AM_CFLAGS = $(DEP_CFLAGS) $(BABL_CFLAGS)
diff --git a/gegl/buffer/gegl-tile.c b/gegl/buffer/gegl-tile.c
index b3a0788..a05e3e4 100644
--- a/gegl/buffer/gegl-tile.c
+++ b/gegl/buffer/gegl-tile.c
@@ -35,6 +35,8 @@
#include "gegl-tile-source.h"
#include "gegl-tile-storage.h"
+#include "gegl-gpu-types.h"
+#include "gegl-gpu-texture.h"
G_DEFINE_TYPE (GeglTile, gegl_tile, G_TYPE_OBJECT)
enum
@@ -110,10 +112,15 @@ set_property (GObject *gobject,
#include "gegl-utils.h"
-static void default_free (gpointer data,
- gpointer userdata)
+static void default_free (gpointer data,
+ GeglGpuTexture *gpu_data,
+ gpointer userdata)
{
- gegl_free (data);
+ if (data != NULL)
+ gegl_free (data);
+
+ if (gpu_data != NULL)
+ gegl_gpu_texture_free (gpu_data);
}
static void
@@ -124,13 +131,17 @@ dispose (GObject *object)
if (!gegl_tile_is_stored (tile))
gegl_tile_store (tile);
- if (tile->data)
+ if (tile->data != NULL || tile->gpu_data != NULL)
{
if (tile->next_shared == tile)
- { /* no clones */
+ {
+ /* no clones */
if (tile->destroy_notify)
- tile->destroy_notify (tile->data, tile->destroy_notify_data);
- tile->data = NULL;
+ tile->destroy_notify (tile->data, tile->gpu_data,
+ tile->destroy_notify_data);
+
+ tile->data = NULL;
+ tile->gpu_data = NULL;
}
else
{
@@ -142,12 +153,12 @@ dispose (GObject *object)
#if ENABLE_MP
if (tile->mutex)
{
- g_mutex_free (tile->mutex);
+ g_static_mutex_free (tile->mutex);
tile->mutex = NULL;
}
#endif
- (*G_OBJECT_CLASS (parent_class)->dispose)(object);
+ (*G_OBJECT_CLASS (parent_class)->dispose) (object);
}
static void
@@ -184,18 +195,23 @@ gegl_tile_class_init (GeglTileClass *class)
static void
gegl_tile_init (GeglTile *tile)
{
- tile->tile_storage = NULL;
- tile->stored_rev = 0;
+ tile->data = NULL;
+ tile->gpu_data = NULL;
+
+ tile->tile_storage = NULL;
+
tile->rev = 0;
+ tile->stored_rev = 0;
+
tile->lock = 0;
- tile->data = NULL;
tile->next_shared = tile;
tile->prev_shared = tile;
#if ENABLE_MP
- tile->mutex = g_mutex_new ();
+ tile->lock = g_mutex_new ();
#endif
+
tile->destroy_notify = default_free;
}
@@ -204,11 +220,14 @@ gegl_tile_dup (GeglTile *src)
{
GeglTile *tile = g_object_new (GEGL_TYPE_TILE, NULL);
+ tile->data = src->data;
+ tile->size = src->size;
+ tile->gpu_data = src->gpu_data;
+
+ tile->tile_storage = src->tile_storage;
+
tile->rev = 1;
tile->stored_rev = 1;
- tile->tile_storage = src->tile_storage;
- tile->data = src->data;
- tile->size = src->size;
tile->next_shared = src->next_shared;
src->next_shared = tile;
@@ -266,6 +285,7 @@ gegl_tile_unclone (GeglTile *tile)
* create a local copy
*/
tile->data = gegl_memdup (tile->data, tile->size);
+ tile->gpu_data = gegl_gpu_texture_dup (tile->gpu_data);
tile->prev_shared->next_shared = tile->next_shared;
tile->next_shared->prev_shared = tile->prev_shared;
tile->prev_shared = tile;
diff --git a/gegl/buffer/gegl-tile.h b/gegl/buffer/gegl-tile.h
index 464de90..a691c60 100644
--- a/gegl/buffer/gegl-tile.h
+++ b/gegl/buffer/gegl-tile.h
@@ -22,6 +22,7 @@
#include <glib-object.h>
#include "gegl-buffer-types.h"
+#include "gegl-gpu-types.h"
#define GEGL_TYPE_TILE (gegl_tile_get_type ())
#define GEGL_TILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEGL_TYPE_TILE, GeglTile))
@@ -40,6 +41,7 @@ struct _GeglTile
guchar *data; /* actual pixel data for tile, a linear buffer*/
gint size; /* The size of the linear buffer */
+ GeglGpuTexture *gpu_data; /* pixel data for tile, stored in the GPU */
GeglTileStorage *tile_storage; /* the buffer from which this tile was
* retrieved needed for the tile to be able to
@@ -64,8 +66,10 @@ struct _GeglTile
GeglTile *next_shared;
GeglTile *prev_shared;
- void (*destroy_notify) (gpointer pixels,
- gpointer data);
+ void (*destroy_notify) (gpointer pixels,
+ GeglGpuTexture *gpu_data,
+ gpointer data);
+
gpointer destroy_notify_data;
};
@@ -87,9 +91,12 @@ gint gegl_tile_get_height (GeglTile *tile);
* later gotten with get_data()
*/
void gegl_tile_lock (GeglTile *tile);
-/* get a pointer to the linear buffer of the tile.
- */
-#define gegl_tile_get_data(tile) ((guchar*)((tile)->data))
+
+/* get a pointer to the linear buffer of the tile */
+void *gegl_tile_get_data (GeglTile *tile);
+
+/* get a pointer to the GPU data of the tile */
+GeglGpuTexture *gegl_tile_get_gpu_data (GeglTile *tile);
/* unlock the tile notifying the tile that we're done manipulating
* the data.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]