[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, 15 Jun 2012 10:45:40 +0000 (UTC)
commit 7aaab110add5599f6842bf9681bb093620aacf2e
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 | 69 ++++++++++++++++++++++++++++-------
gegl/buffer/gegl-buffer-iterator.c | 6 ++-
gegl/buffer/gegl-buffer-linear.c | 2 +-
gegl/buffer/gegl-buffer-private.h | 7 ++--
gegl/gegl-enums.h | 6 +++-
operations/external/path.c | 2 +-
6 files changed, 70 insertions(+), 22 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index 77c0644..3338ccb 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -107,7 +107,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 )
{
@@ -196,11 +196,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,
+ GeglAbyssPolicy repeat_mode)
{
guchar *buf = data;
gint tile_width = buffer->tile_storage->tile_width;
@@ -224,8 +225,47 @@ gegl_buffer_get_pixel (GeglBuffer *buffer,
if (gegl_buffer_in_abyss (buffer, x, y))
{ /* in abyss */
- memset (buf, 0x00, bpx_size);
- return;
+ const GeglRectangle *abyss;
+ switch (repeat_mode)
+ {
+ case GEGL_ABYSS_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_ABYSS_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_ABYSS_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_ABYSS_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_ABYSS_NONE:
+ memset (buf, 0x00, bpx_size);
+ return;
+ }
}
else
{
@@ -931,7 +971,8 @@ gegl_buffer_get_unlocked (GeglBuffer *buffer,
const GeglRectangle *rect,
const Babl *format,
gpointer dest_buf,
- gint rowstride)
+ gint rowstride,
+ GeglAbyssPolicy repeat_mode)
{
if (format == NULL)
@@ -944,7 +985,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
@@ -1062,7 +1103,7 @@ gegl_buffer_get (GeglBuffer *buffer,
GeglAbyssPolicy 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 *
@@ -1084,14 +1125,14 @@ gegl_buffer_sample (GeglBuffer *buffer,
gpointer dest,
const Babl *format,
GeglSamplerType sampler_type,
- GeglAbyssPolicy repeat_mode)
+ GeglAbyssPolicy repeat_mode)
{
GType desired_type;
g_return_if_fail (GEGL_IS_BUFFER (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
@@ -1104,7 +1145,7 @@ gegl_buffer_sample (GeglBuffer *buffer,
sampler_type == GEGL_SAMPLER_NEAREST)
{
/* XXX: not thread safe */
- gegl_buffer_get_pixel (buffer, x, y, format, dest);
+ gegl_buffer_get_pixel (buffer, x, y, format, dest, repeat_mode);
return;
}
/* unset the cached sampler if it dosn't match the needs */
diff --git a/gegl/buffer/gegl-buffer-iterator.c b/gegl/buffer/gegl-buffer-iterator.c
index 191c148..ef435d9 100644
--- a/gegl/buffer/gegl-buffer-iterator.c
+++ b/gegl/buffer/gegl-buffer-iterator.c
@@ -527,7 +527,8 @@ 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_ABYSS_NONE);
}
i->data[no]=i->buf[no];
@@ -547,7 +548,8 @@ 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_ABYSS_NONE);
}
i->data[no]=i->buf[no];
diff --git a/gegl/buffer/gegl-buffer-linear.c b/gegl/buffer/gegl-buffer-linear.c
index 9db8e96..27970c5 100644
--- a/gegl/buffer/gegl-buffer-linear.c
+++ b/gegl/buffer/gegl-buffer-linear.c
@@ -205,7 +205,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_ABYSS_NONE);
return info->buf;
}
return NULL;
diff --git a/gegl/buffer/gegl-buffer-private.h b/gegl/buffer/gegl-buffer-private.h
index 3f6d7fb1..99829f6 100644
--- a/gegl/buffer/gegl-buffer-private.h
+++ b/gegl/buffer/gegl-buffer-private.h
@@ -46,8 +46,8 @@ struct _GeglBuffer
be different from format */
gint shift_x; /* The relative offset of origins compared with */
- gint shift_y; /* anchestral tile_storage buffer, during */
- /* construction relative to immediate source */
+ gint shift_y; /* anchestral tile_storage buffer, during */
+ /* construction relative to immediate source */
GeglRectangle abyss;
gboolean abyss_tracks_extent; /* specifies whether the abyss rectangle
@@ -120,7 +120,8 @@ void gegl_buffer_get_unlocked (GeglBuffer *buffer,
const GeglRectangle *rect,
const Babl *format,
gpointer dest_buf,
- gint rowstride);
+ gint rowstride,
+ GeglAbyssPolicy repeat_mode);
GeglBuffer *
gegl_buffer_new_ram (const GeglRectangle *extent,
diff --git a/gegl/gegl-enums.h b/gegl/gegl-enums.h
index 434dc8b..648a766 100644
--- a/gegl/gegl-enums.h
+++ b/gegl/gegl-enums.h
@@ -41,7 +41,11 @@ GType gegl_sampler_type_get_type (void) G_GNUC_CONST;
#define GEGL_TYPE_SAMPLER_TYPE (gegl_sampler_type_get_type())
typedef enum {
- GEGL_ABYSS_NONE
+ GEGL_ABYSS_NONE,
+ GEGL_ABYSS_CLAMP,
+ GEGL_ABYSS_LOOP,
+ GEGL_ABYSS_BLACK,
+ GEGL_ABYSS_WHITE
} GeglAbyssPolicy;
GType gegl_abyss_policy_get_type (void) G_GNUC_CONST;
#define GEGL_ABYSS_POLICY_TYPE (gegl_abyss_policy_get_type())
diff --git a/operations/external/path.c b/operations/external/path.c
index 4575139..bad2d41 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_ABYSS_NONE);
{
gint u, v;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]