[gegl/abyss: 3/3] abyss: get down to gegl_buffer_get_pixel in the call graph with the repeat_mode parameter and implem
- From: Michael Murà <mmure src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl/abyss: 3/3] abyss: get down to gegl_buffer_get_pixel in the call graph with the repeat_mode parameter and implem
- Date: Fri, 16 Sep 2011 15:23:06 +0000 (UTC)
commit deab35b667ca70ef661ed89d9002e7c2ee488bc3
Author: Michael Murà <batolettre gmail com>
Date: Fri Sep 16 17:20:31 2011 +0200
abyss: get down to gegl_buffer_get_pixel in the call graph with the repeat_mode parameter and implement the abyss policy here.
Next and last function to be treated is gegl_buffer_iterate.
gegl/buffer/gegl-buffer-access.c | 159 +++++++++++++++++++++++-------------
gegl/buffer/gegl-buffer-iterator.c | 6 +-
gegl/buffer/gegl-buffer-linear.c | 2 +-
gegl/buffer/gegl-buffer-private.h | 3 +-
gegl/gegl-enums.h | 3 +-
operations/external/path.c | 2 +-
6 files changed, 110 insertions(+), 65 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index 198705b..970eba4 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -106,7 +106,7 @@ gegl_buffer_pixel_set (GeglBuffer *buffer,
#endif
static gboolean
-gegl_buffer_in_abyss( GeglBuffer *buffer,
+gegl_buffer_in_abyss (GeglBuffer *buffer,
gint x,
gint y )
{
@@ -204,11 +204,12 @@ gegl_buffer_set_pixel (GeglBuffer *buffer,
}
static inline void
-gegl_buffer_get_pixel (GeglBuffer *buffer,
- gint x,
- gint y,
- const Babl *format,
- gpointer data)
+gegl_buffer_get_pixel (GeglBuffer *buffer,
+ gint x,
+ gint y,
+ const Babl *format,
+ gpointer data,
+ GeglRepeatMode repeat_mode)
{
guchar *buf = data;
gint tile_width = buffer->tile_storage->tile_width;
@@ -216,9 +217,57 @@ gegl_buffer_get_pixel (GeglBuffer *buffer,
gint bpx_size = babl_format_get_bytes_per_pixel (format);
Babl *fish = NULL;
- gint buffer_shift_x = buffer->shift_x;
- gint buffer_shift_y = buffer->shift_y;
- gint px_size = babl_format_get_bytes_per_pixel (buffer->format);
+ gint tiledy, tiledx;
+ gint indice_x, indice_y;
+ gint buffer_shift_x, buffer_shift_y;
+ gint px_size;
+ GeglTile *tile;
+
+ const GeglRectangle *abyss;
+
+ if (gegl_buffer_in_abyss (buffer, x, y))
+ { /* in abyss */
+ switch (repeat_mode)
+ {
+ case GEGL_REPEAT_MODE_CLAMP:
+ abyss = gegl_buffer_get_abyss (buffer);
+ x = CLAMP (x, abyss->x, abyss->x+abyss->width);
+ y = CLAMP (y, abyss->y, abyss->x+abyss->height);
+ break;
+
+ case GEGL_REPEAT_MODE_LOOP:
+ abyss = gegl_buffer_get_abyss (buffer);
+ x = abyss->x + (x - abyss->x) % abyss->width;
+ y = abyss->y + (y - abyss->y) % abyss->height;
+ break;
+
+ case GEGL_REPEAT_MODE_BLACK:
+ {
+ gfloat color[4] = {0.0, 0.0, 0.0, 1.0};
+ babl_process (babl_fish (babl_format ("RGBA float"), format),
+ color,
+ buf,
+ 1);
+ return;
+ }
+
+ case GEGL_REPEAT_MODE_WHITE:
+ {
+ gfloat color[4] = {1.0, 1.0, 1.0, 1.0};
+ babl_process (babl_fish (babl_format ("RGBA float"),
+ format),
+ color,
+ buf,
+ 1);
+ return;
+ }
+
+ default:
+ case GEGL_REPEAT_MODE_ZERO:
+ memset (buf, 0x00, bpx_size);
+ return;
+ }
+ }
if (format != buffer->format)
{
@@ -226,55 +275,48 @@ gegl_buffer_get_pixel (GeglBuffer *buffer,
(gpointer) format);
}
- {
- gint tiledy = y + buffer_shift_y;
- gint tiledx = x + buffer_shift_x;
+ buffer_shift_x = buffer->shift_x;
+ buffer_shift_y = buffer->shift_y;
+ px_size = babl_format_get_bytes_per_pixel (buffer->format);
- if (gegl_buffer_in_abyss (buffer, x, y))
- { /* in abyss */
- memset (buf, 0x00, bpx_size);
- return;
- }
- else
- {
- gint indice_x = gegl_tile_indice (tiledx, tile_width);
- gint indice_y = gegl_tile_indice (tiledy, tile_height);
- GeglTile *tile = NULL;
+ tiledy = y + buffer_shift_y;
+ tiledx = x + buffer_shift_x;
- if (buffer->hot_tile &&
- buffer->hot_tile->x == indice_x &&
- buffer->hot_tile->y == indice_y)
- {
- tile = buffer->hot_tile;
- }
- else
- {
- if (buffer->hot_tile)
- {
- gegl_tile_unref (buffer->hot_tile);
- buffer->hot_tile = NULL;
- }
- tile = gegl_tile_source_get_tile ((GeglTileSource *) (buffer),
- indice_x, indice_y,
- 0);
- }
+ indice_x = gegl_tile_indice (tiledx, tile_width);
+ indice_y = gegl_tile_indice (tiledy, tile_height);
- if (tile)
- {
- gint offsetx = gegl_tile_offset (tiledx, tile_width);
- gint offsety = gegl_tile_offset (tiledy, tile_height);
- guchar *tp = gegl_tile_get_data (tile) +
- (offsety * tile_width + offsetx) * px_size;
- if (fish)
- babl_process (fish, tp, buf, 1);
- else
- memcpy (buf, tp, px_size);
+ if (buffer->hot_tile &&
+ buffer->hot_tile->x == indice_x &&
+ buffer->hot_tile->y == indice_y)
+ {
+ tile = buffer->hot_tile;
+ }
+ else
+ {
+ if (buffer->hot_tile)
+ {
+ gegl_tile_unref (buffer->hot_tile);
+ buffer->hot_tile = NULL;
+ }
+ tile = gegl_tile_source_get_tile ((GeglTileSource *) (buffer),
+ indice_x, indice_y,
+ 0);
+ }
- /*gegl_tile_unref (tile);*/
- buffer->hot_tile = tile;
- }
- }
- }
+ if (tile)
+ {
+ gint offsetx = gegl_tile_offset (tiledx, tile_width);
+ gint offsety = gegl_tile_offset (tiledy, tile_height);
+ guchar *tp = gegl_tile_get_data (tile) +
+ (offsety * tile_width + offsetx) * px_size;
+ if (fish)
+ babl_process (fish, tp, buf, 1);
+ else
+ memcpy (buf, tp, px_size);
+
+ /*gegl_tile_unref (tile);*/
+ buffer->hot_tile = tile;
+ }
}
/* flush any unwritten data (flushes the hot-cache of a single
@@ -930,7 +972,8 @@ gegl_buffer_get_unlocked (GeglBuffer *buffer,
const GeglRectangle *rect,
const Babl *format,
gpointer dest_buf,
- gint rowstride)
+ gint rowstride,
+ GeglRepeatMode repeat_mode)
{
if (format == NULL)
@@ -943,7 +986,7 @@ gegl_buffer_get_unlocked (GeglBuffer *buffer,
rect->width == 1 &&
rect->height == 1) /* fast path */
{
- gegl_buffer_get_pixel (buffer, rect->x, rect->y, format, dest_buf);
+ gegl_buffer_get_pixel (buffer, rect->x, rect->y, format, dest_buf, repeat_mode);
return;
}
#endif
@@ -1056,7 +1099,7 @@ gegl_buffer_get (GeglBuffer *buffer,
GeglRepeatMode repeat_mode)
{
g_return_if_fail (GEGL_IS_BUFFER (buffer));
- gegl_buffer_get_unlocked (buffer, scale, rect, format, dest_buf, rowstride);
+ gegl_buffer_get_unlocked (buffer, scale, rect, format, dest_buf, rowstride, repeat_mode);
}
const GeglRectangle *
@@ -1085,7 +1128,7 @@ gegl_buffer_sample (GeglBuffer *buffer,
/*#define USE_WORKING_SHORTCUT*/
#ifdef USE_WORKING_SHORTCUT
- gegl_buffer_get_pixel (buffer, x, y, format, dest);
+ gegl_buffer_get_pixel (buffer, x, y, format, dest, repeat_mode);
return;
#endif
diff --git a/gegl/buffer/gegl-buffer-iterator.c b/gegl/buffer/gegl-buffer-iterator.c
index 5ef5565..17a2231 100644
--- a/gegl/buffer/gegl-buffer-iterator.c
+++ b/gegl/buffer/gegl-buffer-iterator.c
@@ -466,7 +466,8 @@ gboolean gegl_buffer_iterator_next (GeglBufferIterator *iterator)
if (i->flags[no] & GEGL_BUFFER_READ)
{
- gegl_buffer_get_unlocked (i->buffer[no], 1.0, &(i->roi[no]), i->format[no], i->buf[no], GEGL_AUTO_ROWSTRIDE);
+ gegl_buffer_get_unlocked (i->buffer[no], 1.0, &(i->roi[no]), i->format[no], i->buf[no],
+ GEGL_AUTO_ROWSTRIDE, GEGL_REPEAT_MODE_ZERO);
}
i->data[no]=i->buf[no];
@@ -486,7 +487,8 @@ gboolean gegl_buffer_iterator_next (GeglBufferIterator *iterator)
if (i->flags[no] & GEGL_BUFFER_READ)
{
- gegl_buffer_get_unlocked (i->buffer[no], 1.0, &(i->roi[no]), i->format[no], i->buf[no], GEGL_AUTO_ROWSTRIDE);
+ gegl_buffer_get_unlocked (i->buffer[no], 1.0, &(i->roi[no]), i->format[no], i->buf[no],
+ GEGL_AUTO_ROWSTRIDE, GEGL_REPEAT_MODE_ZERO);
}
i->data[no]=i->buf[no];
diff --git a/gegl/buffer/gegl-buffer-linear.c b/gegl/buffer/gegl-buffer-linear.c
index 55475f3..8b85f3e 100644
--- a/gegl/buffer/gegl-buffer-linear.c
+++ b/gegl/buffer/gegl-buffer-linear.c
@@ -198,7 +198,7 @@ gegl_buffer_linear_open (GeglBuffer *buffer,
if(rowstride)*rowstride = rs;
info->buf = gegl_malloc (rs * info->extent.height);
- gegl_buffer_get_unlocked (buffer, 1.0, &info->extent, format, info->buf, rs);
+ gegl_buffer_get_unlocked (buffer, 1.0, &info->extent, format, info->buf, rs, GEGL_REPEAT_MODE_ZERO);
return info->buf;
}
return NULL;
diff --git a/gegl/buffer/gegl-buffer-private.h b/gegl/buffer/gegl-buffer-private.h
index 2966c2b..bf1f17c 100644
--- a/gegl/buffer/gegl-buffer-private.h
+++ b/gegl/buffer/gegl-buffer-private.h
@@ -115,7 +115,8 @@ void gegl_buffer_get_unlocked (GeglBuffer *buffer,
const GeglRectangle *rect,
const Babl *format,
gpointer dest_buf,
- gint rowstride);
+ gint rowstride,
+ GeglRepeatMode repeat_mode);
GeglBuffer *
gegl_buffer_new_ram (const GeglRectangle *extent,
diff --git a/gegl/gegl-enums.h b/gegl/gegl-enums.h
index 0577ec2..86ab167 100644
--- a/gegl/gegl-enums.h
+++ b/gegl/gegl-enums.h
@@ -46,8 +46,7 @@ typedef enum {
GEGL_REPEAT_MODE_LOOP,
GEGL_REPEAT_MODE_BLACK,
GEGL_REPEAT_MODE_WHITE,
- GEGL_REPEAT_MODE_ZERO,
- GEGL_REPEAT_MODE_ONE
+ GEGL_REPEAT_MODE_ZERO
} GeglRepeatMode;
GType gegl_repeat_mode_get_type (void) G_GNUC_CONST;
#define GEGL_REPEAT_MODE_TYPE (gegl_repeat_mode_get_type())
diff --git a/operations/external/path.c b/operations/external/path.c
index c88642a..7b78fbb 100644
--- a/operations/external/path.c
+++ b/operations/external/path.c
@@ -256,7 +256,7 @@ gegl_path_stamp (GeglBuffer *buffer,
}
g_assert (s.buf);
- gegl_buffer_get_unlocked (buffer, 1.0, &roi, s.format, s.buf, 0);
+ gegl_buffer_get_unlocked (buffer, 1.0, &roi, s.format, s.buf, 0, GEGL_REPEAT_MODE_ZERO);
{
gint u, v;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]