gegl r2405 - in trunk: . gegl/buffer
- From: ok svn gnome org
- To: svn-commits-list gnome org
- Subject: gegl r2405 - in trunk: . gegl/buffer
- Date: Tue, 10 Jun 2008 10:00:36 +0000 (UTC)
Author: ok
Date: Tue Jun 10 10:00:36 2008
New Revision: 2405
URL: http://svn.gnome.org/viewvc/gegl?rev=2405&view=rev
Log:
* gegl/buffer/gegl-buffer-iterator.c:
(gegl_buffer_tile_iterator_init), (gegl_buffer_tile_iterator_next),
(gegl_buffer_scan_iterator_init), (gegl_buffer_iterator_add): Made
GeglBufferIterator potentially able of handling different pyramid levels
Modified:
trunk/ChangeLog
trunk/gegl/buffer/gegl-buffer-iterator.c
Modified: trunk/gegl/buffer/gegl-buffer-iterator.c
==============================================================================
--- trunk/gegl/buffer/gegl-buffer-iterator.c (original)
+++ trunk/gegl/buffer/gegl-buffer-iterator.c Tue Jun 10 10:00:36 2008
@@ -47,6 +47,7 @@
gint next_col; /* used internally */
gint next_row; /* used internally */
+ gint level;
} GeglBufferTileIterator;
typedef struct GeglBufferScanIterator {
@@ -88,12 +89,14 @@
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);
static void gegl_buffer_scan_iterator_init (GeglBufferScanIterator *i,
GeglBuffer *buffer,
GeglRectangle roi,
- gboolean write);
+ gboolean write,
+ gint level);
static gboolean gegl_buffer_scan_iterator_next (GeglBufferScanIterator *i);
/*
@@ -125,7 +128,8 @@
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));
@@ -140,6 +144,7 @@
i->col = 0;
i->row = 0;
i->write = write;
+ i->level = level;
}
static gboolean
@@ -152,10 +157,23 @@
gint buffer_shift_y = buffer->shift_y /*+ i->roi.y*/;
gint buffer_x = buffer->extent.x + buffer_shift_x;
gint buffer_y = buffer->extent.y + buffer_shift_y;
+ gint width = i->roi.width;
+ gint height = i->roi.height;
+ gint j;
+ gint factor = 1;
if (i->roi.width == 0 || i->roi.height == 0)
return FALSE;
+ for (j=0; j< i->level; j++)
+ {
+ factor *= 2;
+ }
+ buffer_x /= factor;
+ buffer_y /= factor;
+ width /= factor;
+ height /= factor;
+
gulp:
/* unref previously held tile */
@@ -169,7 +187,7 @@
i->tile = NULL;
}
- if (i->next_col < i->roi.width)
+ if (i->next_col < width)
{ /* return tile on this row */
gint tiledx = buffer_x + i->next_col;
gint tiledy = buffer_y + i->next_row;
@@ -178,21 +196,21 @@
{
i->subrect.x = offsetx;
- i->subrect.y = offsety;
- if (i->roi.width + offsetx - i->next_col < tile_width)
- i->subrect.width = (i->roi.width + offsetx - i->next_col) - offsetx;
+
+ if (width + offsetx - i->next_col < tile_width)
+ i->subrect.width = (width + offsetx - i->next_col) - offsetx;
else
i->subrect.width = tile_width - offsetx;
- if (i->roi.height + offsety - i->next_row < tile_height)
- i->subrect.height = (i->roi.height + offsety - i->next_row) - offsety;
+ if (height + offsety - i->next_row < tile_height)
+ i->subrect.height = (height + offsety - i->next_row) - offsety;
else
i->subrect.height = tile_height - offsety;
i->tile = gegl_tile_source_get_tile ((GeglTileSource *) (buffer),
gegl_tile_indice (tiledx, tile_width),
gegl_tile_indice (tiledy, tile_height),
- 0);
+ i->level);
if (i->write)
{
gegl_tile_lock (i->tile);
@@ -226,7 +244,7 @@
i->next_row += tile_height - offsety;
i->next_col=0;
- if (i->next_row < i->roi.height)
+ if (i->next_row < height)
{
goto gulp; /* return the first tile in the next row */
}
@@ -238,12 +256,13 @@
static void gegl_buffer_scan_iterator_init (GeglBufferScanIterator *i,
GeglBuffer *buffer,
GeglRectangle roi,
- gboolean write)
+ gboolean write,
+ gint level)
{
GeglBufferTileIterator *tile_i = (GeglBufferTileIterator*)i;
g_assert (i);
memset (i, 0, sizeof (GeglBufferScanIterator));
- gegl_buffer_tile_iterator_init (tile_i, buffer, roi, write);
+ gegl_buffer_tile_iterator_init (tile_i, buffer, roi, write, level);
i->max_size = tile_i->buffer->tile_storage->tile_width *
tile_i->buffer->tile_storage->tile_height *
tile_i->buffer->format->format.bytes_per_pixel;
@@ -319,6 +338,7 @@
guint flags)
{
GeglBufferIterators *i = (gpointer)iterator;
+ gint level = flags >> 16;
gint self = 0;
if (i->iterators+1 > GEGL_BUFFER_MAX_ITERATORS)
{
@@ -345,7 +365,7 @@
if (self==0) /* The first buffer which is always scan aligned */
{
i->compatible[self]= TRUE;
- gegl_buffer_scan_iterator_init (&i->i[self], i->buffer[self], i->rect[self], ((i->flags[self] & GEGL_BUFFER_WRITE) != 0) );
+ gegl_buffer_scan_iterator_init (&i->i[self], i->buffer[self], i->rect[self], ((i->flags[self] & GEGL_BUFFER_WRITE) != 0), level);
}
else
{
@@ -357,7 +377,7 @@
i->buffer[self], i->rect[self].x, i->rect[self].y))
{
i->compatible[self] = TRUE;
- gegl_buffer_scan_iterator_init (&i->i[self], i->buffer[self], i->rect[self], ((i->flags[self] & GEGL_BUFFER_WRITE) != 0));
+ gegl_buffer_scan_iterator_init (&i->i[self], i->buffer[self], i->rect[self], ((i->flags[self] & GEGL_BUFFER_WRITE) != 0), level);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]