gegl r3010 - in trunk: . gegl/buffer
- From: martinn svn gnome org
- To: svn-commits-list gnome org
- Subject: gegl r3010 - in trunk: . gegl/buffer
- Date: Tue, 31 Mar 2009 20:38:26 +0000 (UTC)
Author: martinn
Date: Tue Mar 31 20:38:26 2009
New Revision: 3010
URL: http://svn.gnome.org/viewvc/gegl?rev=3010&view=rev
Log:
introduce gegl_buffer_in_abyss()
Patch from Henrik Akesson that extracts duplicated code from
gegl_buffer_pixel_get and gegl_buffer_pixel_set into the function
gegl_buffer_in_abyss to improve readability of code and
maintainability.
Modified:
trunk/ChangeLog
trunk/gegl/buffer/gegl-buffer-access.c
Modified: trunk/gegl/buffer/gegl-buffer-access.c
==============================================================================
--- trunk/gegl/buffer/gegl-buffer-access.c (original)
+++ trunk/gegl/buffer/gegl-buffer-access.c Tue Mar 31 20:38:26 2009
@@ -115,6 +115,28 @@
}
#endif
+static gboolean
+gegl_buffer_in_abyss( GeglBuffer *buffer,
+ gint x,
+ gint y )
+{
+ gint buffer_shift_x = buffer->shift_x;
+ gint buffer_shift_y = buffer->shift_y;
+ gint buffer_abyss_x = buffer->abyss.x + buffer_shift_x;
+ gint buffer_abyss_y = buffer->abyss.y + buffer_shift_y;
+ gint abyss_x_total = buffer_abyss_x + buffer->abyss.width;
+ gint abyss_y_total = buffer_abyss_y + buffer->abyss.height;
+
+
+ gint tiledy = y + buffer_shift_y;
+ gint tiledx = x + buffer_shift_x;
+
+ return !(tiledy >= buffer_abyss_y &&
+ tiledy < abyss_y_total &&
+ tiledx >= buffer_abyss_x &&
+ tiledx < abyss_x_total);
+}
+
static inline void
gegl_buffer_set_pixel (GeglBuffer *buffer,
gint x,
@@ -130,10 +152,6 @@
gint buffer_shift_x = buffer->shift_x;
gint buffer_shift_y = buffer->shift_y;
- gint buffer_abyss_x = buffer->abyss.x + buffer_shift_x;
- gint buffer_abyss_y = buffer->abyss.y + buffer_shift_y;
- gint abyss_x_total = buffer_abyss_x + buffer->abyss.width;
- gint abyss_y_total = buffer_abyss_y + buffer->abyss.height;
gint px_size = babl_format_get_bytes_per_pixel (buffer->format);
if (format != buffer->format)
@@ -146,10 +164,7 @@
gint tiledy = y + buffer_shift_y;
gint tiledx = x + buffer_shift_x;
- if (!(tiledy >= buffer_abyss_y &&
- tiledy < abyss_y_total &&
- tiledx >= buffer_abyss_x &&
- tiledx < abyss_x_total))
+ if (gegl_buffer_in_abyss( buffer, x, y))
{ /* in abyss */
return;
}
@@ -214,10 +229,6 @@
gint buffer_shift_x = buffer->shift_x;
gint buffer_shift_y = buffer->shift_y;
- gint buffer_abyss_x = buffer->abyss.x + buffer_shift_x;
- gint buffer_abyss_y = buffer->abyss.y + buffer_shift_y;
- gint abyss_x_total = buffer_abyss_x + buffer->abyss.width;
- gint abyss_y_total = buffer_abyss_y + buffer->abyss.height;
gint px_size = babl_format_get_bytes_per_pixel (buffer->format);
if (format != buffer->format)
@@ -230,10 +241,7 @@
gint tiledy = y + buffer_shift_y;
gint tiledx = x + buffer_shift_x;
- if (!(tiledy >= buffer_abyss_y &&
- tiledy < abyss_y_total &&
- tiledx >= buffer_abyss_x &&
- tiledx < abyss_x_total))
+ if (gegl_buffer_in_abyss (buffer, x, y))
{ /* in abyss */
memset (buf, 0x00, bpx_size);
return;
@@ -316,9 +324,6 @@
const Babl *format,
gint level)
{
- gint width = buffer->extent.width;
- gint height = buffer->extent.height;
-
gint tile_width = buffer->tile_storage->tile_width;
gint tile_height = buffer->tile_storage->tile_height;
gint px_size = babl_format_get_bytes_per_pixel (buffer->format);
@@ -331,6 +336,8 @@
gint buffer_shift_x = buffer->shift_x;
gint buffer_shift_y = buffer->shift_y;
+ gint width = buffer->extent.width;
+ gint height = buffer->extent.height;
gint buffer_x = buffer->extent.x + buffer_shift_x;
gint buffer_y = buffer->extent.y + buffer_shift_y;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]