[gegl/pippin/wip/mipmap-prerenders: 2/4] add level parameter to gegl_iterator_api
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl/pippin/wip/mipmap-prerenders: 2/4] add level parameter to gegl_iterator_api
- Date: Mon, 13 Jun 2011 11:33:11 +0000 (UTC)
commit 559b2b585e7e5a1e494909b3cfa147d40f0b2513
Author: �yvind Kolås <pippin gimp org>
Date: Sun Jun 5 03:15:12 2011 +0100
add level parameter to gegl_iterator_api
gegl/buffer/gegl-buffer-access.c | 4 ++--
gegl/buffer/gegl-buffer-iterator.c | 21 +++++++++++++--------
gegl/buffer/gegl-buffer-iterator.h | 8 +++++++-
gegl/operation/gegl-operation-point-composer.c | 2 +-
gegl/operation/gegl-operation-point-composer3.c | 2 +-
gegl/operation/gegl-operation-point-filter.c | 2 +-
gegl/operation/gegl-operation-point-render.c | 2 +-
gegl/operation/gegl-operation.h | 3 +++
operations/affine/affine.c | 23 ++++++++++++++---------
operations/common/map-absolute.c | 2 +-
operations/common/map-relative.c | 2 +-
11 files changed, 45 insertions(+), 26 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index 9440ee4..6bc6a2d 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -1173,7 +1173,7 @@ gegl_buffer_copy (GeglBuffer *src,
dest_rect_r.width = src_rect->width;
dest_rect_r.height = src_rect->height;
- i = gegl_buffer_iterator_new (dst, &dest_rect_r, dst->format, GEGL_BUFFER_WRITE);
+ i = gegl_buffer_iterator_new (dst, &dest_rect_r, dst->format, GEGL_BUFFER_WRITE, 0); /* XXX: is level 0 right? */
read = gegl_buffer_iterator_add (i, src, src_rect, src->format, GEGL_BUFFER_READ);
while (gegl_buffer_iterator_next (i))
babl_process (fish, i->data[read], i->data[0], i->length);
@@ -1202,7 +1202,7 @@ gegl_buffer_clear (GeglBuffer *dst,
/* FIXME: this can be even further optimized by special casing it so
* that fully voided tiles are dropped.
*/
- i = gegl_buffer_iterator_new (dst, dst_rect, dst->format, GEGL_BUFFER_WRITE);
+ i = gegl_buffer_iterator_new (dst, dst_rect, dst->format, GEGL_BUFFER_WRITE, 0); /* XXX: should level be settable */
while (gegl_buffer_iterator_next (i))
{
memset (((guchar*)(i->data[0])), 0, i->length * pxsize);
diff --git a/gegl/buffer/gegl-buffer-iterator.c b/gegl/buffer/gegl-buffer-iterator.c
index e0f8681..5a5a8eb 100644
--- a/gegl/buffer/gegl-buffer-iterator.c
+++ b/gegl/buffer/gegl-buffer-iterator.c
@@ -52,7 +52,7 @@ typedef struct GeglBufferTileIterator
GeglRectangle roi2; /* the rectangular subregion of data
* in the buffer represented by this scan.
*/
-
+ gint level;
} GeglBufferTileIterator;
#define GEGL_BUFFER_SCAN_COMPATIBLE 128 /* should be integrated into enum */
@@ -82,7 +82,8 @@ typedef struct GeglBufferIterators
static void gegl_buffer_tile_iterator_init (GeglBufferTileIterator *i,
GeglBuffer *buffer,
GeglRectangle roi,
- gboolean write);
+ gboolean write,
+ gint level);
static gboolean gegl_buffer_tile_iterator_next (GeglBufferTileIterator *i);
/*
@@ -114,7 +115,8 @@ static gboolean gegl_buffer_scan_compatible (GeglBuffer *bufferA,
static void gegl_buffer_tile_iterator_init (GeglBufferTileIterator *i,
GeglBuffer *buffer,
GeglRectangle roi,
- gboolean write)
+ gboolean write,
+ gint level)
{
g_assert (i);
memset (i, 0, sizeof (GeglBufferTileIterator));
@@ -123,6 +125,7 @@ static void gegl_buffer_tile_iterator_init (GeglBufferTileIterator *i,
g_error ("eeek");
i->buffer = buffer;
i->roi = roi;
+ i->level = level;
i->next_row = 0;
i->next_col = 0;
i->tile = NULL;
@@ -275,7 +278,7 @@ gegl_buffer_iterator_add (GeglBufferIterator *iterator,
if (self==0) /* The first buffer which is always scan aligned */
{
i->flags[self] |= GEGL_BUFFER_SCAN_COMPATIBLE;
- gegl_buffer_tile_iterator_init (&i->i[self], i->buffer[self], i->rect[self], ((i->flags[self] & GEGL_BUFFER_WRITE) != 0) );
+ gegl_buffer_tile_iterator_init (&i->i[self], i->buffer[self], i->rect[self], ((i->flags[self] & GEGL_BUFFER_WRITE) != 0), iterator->level);
}
else
{
@@ -287,7 +290,7 @@ gegl_buffer_iterator_add (GeglBufferIterator *iterator,
i->buffer[self], i->rect[self].x, i->rect[self].y))
{
i->flags[self] |= GEGL_BUFFER_SCAN_COMPATIBLE;
- gegl_buffer_tile_iterator_init (&i->i[self], i->buffer[self], i->rect[self], ((i->flags[self] & GEGL_BUFFER_WRITE) != 0));
+ gegl_buffer_tile_iterator_init (&i->i[self], i->buffer[self], i->rect[self], ((i->flags[self] & GEGL_BUFFER_WRITE) != 0), iterator->level);
}
}
@@ -301,7 +304,7 @@ gegl_buffer_iterator_add (GeglBufferIterator *iterator,
}
/* FIXME: we are currently leaking this buf pool, it should be
- * freeing it when gegl is uninitialized
+ * freed when gegl is uninitialized
*/
typedef struct BufInfo {
@@ -404,7 +407,7 @@ gboolean gegl_buffer_iterator_next (GeglBufferIterator *iterator)
i->flags[no] & GEGL_BUFFER_FORMAT_COMPATIBLE &&
i->roi[no].width == i->i[no].buffer->tile_storage->tile_width && (i->flags[no] & GEGL_BUFFER_FORMAT_COMPATIBLE))
{
- /* direct access */
+ /* direct access, don't need to do anything */
#if DEBUG_DIRECT
direct_write += i->roi[no].width * i->roi[no].height;
#endif
@@ -535,9 +538,11 @@ gboolean gegl_buffer_iterator_next (GeglBufferIterator *iterator)
GeglBufferIterator *gegl_buffer_iterator_new (GeglBuffer *buffer,
const GeglRectangle *roi,
const Babl *format,
- guint flags)
+ guint flags,
+ gint level)
{
GeglBufferIterator *i = (gpointer)g_slice_new0 (GeglBufferIterators);
+ i->level = level;
gegl_buffer_iterator_add (i, buffer, roi, format, flags);
return i;
}
diff --git a/gegl/buffer/gegl-buffer-iterator.h b/gegl/buffer/gegl-buffer-iterator.h
index 68b2619..b374f56 100644
--- a/gegl/buffer/gegl-buffer-iterator.h
+++ b/gegl/buffer/gegl-buffer-iterator.h
@@ -33,6 +33,7 @@ typedef struct GeglBufferIterator
gint length;
gpointer data[GEGL_BUFFER_MAX_ITERATORS];
GeglRectangle roi[GEGL_BUFFER_MAX_ITERATORS];
+ gint level;
} GeglBufferIterator;
@@ -42,6 +43,8 @@ typedef struct GeglBufferIterator
* @roi: the rectangle to iterate over
* @format: the format we want to process this buffers data in, pass 0 to use the buffers format.
* @flags: whether we need reading or writing to this buffer one of GEGL_BUFFER_READ, GEGL_BUFFER_WRITE and GEGL_BUFFER_READWRITE.
+ * @level: the level at which we are iterating, the roi will indicate the
+ * extent at 1:1, x,y,width and height are/(2^level)
*
* Create a new buffer iterator, this buffer will be iterated through
* in linear chunks, some chunks might be full tiles the coordinates, see
@@ -54,7 +57,10 @@ typedef struct GeglBufferIterator
GeglBufferIterator * gegl_buffer_iterator_new (GeglBuffer *buffer,
const GeglRectangle *roi,
const Babl *format,
- guint flags);
+ guint flags,
+ gint level); /* XXX: or encode it in flags? */
+/* should maybe be reporting the roi in process, as base image roi when level != 0 */
+
/**
* gegl_buffer_iterator_add:
diff --git a/gegl/operation/gegl-operation-point-composer.c b/gegl/operation/gegl-operation-point-composer.c
index a037b7c..0d70231 100644
--- a/gegl/operation/gegl-operation-point-composer.c
+++ b/gegl/operation/gegl-operation-point-composer.c
@@ -147,7 +147,7 @@ gegl_operation_point_composer_process (GeglOperation *operation,
if ((result->width > 0) && (result->height > 0))
{
- GeglBufferIterator *i = gegl_buffer_iterator_new (output, result, out_format, GEGL_BUFFER_WRITE);
+ GeglBufferIterator *i = gegl_buffer_iterator_new (output, result, out_format, GEGL_BUFFER_WRITE, level);
gint read = /*output == input ? 0 :*/ gegl_buffer_iterator_add (i, input, result, in_format, GEGL_BUFFER_READ);
/* using separate read and write iterators for in-place ideally a single
* readwrite indice would be sufficient
diff --git a/gegl/operation/gegl-operation-point-composer3.c b/gegl/operation/gegl-operation-point-composer3.c
index f79d2cd..0101419 100644
--- a/gegl/operation/gegl-operation-point-composer3.c
+++ b/gegl/operation/gegl-operation-point-composer3.c
@@ -158,7 +158,7 @@ gegl_operation_point_composer3_process (GeglOperation *operation,
if ((result->width > 0) && (result->height > 0))
{
- GeglBufferIterator *i = gegl_buffer_iterator_new (output, result, out_format, GEGL_BUFFER_WRITE);
+ GeglBufferIterator *i = gegl_buffer_iterator_new (output, result, out_format, GEGL_BUFFER_WRITE, level);
gint read = gegl_buffer_iterator_add (i, input, result, in_format, GEGL_BUFFER_READ);
if (aux)
diff --git a/gegl/operation/gegl-operation-point-filter.c b/gegl/operation/gegl-operation-point-filter.c
index 45aec1f..1b2354f 100644
--- a/gegl/operation/gegl-operation-point-filter.c
+++ b/gegl/operation/gegl-operation-point-filter.c
@@ -86,7 +86,7 @@ gegl_operation_point_filter_process (GeglOperation *operation,
{
{
- GeglBufferIterator *i = gegl_buffer_iterator_new (output, result, out_format, GEGL_BUFFER_WRITE);
+ GeglBufferIterator *i = gegl_buffer_iterator_new (output, result, out_format, GEGL_BUFFER_WRITE, level);
gint read = /*output == input ? 0 :*/ gegl_buffer_iterator_add (i, input, result, in_format, GEGL_BUFFER_READ);
/* using separate read and write iterators for in-place ideally a single
* readwrite indice would be sufficient
diff --git a/gegl/operation/gegl-operation-point-render.c b/gegl/operation/gegl-operation-point-render.c
index f822e3b..a98aa1f 100644
--- a/gegl/operation/gegl-operation-point-render.c
+++ b/gegl/operation/gegl-operation-point-render.c
@@ -97,7 +97,7 @@ gegl_operation_point_render_process (GeglOperation *operation,
if ((result->width > 0) && (result->height > 0))
{
- GeglBufferIterator *i = gegl_buffer_iterator_new (output, result, out_format, GEGL_BUFFER_WRITE);
+ GeglBufferIterator *i = gegl_buffer_iterator_new (output, result, out_format, GEGL_BUFFER_WRITE, level);
while (gegl_buffer_iterator_next (i))
point_render_class->process (operation, i->data[0], i->length, &i->roi[0], level);
diff --git a/gegl/operation/gegl-operation.h b/gegl/operation/gegl-operation.h
index c2245eb..45b8ed3 100644
--- a/gegl/operation/gegl-operation.h
+++ b/gegl/operation/gegl-operation.h
@@ -64,6 +64,9 @@ struct _GeglOperation
#define MAX_PROCESSOR 4
+/* the level at which is being operated is stored in the context,
+*/
+
void gegl_operation_class_add_processor (GeglOperationClass *cclass,
GCallback process,
const gchar *string);
diff --git a/operations/affine/affine.c b/operations/affine/affine.c
index 8992aed..9cb5262 100644
--- a/operations/affine/affine.c
+++ b/operations/affine/affine.c
@@ -93,11 +93,13 @@ static gboolean gegl_affine_matrix3_allow_fast_reflect_y (GeglMatrix3
static void gegl_affine_fast_reflect_x (GeglBuffer *dest,
GeglBuffer *src,
const GeglRectangle *dest_rect,
- const GeglRectangle *src_rect);
+ const GeglRectangle *src_rect,
+ gint level);
static void gegl_affine_fast_reflect_y (GeglBuffer *dest,
GeglBuffer *src,
const GeglRectangle *dest_rect,
- const GeglRectangle *src_rect);
+ const GeglRectangle *src_rect,
+ gint level);
/* ************************* */
@@ -673,7 +675,8 @@ static void
affine_generic (GeglBuffer *dest,
GeglBuffer *src,
GeglMatrix3 *matrix,
- GeglSampler *sampler)
+ GeglSampler *sampler,
+ gint level)
{
GeglBufferIterator *i;
const GeglRectangle *dest_extent;
@@ -701,7 +704,7 @@ affine_generic (GeglBuffer *dest,
dest_extent = gegl_buffer_get_extent (dest);
- i = gegl_buffer_iterator_new (dest, dest_extent, format, GEGL_BUFFER_WRITE);
+ i = gegl_buffer_iterator_new (dest, dest_extent, format, GEGL_BUFFER_WRITE, level);
while (gegl_buffer_iterator_next (i))
{
GeglRectangle *roi = &i->roi[0];
@@ -781,7 +784,8 @@ static void
gegl_affine_fast_reflect_x (GeglBuffer *dest,
GeglBuffer *src,
const GeglRectangle *dest_rect,
- const GeglRectangle *src_rect)
+ const GeglRectangle *src_rect,
+ gint level)
{
const Babl *format = gegl_buffer_get_format (src);
const gint px_size = babl_format_get_bytes_per_pixel (format),
@@ -817,7 +821,8 @@ static void
gegl_affine_fast_reflect_y (GeglBuffer *dest,
GeglBuffer *src,
const GeglRectangle *dest_rect,
- const GeglRectangle *src_rect)
+ const GeglRectangle *src_rect,
+ gint level)
{
const Babl *format = gegl_buffer_get_format (src);
const gint px_size = babl_format_get_bytes_per_pixel (format),
@@ -934,7 +939,7 @@ gegl_affine_process (GeglOperation *operation,
src_rect.width -= sampler->context_rect.width;
src_rect.height -= sampler->context_rect.height;
- gegl_affine_fast_reflect_x (output, input, result, &src_rect);
+ gegl_affine_fast_reflect_x (output, input, result, &src_rect, context->level);
if (input != NULL)
g_object_unref (input);
@@ -960,7 +965,7 @@ gegl_affine_process (GeglOperation *operation,
src_rect.width -= sampler->context_rect.width;
src_rect.height -= sampler->context_rect.height;
- gegl_affine_fast_reflect_y (output, input, result, &src_rect);
+ gegl_affine_fast_reflect_y (output, input, result, &src_rect, context->level);
if (input != NULL)
g_object_unref (input);
@@ -976,7 +981,7 @@ gegl_affine_process (GeglOperation *operation,
sampler = op_affine_sampler (affine);
g_object_set(sampler, "buffer", input, NULL);
gegl_sampler_prepare (sampler);
- affine_generic (output, input, &matrix, sampler);
+ affine_generic (output, input, &matrix, sampler, context->level);
g_object_unref(sampler->buffer);
sampler->buffer = NULL;
g_object_unref (sampler);
diff --git a/operations/common/map-absolute.c b/operations/common/map-absolute.c
index 8b04cd7..dbe05a9 100644
--- a/operations/common/map-absolute.c
+++ b/operations/common/map-absolute.c
@@ -88,7 +88,7 @@ process (GeglOperation *operation,
if (aux != NULL)
{
- it = gegl_buffer_iterator_new (output, result, format_io, GEGL_BUFFER_WRITE);
+ it = gegl_buffer_iterator_new (output, result, format_io, GEGL_BUFFER_WRITE, level);
index_out = 0;
index_coords = gegl_buffer_iterator_add (it, aux, result, format_coords, GEGL_BUFFER_READ);
diff --git a/operations/common/map-relative.c b/operations/common/map-relative.c
index 0890f9e..23b01bd 100644
--- a/operations/common/map-relative.c
+++ b/operations/common/map-relative.c
@@ -92,7 +92,7 @@ process (GeglOperation *operation,
if (aux != NULL)
{
- it = gegl_buffer_iterator_new (output, result, format_io, GEGL_BUFFER_WRITE);
+ it = gegl_buffer_iterator_new (output, result, format_io, GEGL_BUFFER_WRITE, level);
index_out = 0;
index_coords = gegl_buffer_iterator_add (it, aux, result, format_coords, GEGL_BUFFER_READ);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]