[gegl] buffer: move definitions of GeglRectangle and buffer enums to buffer



commit cc7028d85db62e89bdccaa94704c574414a7da03
Author: Øyvind Kolås <pippin gimp org>
Date:   Mon Oct 1 14:43:33 2018 +0200

    buffer: move definitions of GeglRectangle and buffer enums to buffer
    
    This reverts earlier indentation breaking changes when GeglRectangle was
    renamed GeglBufferRectangle this change also retains the existing released API
    and ABI more exactly.

 gegl/Makefile.am                           |   2 +
 gegl/buffer/Makefile.am                    |   4 +
 gegl/buffer/gegl-algorithms-bilinear.inc   |  12 +-
 gegl/buffer/gegl-algorithms-boxfilter.inc  |  12 +-
 gegl/buffer/gegl-algorithms.c              | 146 +++++----
 gegl/buffer/gegl-algorithms.h              | 231 +++++++-------
 gegl/buffer/gegl-buffer-access.c           | 463 +++++++++++++++--------------
 gegl/buffer/gegl-buffer-backend.h          |   5 +-
 gegl/buffer/gegl-buffer-config.c           |   3 +-
 gegl/buffer/gegl-buffer-enums.c            | 107 +++++++
 gegl/buffer/gegl-buffer-enums.h            |  92 ++++++
 gegl/buffer/gegl-buffer-formats.h          |   7 +-
 gegl/buffer/gegl-buffer-iterator.c         |  61 ++--
 gegl/buffer/gegl-buffer-iterator.h         |  32 +-
 gegl/buffer/gegl-buffer-iterator2.c        |  74 ++---
 gegl/buffer/gegl-buffer-iterator2.h        |  34 +--
 gegl/buffer/gegl-buffer-linear.c           |  35 +--
 gegl/buffer/gegl-buffer-load.c             |   2 +-
 gegl/buffer/gegl-buffer-private.h          |  73 +++--
 gegl/buffer/gegl-buffer-save.c             |   8 +-
 gegl/buffer/gegl-buffer-types.h            |  22 +-
 gegl/buffer/gegl-buffer.c                  |  60 ++--
 gegl/buffer/gegl-buffer.h                  | 206 +++++++------
 gegl/buffer/gegl-rectangle.c               | 367 +++++++++++++++++++++++
 gegl/buffer/gegl-rectangle.h               | 261 ++++++++++++++++
 gegl/buffer/gegl-sampler-cubic.c           |   2 +-
 gegl/buffer/gegl-sampler-linear.c          |   2 +-
 gegl/buffer/gegl-sampler-lohalo.c          |   2 +-
 gegl/buffer/gegl-sampler-nearest.c         |   4 +-
 gegl/buffer/gegl-sampler-nohalo.c          |   2 +-
 gegl/buffer/gegl-sampler.c                 |  29 +-
 gegl/buffer/gegl-sampler.h                 |  18 +-
 gegl/buffer/gegl-tile-backend-buffer.c     |   2 +-
 gegl/buffer/gegl-tile-backend-file-async.c |   8 +-
 gegl/buffer/gegl-tile-backend-swap.c       |   2 +-
 gegl/buffer/gegl-tile-backend.c            |   6 +-
 gegl/buffer/gegl-tile-backend.h            |   7 +-
 gegl/buffer/gegl-tile-handler.c            |   4 +-
 gegl/buffer/gegl-tile-handler.h            |   4 +-
 gegl/buffer/gegl-tile.c                    |   2 +-
 gegl/gegl-enums.c                          |  84 ------
 gegl/gegl-enums.h                          |  53 ----
 gegl/gegl-types.h                          |  30 --
 gegl/gegl-utils.c                          | 342 ---------------------
 gegl/gegl-utils.h                          | 250 +---------------
 gegl/graph/gegl-cache.c                    |   1 +
 gegl/graph/gegl-cache.h                    |   1 +
 47 files changed, 1645 insertions(+), 1529 deletions(-)
---
diff --git a/gegl/Makefile.am b/gegl/Makefile.am
index 8b0b5a7a5..cf14f2416 100644
--- a/gegl/Makefile.am
+++ b/gegl/Makefile.am
@@ -62,9 +62,11 @@ GEGL_introspectable_headers =        \
        buffer/gegl-buffer-iterator.h   \
        buffer/gegl-buffer-iterator2.h  \
        buffer/gegl-buffer-backend.h    \
+       buffer/gegl-rectangle.h         \
        buffer/gegl-tile-backend.h              \
        buffer/gegl-tile-handler.h              \
        buffer/gegl-tile-source.h               \
+       buffer/gegl-buffer-enums.h              \
        graph/gegl-node.h                       \
        process/gegl-graph-debug.h              \
        process/gegl-processor.h                \
diff --git a/gegl/buffer/Makefile.am b/gegl/buffer/Makefile.am
index 2bea1db40..0c1f79ca4 100644
--- a/gegl/buffer/Makefile.am
+++ b/gegl/buffer/Makefile.am
@@ -29,12 +29,15 @@ libbuffer_la_SOURCES = \
     gegl-buffer-access.c       \
     gegl-buffer-config.c       \
     gegl-buffer-config.h       \
+    gegl-buffer-enums.c                \
+    gegl-buffer-enums.h                \
     gegl-buffer-matrix2.c      \
     gegl-buffer-matrix2.h      \
     gegl-buffer-index.h                \
     gegl-buffer-iterator.c     \
     gegl-buffer-iterator2.c    \
     gegl-buffer-linear.c       \
+    gegl-rectangle.c   \
        gegl-buffer-load.c      \
     gegl-buffer-save.c         \
     gegl-sampler.c             \
@@ -64,6 +67,7 @@ libbuffer_la_SOURCES = \
     gegl-buffer-iterator.h     \
     gegl-buffer-iterator2.h    \
     gegl-buffer-iterator-private.h     \
+    gegl-rectangle.h   \
     gegl-buffer-types.h                \
     gegl-buffer-formats.h      \
     gegl-sampler.h             \
diff --git a/gegl/buffer/gegl-algorithms-bilinear.inc b/gegl/buffer/gegl-algorithms-bilinear.inc
index b759d75e7..d5bf3ae41 100644
--- a/gegl/buffer/gegl-algorithms-bilinear.inc
+++ b/gegl/buffer/gegl-algorithms-bilinear.inc
@@ -1,12 +1,12 @@
 void
-BILINEAR_FUNCNAME (guchar              *dest_buf,
-                   const guchar        *source_buf,
+BILINEAR_FUNCNAME (guchar                    *dest_buf,
+                   const guchar              *source_buf,
                    const GeglRectangle *dst_rect,
                    const GeglRectangle *src_rect,
-                   const gint           s_rowstride,
-                   const gdouble        scale,
-                   const gint           bpp,
-                   const gint           d_rowstride)
+                   const gint                 s_rowstride,
+                   const gdouble              scale,
+                   const gint                 bpp,
+                   const gint                 d_rowstride)
 {
   const gint components = bpp / sizeof(BILINEAR_TYPE);
   const gint ver  = s_rowstride/(bpp/components);
diff --git a/gegl/buffer/gegl-algorithms-boxfilter.inc b/gegl/buffer/gegl-algorithms-boxfilter.inc
index f8a0f1466..5a5704f43 100644
--- a/gegl/buffer/gegl-algorithms-boxfilter.inc
+++ b/gegl/buffer/gegl-algorithms-boxfilter.inc
@@ -1,12 +1,12 @@
 void
-BOXFILTER_FUNCNAME (guchar              *dest_buf,
-                    const guchar        *source_buf,
+BOXFILTER_FUNCNAME (guchar                    *dest_buf,
+                    const guchar              *source_buf,
                     const GeglRectangle *dst_rect,
                     const GeglRectangle *src_rect,
-                    const gint           s_rowstride,
-                    const gdouble        scale,
-                    const gint           bpp,
-                    const gint           d_rowstride)
+                    const gint                 s_rowstride,
+                    const gdouble              scale,
+                    const gint                 bpp,
+                    const gint                 d_rowstride)
 {
   const BOXFILTER_TYPE *src[9];
   gint  components = bpp / sizeof(BOXFILTER_TYPE);
diff --git a/gegl/buffer/gegl-algorithms.c b/gegl/buffer/gegl-algorithms.c
index fe525d7cf..ad76681de 100644
--- a/gegl/buffer/gegl-algorithms.c
+++ b/gegl/buffer/gegl-algorithms.c
@@ -26,9 +26,7 @@
 #include <babl/babl.h>
 
 #include "gegl-buffer.h"
-#include "gegl-types.h"
 #include "gegl-buffer-formats.h"
-#include "gegl-utils.h"
 #include "gegl-algorithms.h"
 
 #include <math.h>
@@ -151,14 +149,14 @@ static inline int int_floorf (float x)
 
 
 static void
-gegl_boxfilter_u8_nl (guchar                    *dest_buf,
-                      const guchar              *source_buf,
-                      const GeglBufferRectangle *dst_rect,
-                      const GeglBufferRectangle *src_rect,
-                      const gint                 s_rowstride,
-                      const gdouble              scale,
-                      const gint                 bpp,
-                      const gint                 d_rowstride)
+gegl_boxfilter_u8_nl (guchar              *dest_buf,
+                      const guchar        *source_buf,
+                      const GeglRectangle *dst_rect,
+                      const GeglRectangle *src_rect,
+                      const gint           s_rowstride,
+                      const gdouble        scale,
+                      const gint           bpp,
+                      const gint           d_rowstride)
 {
   const uint8_t *src[9];
   gint  components = bpp / sizeof(uint8_t);
@@ -324,14 +322,14 @@ gegl_boxfilter_u8_nl (guchar                    *dest_buf,
 }
 
 static void
-gegl_boxfilter_u8_nl_alpha (guchar                    *dest_buf,
-                            const guchar              *source_buf,
-                            const GeglBufferRectangle *dst_rect,
-                            const GeglBufferRectangle *src_rect,
-                            const gint                 s_rowstride,
-                            const gdouble              scale,
-                            const gint                 bpp,
-                            const gint                 d_rowstride)
+gegl_boxfilter_u8_nl_alpha (guchar              *dest_buf,
+                            const guchar        *source_buf,
+                            const GeglRectangle *dst_rect,
+                            const GeglRectangle *src_rect,
+                            const gint           s_rowstride,
+                            const gdouble        scale,
+                            const gint           bpp,
+                            const gint           d_rowstride)
 {
   const uint8_t *src[9];
   gint  components = bpp / sizeof(uint8_t);
@@ -457,14 +455,14 @@ gegl_boxfilter_u8_nl_alpha (guchar                    *dest_buf,
 #undef C
 
 static void
-gegl_bilinear_u8_nl (guchar                    *dest_buf,
-                     const guchar              *source_buf,
-                     const GeglBufferRectangle *dst_rect,
-                     const GeglBufferRectangle *src_rect,
-                     const gint                 s_rowstride,
-                     const gdouble              scale,
-                     const gint                 components,
-                     const gint                 d_rowstride)
+gegl_bilinear_u8_nl (guchar              *dest_buf,
+                     const guchar        *source_buf,
+                     const GeglRectangle *dst_rect,
+                     const GeglRectangle *src_rect,
+                     const gint           s_rowstride,
+                     const gdouble        scale,
+                     const gint           components,
+                     const gint           d_rowstride)
 {
   const gint ver  = s_rowstride;
   const gint diag = ver + components;
@@ -585,14 +583,14 @@ gegl_bilinear_u8_nl (guchar                    *dest_buf,
 }
 
 static void
-gegl_bilinear_u8_nl_alpha (guchar                    *dest_buf,
-                           const guchar              *source_buf,
-                           const GeglBufferRectangle *dst_rect,
-                           const GeglBufferRectangle *src_rect,
-                           const gint                 s_rowstride,
-                           const gdouble              scale,
-                           const gint                 components,
-                           const gint                 d_rowstride)
+gegl_bilinear_u8_nl_alpha (guchar              *dest_buf,
+                           const guchar        *source_buf,
+                           const GeglRectangle *dst_rect,
+                           const GeglRectangle *src_rect,
+                           const gint           s_rowstride,
+                           const gdouble        scale,
+                           const gint           components,
+                           const gint           d_rowstride)
 {
   const gint ver  = s_rowstride;
   const gint diag = ver + components;
@@ -993,14 +991,14 @@ gegl_downscale_2x2_nearest (const Babl *format,
 }
 
 static void
-gegl_resample_boxfilter_generic (guchar                    *dest_buf,
-                                 const guchar              *source_buf,
-                                 const GeglBufferRectangle *dst_rect,
-                                 const GeglBufferRectangle *src_rect,
-                                 gint                       s_rowstride,
-                                 gdouble                    scale,
-                                 const Babl                *format,
-                                 gint                       d_rowstride)
+gegl_resample_boxfilter_generic (guchar       *dest_buf,
+                                 const guchar *source_buf,
+                                 const GeglRectangle *dst_rect,
+                                 const GeglRectangle *src_rect,
+                                 gint  s_rowstride,
+                                 gdouble scale,
+                                 const Babl *format,
+                                 gint d_rowstride)
 {
   const Babl *tmp_format = babl_format_with_space ("RGBA float", format);
   const Babl *from_fish  = babl_fish (format, tmp_format);
@@ -1045,14 +1043,14 @@ gegl_resample_boxfilter_generic (guchar                    *dest_buf,
     }
 }
 
-void gegl_resample_boxfilter (guchar                    *dest_buf,
-                              const guchar              *source_buf,
-                              const GeglBufferRectangle *dst_rect,
-                              const GeglBufferRectangle *src_rect,
-                              gint                       s_rowstride,
-                              gdouble                    scale,
-                              const Babl                *format,
-                              gint                       d_rowstride)
+void gegl_resample_boxfilter (guchar              *dest_buf,
+                              const guchar        *source_buf,
+                              const GeglRectangle *dst_rect,
+                              const GeglRectangle *src_rect,
+                              gint                 s_rowstride,
+                              gdouble              scale,
+                              const Babl          *format,
+                              gint                 d_rowstride)
 {
   const Babl *model     = babl_format_get_model (format);
   const Babl *comp_type  = babl_format_get_type (format, 0);
@@ -1100,14 +1098,14 @@ void gegl_resample_boxfilter (guchar                    *dest_buf,
 }
 
 static void
-gegl_resample_bilinear_generic (guchar                    *dest_buf,
-                                const guchar              *source_buf,
-                                const GeglBufferRectangle *dst_rect,
-                                const GeglBufferRectangle *src_rect,
-                                gint                       s_rowstride,
-                                gdouble                    scale,
-                                const Babl                *format,
-                                gint                       d_rowstride)
+gegl_resample_bilinear_generic (guchar              *dest_buf,
+                                const guchar        *source_buf,
+                                const GeglRectangle *dst_rect,
+                                const GeglRectangle *src_rect,
+                                gint                 s_rowstride,
+                                gdouble              scale,
+                                const Babl          *format,
+                                gint                 d_rowstride)
 {
   const Babl *tmp_format = babl_format_with_space ("RGBA float", format);
   const Babl *from_fish  = babl_fish (format, tmp_format);
@@ -1153,14 +1151,14 @@ gegl_resample_bilinear_generic (guchar                    *dest_buf,
     }
 }
 
-void gegl_resample_bilinear (guchar                    *dest_buf,
-                             const guchar              *source_buf,
-                             const GeglBufferRectangle *dst_rect,
-                             const GeglBufferRectangle *src_rect,
-                             gint                       s_rowstride,
-                             gdouble                    scale,
-                             const Babl                *format,
-                             gint                       d_rowstride)
+void gegl_resample_bilinear (guchar              *dest_buf,
+                             const guchar        *source_buf,
+                             const GeglRectangle *dst_rect,
+                             const GeglRectangle *src_rect,
+                             gint                 s_rowstride,
+                             gdouble              scale,
+                             const Babl          *format,
+                             gint                 d_rowstride)
 {
   const Babl *model     = babl_format_get_model (format);
   const Babl *comp_type  = babl_format_get_type (format, 0);
@@ -1210,14 +1208,14 @@ void gegl_resample_bilinear (guchar                    *dest_buf,
 }
 
 void
-gegl_resample_nearest (guchar                    *dst,
-                       const guchar              *src,
-                       const GeglBufferRectangle *dst_rect,
-                       const GeglBufferRectangle *src_rect,
-                       const gint                 src_stride,
-                       const gdouble              scale,
-                       const gint                 bpp,
-                       const gint                 dst_stride)
+gegl_resample_nearest (guchar              *dst,
+                       const guchar        *src,
+                       const GeglRectangle *dst_rect,
+                       const GeglRectangle *src_rect,
+                       const gint           src_stride,
+                       const gdouble        scale,
+                       const gint           bpp,
+                       const gint           dst_stride)
 {
   gint jj[dst_rect->width];
   gint x, y;
diff --git a/gegl/buffer/gegl-algorithms.h b/gegl/buffer/gegl-algorithms.h
index 9461a0ed3..1006608a3 100644
--- a/gegl/buffer/gegl-algorithms.h
+++ b/gegl/buffer/gegl-algorithms.h
@@ -19,6 +19,7 @@
 #ifndef __GEGL_ALGORITHMS_H__
 #define __GEGL_ALGORITHMS_H__
 
+#include "gegl-buffer.h"
 G_BEGIN_DECLS
 
 #define GEGL_SCALE_EPSILON 1.e-6
@@ -92,125 +93,125 @@ void gegl_downscale_2x2_nearest (const Babl *format,
  * available for #format fall back to nearest neighbor.
  * #scale is assumed to be between 0.5 and +inf.
  */
-void gegl_resample_boxfilter (guchar                    *dest_buf,
-                              const guchar              *source_buf,
-                              const GeglBufferRectangle *dst_rect,
-                              const GeglBufferRectangle *src_rect,
-                              gint                       s_rowstride,
-                              gdouble                    scale,
-                              const Babl                *format,
-                              gint                       d_rowstride);
-
-void gegl_resample_boxfilter_double (guchar                    *dest_buf,
-                                     const guchar              *source_buf,
-                                     const GeglBufferRectangle *dst_rect,
-                                     const GeglBufferRectangle *src_rect,
-                                     gint                       s_rowstride,
-                                     gdouble                    scale,
-                                     gint                       bpp,
-                                     gint                       d_rowstride);
-
-void gegl_resample_boxfilter_float (guchar                    *dest_buf,
-                                    const guchar              *source_buf,
-                                    const GeglBufferRectangle *dst_rect,
-                                    const GeglBufferRectangle *src_rect,
-                                    gint                       s_rowstride,
-                                    gdouble                    scale,
-                                    gint                       bpp,
-                                    gint                       d_rowstride);
-
-void gegl_resample_boxfilter_u32 (guchar                    *dest_buf,
-                                  const guchar              *source_buf,
-                                  const GeglBufferRectangle *dst_rect,
-                                  const GeglBufferRectangle *src_rect,
-                                  gint                       s_rowstride,
-                                  gdouble                    scale,
-                                  gint                       bpp,
-                                  gint                       d_rowstride);
-
-void gegl_resample_boxfilter_u16 (guchar                    *dest_buf,
-                                  const guchar              *source_buf,
-                                  const GeglBufferRectangle *dst_rect,
-                                  const GeglBufferRectangle *src_rect,
-                                  gint                       s_rowstride,
-                                  gdouble                    scale,
-                                  gint                       bpp,
-                                  gint                       d_rowstride);
-
-void gegl_resample_boxfilter_u8 (guchar                    *dest_buf,
-                                 const guchar              *source_buf,
-                                 const GeglBufferRectangle *dst_rect,
-                                 const GeglBufferRectangle *src_rect,
-                                 gint                       s_rowstride,
-                                 gdouble                    scale,
-                                 gint                       bpp,
-                                 gint                       d_rowstride);
+void gegl_resample_boxfilter (guchar              *dest_buf,
+                              const guchar        *source_buf,
+                              const GeglRectangle *dst_rect,
+                              const GeglRectangle *src_rect,
+                              gint                 s_rowstride,
+                              gdouble              scale,
+                              const Babl          *format,
+                              gint                 d_rowstride);
+
+void gegl_resample_boxfilter_double (guchar              *dest_buf,
+                                     const guchar        *source_buf,
+                                     const GeglRectangle *dst_rect,
+                                     const GeglRectangle *src_rect,
+                                     gint                 s_rowstride,
+                                     gdouble              scale,
+                                     gint                 bpp,
+                                     gint                 d_rowstride);
+
+void gegl_resample_boxfilter_float (guchar              *dest_buf,
+                                    const guchar        *source_buf,
+                                    const GeglRectangle *dst_rect,
+                                    const GeglRectangle *src_rect,
+                                    gint                 s_rowstride,
+                                    gdouble              scale,
+                                    gint                 bpp,
+                                    gint                 d_rowstride);
+
+void gegl_resample_boxfilter_u32 (guchar              *dest_buf,
+                                  const guchar        *source_buf,
+                                  const GeglRectangle *dst_rect,
+                                  const GeglRectangle *src_rect,
+                                  gint                 s_rowstride,
+                                  gdouble              scale,
+                                  gint                 bpp,
+                                  gint                 d_rowstride);
+
+void gegl_resample_boxfilter_u16 (guchar              *dest_buf,
+                                  const guchar        *source_buf,
+                                  const GeglRectangle *dst_rect,
+                                  const GeglRectangle *src_rect,
+                                  gint                 s_rowstride,
+                                  gdouble              scale,
+                                  gint                 bpp,
+                                  gint                 d_rowstride);
+
+void gegl_resample_boxfilter_u8 (guchar              *dest_buf,
+                                 const guchar        *source_buf,
+                                 const GeglRectangle *dst_rect,
+                                 const GeglRectangle *src_rect,
+                                 gint                 s_rowstride,
+                                 gdouble              scale,
+                                 gint                 bpp,
+                                 gint                 d_rowstride);
 
 /* Attempt to resample with a 2x2 bilinear filter, if no implementation is
  * available for #format fall back to nearest neighbor.
  */
-void gegl_resample_bilinear (guchar                    *dest_buf,
-                             const guchar              *source_buf,
-                             const GeglBufferRectangle *dst_rect,
-                             const GeglBufferRectangle *src_rect,
-                             gint                       s_rowstride,
-                             gdouble                    scale,
-                             const Babl                *format,
-                             gint                       d_rowstride);
-
-void gegl_resample_bilinear_double (guchar                    *dest_buf,
-                                    const guchar              *source_buf,
-                                    const GeglBufferRectangle *dst_rect,
-                                    const GeglBufferRectangle *src_rect,
-                                    gint                       s_rowstride,
-                                    gdouble                    scale,
-                                    gint                       bpp,
-                                    gint                       d_rowstride);
-
-void gegl_resample_bilinear_float (guchar                    *dest_buf,
-                                   const guchar              *source_buf,
-                                   const GeglBufferRectangle *dst_rect,
-                                   const GeglBufferRectangle *src_rect,
-                                   gint                       s_rowstride,
-                                   gdouble                    scale,
-                                   gint                       bpp,
-                                   gint                       d_rowstride);
-
-void gegl_resample_bilinear_u32 (guchar                    *dest_buf,
-                                 const guchar              *source_buf,
-                                 const GeglBufferRectangle *dst_rect,
-                                 const GeglBufferRectangle *src_rect,
-                                 gint                       s_rowstride,
-                                 gdouble                    scale,
-                                 gint                       bpp,
-                                 gint                       d_rowstride);
-
-void gegl_resample_bilinear_u16 (guchar                    *dest_buf,
-                                 const guchar              *source_buf,
-                                 const GeglBufferRectangle *dst_rect,
-                                 const GeglBufferRectangle *src_rect,
-                                 gint                       s_rowstride,
-                                 gdouble                    scale,
-                                 gint                       bpp,
-                                 gint                       d_rowstride);
-
-void gegl_resample_bilinear_u8 (guchar                    *dest_buf,
-                                const guchar              *source_buf,
-                                const GeglBufferRectangle *dst_rect,
-                                const GeglBufferRectangle *src_rect,
-                                gint                       s_rowstride,
-                                gdouble                    scale,
-                                gint                       bpp,
-                                gint                       d_rowstride);
-
-void gegl_resample_nearest (guchar                    *dst,
-                            const guchar              *src,
-                            const GeglBufferRectangle *dst_rect,
-                            const GeglBufferRectangle *src_rect,
-                            gint                       src_stride,
-                            gdouble                    scale,
-                            gint                       bpp,
-                            gint                       dst_stride);
+void gegl_resample_bilinear (guchar              *dest_buf,
+                             const guchar        *source_buf,
+                             const GeglRectangle *dst_rect,
+                             const GeglRectangle *src_rect,
+                             gint                 s_rowstride,
+                             gdouble              scale,
+                             const Babl          *format,
+                             gint                 d_rowstride);
+
+void gegl_resample_bilinear_double (guchar              *dest_buf,
+                                    const guchar        *source_buf,
+                                    const GeglRectangle *dst_rect,
+                                    const GeglRectangle *src_rect,
+                                    gint                 s_rowstride,
+                                    gdouble              scale,
+                                    gint                 bpp,
+                                    gint                 d_rowstride);
+
+void gegl_resample_bilinear_float (guchar              *dest_buf,
+                                   const guchar        *source_buf,
+                                   const GeglRectangle *dst_rect,
+                                   const GeglRectangle *src_rect,
+                                   gint                 s_rowstride,
+                                   gdouble              scale,
+                                   gint                 bpp,
+                                   gint                 d_rowstride);
+
+void gegl_resample_bilinear_u32 (guchar              *dest_buf,
+                                 const guchar        *source_buf,
+                                 const GeglRectangle *dst_rect,
+                                 const GeglRectangle *src_rect,
+                                 gint                 s_rowstride,
+                                 gdouble              scale,
+                                 gint                 bpp,
+                                 gint                 d_rowstride);
+
+void gegl_resample_bilinear_u16 (guchar              *dest_buf,
+                                 const guchar        *source_buf,
+                                 const GeglRectangle *dst_rect,
+                                 const GeglRectangle *src_rect,
+                                 gint                 s_rowstride,
+                                 gdouble              scale,
+                                 gint                 bpp,
+                                 gint                 d_rowstride);
+
+void gegl_resample_bilinear_u8 (guchar              *dest_buf,
+                                const guchar        *source_buf,
+                                const GeglRectangle *dst_rect,
+                                const GeglRectangle *src_rect,
+                                gint                 s_rowstride,
+                                gdouble              scale,
+                                gint                 bpp,
+                                gint                 d_rowstride);
+
+void gegl_resample_nearest (guchar              *dst,
+                            const guchar        *src,
+                            const GeglRectangle *dst_rect,
+                            const GeglRectangle *src_rect,
+                            gint                 src_stride,
+                            gdouble              scale,
+                            gint                 bpp,
+                            gint                 dst_stride);
 
 GeglDownscale2x2Fun gegl_downscale_2x2_get_fun (const Babl *format);
 
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index 66dec4dec..1bf8f00e9 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -22,13 +22,14 @@
 #include "config.h"
 #include <string.h>
 #include <stdlib.h>
+#include <stdint.h>
 #include <math.h>
 
 #include <glib-object.h>
 #include <glib/gprintf.h>
 #include <gio/gio.h>
 
-#include "gegl.h"
+#include <babl/babl.h>
 #include "gegl-algorithms.h"
 #include "gegl-buffer-types.h"
 #include "gegl-buffer.h"
@@ -37,26 +38,27 @@
 #include "gegl-sampler.h"
 #include "gegl-tile-backend.h"
 #include "gegl-buffer-iterator.h"
+#include "gegl-rectangle.h"
 #include "gegl-buffer-iterator-private.h"
 #include "gegl-buffer-formats.h"
 
-static void gegl_buffer_iterate_read_fringed (GeglBuffer                *buffer,
-                                              const GeglBufferRectangle *roi,
-                                              const GeglBufferRectangle *abyss,
-                                              guchar                    *buf,
-                                              gint                       buf_stride,
-                                              const Babl                *format,
-                                              gint                       level,
-                                              GeglAbyssPolicy            repeat_mode);
+static void gegl_buffer_iterate_read_fringed (GeglBuffer          *buffer,
+                                              const GeglRectangle *roi,
+                                              const GeglRectangle *abyss,
+                                              guchar              *buf,
+                                              gint                 buf_stride,
+                                              const Babl          *format,
+                                              gint                 level,
+                                              GeglAbyssPolicy      repeat_mode);
 
 
-static void gegl_buffer_iterate_read_dispatch (GeglBuffer                *buffer,
-                                               const GeglBufferRectangle *roi,
-                                               guchar                    *buf,
-                                               gint                       rowstride,
-                                               const Babl                *format,
-                                               gint                       level,
-                                               GeglAbyssPolicy            repeat_mode);
+static void gegl_buffer_iterate_read_dispatch (GeglBuffer          *buffer,
+                                               const GeglRectangle *roi,
+                                               guchar              *buf,
+                                               gint                 rowstride,
+                                               const Babl          *format,
+                                               gint                 level,
+                                               GeglAbyssPolicy      repeat_mode);
 
 static void inline
 gegl_buffer_get_pixel (GeglBuffer     *buffer,
@@ -66,7 +68,7 @@ gegl_buffer_get_pixel (GeglBuffer     *buffer,
                        gpointer        data,
                        GeglAbyssPolicy repeat_mode)
 {
-  const GeglBufferRectangle *abyss = &buffer->abyss;
+  const GeglRectangle *abyss = &buffer->abyss;
   guchar              *buf   = data;
 
   if (y <  abyss->y ||
@@ -177,8 +179,8 @@ __gegl_buffer_set_pixel (GeglBuffer     *buffer,
                        const Babl     *format,
                        gconstpointer   data)
 {
-  const GeglBufferRectangle *abyss = &buffer->abyss;
-  const guchar              *buf   = data;
+  const GeglRectangle *abyss = &buffer->abyss;
+  const guchar        *buf   = data;
 
   if (y <  abyss->y ||
       x <  abyss->x ||
@@ -260,13 +262,13 @@ enum _GeglBufferSetFlag {
 typedef enum _GeglBufferSetFlag GeglBufferSetFlag;
 
 void
-gegl_buffer_set_with_flags (GeglBuffer                *buffer,
-                            const GeglBufferRectangle *rect,
-                            gint                       level,
-                            const Babl                *format,
-                            const void                *src,
-                            gint                       rowstride,
-                            GeglBufferSetFlag          set_flags);
+gegl_buffer_set_with_flags (GeglBuffer          *buffer,
+                            const GeglRectangle *rect,
+                            gint                 level,
+                            const Babl          *format,
+                            const void          *src,
+                            gint                 rowstride,
+                            GeglBufferSetFlag    set_flags);
 
 
 static inline void
@@ -277,7 +279,7 @@ _gegl_buffer_set_pixel (GeglBuffer       *buffer,
                         gconstpointer     data,
                         GeglBufferSetFlag flags)
 {
-  GeglBufferRectangle rect = {x,y,1,1};
+  GeglRectangle rect = {x,y,1,1};
   switch (flags)
   {
     case GEGL_BUFFER_SET_FLAG_FAST:
@@ -327,7 +329,7 @@ gegl_buffer_flush (GeglBuffer *buffer)
 }
 
 void
-gegl_buffer_flush_ext (GeglBuffer *buffer, const GeglBufferRectangle *rect)
+gegl_buffer_flush_ext (GeglBuffer *buffer, const GeglRectangle *rect)
 {
   if (gegl_buffer_ext_flush)
     gegl_buffer_ext_flush (buffer, rect);
@@ -336,12 +338,12 @@ gegl_buffer_flush_ext (GeglBuffer *buffer, const GeglBufferRectangle *rect)
 
 
 static inline void
-gegl_buffer_iterate_write (GeglBuffer                *buffer,
-                           const GeglBufferRectangle *roi,
-                           guchar                    *buf,
-                           gint                       rowstride,
-                           const Babl                *format,
-                           gint                       level)
+gegl_buffer_iterate_write (GeglBuffer          *buffer,
+                           const GeglRectangle *roi,
+                           guchar              *buf,
+                           gint                 rowstride,
+                           const Babl          *format,
+                           gint                 level)
 {
   gint tile_width  = buffer->tile_storage->tile_width;
   gint tile_height = buffer->tile_storage->tile_height;
@@ -365,7 +367,7 @@ gegl_buffer_iterate_write (GeglBuffer                *buffer,
   gint abyss_y_total  = buffer_abyss_y + buffer->abyss.height;
   gint factor         = 1<<level;
   const Babl *fish;
-  GeglBufferRectangle scaled_rect;
+  GeglRectangle scaled_rect;
   if (level && roi)
   {
     scaled_rect = *roi;
@@ -852,18 +854,18 @@ with multi-threading - and should be added back later.
   if (level == 0)
     {
       gegl_tile_handler_damage_rect (GEGL_TILE_HANDLER (buffer->tile_storage),
-                                     GEGL_BUFFER_RECTANGLE (buffer_x, buffer_y,
-                                                            width,    height));
+                                     GEGL_RECTANGLE (buffer_x, buffer_y,
+                                                     width,    height));
     }
 }
 
 static inline void
-gegl_buffer_set_internal (GeglBuffer                *buffer,
-                          const GeglBufferRectangle *rect,
-                          gint                       level,
-                          const Babl                *format,
-                          const void                *src,
-                          gint                       rowstride)
+gegl_buffer_set_internal (GeglBuffer          *buffer,
+                          const GeglRectangle *rect,
+                          gint                 level,
+                          const Babl          *format,
+                          const void          *src,
+                          gint                 rowstride)
 {
   if (gegl_buffer_ext_flush)
     {
@@ -879,13 +881,13 @@ gegl_buffer_set_internal (GeglBuffer                *buffer,
 }
 
 static void inline
-_gegl_buffer_set_with_flags (GeglBuffer               *buffer,
-                            const GeglBufferRectangle *rect,
-                            gint                       level,
-                            const Babl                *format,
-                            const void                *src,
-                            gint                       rowstride,
-                            GeglBufferSetFlag          flags)
+_gegl_buffer_set_with_flags (GeglBuffer       *buffer,
+                            const GeglRectangle *rect,
+                            gint                 level,
+                            const Babl          *format,
+                            const void          *src,
+                            gint                 rowstride,
+                            GeglBufferSetFlag    flags)
 {
   switch (flags)
   {
@@ -913,13 +915,13 @@ _gegl_buffer_set_with_flags (GeglBuffer               *buffer,
 }
 
 void
-gegl_buffer_set_with_flags (GeglBuffer                *buffer,
-                            const GeglBufferRectangle *rect,
-                            gint                       level,
-                            const Babl                *format,
-                            const void                *src,
-                            gint                       rowstride,
-                            GeglBufferSetFlag          flags)
+gegl_buffer_set_with_flags (GeglBuffer       *buffer,
+                            const GeglRectangle *rect,
+                            gint                 level,
+                            const Babl          *format,
+                            const void          *src,
+                            gint                 rowstride,
+                            GeglBufferSetFlag    flags)
 {
   g_return_if_fail (GEGL_IS_BUFFER (buffer));
   if (format == NULL)
@@ -928,12 +930,12 @@ gegl_buffer_set_with_flags (GeglBuffer                *buffer,
 }
 
 static void
-gegl_buffer_iterate_read_simple (GeglBuffer                *buffer,
-                                 const GeglBufferRectangle *roi,
-                                 guchar                    *buf,
-                                 gint                       buf_stride,
-                                 const Babl                *format,
-                                 gint                       level)
+gegl_buffer_iterate_read_simple (GeglBuffer          *buffer,
+                                 const GeglRectangle *roi,
+                                 guchar              *buf,
+                                 gint                 buf_stride,
+                                 const Babl          *format,
+                                 gint                 level)
 {
   gint tile_width  = buffer->tile_storage->tile_width;
   gint tile_height = buffer->tile_storage->tile_height;
@@ -1280,17 +1282,17 @@ fill_abyss_color (guchar *buf, gint width, gint height, gint buf_stride, guchar
 }
 
 static void
-gegl_buffer_iterate_read_abyss_color (GeglBuffer                *buffer,
-                                      const GeglBufferRectangle *roi,
-                                      const GeglBufferRectangle *abyss,
-                                      guchar                    *buf,
-                                      gint                       buf_stride,
-                                      const Babl                *format,
-                                      gint                       level,
-                                      guchar                    *color,
-                                      GeglAbyssPolicy            repeat_mode)
+gegl_buffer_iterate_read_abyss_color (GeglBuffer          *buffer,
+                                      const GeglRectangle *roi,
+                                      const GeglRectangle *abyss,
+                                      guchar              *buf,
+                                      gint                 buf_stride,
+                                      const Babl          *format,
+                                      gint                 level,
+                                      guchar              *color,
+                                      GeglAbyssPolicy      repeat_mode)
 {
-  GeglBufferRectangle current_roi = *roi;
+  GeglRectangle current_roi = *roi;
   gint bpp = babl_format_get_bytes_per_pixel (format);
 
   if (current_roi.y < abyss->y)
@@ -1310,7 +1312,7 @@ gegl_buffer_iterate_read_abyss_color (GeglBuffer                *buffer,
 
   if (current_roi.height && (current_roi.y < abyss->y + abyss->height))
     {
-      GeglBufferRectangle inner_roi = current_roi;
+      GeglRectangle inner_roi = current_roi;
       guchar *inner_buf       = buf;
 
       if (inner_roi.height + inner_roi.y > abyss->height + abyss->y)
@@ -1391,16 +1393,16 @@ gegl_buffer_iterate_read_abyss_color (GeglBuffer                *buffer,
 }
 
 static void
-gegl_buffer_iterate_read_abyss_clamp (GeglBuffer                *buffer,
-                                      const GeglBufferRectangle *roi,
-                                      const GeglBufferRectangle *abyss,
-                                      guchar                    *buf,
-                                      gint                       buf_stride,
-                                      const Babl                *format,
-                                      gint                       level)
+gegl_buffer_iterate_read_abyss_clamp (GeglBuffer          *buffer,
+                                      const GeglRectangle *roi,
+                                      const GeglRectangle *abyss,
+                                      guchar              *buf,
+                                      gint                 buf_stride,
+                                      const Babl          *format,
+                                      gint                 level)
 {
-  GeglBufferRectangle read_output_rect;
-  GeglBufferRectangle read_input_rect;
+  GeglRectangle read_output_rect;
+  GeglRectangle read_input_rect;
 
   gint    bpp           = babl_format_get_bytes_per_pixel (format);
   gint    x_read_offset = 0;
@@ -1423,10 +1425,10 @@ gegl_buffer_iterate_read_abyss_clamp (GeglBuffer                *buffer,
   /* Intersect our shifted abyss with the roi */
   gegl_rectangle_intersect (&read_output_rect,
                             roi,
-                            GEGL_BUFFER_RECTANGLE (abyss->x + x_read_offset,
-                                                   abyss->y + y_read_offset,
-                                                   abyss->width,
-                                                   abyss->height));
+                            GEGL_RECTANGLE (abyss->x + x_read_offset,
+                                            abyss->y + y_read_offset,
+                                            abyss->width,
+                                            abyss->height));
 
   /* Offset into *buf based on the intersected rect's x & y */
   buf_offset_cols = read_output_rect.x - roi->x;
@@ -1565,15 +1567,15 @@ gegl_buffer_iterate_read_abyss_clamp (GeglBuffer                *buffer,
 }
 
 static void
-gegl_buffer_iterate_read_abyss_loop (GeglBuffer                *buffer,
-                                     const GeglBufferRectangle *roi,
-                                     const GeglBufferRectangle *abyss,
-                                     guchar                    *buf,
-                                     gint                       buf_stride,
-                                     const Babl                *format,
-                                     gint                       level)
+gegl_buffer_iterate_read_abyss_loop (GeglBuffer          *buffer,
+                                     const GeglRectangle *roi,
+                                     const GeglRectangle *abyss,
+                                     guchar              *buf,
+                                     gint                 buf_stride,
+                                     const Babl          *format,
+                                     gint                 level)
 {
-  GeglBufferRectangle current_roi;
+  GeglRectangle current_roi;
   gint          bpp = babl_format_get_bytes_per_pixel (format);
   gint          origin_x;
 
@@ -1596,14 +1598,14 @@ gegl_buffer_iterate_read_abyss_loop (GeglBuffer                *buffer,
 
       while (current_roi.x < roi->x + roi->width)
         {
-          GeglBufferRectangle simple_roi;
+          GeglRectangle simple_roi;
           gegl_rectangle_intersect (&simple_roi, &current_roi, roi);
 
           gegl_buffer_iterate_read_simple (buffer,
-                                           GEGL_BUFFER_RECTANGLE (abyss->x + (simple_roi.x - current_roi.x),
-                                                                  abyss->y + (simple_roi.y - current_roi.y),
-                                                                  simple_roi.width,
-                                                                  simple_roi.height),
+                                           GEGL_RECTANGLE (abyss->x + (simple_roi.x - current_roi.x),
+                                                           abyss->y + (simple_roi.y - current_roi.y),
+                                                           simple_roi.width,
+                                                           simple_roi.height),
                                            inner_buf,
                                            buf_stride,
                                            format,
@@ -1623,13 +1625,13 @@ gegl_buffer_iterate_read_abyss_loop (GeglBuffer                *buffer,
 }
 
 static gpointer
-gegl_buffer_read_at_level (GeglBuffer                *buffer,
-                           const GeglBufferRectangle *roi,
-                           guchar                    *buf,
-                           gint                       rowstride,
-                           const Babl                *format,
-                           gint                       level,
-                           GeglAbyssPolicy            repeat_mode)
+gegl_buffer_read_at_level (GeglBuffer          *buffer,
+                           const GeglRectangle *roi,
+                           guchar              *buf,
+                           gint                 rowstride,
+                           const Babl          *format,
+                           gint                 level,
+                           GeglAbyssPolicy      repeat_mode)
 {
   gint bpp = babl_format_get_bytes_per_pixel (format);
 
@@ -1653,7 +1655,7 @@ gegl_buffer_read_at_level (GeglBuffer                *buffer,
   else
     {
       gpointer scratch;
-      GeglBufferRectangle next_roi;
+      GeglRectangle next_roi;
       next_roi.x = roi->x * 2;
       next_roi.y = roi->y * 2;
       next_roi.width = roi->width * 2;
@@ -1662,8 +1664,8 @@ gegl_buffer_read_at_level (GeglBuffer                *buffer,
       /* If the next block is too big split it in half */
       if (next_roi.width * next_roi.height > 256 * 256)
         {
-          GeglBufferRectangle next_roi_a = next_roi;
-          GeglBufferRectangle next_roi_b = next_roi;
+          GeglRectangle next_roi_a = next_roi;
+          GeglRectangle next_roi_b = next_roi;
           gint scratch_stride = next_roi.width * bpp;
           gpointer scratch_a;
           gpointer scratch_b;
@@ -1724,14 +1726,14 @@ gegl_buffer_read_at_level (GeglBuffer                *buffer,
 }
 
 static void
-gegl_buffer_iterate_read_fringed (GeglBuffer                *buffer,
-                                  const GeglBufferRectangle *roi,
-                                  const GeglBufferRectangle *abyss,
-                                  guchar                    *buf,
-                                  gint                       buf_stride,
-                                  const Babl                *format,
-                                  gint                       level,
-                                  GeglAbyssPolicy            repeat_mode)
+gegl_buffer_iterate_read_fringed (GeglBuffer          *buffer,
+                                  const GeglRectangle *roi,
+                                  const GeglRectangle *abyss,
+                                  guchar              *buf,
+                                  gint                 buf_stride,
+                                  const Babl          *format,
+                                  gint                 level,
+                                  GeglAbyssPolicy      repeat_mode)
 {
   gint x = roi->x;
   gint y = roi->y;
@@ -1743,7 +1745,7 @@ gegl_buffer_iterate_read_fringed (GeglBuffer                *buffer,
 
   if (x <= abyss->x)
     {
-      GeglBufferRectangle fringe_roi = {x, y, 1, height};
+      GeglRectangle fringe_roi = {x, y, 1, height};
       guchar *fringe_buf = inner_buf;
 
       gegl_buffer_read_at_level (buffer, &fringe_roi, fringe_buf, buf_stride, format, level, repeat_mode);
@@ -1757,7 +1759,7 @@ gegl_buffer_iterate_read_fringed (GeglBuffer                *buffer,
 
   if (y <= abyss->y)
     {
-      GeglBufferRectangle fringe_roi = {x, y, width, 1};
+      GeglRectangle fringe_roi = {x, y, width, 1};
       guchar *fringe_buf = inner_buf;
 
       gegl_buffer_read_at_level (buffer, &fringe_roi, fringe_buf, buf_stride, format, level, repeat_mode);
@@ -1771,7 +1773,7 @@ gegl_buffer_iterate_read_fringed (GeglBuffer                *buffer,
 
   if (y + height >= abyss->y + abyss->height)
     {
-      GeglBufferRectangle fringe_roi = {x, y + height - 1, width, 1};
+      GeglRectangle fringe_roi = {x, y + height - 1, width, 1};
       guchar *fringe_buf = inner_buf + (height - 1) * buf_stride;
 
       gegl_buffer_read_at_level (buffer, &fringe_roi, fringe_buf, buf_stride, format, level, repeat_mode);
@@ -1783,7 +1785,7 @@ gegl_buffer_iterate_read_fringed (GeglBuffer                *buffer,
 
   if (x + width >= abyss->x + abyss->width)
     {
-      GeglBufferRectangle fringe_roi = {x + width - 1, y, 1, height};
+      GeglRectangle fringe_roi = {x + width - 1, y, 1, height};
       guchar *fringe_buf = inner_buf + (width - 1) * bpp;
 
       gegl_buffer_read_at_level (buffer, &fringe_roi, fringe_buf, buf_stride, format, level, repeat_mode);
@@ -1794,7 +1796,7 @@ gegl_buffer_iterate_read_fringed (GeglBuffer                *buffer,
     }
 
   gegl_buffer_iterate_read_simple (buffer,
-                                   GEGL_BUFFER_RECTANGLE (x, y, width, height),
+                                   GEGL_RECTANGLE (x, y, width, height),
                                    inner_buf,
                                    buf_stride,
                                    format,
@@ -1802,17 +1804,17 @@ gegl_buffer_iterate_read_fringed (GeglBuffer                *buffer,
 }
 
 static void
-gegl_buffer_iterate_read_dispatch (GeglBuffer                *buffer,
-                                   const GeglBufferRectangle *roi,
-                                   guchar                    *buf,
-                                   gint                       rowstride,
-                                   const Babl                *format,
-                                   gint                       level,
-                                   GeglAbyssPolicy            repeat_mode)
+gegl_buffer_iterate_read_dispatch (GeglBuffer          *buffer,
+                                   const GeglRectangle *roi,
+                                   guchar              *buf,
+                                   gint                 rowstride,
+                                   const Babl          *format,
+                                   gint                 level,
+                                   GeglAbyssPolicy      repeat_mode)
 {
-  GeglBufferRectangle abyss          = buffer->abyss;
-  GeglBufferRectangle abyss_factored = abyss;
-  GeglBufferRectangle roi_factored   = *roi;
+  GeglRectangle abyss          = buffer->abyss;
+  GeglRectangle abyss_factored = abyss;
+  GeglRectangle roi_factored   = *roi;
 
   if (level)
     {
@@ -1900,24 +1902,24 @@ gegl_buffer_iterate_read_dispatch (GeglBuffer                *buffer,
 }
 
 void
-gegl_buffer_set_unlocked (GeglBuffer                *buffer,
-                          const GeglBufferRectangle *rect,
-                          gint                       level,
-                          const Babl                *format,
-                          const void                *src,
-                          gint                       rowstride)
+gegl_buffer_set_unlocked (GeglBuffer          *buffer,
+                          const GeglRectangle *rect,
+                          gint                 level,
+                          const Babl          *format,
+                          const void          *src,
+                          gint                 rowstride)
 {
   _gegl_buffer_set_with_flags (buffer, rect, level, format, src, rowstride,
                                GEGL_BUFFER_SET_FLAG_NOTIFY);
 }
 
 void
-gegl_buffer_set_unlocked_no_notify (GeglBuffer                *buffer,
-                                    const GeglBufferRectangle *rect,
-                                    gint                       level,
-                                    const Babl                *format,
-                                    const void                *src,
-                                    gint                       rowstride)
+gegl_buffer_set_unlocked_no_notify (GeglBuffer          *buffer,
+                                    const GeglRectangle *rect,
+                                    gint                 level,
+                                    const Babl          *format,
+                                    const void          *src,
+                                    gint                 rowstride)
 {
   _gegl_buffer_set_with_flags (buffer, rect, level, format, src, rowstride,
                                GEGL_BUFFER_SET_FLAG_FAST);
@@ -1925,12 +1927,12 @@ gegl_buffer_set_unlocked_no_notify (GeglBuffer                *buffer,
 
 
 void
-gegl_buffer_set (GeglBuffer                *buffer,
-                 const GeglBufferRectangle *rect,
-                 gint                       level,
-                 const Babl                *format,
-                 const void                *src,
-                 gint                       rowstride)
+gegl_buffer_set (GeglBuffer          *buffer,
+                 const GeglRectangle *rect,
+                 gint                 level,
+                 const Babl          *format,
+                 const void          *src,
+                 gint                 rowstride)
 {
   g_return_if_fail (GEGL_IS_BUFFER (buffer));
   if (format == NULL)
@@ -1968,9 +1970,9 @@ gegl_buffer_set (GeglBuffer                *buffer,
 /* Expand roi by scale so it uncludes all pixels needed
  * to satisfy a gegl_buffer_get() call at level 0.
  */
-GeglBufferRectangle
-_gegl_get_required_for_scale (const GeglBufferRectangle *roi,
-                              gdouble                    scale)
+GeglRectangle
+_gegl_get_required_for_scale (const GeglRectangle *roi,
+                              gdouble              scale)
 {
   if (GEGL_FLOAT_EQUAL (scale, 1.0))
     return *roi;
@@ -1985,26 +1987,29 @@ _gegl_get_required_for_scale (const GeglBufferRectangle *roi,
 
       if (scale < 1.0)
         {
-          return *GEGL_BUFFER_RECTANGLE (x1 - pad, y1 - pad,
-                                         x2 - x1 + 2 * pad, y2 - y1 + 2 * pad);
+          return *GEGL_RECTANGLE (x1 - pad,
+                                  y1 - pad,
+                                  x2 - x1 + 2 * pad,
+                                  y2 - y1 + 2 * pad);
         }
       else
         {
-          return *GEGL_BUFFER_RECTANGLE (x1, y1,
-                                         x2 - x1,
-                                         y2 - y1);
+          return *GEGL_RECTANGLE (x1,
+                                  y1,
+                                  x2 - x1,
+                                  y2 - y1);
         }
       }
 }
 
 static inline void
-_gegl_buffer_get_unlocked (GeglBuffer                *buffer,
-                           gdouble                    scale,
-                           const GeglBufferRectangle *rect,
-                           const Babl                *format,
-                           gpointer                   dest_buf,
-                           gint                       rowstride,
-                           GeglAbyssPolicy            flags)
+_gegl_buffer_get_unlocked (GeglBuffer          *buffer,
+                           gdouble              scale,
+                           const GeglRectangle *rect,
+                           const Babl          *format,
+                           gpointer             dest_buf,
+                           gint                 rowstride,
+                           GeglAbyssPolicy      flags)
 {
   GeglAbyssPolicy repeat_mode = flags & 0x7; /* mask off interpolation from repeat mode part of flags */
 
@@ -2072,7 +2077,7 @@ _gegl_buffer_get_unlocked (GeglBuffer                *buffer,
   else
   {
     gint chunk_height;
-    GeglBufferRectangle rect2 = *rect;
+    GeglRectangle rect2       = *rect;
     gint    bpp               = babl_format_get_bytes_per_pixel (format);
     gint    ystart            = rect->y;
     float   scale_orig        = scale;
@@ -2141,7 +2146,7 @@ _gegl_buffer_get_unlocked (GeglBuffer                *buffer,
 
     while (rect2.width > 0 && rect2.height > 0)
     {
-      GeglBufferRectangle sample_rect;
+      GeglRectangle sample_rect;
       gint    buf_width, buf_height;
       gint    y1 = floorf (rect2.y / scale_orig + GEGL_SCALE_EPSILON);
       gint    y2 = ceilf ((rect2.y + rect2.height) / scale_orig - GEGL_SCALE_EPSILON);
@@ -2272,25 +2277,25 @@ setup_next_chunk:
 }
 
 void
-gegl_buffer_get_unlocked (GeglBuffer                *buffer,
-                          gdouble                    scale,
-                          const GeglBufferRectangle *rect,
-                          const Babl                *format,
-                          gpointer                   dest_buf,
-                          gint                       rowstride,
-                          GeglAbyssPolicy            repeat_mode)
+gegl_buffer_get_unlocked (GeglBuffer          *buffer,
+                          gdouble              scale,
+                          const GeglRectangle *rect,
+                          const Babl          *format,
+                          gpointer             dest_buf,
+                          gint                 rowstride,
+                          GeglAbyssPolicy      repeat_mode)
 {
   return _gegl_buffer_get_unlocked (buffer, scale, rect, format, dest_buf, rowstride, repeat_mode);
 }
 
 void
-gegl_buffer_get (GeglBuffer                *buffer,
-                 const GeglBufferRectangle *rect,
-                 gdouble                    scale,
-                 const Babl                *format,
-                 gpointer                   dest_buf,
-                 gint                       rowstride,
-                 GeglAbyssPolicy            repeat_mode)
+gegl_buffer_get (GeglBuffer          *buffer,
+                 const GeglRectangle *rect,
+                 gdouble              scale,
+                 const Babl          *format,
+                 gpointer             dest_buf,
+                 gint                 rowstride,
+                 GeglAbyssPolicy      repeat_mode)
 {
   g_return_if_fail (GEGL_IS_BUFFER (buffer));
   gegl_buffer_lock (buffer);
@@ -2299,11 +2304,11 @@ gegl_buffer_get (GeglBuffer                *buffer,
 }
 
 static void
-gegl_buffer_copy2 (GeglBuffer                *src,
-                   const GeglBufferRectangle *src_rect,
-                   GeglAbyssPolicy            repeat_mode,
-                   GeglBuffer                *dst,
-                   const GeglBufferRectangle *dst_rect)
+gegl_buffer_copy2 (GeglBuffer          *src,
+                   const GeglRectangle *src_rect,
+                   GeglAbyssPolicy      repeat_mode,
+                   GeglBuffer          *dst,
+                   const GeglRectangle *dst_rect)
 {
   GeglBufferIterator *i;
   gint offset_x = src_rect->x - dst_rect->x;
@@ -2314,7 +2319,7 @@ gegl_buffer_copy2 (GeglBuffer                *src,
                                 repeat_mode, 1);
   while (gegl_buffer_iterator_next (i))
     {
-      GeglBufferRectangle src_rect = i->items[0].roi;
+      GeglRectangle src_rect = i->items[0].roi;
       src_rect.x += offset_x;
       src_rect.y += offset_y;
       gegl_buffer_iterate_read_dispatch (src, &src_rect, i->items[0].data, 0,
@@ -2323,13 +2328,13 @@ gegl_buffer_copy2 (GeglBuffer                *src,
 }
 
 void
-gegl_buffer_copy (GeglBuffer                *src,
-                  const GeglBufferRectangle *src_rect,
-                  GeglAbyssPolicy            repeat_mode,
-                  GeglBuffer                *dst,
-                  const GeglBufferRectangle *dst_rect)
+gegl_buffer_copy (GeglBuffer          *src,
+                  const GeglRectangle *src_rect,
+                  GeglAbyssPolicy      repeat_mode,
+                  GeglBuffer          *dst,
+                  const GeglRectangle *dst_rect)
 {
-  GeglBufferRectangle dest_rect_r;
+  GeglRectangle dest_rect_r;
 
   g_return_if_fail (GEGL_IS_BUFFER (src));
   g_return_if_fail (GEGL_IS_BUFFER (dst));
@@ -2364,7 +2369,7 @@ gegl_buffer_copy (GeglBuffer                *src,
       gint tile_width  = dst->tile_width;
       gint tile_height = dst->tile_height;
 
-      GeglBufferRectangle cow_rect = *dst_rect;
+      GeglRectangle cow_rect = *dst_rect;
       gint          rem;
 
       /* adjust origin to match the start of tile alignment */
@@ -2386,7 +2391,7 @@ gegl_buffer_copy (GeglBuffer                *src,
 
       if (cow_rect.width > 0 && cow_rect.height > 0)
         {
-          GeglBufferRectangle top, bottom, left, right;
+          GeglRectangle top, bottom, left, right;
 
           /* iterate over rectangle that can be cow copied, duplicating
            * one and one tile
@@ -2490,27 +2495,27 @@ gegl_buffer_copy (GeglBuffer                *src,
 
           if (top.height)
           gegl_buffer_copy2 (src,
-                             GEGL_BUFFER_RECTANGLE (src_rect->x + (top.x-dst_rect->x),
+                             GEGL_RECTANGLE (src_rect->x + (top.x-dst_rect->x),
                                              src_rect->y + (top.y-dst_rect->y),
-                                             top.width, top.height),
+                                 top.width, top.height),
                              repeat_mode, dst, &top);
           if (bottom.height)
           gegl_buffer_copy2 (src,
-                             GEGL_BUFFER_RECTANGLE (src_rect->x + (bottom.x-dst_rect->x),
-                                                    src_rect->y + (bottom.y-dst_rect->y),
-                                                    bottom.width, bottom.height),
+                             GEGL_RECTANGLE (src_rect->x + (bottom.x-dst_rect->x),
+                                             src_rect->y + (bottom.y-dst_rect->y),
+                                 bottom.width, bottom.height),
                              repeat_mode, dst, &bottom);
           if (left.width && left.height)
           gegl_buffer_copy2 (src,
-                             GEGL_BUFFER_RECTANGLE (src_rect->x + (left.x-dst_rect->x),
-                                                    src_rect->y + (left.y-dst_rect->y),
-                                                    left.width, left.height),
+                             GEGL_RECTANGLE (src_rect->x + (left.x-dst_rect->x),
+                                             src_rect->y + (left.y-dst_rect->y),
+                                 left.width, left.height),
                              repeat_mode, dst, &left);
           if (right.width && right.height)
           gegl_buffer_copy2 (src,
-                             GEGL_BUFFER_RECTANGLE (src_rect->x + (right.x-dst_rect->x),
-                                                    src_rect->y + (right.y-dst_rect->y),
-                                                    right.width, right.height),
+                             GEGL_RECTANGLE (src_rect->x + (right.x-dst_rect->x),
+                                             src_rect->y + (right.y-dst_rect->y),
+                                 right.width, right.height),
                              repeat_mode, dst, &right);
         }
       else
@@ -2527,8 +2532,8 @@ gegl_buffer_copy (GeglBuffer                *src,
 }
 
 static void
-gegl_buffer_clear2 (GeglBuffer                *dst,
-                    const GeglBufferRectangle *dst_rect)
+gegl_buffer_clear2 (GeglBuffer          *dst,
+                    const GeglRectangle *dst_rect)
 {
   GeglBufferIterator *i;
   gint                pxsize;
@@ -2550,8 +2555,8 @@ gegl_buffer_clear2 (GeglBuffer                *dst,
 }
 
 void
-gegl_buffer_clear (GeglBuffer                *dst,
-                   const GeglBufferRectangle *dst_rect)
+gegl_buffer_clear (GeglBuffer          *dst,
+                   const GeglRectangle *dst_rect)
 {
   g_return_if_fail (GEGL_IS_BUFFER (dst));
 
@@ -2572,7 +2577,7 @@ gegl_buffer_clear (GeglBuffer                *dst,
       gint tile_width  = dst->tile_width;
       gint tile_height = dst->tile_height;
 
-      GeglBufferRectangle cow_rect = *dst_rect;
+      GeglRectangle cow_rect = *dst_rect;
       gint          rem;
 
       /* adjust origin to match the start of tile alignment */
@@ -2594,7 +2599,7 @@ gegl_buffer_clear (GeglBuffer                *dst,
 
       if (cow_rect.width > 0 && cow_rect.height > 0)
         {
-          GeglBufferRectangle top, bottom, left, right;
+          GeglRectangle top, bottom, left, right;
 
           /* iterate over rectangle that can be cow copied, duplicating
            * one and one tile
@@ -2667,17 +2672,17 @@ gegl_buffer_clear (GeglBuffer                *dst,
 }
 
 void
-gegl_buffer_set_pattern (GeglBuffer                *buffer,
-                         const GeglBufferRectangle *rect,
-                         GeglBuffer                *pattern,
-                         gint                       x_offset,
-                         gint                       y_offset)
+gegl_buffer_set_pattern (GeglBuffer          *buffer,
+                         const GeglRectangle *rect,
+                         GeglBuffer          *pattern,
+                         gint                 x_offset,
+                         gint                 y_offset)
 {
-  const GeglBufferRectangle *pattern_extent;
+  const GeglRectangle *pattern_extent;
   const Babl          *buffer_format;
-  GeglBufferRectangle        roi;                  /* the rect if not NULL, else the whole buffer */
-  GeglBufferRectangle        pattern_data_extent;  /* pattern_extent clamped to rect */
-  GeglBufferRectangle        extended_data_extent; /* many patterns to avoid copying too small chunks of 
data */
+  GeglRectangle        roi;                  /* the rect if not NULL, else the whole buffer */
+  GeglRectangle        pattern_data_extent;  /* pattern_extent clamped to rect */
+  GeglRectangle        extended_data_extent; /* many patterns to avoid copying too small chunks of data */
   gint                 bpp;
   gint                 x, y;
   gint                 rowstride;
@@ -2721,8 +2726,8 @@ gegl_buffer_set_pattern (GeglBuffer                *buffer,
   /* XXX: Bad taste, the pattern needs to be small enough.
    * See Bug 712814 for an alternative malloc-free implementation */
   pattern_data = gegl_malloc (extended_data_extent.width *
-                              extended_data_extent.height *
-                              bpp);
+                                     extended_data_extent.height *
+                                     bpp);
 
   rowstride = extended_data_extent.width * bpp;
 
@@ -2757,7 +2762,7 @@ gegl_buffer_set_pattern (GeglBuffer                *buffer,
   for (y = roi.y; y < roi.y + roi.height; y += extended_data_extent.height)
     for (x = roi.x; x < roi.x + roi.width; x += extended_data_extent.width)
       {
-        GeglBufferRectangle dest_rect = {x, y,
+        GeglRectangle dest_rect = {x, y,
                                    extended_data_extent.width,
                                    extended_data_extent.height};
 
@@ -2771,10 +2776,10 @@ gegl_buffer_set_pattern (GeglBuffer                *buffer,
 }
 
 void
-gegl_buffer_set_color_from_pixel (GeglBuffer                *dst,
-                                  const GeglBufferRectangle *dst_rect,
-                                  const uint8_t             *pixel,
-                                  const Babl                *pixel_format)
+gegl_buffer_set_color_from_pixel (GeglBuffer          *dst,
+                                  const GeglRectangle *dst_rect,
+                                  const uint8_t       *pixel,
+                                  const Babl          *pixel_format)
 {
   GeglBufferIterator *i;
   gint                bpp;
diff --git a/gegl/buffer/gegl-buffer-backend.h b/gegl/buffer/gegl-buffer-backend.h
index f7a415f58..ba3af2d4e 100644
--- a/gegl/buffer/gegl-buffer-backend.h
+++ b/gegl/buffer/gegl-buffer-backend.h
@@ -19,7 +19,6 @@
 #ifndef __GEGL_BUFFER_BACKEND_H__
 #define __GEGL_BUFFER_BACKEND_H__
 
-#include "gegl-types.h"
 
 G_BEGIN_DECLS
 
@@ -31,6 +30,8 @@ typedef struct _GeglTileHandler           GeglTileHandler;
 typedef void   (*GeglTileCallback)       (GeglTile *tile,
                                           gpointer user_data);
 
+
+
 /* All commands have the ability to pass commands to all tiles the handlers
  * add abstraction to the commands the documentaiton given here is valid
  * when the commands are issued to a full blown GeglBuffer instance.
@@ -65,6 +66,8 @@ typedef struct _GeglTileCopyParams
 
 G_END_DECLS
 
+#include "gegl-buffer.h"
+#include "gegl-buffer-enums.h"
 #include "gegl-tile-backend.h"
 #include "gegl-tile-source.h"
 #include "gegl-tile-handler.h"
diff --git a/gegl/buffer/gegl-buffer-config.c b/gegl/buffer/gegl-buffer-config.c
index deea092fc..b80eb2995 100644
--- a/gegl/buffer/gegl-buffer-config.c
+++ b/gegl/buffer/gegl-buffer-config.c
@@ -23,10 +23,9 @@
 #include <glib-object.h>
 #include <glib/gprintf.h>
 
-#include "gegl.h"
+#include "gegl-buffer.h"
 #include "gegl-buffer-config.h"
 
-#include "opencl/gegl-cl.h"
 
 G_DEFINE_TYPE (GeglBufferConfig, gegl_buffer_config, G_TYPE_OBJECT)
 
diff --git a/gegl/buffer/gegl-buffer-enums.c b/gegl/buffer/gegl-buffer-enums.c
new file mode 100644
index 000000000..1dfcbf6f3
--- /dev/null
+++ b/gegl/buffer/gegl-buffer-enums.c
@@ -0,0 +1,107 @@
+/* This file is part of GEGL
+ *
+ * GEGL is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * GEGL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GEGL; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <glib-object.h>
+#include <glib/gi18n-lib.h>
+
+#include "gegl-buffer-enums.h"
+
+GType
+gegl_abyss_policy_get_type (void)
+{
+  static GType etype = 0;
+
+  if (etype == 0)
+    {
+      static GEnumValue values[] = {
+        { GEGL_ABYSS_NONE,  N_("None"),  "none"  },
+        { GEGL_ABYSS_CLAMP, N_("Clamp"), "clamp" },
+        { GEGL_ABYSS_LOOP,  N_("Loop"),  "loop"  },
+        { GEGL_ABYSS_BLACK, N_("Black"), "black" },
+        { GEGL_ABYSS_WHITE, N_("White"), "white" },
+        // we do not really want this one introspected/translated,
+        // will this bite us?
+        //{ GEGL_BUFFER_NEAREST, N_("Nearest"), "nearest" },
+        { 0, NULL, NULL }
+      };
+      gint i;
+
+      for (i = 0; i < G_N_ELEMENTS (values); i++)
+        if (values[i].value_name)
+          values[i].value_name =
+            dgettext (GETTEXT_PACKAGE, values[i].value_name);
+
+      etype = g_enum_register_static ("GeglAbyssPolicy", values);
+    }
+
+  return etype;
+}
+
+GType
+gegl_access_mode_get_type (void)
+{
+  static GType ftype = 0;
+
+  if (ftype == 0)
+    {
+      static GFlagsValue values[] = {
+        { GEGL_ACCESS_READ,      N_("Read"),        "read"      },
+        { GEGL_ACCESS_WRITE,     N_("Write"),       "write"     },
+        { GEGL_ACCESS_READWRITE, N_("Read/Write"), "readwrite" },
+        { 0, NULL, NULL }
+      };
+      gint i;
+
+      for (i = 0; i < G_N_ELEMENTS (values); i++)
+        if (values[i].value_name)
+          values[i].value_name =
+            dgettext (GETTEXT_PACKAGE, values[i].value_name);
+
+      ftype = g_flags_register_static ("GeglAccessMode", values);
+    }
+
+  return ftype;
+}
+
+GType
+gegl_sampler_type_get_type (void)
+{
+  static GType etype = 0;
+
+  if (etype == 0)
+    {
+      static GEnumValue values[] = {
+        { GEGL_SAMPLER_NEAREST, N_("Nearest"), "nearest" },
+        { GEGL_SAMPLER_LINEAR,  N_("Linear"),  "linear"  },
+        { GEGL_SAMPLER_CUBIC,   N_("Cubic"),   "cubic"   },
+        { GEGL_SAMPLER_NOHALO,  N_("NoHalo"),  "nohalo"  },
+        { GEGL_SAMPLER_LOHALO,  N_("LoHalo"),  "lohalo"  },
+        { 0, NULL, NULL }
+      };
+      gint i;
+
+      for (i = 0; i < G_N_ELEMENTS (values); i++)
+        if (values[i].value_name)
+          values[i].value_name =
+            dgettext (GETTEXT_PACKAGE, values[i].value_name);
+
+      etype = g_enum_register_static ("GeglSamplerType", values);
+    }
+
+  return etype;
+}
diff --git a/gegl/buffer/gegl-buffer-enums.h b/gegl/buffer/gegl-buffer-enums.h
new file mode 100644
index 000000000..aa110c6dd
--- /dev/null
+++ b/gegl/buffer/gegl-buffer-enums.h
@@ -0,0 +1,92 @@
+/* This file is part of GEGL
+ *
+ * GEGL is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * GEGL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GEGL; if not, see <https://www.gnu.org/licenses/>.
+ *
+ * Copyright 2011 Michael Muré <batolettre gmail com>
+ *
+ */
+
+/* This file holds public enums from GEGL
+ *
+ * !!!!!!!!!!!! NOTE !!!!!!!!!!!!!!
+ *
+ * Normally, gegl-enums.c file would be be generated my glib-mkenums,
+ * but we use the enum values' registered names for translatable,
+ * human readable labels for the GUI, so gegl-enums.c is maintained
+ * manually.
+ *
+ * DON'T FORGET TO UPDATE gegl-enums.c AFTER CHANGING THIS HEADER
+ *
+ * !!!!!!!!!!!! NOTE !!!!!!!!!!!!!!
+ */
+
+#ifndef __GEGL_BUFFER_ENUMS_H__
+#define __GEGL_BUFFER_ENUMS_H__
+
+G_BEGIN_DECLS
+
+typedef enum {
+  /* this enum should be renamed GeglBufferFlags, since it contains
+   * multiple flags - and possibly more in the future
+   */
+
+  /* XXX: API tidying of the following would be to make them be
+   *      GEGL_BUFFER_EDGE_NONE or GEGL_BUFFER_REPEAT_NONE instead.
+  */
+  GEGL_ABYSS_NONE  = 0,
+  GEGL_ABYSS_CLAMP = 1,
+  GEGL_ABYSS_LOOP  = 2,
+  GEGL_ABYSS_BLACK = 3,
+  GEGL_ABYSS_WHITE = 4,
+
+  GEGL_BUFFER_FILTER_AUTO     = 0,
+  /* auto gives bilinear for scales <1.0 box for <2.0 and nearest above */
+  GEGL_BUFFER_FILTER_BILINEAR = 16,
+  GEGL_BUFFER_FILTER_NEAREST  = 32,
+  GEGL_BUFFER_FILTER_BOX      = 48,
+  GEGL_BUFFER_FILTER_ALL      = (GEGL_BUFFER_FILTER_BILINEAR|
+                                 GEGL_BUFFER_FILTER_NEAREST|
+                                 GEGL_BUFFER_FILTER_BOX),
+} GeglAbyssPolicy;
+
+GType gegl_abyss_policy_get_type (void) G_GNUC_CONST;
+
+#define GEGL_TYPE_ABYSS_POLICY (gegl_abyss_policy_get_type ())
+
+
+typedef enum {
+  GEGL_ACCESS_READ      = 1 << 0,
+  GEGL_ACCESS_WRITE     = 1 << 1,
+  GEGL_ACCESS_READWRITE = (GEGL_ACCESS_READ | GEGL_ACCESS_WRITE)
+} GeglAccessMode;
+
+GType gegl_access_mode_get_type (void) G_GNUC_CONST;
+
+#define GEGL_TYPE_ACCESS_MODE (gegl_access_mode_get_type ())
+
+typedef enum {
+  GEGL_SAMPLER_NEAREST,
+  GEGL_SAMPLER_LINEAR,
+  GEGL_SAMPLER_CUBIC,
+  GEGL_SAMPLER_NOHALO,
+  GEGL_SAMPLER_LOHALO
+} GeglSamplerType;
+
+GType gegl_sampler_type_get_type (void) G_GNUC_CONST;
+
+#define GEGL_TYPE_SAMPLER_TYPE (gegl_sampler_type_get_type ())
+
+G_END_DECLS
+
+#endif /* __GEGL_ENUMS_H__ */
diff --git a/gegl/buffer/gegl-buffer-formats.h b/gegl/buffer/gegl-buffer-formats.h
index 738110eac..d93547b8f 100644
--- a/gegl/buffer/gegl-buffer-formats.h
+++ b/gegl/buffer/gegl-buffer-formats.h
@@ -19,9 +19,10 @@
 #ifndef __GEGL_BUFFER_FORMATS_H__
 #define __GEGL_BUFFER_FORMATS_H__
 
-#include <babl/babl.h>
 
-G_BEGIN_DECLS
+//G_BEGIN_DECLS
+
+#include <babl/babl.h>
 
 /* the code in babl for looking up models, formats and types is quick -
    but when formats end up being used as consts for comparisons in the core of
@@ -79,6 +80,6 @@ GEGL_CACHED_BABL(format, yA_linear_float, "YaA float")
   #define GEGL_ALLOCA_THRESHOLD  (1024*1024/2)
 #endif
 
-G_END_DECLS
+//G_END_DECLS
 
 #endif /* __GEGL_BUFFER_FORMATS_H__ */
diff --git a/gegl/buffer/gegl-buffer-iterator.c b/gegl/buffer/gegl-buffer-iterator.c
index 672c1b7e4..72ed38e03 100644
--- a/gegl/buffer/gegl-buffer-iterator.c
+++ b/gegl/buffer/gegl-buffer-iterator.c
@@ -25,11 +25,12 @@
 #include <glib-object.h>
 #include <glib/gprintf.h>
 
-#include "gegl.h"
+#include "gegl-buffer.h"
 #include "gegl-buffer-types.h"
 #include "gegl-buffer-iterator.h"
 #include "gegl-buffer-iterator-private.h"
 #include "gegl-buffer-private.h"
+#include "gegl-rectangle.h"
 
 typedef enum {
   GeglIteratorState_Start,
@@ -49,7 +50,7 @@ typedef enum {
 } GeglIteratorTileMode;
 
 typedef struct _SubIterState {
-  GeglBufferRectangle  full_rect; /* The entire area we are iterating over */
+  GeglRectangle        full_rect; /* The entire area we are iterating over */
   GeglBuffer          *buffer;
   GeglAccessMode       access_mode;
   GeglAbyssPolicy      abyss_policy;
@@ -57,7 +58,7 @@ typedef struct _SubIterState {
   gint                 format_bpp;
   GeglIteratorTileMode current_tile_mode;
   gint                 row_stride;
-  GeglBufferRectangle  real_roi;
+  GeglRectangle        real_roi;
   gint                 level;
   /* Direct data members */
   GeglTile            *current_tile;
@@ -70,11 +71,11 @@ typedef struct _SubIterState {
 
 struct _GeglBufferIteratorPriv
 {
-  gint                num_buffers;
-  GeglIteratorState   state;
-  GeglBufferRectangle origin_tile;
-  gint                remaining_rows;
-  SubIterState        sub_iter[GEGL_BUFFER_MAX_ITERATORS];
+  gint              num_buffers;
+  GeglIteratorState state;
+  GeglRectangle     origin_tile;
+  gint              remaining_rows;
+  SubIterState      sub_iter[GEGL_BUFFER_MAX_ITERATORS];
 };
 
 static inline GeglBufferIterator *
@@ -98,13 +99,13 @@ gegl_buffer_iterator_empty_new (void)
 
 
 static inline int
-_gegl_buffer_iterator_add (GeglBufferIterator        *iter,
-                          GeglBuffer                *buf,
-                          const GeglBufferRectangle *roi,
-                          gint                       level,
-                          const Babl                *format,
-                          GeglAccessMode             access_mode,
-                          GeglAbyssPolicy            abyss_policy)
+_gegl_buffer_iterator_add (GeglBufferIterator  *iter,
+                          GeglBuffer          *buf,
+                          const GeglRectangle *roi,
+                          gint                 level,
+                          const Babl          *format,
+                          GeglAccessMode       access_mode,
+                          GeglAbyssPolicy      abyss_policy)
 {
   GeglBufferIteratorPriv *priv = iter->priv;
   int                     index;
@@ -149,13 +150,13 @@ _gegl_buffer_iterator_add (GeglBufferIterator        *iter,
 }
 
 int
-gegl_buffer_iterator_add (GeglBufferIterator        *iter,
-                          GeglBuffer                *buf,
-                          const GeglBufferRectangle *roi,
-                          gint                       level,
-                          const Babl                *format,
-                          GeglAccessMode             access_mode,
-                          GeglAbyssPolicy            abyss_policy)
+gegl_buffer_iterator_add (GeglBufferIterator  *iter,
+                          GeglBuffer          *buf,
+                          const GeglRectangle *roi,
+                          gint                 level,
+                          const Babl          *format,
+                          GeglAccessMode       access_mode,
+                          GeglAbyssPolicy      abyss_policy)
 {
   return _gegl_buffer_iterator_add (iter, buf, roi, level, format, access_mode,
 abyss_policy);
@@ -163,12 +164,12 @@ abyss_policy);
 
 
 GeglBufferIterator *
-gegl_buffer_iterator_new (GeglBuffer                *buf,
-                          const GeglBufferRectangle *roi,
-                          gint                       level,
-                          const Babl                *format,
-                          GeglAccessMode             access_mode,
-                          GeglAbyssPolicy            abyss_policy)
+gegl_buffer_iterator_new (GeglBuffer          *buf,
+                          const GeglRectangle *roi,
+                          gint                 level,
+                          const Babl          *format,
+                          GeglAccessMode       access_mode,
+                          GeglAbyssPolicy      abyss_policy)
 {
   GeglBufferIterator *iter = _gegl_buffer_iterator_empty_new ();
   _gegl_buffer_iterator_add (iter, buf, roi, level, format,
@@ -238,7 +239,7 @@ retile_subs (GeglBufferIterator *iter,
              int                 y)
 {
   GeglBufferIteratorPriv *priv = iter->priv;
-  GeglBufferRectangle real_roi;
+  GeglRectangle real_roi;
   int index;
 
   int shift_x = priv->origin_tile.x;
@@ -555,7 +556,7 @@ _gegl_buffer_iterator_stop (GeglBufferIterator *iter)
               sub->access_mode & GEGL_ACCESS_WRITE &&
               ! (sub->access_mode & GEGL_ITERATOR_INCOMPATIBLE))
             {
-              GeglBufferRectangle damage_rect;
+              GeglRectangle damage_rect;
 
               damage_rect.x      = sub->full_rect.x + sub->buffer->shift_x;
               damage_rect.y      = sub->full_rect.y + sub->buffer->shift_y;
diff --git a/gegl/buffer/gegl-buffer-iterator.h b/gegl/buffer/gegl-buffer-iterator.h
index ba0f1bc33..671937786 100644
--- a/gegl/buffer/gegl-buffer-iterator.h
+++ b/gegl/buffer/gegl-buffer-iterator.h
@@ -41,9 +41,9 @@ typedef struct _GeglBufferIteratorPriv GeglBufferIteratorPriv;
  */
 typedef struct GeglBufferIterator
 {
-  gint                 length;
-  gpointer             data[GEGL_BUFFER_MAX_ITERATORS];
-  GeglBufferRectangle  roi[GEGL_BUFFER_MAX_ITERATORS];
+  gint           length;
+  gpointer       data[GEGL_BUFFER_MAX_ITERATORS];
+  GeglRectangle  roi[GEGL_BUFFER_MAX_ITERATORS];
   /* Private */
   GeglBufferIteratorPriv *priv;
 } GeglBufferIterator;
@@ -75,12 +75,12 @@ GeglBufferIterator *gegl_buffer_iterator_empty_new (void);
  * Returns: a new buffer iterator that can be used to iterate through the
  * buffers pixels.
  */
-GeglBufferIterator * gegl_buffer_iterator_new  (GeglBuffer                *buffer,
-                                                const GeglBufferRectangle *roi,
-                                                gint                       level,
-                                                const Babl                *format,
-                                                GeglAccessMode             access_mode,
-                                                GeglAbyssPolicy            abyss_policy) G_DEPRECATED;
+GeglBufferIterator * gegl_buffer_iterator_new  (GeglBuffer          *buffer,
+                                                const GeglRectangle *roi,
+                                                gint                 level,
+                                                const Babl          *format,
+                                                GeglAccessMode       access_mode,
+                                                GeglAbyssPolicy      abyss_policy) G_DEPRECATED;
 
 
 /**
@@ -102,13 +102,13 @@ GeglBufferIterator * gegl_buffer_iterator_new  (GeglBuffer                *buffe
  * Returns: an integer handle refering to the indice in the iterator structure
  * of the added buffer.
  */
-gint                 gegl_buffer_iterator_add  (GeglBufferIterator        *iterator,
-                                                GeglBuffer                *buffer,
-                                                const GeglBufferRectangle *roi,
-                                                gint                       level,
-                                                const Babl                *format,
-                                                GeglAccessMode             access_mode,
-                                                GeglAbyssPolicy            abyss_policy);
+gint                 gegl_buffer_iterator_add  (GeglBufferIterator  *iterator,
+                                                GeglBuffer          *buffer,
+                                                const GeglRectangle *roi,
+                                                gint                 level,
+                                                const Babl          *format,
+                                                GeglAccessMode       access_mode,
+                                                GeglAbyssPolicy      abyss_policy);
 
 /**
  * gegl_buffer_iterator_stop: (skip)
diff --git a/gegl/buffer/gegl-buffer-iterator2.c b/gegl/buffer/gegl-buffer-iterator2.c
index e32996093..22d4cb9e8 100644
--- a/gegl/buffer/gegl-buffer-iterator2.c
+++ b/gegl/buffer/gegl-buffer-iterator2.c
@@ -25,13 +25,13 @@
 #include <glib-object.h>
 #include <glib/gprintf.h>
 
-#include "gegl.h"
+#include "gegl-buffer.h"
 #include "gegl-buffer-types.h"
+#include "gegl-rectangle.h"
 #include "gegl-buffer-iterator.h"
 #include "gegl-buffer-iterator2.h"
 #include "gegl-buffer-iterator-private.h"
 #include "gegl-buffer-private.h"
-#include "gegl-buffer-cl-cache.h"
 
 typedef enum {
   GeglIteratorState_Start,
@@ -51,7 +51,7 @@ typedef enum {
 } GeglIteratorTileMode;
 
 typedef struct _SubIterState {
-  GeglBufferRectangle  full_rect; /* The entire area we are iterating over */
+  GeglRectangle        full_rect; /* The entire area we are iterating over */
   GeglBuffer          *buffer;
   GeglAccessMode       access_mode;
   GeglAbyssPolicy      abyss_policy;
@@ -59,7 +59,7 @@ typedef struct _SubIterState {
   gint                 format_bpp;
   GeglIteratorTileMode current_tile_mode;
   gint                 row_stride;
-  GeglBufferRectangle  real_roi;
+  GeglRectangle        real_roi;
   gint                 level;
   /* Direct data members */
   GeglTile            *current_tile;
@@ -72,12 +72,12 @@ typedef struct _SubIterState {
 
 struct _GeglBufferIterator2Priv
 {
-  gint                num_buffers;
-  GeglIteratorState   state;
-  GeglBufferRectangle origin_tile;
-  gint                remaining_rows;
-  gint                max_slots;
-  SubIterState        sub_iter[];
+  gint              num_buffers;
+  GeglIteratorState state;
+  GeglRectangle     origin_tile;
+  gint              remaining_rows;
+  gint              max_slots;
+  SubIterState      sub_iter[];
   /* gint           access_order[]; */ /* allocated, but accessed through
                                         * get_access_order().
                                         */
@@ -119,13 +119,13 @@ gegl_buffer_iterator2_empty_new (gint max_slots)
 
 
 static inline int
-_gegl_buffer_iterator2_add (GeglBufferIterator2       *iter,
-                            GeglBuffer                *buf,
-                            const GeglBufferRectangle *roi,
-                            gint                       level,
-                            const Babl                *format,
-                            GeglAccessMode             access_mode,
-                            GeglAbyssPolicy            abyss_policy)
+_gegl_buffer_iterator2_add (GeglBufferIterator2  *iter,
+                          GeglBuffer          *buf,
+                          const GeglRectangle *roi,
+                          gint                 level,
+                          const Babl          *format,
+                          GeglAccessMode       access_mode,
+                          GeglAbyssPolicy      abyss_policy)
 {
   GeglBufferIterator2Priv *priv = iter->priv;
   int                     index;
@@ -170,13 +170,13 @@ _gegl_buffer_iterator2_add (GeglBufferIterator2       *iter,
 }
 
 int
-gegl_buffer_iterator2_add (GeglBufferIterator2      *iter,
-                          GeglBuffer                *buf,
-                          const GeglBufferRectangle *roi,
-                          gint                       level,
-                          const Babl                *format,
-                          GeglAccessMode             access_mode,
-                          GeglAbyssPolicy            abyss_policy)
+gegl_buffer_iterator2_add (GeglBufferIterator2  *iter,
+                          GeglBuffer          *buf,
+                          const GeglRectangle *roi,
+                          gint                 level,
+                          const Babl          *format,
+                          GeglAccessMode       access_mode,
+                          GeglAbyssPolicy      abyss_policy)
 {
   return _gegl_buffer_iterator2_add (iter, buf, roi, level, format, access_mode,
 abyss_policy);
@@ -184,13 +184,13 @@ abyss_policy);
 
 
 GeglBufferIterator2 *
-gegl_buffer_iterator2_new (GeglBuffer                *buf,
-                          const GeglBufferRectangle *roi,
-                          gint                       level,
-                          const Babl                *format,
-                          GeglAccessMode             access_mode,
-                          GeglAbyssPolicy            abyss_policy,
-                          gint                       max_slots)
+gegl_buffer_iterator2_new (GeglBuffer          *buf,
+                          const GeglRectangle *roi,
+                          gint                 level,
+                          const Babl          *format,
+                          GeglAccessMode       access_mode,
+                          GeglAbyssPolicy      abyss_policy,
+                          gint                 max_slots)
 {
   GeglBufferIterator2 *iter = _gegl_buffer_iterator2_empty_new (max_slots);
   _gegl_buffer_iterator2_add (iter, buf, roi, level, format,
@@ -260,7 +260,7 @@ retile_subs (GeglBufferIterator2 *iter,
              int                 y)
 {
   GeglBufferIterator2Priv *priv = iter->priv;
-  GeglBufferRectangle real_roi;
+  GeglRectangle real_roi;
   int index;
 
   int shift_x = priv->origin_tile.x;
@@ -605,7 +605,7 @@ _gegl_buffer_iterator2_stop (GeglBufferIterator2 *iter)
               sub->access_mode & GEGL_ACCESS_WRITE &&
               ! (sub->access_mode & GEGL_ITERATOR_INCOMPATIBLE))
             {
-              GeglBufferRectangle damage_rect;
+              GeglRectangle damage_rect;
 
               damage_rect.x      = sub->full_rect.x + sub->buffer->shift_x;
               damage_rect.y      = sub->full_rect.y + sub->buffer->shift_y;
@@ -710,11 +710,11 @@ gegl_buffer_iterator2_next (GeglBufferIterator2 *iter)
 
                        XXX: still? */
       {
-        if (gegl_cl_is_accelerated ())
+        if (gegl_buffer_ext_flush)
           for (index = 0; index < priv->num_buffers; index++)
             {
               SubIterState *sub = &priv->sub_iter[index];
-              gegl_buffer_cl_cache_flush (sub->buffer, &sub->full_rect);
+              gegl_buffer_ext_flush (sub->buffer, &sub->full_rect);
             }
         linear_shortcut (iter);
         return TRUE;
@@ -722,11 +722,11 @@ gegl_buffer_iterator2_next (GeglBufferIterator2 *iter)
 
       prepare_iteration (iter);
 
-      if (gegl_cl_is_accelerated ())
+      if (gegl_buffer_ext_flush)
         for (index = 0; index < priv->num_buffers; index++)
           {
             SubIterState *sub = &priv->sub_iter[index];
-            gegl_buffer_cl_cache_flush (sub->buffer, &sub->full_rect);
+            gegl_buffer_ext_flush (sub->buffer, &sub->full_rect);
           }
 
       initialize_rects (iter);
diff --git a/gegl/buffer/gegl-buffer-iterator2.h b/gegl/buffer/gegl-buffer-iterator2.h
index c1e0cd612..caa87aa12 100644
--- a/gegl/buffer/gegl-buffer-iterator2.h
+++ b/gegl/buffer/gegl-buffer-iterator2.h
@@ -34,13 +34,13 @@ typedef struct _GeglBufferIterator2Priv GeglBufferIterator2Priv;
 
 typedef struct GeglBufferIterator2Item
 {
-  gpointer            data;
-  GeglBufferRectangle roi;
+  gpointer      data;
+  GeglRectangle roi;
 } GeglBufferIterator2Item;
 
 typedef struct GeglBufferIterator2
 {
-  gint                     length;
+  gint           length;
   GeglBufferIterator2Priv *priv;
   GeglBufferIterator2Item  items[];
 } GeglBufferIterator2;
@@ -73,13 +73,13 @@ GeglBufferIterator2 *gegl_buffer_iterator2_empty_new (int max_slots);
  * buffers pixels.
  */
 GeglBufferIterator2 * gegl_buffer_iterator2_new  (
-                                                 GeglBuffer                *buffer,
-                                                 const GeglBufferRectangle *roi,
-                                                 gint                       level,
-                                                 const Babl                *format,
-                                                 GeglAccessMode             access_mode,
-                                                 GeglAbyssPolicy            abyss_policy,
-                                                 gint                       max_slots);
+                                                 GeglBuffer          *buffer,
+                                                 const GeglRectangle *roi,
+                                                 gint                 level,
+                                                 const Babl          *format,
+                                                 GeglAccessMode       access_mode,
+                                                 GeglAbyssPolicy      abyss_policy,
+                                                 gint                 max_slots);
 
 
 /**
@@ -111,13 +111,13 @@ GeglBufferIterator2 * gegl_buffer_iterator2_new  (
  * Returns: an integer handle refering to the indice in the iterator structure
  * of the added buffer.
  */
-gint                gegl_buffer_iterator2_add  (GeglBufferIterator2       *iterator,
-                                                GeglBuffer                *buffer,
-                                                const GeglBufferRectangle *roi,
-                                                gint                       level,
-                                                const Babl                *format,
-                                                GeglAccessMode             access_mode,
-                                                GeglAbyssPolicy            abyss_policy);
+gint                 gegl_buffer_iterator2_add  (GeglBufferIterator2  *iterator,
+                                                GeglBuffer          *buffer,
+                                                const GeglRectangle *roi,
+                                                gint                 level,
+                                                const Babl          *format,
+                                                GeglAccessMode       access_mode,
+                                                GeglAbyssPolicy      abyss_policy);
 
 /**
  * gegl_buffer_iterator2_stop: (skip)
diff --git a/gegl/buffer/gegl-buffer-linear.c b/gegl/buffer/gegl-buffer-linear.c
index c2df4bed9..18bf1ce09 100644
--- a/gegl/buffer/gegl-buffer-linear.c
+++ b/gegl/buffer/gegl-buffer-linear.c
@@ -5,16 +5,17 @@
 #include <glib-object.h>
 #include <glib/gprintf.h>
 
-#include "gegl.h"
+#include "gegl-buffer.h"
 #include "gegl-buffer-formats.h"
 #include "gegl-buffer-types.h"
+#include "gegl-rectangle.h"
 #include "gegl-buffer-private.h"
 #include "gegl-tile-storage.h"
 #include "gegl-tile-handler-cache.h"
 
 GeglBuffer *
-gegl_buffer_linear_new (const GeglBufferRectangle *extent,
-                        const Babl                *format)
+gegl_buffer_linear_new (const GeglRectangle *extent,
+                        const Babl          *format)
 {
   GeglBuffer *buffer;
 
@@ -56,12 +57,12 @@ void gegl_tile_handler_cache_insert (GeglTileHandlerCache *cache,
                                      gint                  z);
 
 GeglBuffer *
-gegl_buffer_linear_new_from_data (const gpointer             data,
-                                  const Babl                *format,
-                                  const GeglBufferRectangle *extent,
-                                  gint                       rowstride,
-                                  GDestroyNotify             destroy_fn,
-                                  gpointer                   destroy_fn_data)
+gegl_buffer_linear_new_from_data (const gpointer       data,
+                                  const Babl          *format,
+                                  const GeglRectangle *extent,
+                                  gint                 rowstride,
+                                  GDestroyNotify       destroy_fn,
+                                  gpointer             destroy_fn_data)
 {
   GeglBuffer *buffer;
   GeglTile   *tile;
@@ -123,20 +124,20 @@ gegl_buffer_linear_new_from_data (const gpointer             data,
  * an immediate shared access to the linear buffer.
  */
 typedef struct {
-  gpointer             buf;
-  GeglBufferRectangle  extent;
-  const Babl          *format;
-  gint                 refs;
+  gpointer       buf;
+  GeglRectangle  extent;
+  const Babl    *format;
+  gint           refs;
 } BufferInfo;
 
 /* FIXME: make this use direct data access in more cases than the
  * case of the base buffer.
  */
 gpointer
-gegl_buffer_linear_open (GeglBuffer                *buffer,
-                         const GeglBufferRectangle *extent,   /* if NULL, use buf  */
-                         gint                      *rowstride,/* returns rowstride */
-                         const Babl                *format)   /* if NULL, from buf */
+gegl_buffer_linear_open (GeglBuffer          *buffer,
+                         const GeglRectangle *extent,   /* if NULL, use buf  */
+                         gint                *rowstride,/* returns rowstride */
+                         const Babl          *format)   /* if NULL, from buf */
 {
   if (!format)
     format = buffer->soft_format;
diff --git a/gegl/buffer/gegl-buffer-load.c b/gegl/buffer/gegl-buffer-load.c
index 87371b597..5455661a7 100644
--- a/gegl/buffer/gegl-buffer-load.c
+++ b/gegl/buffer/gegl-buffer-load.c
@@ -26,7 +26,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 
-#include "gegl.h"
+#include "gegl-buffer.h"
 #include "gegl-buffer-private.h"
 #include "gegl-buffer-index.h"
 #include "gegl-debug.h"
diff --git a/gegl/buffer/gegl-buffer-private.h b/gegl/buffer/gegl-buffer-private.h
index b2c86536c..5b1874efc 100644
--- a/gegl/buffer/gegl-buffer-private.h
+++ b/gegl/buffer/gegl-buffer-private.h
@@ -23,7 +23,6 @@
 #include "gegl-buffer.h"
 #include "gegl-tile-handler.h"
 #include "gegl-buffer-iterator.h"
-#include "gegl-buffer-cl-iterator.h"
 
 #define GEGL_BUFFER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  GEGL_TYPE_BUFFER, GeglBufferClass))
 #define GEGL_IS_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  GEGL_TYPE_BUFFER))
@@ -33,22 +32,22 @@ typedef struct _GeglBufferClass GeglBufferClass;
 
 struct _GeglBuffer
 {
-  GeglTileHandler     parent_instance; /* which is a GeglTileHandler which has a
+  GeglTileHandler   parent_instance; /* which is a GeglTileHandler which has a
                                         source field which is used for chaining
                                         sub buffers with their anchestors */
 
-  GeglBufferRectangle extent;        /* the dimensions of the buffer */
+  GeglRectangle     extent;        /* the dimensions of the buffer */
 
-  const Babl         *format;  /* the pixel format used for pixels in this
+  const Babl       *format;  /* the pixel format used for pixels in this
                                 buffer */
-  const Babl         *soft_format;  /* the format the buffer pretends to be, might
-                                       be different from format */
+  const Babl  *soft_format;  /* the format the buffer pretends to be, might
+                                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    */
 
-  GeglBufferRectangle abyss;
+  GeglRectangle     abyss;
   gboolean          abyss_tracks_extent; /* specifies whether the abyss rectangle
                                             should track any modifications to the
                                             extent rectangle */
@@ -106,33 +105,33 @@ gboolean          gegl_buffer_lock        (GeglBuffer *buffer);
 gboolean          gegl_buffer_unlock      (GeglBuffer *buffer);
 #endif
 
-void              gegl_buffer_set_unlocked (GeglBuffer                *buffer,
-                                            const GeglBufferRectangle *rect,
-                                            gint                       level,
-                                            const Babl                *format,
-                                            const void                *src,
-                                            gint                       rowstride);
-
-void              gegl_buffer_set_unlocked_no_notify (GeglBuffer                *buffer,
-                                                      const GeglBufferRectangle *rect,
-                                                      gint                       level,
-                                                      const Babl                *format,
-                                                      const void                *src,
-                                                      gint                       rowstride);
-
-void              gegl_buffer_get_unlocked (GeglBuffer                *buffer,
-                                            gdouble                    scale,
-                                            const GeglBufferRectangle *rect,
-                                            const Babl                *format,
-                                            gpointer                   dest_buf,
-                                            gint                       rowstride,
-                                            GeglAbyssPolicy            repeat_mode);
-
-GeglBuffer *      gegl_buffer_new_ram     (const GeglBufferRectangle *extent,
-                                           const Babl                *format);
+void              gegl_buffer_set_unlocked (GeglBuffer          *buffer,
+                                            const GeglRectangle *rect,
+                                            gint                 level,
+                                            const Babl          *format,
+                                            const void          *src,
+                                            gint                 rowstride);
+
+void              gegl_buffer_set_unlocked_no_notify (GeglBuffer          *buffer,
+                                                      const GeglRectangle *rect,
+                                                      gint                 level,
+                                                      const Babl          *format,
+                                                      const void          *src,
+                                                      gint                 rowstride);
+
+void              gegl_buffer_get_unlocked (GeglBuffer          *buffer,
+                                            gdouble              scale,
+                                            const GeglRectangle *rect,
+                                            const Babl          *format,
+                                            gpointer             dest_buf,
+                                            gint                 rowstride,
+                                            GeglAbyssPolicy      repeat_mode);
+
+GeglBuffer *      gegl_buffer_new_ram     (const GeglRectangle *extent,
+                                           const Babl          *format);
 
 void              gegl_buffer_emit_changed_signal (GeglBuffer *buffer,
-                                                   const GeglBufferRectangle *rect);
+                                                   const GeglRectangle *rect);
 
 /* the instance size of a GeglTile is a bit large, and should if possible be
  * trimmed down
@@ -196,8 +195,8 @@ gboolean gegl_tile_damage         (GeglTile *tile,
 
 void _gegl_buffer_drop_hot_tile (GeglBuffer *buffer);
 
-GeglBufferRectangle _gegl_get_required_for_scale (const GeglBufferRectangle *roi,
-                                                  gdouble                    scale);
+GeglRectangle _gegl_get_required_for_scale (const GeglRectangle *roi,
+                                            gdouble              scale);
 
 gboolean gegl_buffer_scan_compatible (GeglBuffer *bufferA,
                                       gint        xA,
@@ -207,9 +206,9 @@ gboolean gegl_buffer_scan_compatible (GeglBuffer *bufferA,
                                       gint        yB);
 
 
-extern void (*gegl_tile_handler_cache_ext_flush) (void *tile_handler_cache, const GeglBufferRectangle *rect);
-extern void (*gegl_buffer_ext_flush) (GeglBuffer *buffer, const GeglBufferRectangle *rect);
-extern void (*gegl_buffer_ext_invalidate) (GeglBuffer *buffer, const GeglBufferRectangle *rect);
+extern void (*gegl_tile_handler_cache_ext_flush) (void *tile_handler_cache, const GeglRectangle *rect);
+extern void (*gegl_buffer_ext_flush) (GeglBuffer *buffer, const GeglRectangle *rect);
+extern void (*gegl_buffer_ext_invalidate) (GeglBuffer *buffer, const GeglRectangle *rect);
 
 
 #ifndef __GEGL_TILE_H__
diff --git a/gegl/buffer/gegl-buffer-save.c b/gegl/buffer/gegl-buffer-save.c
index 257d9e1f6..b020fe8f5 100644
--- a/gegl/buffer/gegl-buffer-save.c
+++ b/gegl/buffer/gegl-buffer-save.c
@@ -29,7 +29,7 @@
 #include <glib-object.h>
 #include <glib/gstdio.h>
 
-#include "gegl.h"
+#include "gegl-buffer.h"
 #include "gegl-buffer-types.h"
 #include "gegl-buffer-private.h"
 #include "gegl-debug.h"
@@ -188,9 +188,9 @@ gegl_buffer_header_init (GeglBufferHeader *header,
 }
 
 void
-gegl_buffer_save (GeglBuffer                *buffer,
-                  const gchar               *path,
-                  const GeglBufferRectangle *roi)
+gegl_buffer_save (GeglBuffer          *buffer,
+                  const gchar         *path,
+                  const GeglRectangle *roi)
 {
   SaveInfo *info = g_slice_new0 (SaveInfo);
 
diff --git a/gegl/buffer/gegl-buffer-types.h b/gegl/buffer/gegl-buffer-types.h
index ced2b53f8..dbc23d47e 100644
--- a/gegl/buffer/gegl-buffer-types.h
+++ b/gegl/buffer/gegl-buffer-types.h
@@ -19,7 +19,7 @@
 #ifndef __GEGL_BUFFER_TYPES_H__
 #define __GEGL_BUFFER_TYPES_H__
 
-#include "gegl-types.h"
+#include "gegl-buffer-enums.h"
 #include "gegl-buffer-backend.h"
 
 
@@ -30,19 +30,19 @@
 
 struct _GeglTileBackendPrivate
 {
-  gint                         tile_width;
-  gint                         tile_height;
-  const Babl                  *format;    /* defaults to the babl format "R'G'B'A u8" */
-  gint                         px_size;   /* size of a single pixel in bytes */
-  gint                         tile_size; /* size of an entire tile in bytes */
-  gboolean                     flush_on_destroy;
+  gint                   tile_width;
+  gint                   tile_height;
+  const Babl            *format;    /* defaults to the babl format "R'G'B'A u8" */
+  gint                   px_size;   /* size of a single pixel in bytes */
+  gint                   tile_size; /* size of an entire tile in bytes */
 
-  GeglBufferRectangle          extent;
+  gboolean               flush_on_destroy;
+  GeglRectangle          extent;
 
-  gpointer                     storage;
-  gboolean                     shared;
+  gpointer               storage;
+  gboolean               shared;
 
-  GeglTileSourceCommand        command;
+  GeglTileSourceCommand  command;
 };
 
 typedef struct _GeglTileHandlerChain      GeglTileHandlerChain;
diff --git a/gegl/buffer/gegl-buffer.c b/gegl/buffer/gegl-buffer.c
index 0938daabd..b922066cb 100644
--- a/gegl/buffer/gegl-buffer.c
+++ b/gegl/buffer/gegl-buffer.c
@@ -36,10 +36,12 @@
 #include <glib-object.h>
 #include <glib/gstdio.h>
 
+#include "gegl-debug.h"
 #include "gegl-buffer.h"
 #include "gegl-buffer-types.h"
 #include "gegl-buffer-config.h"
 #include "gegl-buffer-private.h"
+#include "gegl-rectangle.h"
 #include "gegl-tile-storage.h"
 #include "gegl-tile-backend-file.h"
 #include "gegl-tile-backend-swap.h"
@@ -285,8 +287,8 @@ static volatile gint  de_allocated_buffers   = 0;
  * would be voided as a result of changing the extent.
  */
 gboolean
-gegl_buffer_set_extent (GeglBuffer                *buffer,
-                        const GeglBufferRectangle *extent)
+gegl_buffer_set_extent (GeglBuffer          *buffer,
+                        const GeglRectangle *extent)
 {
   g_return_val_if_fail (GEGL_IS_BUFFER (buffer), FALSE);
 
@@ -302,8 +304,8 @@ gegl_buffer_set_extent (GeglBuffer                *buffer,
 }
 
 gboolean
-gegl_buffer_set_abyss (GeglBuffer                *buffer,
-                       const GeglBufferRectangle *abyss)
+gegl_buffer_set_abyss (GeglBuffer          *buffer,
+                       const GeglRectangle *abyss)
 {
   g_return_val_if_fail (GEGL_IS_BUFFER (buffer), FALSE);
 
@@ -453,9 +455,9 @@ gegl_buffer_tile_storage (GeglBuffer *buffer)
 }
 
 static void
-gegl_buffer_storage_changed (GeglTileStorage           *storage,
-                             const GeglBufferRectangle *rect,
-                             gpointer                   userdata)
+gegl_buffer_storage_changed (GeglTileStorage     *storage,
+                             const GeglRectangle *rect,
+                             gpointer             userdata)
 {
   gegl_buffer_emit_changed_signal (GEGL_BUFFER (userdata), rect);
 }
@@ -648,9 +650,9 @@ gegl_buffer_constructor (GType                  type,
   if (GEGL_IS_BUFFER (source))
     {
       GeglBuffer *source_buf = GEGL_BUFFER (source);
-      GeglBufferRectangle parent;
-      GeglBufferRectangle request;
-      GeglBufferRectangle self;
+      GeglRectangle parent;
+      GeglRectangle request;
+      GeglRectangle self;
 
       parent.x = source_buf->abyss.x - buffer->shift_x;
       parent.y = source_buf->abyss.y - buffer->shift_y;
@@ -929,7 +931,7 @@ gegl_buffer_init (GeglBuffer *buffer)
 }
 
 
-const GeglBufferRectangle *
+const GeglRectangle *
 gegl_buffer_get_extent (GeglBuffer *buffer)
 {
   g_return_val_if_fail (GEGL_IS_BUFFER (buffer), NULL);
@@ -937,7 +939,7 @@ gegl_buffer_get_extent (GeglBuffer *buffer)
   return &(buffer->extent);
 }
 
-const GeglBufferRectangle *
+const GeglRectangle *
 gegl_buffer_get_abyss (GeglBuffer *buffer)
 {
   g_return_val_if_fail (GEGL_IS_BUFFER (buffer), NULL);
@@ -947,10 +949,10 @@ gegl_buffer_get_abyss (GeglBuffer *buffer)
 
 
 GeglBuffer *
-gegl_buffer_new_ram (const GeglBufferRectangle *extent,
-                     const Babl                *format)
+gegl_buffer_new_ram (const GeglRectangle *extent,
+                     const Babl          *format)
 {
-  GeglBufferRectangle empty={0,0,0,0};
+  GeglRectangle empty={0,0,0,0};
 
   if (extent == NULL)
     extent = &empty;
@@ -969,10 +971,10 @@ gegl_buffer_new_ram (const GeglBufferRectangle *extent,
 }
 
 GeglBuffer *
-gegl_buffer_new (const GeglBufferRectangle *extent,
-                 const Babl                *format)
+gegl_buffer_new (const GeglRectangle *extent,
+                 const Babl          *format)
 {
-  GeglBufferRectangle empty={0,0,0,0};
+  GeglRectangle empty={0,0,0,0};
 
   if (extent == NULL)
     extent = &empty;
@@ -990,10 +992,10 @@ gegl_buffer_new (const GeglBufferRectangle *extent,
 }
 
 GeglBuffer *
-gegl_buffer_new_for_backend (const GeglBufferRectangle *extent,
-                             GeglTileBackend           *backend)
+gegl_buffer_new_for_backend (const GeglRectangle *extent,
+                             GeglTileBackend     *backend)
 {
-  GeglBufferRectangle rect = { 0, 0, 0, 0 };
+  GeglRectangle rect = { 0, 0, 0, 0 };
   const Babl   *format;
 
   /* if no extent is passed in inherit from backend */
@@ -1038,8 +1040,8 @@ gegl_buffer_remove_handler (GeglBuffer *buffer,
  * on runtime, and recycling them through a hashtable?
  */
 GeglBuffer*
-gegl_buffer_create_sub_buffer (GeglBuffer                *buffer,
-                               const GeglBufferRectangle *extent)
+gegl_buffer_create_sub_buffer (GeglBuffer          *buffer,
+                               const GeglRectangle *extent)
 {
   g_return_val_if_fail (GEGL_IS_BUFFER (buffer), NULL);
 
@@ -1167,12 +1169,12 @@ gegl_buffer_unlock (GeglBuffer *buffer)
 #endif
 
 void
-gegl_buffer_emit_changed_signal (GeglBuffer                *buffer,
-                                 const GeglBufferRectangle *rect)
+gegl_buffer_emit_changed_signal (GeglBuffer          *buffer,
+                                 const GeglRectangle *rect)
 {
   if (buffer->changed_signal_connections)
   {
-    GeglBufferRectangle copy;
+    GeglRectangle copy;
 
     if (rect == NULL)
       copy = *gegl_buffer_get_extent (buffer);
@@ -1217,6 +1219,6 @@ gegl_buffer_get_tile (GeglBuffer *buffer,
   return tile;
 }
 
-void (*gegl_tile_handler_cache_ext_flush) (void *cache, const GeglBufferRectangle *rect)=NULL;
-void (*gegl_buffer_ext_flush) (GeglBuffer *buffer, const GeglBufferRectangle *rect)=NULL;
-void (*gegl_buffer_ext_invalidate) (GeglBuffer *buffer, const GeglBufferRectangle *rect)=NULL;
+void (*gegl_tile_handler_cache_ext_flush) (void *cache, const GeglRectangle *rect)=NULL;
+void (*gegl_buffer_ext_flush) (GeglBuffer *buffer, const GeglRectangle *rect)=NULL;
+void (*gegl_buffer_ext_invalidate) (GeglBuffer *buffer, const GeglRectangle *rect)=NULL;
diff --git a/gegl/buffer/gegl-buffer.h b/gegl/buffer/gegl-buffer.h
index 0a32a8301..3553ccaef 100644
--- a/gegl/buffer/gegl-buffer.h
+++ b/gegl/buffer/gegl-buffer.h
@@ -22,7 +22,7 @@
 #include <glib-object.h>
 #include <babl/babl.h>
 #include "gegl-buffer-matrix2.h"
-#include <gegl-types.h>
+#include "gegl-buffer-enums.h"
 
 #define GEGL_AUTO_ROWSTRIDE 0
 
@@ -31,9 +31,9 @@ typedef struct _GeglTileBackend GeglTileBackend;
 typedef struct _GeglBuffer  GeglBuffer;
 typedef struct _GeglSampler       GeglSampler;
 
-typedef struct _GeglBufferRectangle GeglBufferRectangle;
+typedef struct _GeglRectangle GeglRectangle;
 
-struct _GeglBufferRectangle
+struct _GeglRectangle
 {
   gint x;
   gint y;
@@ -41,28 +41,6 @@ struct _GeglBufferRectangle
   gint height;
 };
 
-#ifndef __cplusplus
-
-#define  GEGL_BUFFER_RECTANGLE(x,y,w,h) (&((GeglBufferRectangle){(x), (y),   (w), (h)}))
-
-#else
-
-static inline GeglBufferRectangle
-_gegl_buffer_rectangle_helper (gint x,
-                               gint y,
-                               gint width,
-                               gint height)
-{
-  GeglBufferRectangle result = {x, y, width, height};
-  return result;
-}
-
-#define  GEGL_BUFFER_RECTANGLE(x,y,w,h) \
-  ((GeglBufferRectangle *) &(const GeglBufferRectangle &) ::_gegl_buffer_rectangle_helper (x, y, w, h))
-
-#endif /* __cplusplus */
-
-
 
 /***
  * GeglBuffer:
@@ -79,7 +57,7 @@ _gegl_buffer_rectangle_helper (gint x,
 /**
  * gegl_buffer_new: (skip)
  * @extent: the geometry of the buffer (origin, width and height) a
- * GeglBufferRectangle.
+ * GeglRectangle.
  * @format: the Babl pixel format to be used, create one with babl_format("RGBA
  * u8") and similar.
  *
@@ -87,13 +65,13 @@ _gegl_buffer_rectangle_helper (gint x,
  * possible to pass in NULL for both extent and format, a NULL extent creates
  * an empty buffer and a NULL format makes the buffer default to "RGBA float".
  */
-GeglBuffer *    gegl_buffer_new               (const GeglBufferRectangle *extent,
-                                               const Babl                *format);
+GeglBuffer *    gegl_buffer_new               (const GeglRectangle *extent,
+                                               const Babl          *format);
 
 /**
  * gegl_buffer_new_for_backend:
  * @extent: the geometry of the buffer (origin, width and height) a
- * GeglBufferRectangle.
+ * GeglRectangle.
  * @backend: an instance of a GeglTileBackend subclass.
  *
  * Create a new GeglBuffer from a backend, if NULL is passed in the extent of
@@ -101,7 +79,7 @@ GeglBuffer *    gegl_buffer_new               (const GeglBufferRectangle *extent
  *
  * returns a GeglBuffer, that holds a reference to the provided backend.
  */
-GeglBuffer *   gegl_buffer_new_for_backend    (const GeglBufferRectangle *extent,
+GeglBuffer *   gegl_buffer_new_for_backend    (const GeglRectangle *extent,
                                                GeglTileBackend     *backend);
 
 /**
@@ -145,9 +123,9 @@ GeglBuffer *    gegl_buffer_open              (const gchar         *path);
  *
  * Write a GeglBuffer to a file.
  */
-void            gegl_buffer_save              (GeglBuffer                *buffer,
-                                               const gchar               *path,
-                                               const GeglBufferRectangle *roi);
+void            gegl_buffer_save              (GeglBuffer          *buffer,
+                                               const gchar         *path,
+                                               const GeglRectangle *roi);
 
 /**
  * gegl_buffer_load:
@@ -180,18 +158,18 @@ void            gegl_buffer_flush             (GeglBuffer          *buffer);
  *
  * Return value: (transfer full): the new sub buffer
  */
-GeglBuffer *    gegl_buffer_create_sub_buffer (GeglBuffer                *buffer,
-                                               const GeglBufferRectangle *extent);
+GeglBuffer *    gegl_buffer_create_sub_buffer (GeglBuffer          *buffer,
+                                               const GeglRectangle *extent);
 
 /**
  * gegl_buffer_get_extent:
  * @buffer: the buffer to operate on.
  *
- * Returns a pointer to a GeglBufferRectangle structure defining the geometry of a
+ * Returns a pointer to a GeglRectangle structure defining the geometry of a
  * specific GeglBuffer, this is also the default width/height of buffers passed
  * in to gegl_buffer_set and gegl_buffer_get (with a scale of 1.0 at least).
  */
-const GeglBufferRectangle * gegl_buffer_get_extent  (GeglBuffer *buffer);
+const GeglRectangle * gegl_buffer_get_extent  (GeglBuffer *buffer);
 
 
 /**
@@ -205,8 +183,8 @@ const GeglBufferRectangle * gegl_buffer_get_extent  (GeglBuffer *buffer);
  *
  * Returns TRUE if the change of extent was successful.
  */
-gboolean          gegl_buffer_set_extent      (GeglBuffer               *buffer,
-                                               const GeglBufferRectangle *extent);
+gboolean          gegl_buffer_set_extent      (GeglBuffer          *buffer,
+                                               const GeglRectangle *extent);
 
 /**
  * gegl_buffer_set_abyss:
@@ -217,8 +195,8 @@ gboolean          gegl_buffer_set_extent      (GeglBuffer               *buffer,
  *
  * Returns TRUE if the change of abyss was successful.
  */
-gboolean          gegl_buffer_set_abyss      (GeglBuffer                *buffer,
-                                              const GeglBufferRectangle *abyss);
+gboolean          gegl_buffer_set_abyss      (GeglBuffer          *buffer,
+                                              const GeglRectangle *abyss);
 
 /* convenience access macros */
 
@@ -290,13 +268,13 @@ gboolean          gegl_buffer_set_abyss      (GeglBuffer                *buffer,
  * the tile structure into a linear buffer.
  *
  */
-void            gegl_buffer_get               (GeglBuffer                *buffer,
-                                               const GeglBufferRectangle *rect,
-                                               gdouble                    scale,
-                                               const Babl                *format,
-                                               gpointer                   dest,
-                                               gint                       rowstride,
-                                               GeglAbyssPolicy            repeat_mode);
+void            gegl_buffer_get               (GeglBuffer          *buffer,
+                                               const GeglRectangle *rect,
+                                               gdouble              scale,
+                                               const Babl          *format,
+                                               gpointer             dest,
+                                               gint                 rowstride,
+                                               GeglAbyssPolicy      repeat_mode);
 
 /**
  * gegl_buffer_set: (skip)
@@ -313,13 +291,12 @@ void            gegl_buffer_get               (GeglBuffer                *buffer
  *
  * Store a linear raster buffer into the GeglBuffer.
  */
-void            gegl_buffer_set               (GeglBuffer                *buffer,
-                                               const GeglBufferRectangle *rect,
-                                               gint                       mipmap_level,
-                                               const Babl                *format,
-                                               const void                *src,
-                                               gint                       rowstride);
-
+void            gegl_buffer_set               (GeglBuffer          *buffer,
+                                               const GeglRectangle *rect,
+                                               gint                 mipmap_level,
+                                               const Babl          *format,
+                                               const void          *src,
+                                               gint                 rowstride);
 
 
 
@@ -333,10 +310,10 @@ void            gegl_buffer_set               (GeglBuffer                *buffer
  * Sets the region covered by rect to the the provided pixel.
  */
 void
-gegl_buffer_set_color_from_pixel (GeglBuffer                *buffer,
-                                  const GeglBufferRectangle *rect,
-                                  const guchar              *pixel,
-                                  const Babl                *pixel_format);
+gegl_buffer_set_color_from_pixel (GeglBuffer          *buffer,
+                                  const GeglRectangle *rect,
+                                  const guchar        *pixel,
+                                  const Babl          *pixel_format);
 
 
 /**
@@ -351,11 +328,11 @@ gegl_buffer_set_color_from_pixel (GeglBuffer                *buffer,
  * relative to the origin (0, 0) and not to the rectangle. So be carefull
  * about the origin of @pattern and @buffer extents.
  */
-void            gegl_buffer_set_pattern       (GeglBuffer                *buffer,
-                                               const GeglBufferRectangle *rect,
-                                               GeglBuffer                *pattern,
-                                               gint                       x_offset,
-                                               gint                       y_offset);
+void            gegl_buffer_set_pattern       (GeglBuffer          *buffer,
+                                               const GeglRectangle *rect,
+                                               GeglBuffer          *pattern,
+                                               gint                 x_offset,
+                                               gint                 y_offset);
 
 /**
  * gegl_buffer_get_format: (skip)
@@ -396,8 +373,8 @@ const Babl *    gegl_buffer_set_format        (GeglBuffer          *buffer,
  * Clears the provided rectangular region by setting all the associated memory
  * to 0.
  */
-void            gegl_buffer_clear             (GeglBuffer                *buffer,
-                                               const GeglBufferRectangle *roi);
+void            gegl_buffer_clear             (GeglBuffer          *buffer,
+                                               const GeglRectangle *roi);
 
 
 /**
@@ -417,11 +394,11 @@ void            gegl_buffer_clear             (GeglBuffer                *buffer
  * This function never does any scaling. When src_rect and dst_rect do not have
  * the same width and height, the size of src_rect is used.
  */
-void            gegl_buffer_copy              (GeglBuffer                *src,
-                                               const GeglBufferRectangle *src_rect,
-                                               GeglAbyssPolicy            repeat_mode,
-                                               GeglBuffer                *dst,
-                                               const GeglBufferRectangle *dst_rect);
+void            gegl_buffer_copy              (GeglBuffer          *src,
+                                               const GeglRectangle *src_rect,
+                                               GeglAbyssPolicy      repeat_mode,
+                                               GeglBuffer          *dst,
+                                               const GeglRectangle *dst_rect);
 
 
 
@@ -638,7 +615,7 @@ void              gegl_sampler_get            (GeglSampler       *sampler,
  *
  * Returns:The context rectangle of the given @sampler.
  */
-const GeglBufferRectangle * gegl_sampler_get_context_rect (GeglSampler *sampler);
+const GeglRectangle * gegl_sampler_get_context_rect (GeglSampler *sampler);
 
 /**
  * gegl_buffer_linear_new: (skip)
@@ -651,8 +628,8 @@ const GeglBufferRectangle * gegl_sampler_get_context_rect (GeglSampler *sampler)
  *
  * Returns: a GeglBuffer that can be used as any other GeglBuffer.
  */
-GeglBuffer *  gegl_buffer_linear_new          (const GeglBufferRectangle *extent,
-                                               const Babl                *format);
+GeglBuffer *  gegl_buffer_linear_new          (const GeglRectangle *extent,
+                                               const Babl          *format);
 
 /**
  * gegl_buffer_linear_new_from_data: (skip)
@@ -672,12 +649,12 @@ GeglBuffer *  gegl_buffer_linear_new          (const GeglBufferRectangle *extent
  *
  * Returns: a GeglBuffer that can be used as any other GeglBuffer.
  */
-GeglBuffer * gegl_buffer_linear_new_from_data (const gpointer             data,
-                                               const Babl                *format,
-                                               const GeglBufferRectangle *extent,
-                                               gint                       rowstride,
-                                               GDestroyNotify             destroy_fn,
-                                               gpointer                   destroy_fn_data);
+GeglBuffer * gegl_buffer_linear_new_from_data (const gpointer       data,
+                                               const Babl          *format,
+                                               const GeglRectangle *extent,
+                                               gint                 rowstride,
+                                               GDestroyNotify       destroy_fn,
+                                               gpointer             destroy_fn_data);
 
 /**
  * gegl_buffer_linear_open: (skip)
@@ -692,10 +669,10 @@ GeglBuffer * gegl_buffer_linear_new_from_data (const gpointer             data,
  * request is compatible with the underlying data storage direct access
  * to the underlying data is provided. Otherwise, it returns a copy of the data.
  */
-gpointer        gegl_buffer_linear_open       (GeglBuffer                *buffer,
-                                               const GeglBufferRectangle *extent,
-                                               gint                      *rowstride,
-                                               const Babl                *format);
+gpointer        gegl_buffer_linear_open       (GeglBuffer          *buffer,
+                                               const GeglRectangle *extent,
+                                               gint                *rowstride,
+                                               const Babl          *format);
 
 /**
  * gegl_buffer_linear_close:
@@ -718,7 +695,7 @@ void            gegl_buffer_linear_close      (GeglBuffer    *buffer,
  * Return the abyss extent of a buffer, this expands out to the parents extent in
  * subbuffers.
  */
-const GeglBufferRectangle * gegl_buffer_get_abyss   (GeglBuffer           *buffer);
+const GeglRectangle * gegl_buffer_get_abyss   (GeglBuffer           *buffer);
 
 
 
@@ -742,6 +719,57 @@ glong gegl_buffer_signal_connect (GeglBuffer *buffer,
                                   GCallback   c_handler,
                                   gpointer    data);
 
+
+
+/***
+ * Aligned memory:
+ *
+ * GEGL provides functions to allocate and free buffers that are guaranteed to
+ * be on 16 byte aligned memory addresses.
+ */
+
+/**
+ * gegl_malloc: (skip)
+ * @n_bytes: the number of bytes to allocte.
+ *
+ * Allocates @n_bytes of memory. If n_bytes is 0 it returns NULL.
+ *
+ * Returns a pointer to the allocated memory.
+ */
+gpointer gegl_malloc                  (gsize    n_bytes) G_GNUC_MALLOC;
+
+/**
+ * gegl_free: (skip)
+ * @mem: the memory to free.
+ *
+ * Frees the memory pointed to by @mem, if @mem is NULL it will warn and abort.
+ */
+void     gegl_free                    (gpointer mem);
+
+/**
+ * gegl_calloc: (skip)
+ * @size: size of items to allocate
+ * @n_memb: number of members
+ *
+ * allocated 0'd memory.
+ */
+gpointer gegl_calloc (gsize size, int n_memb) G_GNUC_MALLOC;
+
+/**
+ * gegl_memset_pattern: (skip)
+ * @dst_ptr: pointer to copy to
+ * @src_ptr: pointer to copy from
+ * @pattern_size: the length of @src_ptr
+ * @count: number of copies
+ *
+ * Fill @dst_ptr with @count copies of the bytes in @src_ptr.
+ */
+void gegl_memset_pattern              (void *       dst_ptr,
+                                              const void * src_ptr,
+                                              gint         pattern_size,
+                                              gint         count);
+
+
 /**
  * gegl_buffer_flush_ext:
  * @buffer: a GeglBuffer
@@ -754,10 +782,10 @@ glong gegl_buffer_signal_connect (GeglBuffer *buffer,
  * threads having an implicit synchronization of its own.
  */
 void
-gegl_buffer_flush_ext (GeglBuffer *buffer, const GeglBufferRectangle *rect);
+gegl_buffer_flush_ext (GeglBuffer *buffer, const GeglRectangle *rect);
 
 #include <gegl-buffer-iterator.h>
-
+#include <gegl-rectangle.h>
 
 
 GType gegl_buffer_get_type  (void) G_GNUC_CONST;
@@ -767,9 +795,5 @@ GType gegl_buffer_get_type  (void) G_GNUC_CONST;
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (GeglBuffer, g_object_unref)
 
 
-
-
-
-
 G_END_DECLS
 #endif
diff --git a/gegl/buffer/gegl-rectangle.c b/gegl/buffer/gegl-rectangle.c
new file mode 100644
index 000000000..391e2c129
--- /dev/null
+++ b/gegl/buffer/gegl-rectangle.c
@@ -0,0 +1,367 @@
+/* This file is part of GEGL
+ *
+ * GEGL is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * GEGL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GEGL; if not, see <https://www.gnu.org/licenses/>.
+ *
+ * Copyright 2003-2007 Calvin Williamson, Øyvind Kolås.
+ */
+
+#include "config.h"
+
+#include <string.h>
+#include <glib-object.h>
+#include "gegl-buffer.h"
+#include "gegl-rectangle.h"
+
+GeglRectangle *
+gegl_rectangle_new (gint           x,
+                    gint           y,
+                    guint          w,
+                    guint          h)
+{
+  GeglRectangle *r = g_new (GeglRectangle, 1);
+
+  r->x      = x;
+  r->y      = y;
+  r->width  = w;
+  r->height = h;
+
+  return r;
+}
+
+void
+gegl_rectangle_set (GeglRectangle *r,
+                    gint           x,
+                    gint           y,
+                    guint          w,
+                    guint          h)
+{
+  r->x      = x;
+  r->y      = y;
+  r->width  = w;
+  r->height = h;
+}
+
+void
+gegl_rectangle_bounding_box (GeglRectangle       *dest,
+                             const GeglRectangle *src1,
+                             const GeglRectangle *src2)
+{
+  gboolean s1_has_area = src1->width && src1->height;
+  gboolean s2_has_area = src2->width && src2->height;
+
+  if (!s1_has_area && !s2_has_area)
+    gegl_rectangle_set (dest, 0, 0, 0, 0);
+  else if (!s1_has_area)
+    gegl_rectangle_copy (dest, src2);
+  else if (!s2_has_area)
+    gegl_rectangle_copy (dest, src1);
+  else
+    {
+      gint x1 = MIN (src1->x, src2->x);
+      gint x2 = MAX (src1->x + src1->width, src2->x + src2->width);
+      gint y1 = MIN (src1->y, src2->y);
+      gint y2 = MAX (src1->y + src1->height, src2->y + src2->height);
+
+      dest->x      = x1;
+      dest->y      = y1;
+      dest->width  = x2 - x1;
+      dest->height = y2 - y1;
+    }
+}
+
+gboolean
+gegl_rectangle_intersect (GeglRectangle       *dest,
+                          const GeglRectangle *src1,
+                          const GeglRectangle *src2)
+{
+  gint x1, x2, y1, y2;
+
+  x1 = MAX (src1->x, src2->x);
+  x2 = MIN (src1->x + src1->width, src2->x + src2->width);
+
+  if (x2 <= x1)
+    {
+      if (dest)
+        gegl_rectangle_set (dest, 0, 0, 0, 0);
+      return FALSE;
+    }
+
+  y1 = MAX (src1->y, src2->y);
+  y2 = MIN (src1->y + src1->height, src2->y + src2->height);
+
+  if (y2 <= y1)
+    {
+      if (dest)
+        gegl_rectangle_set (dest, 0, 0, 0, 0);
+      return FALSE;
+    }
+
+  if (dest)
+    gegl_rectangle_set (dest, x1, y1, x2 - x1, y2 - y1);
+  return TRUE;
+}
+
+gboolean
+gegl_rectangle_subtract_bounding_box (GeglRectangle       *dest,
+                                      const GeglRectangle *minuend,
+                                      const GeglRectangle *subtrahend)
+{
+  gint mx1, mx2;
+  gint my1, my2;
+
+  gint sx1, sx2;
+  gint sy1, sy2;
+
+  mx1 = minuend->x;
+  mx2 = minuend->x + minuend->width;
+  my1 = minuend->y;
+  my2 = minuend->y + minuend->height;
+
+  sx1 = subtrahend->x;
+  sx2 = subtrahend->x + subtrahend->width;
+  sy1 = subtrahend->y;
+  sy2 = subtrahend->y + subtrahend->height;
+
+  if (sx1 <= mx1 && sx2 >= mx2)
+    {
+      if (sy1 <= my1) my1 = MAX (my1, sy2);
+      if (sy2 >= my2) my2 = MIN (my2, sy1);
+    }
+  else if (sy1 <= my1 && sy2 >= my2)
+    {
+      if (sx1 <= mx1) mx1 = MAX (mx1, sx2);
+      if (sx2 >= mx2) mx2 = MIN (mx2, sx1);
+    }
+
+  if (mx1 < mx2 && my1 < my2)
+    {
+      gegl_rectangle_set (dest, mx1, my1, mx2 - mx1, my2 - my1);
+      return TRUE;
+    }
+  else
+    {
+      gegl_rectangle_set (dest, 0, 0, 0, 0);
+      return FALSE;
+    }
+}
+
+void
+gegl_rectangle_copy (GeglRectangle       *to,
+                     const GeglRectangle *from)
+{
+  to->x      = from->x;
+  to->y      = from->y;
+  to->width  = from->width;
+  to->height = from->height;
+}
+
+gboolean
+gegl_rectangle_contains (const GeglRectangle *r,
+                         const GeglRectangle *s)
+{
+  g_return_val_if_fail (r && s, FALSE);
+
+  if (s->x >= r->x &&
+      s->y >= r->y &&
+      (s->x + s->width) <= (r->x + r->width) &&
+      (s->y + s->height) <= (r->y + r->height))
+    return TRUE;
+  else
+    return FALSE;
+}
+
+gboolean
+gegl_rectangle_equal (const GeglRectangle *r,
+                      const GeglRectangle *s)
+{
+  g_return_val_if_fail (r && s, FALSE);
+
+  if (r->x == s->x &&
+      r->y == s->y &&
+      r->width == s->width &&
+      r->height == s->height)
+    return TRUE;
+  else
+    return FALSE;
+}
+
+gboolean
+gegl_rectangle_equal_coords (const GeglRectangle *r,
+                             gint                 x,
+                             gint                 y,
+                             gint                 w,
+                             gint                 h)
+{
+  g_return_val_if_fail (r, FALSE);
+
+  if (r->x == x &&
+      r->y == y &&
+      r->width == w &&
+      r->height == h)
+    return TRUE;
+  else
+    return FALSE;
+}
+
+gboolean
+gegl_rectangle_is_empty (const GeglRectangle *r)
+{
+  g_return_val_if_fail (r != NULL, FALSE);
+  return r->width == 0 && r->height == 0;
+}
+
+GeglRectangle *
+gegl_rectangle_dup (const GeglRectangle *rectangle)
+{
+  GeglRectangle *result = g_new (GeglRectangle, 1);
+
+  *result = *rectangle;
+
+  return result;
+}
+
+GeglRectangle
+gegl_rectangle_infinite_plane (void)
+{
+  GeglRectangle infinite_plane_rect = {G_MININT / 2, G_MININT / 2, G_MAXINT, G_MAXINT};
+  return infinite_plane_rect;
+}
+
+gboolean
+gegl_rectangle_is_infinite_plane (const GeglRectangle *rectangle)
+{
+  return (rectangle->x      == G_MININT / 2 &&
+          rectangle->y      == G_MININT / 2 &&
+          rectangle->width  == G_MAXINT     &&
+          rectangle->height == G_MAXINT);
+}
+
+void
+gegl_rectangle_dump (const GeglRectangle *rectangle)
+{
+  g_print ("%d, %d, %d×%d\n",
+           rectangle->x,
+           rectangle->y,
+           rectangle->width,
+           rectangle->height);
+}
+
+GType
+gegl_rectangle_get_type (void)
+{
+  static GType our_type = 0;
+
+  if (our_type == 0)
+    our_type = g_boxed_type_register_static (g_intern_static_string ("GeglRectangle"),
+                                             (GBoxedCopyFunc) gegl_rectangle_dup,
+                                             (GBoxedFreeFunc) g_free);
+  return our_type;
+}
+
+#define GEGL_ALIGN 16
+G_STATIC_ASSERT (GEGL_ALIGN <= G_MAXUINT8);
+
+/* utility call that makes sure allocations are 16 byte aligned.
+ * making RGBA float buffers have aligned access for pixels.
+ */
+gpointer gegl_malloc (gsize size)
+{
+  gchar *mem;
+  gchar *ret;
+  gint   offset;
+
+  mem    = g_malloc (size + GEGL_ALIGN);
+  offset = GEGL_ALIGN - GPOINTER_TO_UINT(mem) % GEGL_ALIGN;
+  ret    = (gpointer)(mem + offset);
+
+  /* store the offset to the real malloc one byte in front of this malloc */
+  *(guint8*)(ret-1)=offset;
+  return (gpointer) ret;
+}
+
+gpointer gegl_calloc (gsize size, int n_memb)
+{
+  gchar *ret = gegl_malloc (size * n_memb);
+  memset (ret, 0, size * n_memb);
+  return ret;
+}
+
+void
+gegl_free (gpointer buf)
+{
+  g_assert (buf);
+  g_free ((gchar*)buf - *((guint8*)buf -1));
+}
+
+void
+gegl_memset_pattern (void * restrict       dst_ptr,
+                            const void * restrict src_ptr,
+                            gint                  pattern_size,
+                            gint                  count)
+{
+  guchar       *dst = dst_ptr;
+  const guchar *src = src_ptr;
+
+  /* g_assert (pattern_size > 0 && count >= 0); */
+
+  if (pattern_size == 1 || count == 0)
+    {
+      memset (dst, *src, count);
+    }
+  else
+    {
+      gsize block_size;
+      gsize remaining_size;
+
+      block_size = pattern_size,
+
+      memcpy (dst, src, block_size);
+      src  = dst;
+      dst += block_size;
+
+      remaining_size = (count - 1) * block_size;
+
+      while (block_size < remaining_size)
+        {
+          memcpy (dst, src, block_size);
+          dst += block_size;
+
+          remaining_size -= block_size;
+
+          /* limit the block size, so that we don't saturate the cache.
+           * 
+           * FIXME: optimal limit could use more benchmarking.
+           */
+          if (block_size <= 2048)
+            block_size *= 2;
+        }
+
+      memcpy (dst, src, remaining_size);
+    }
+}
+
+gint
+_gegl_float_epsilon_zero (float value)
+{
+  return value > -GEGL_FLOAT_EPSILON && value < GEGL_FLOAT_EPSILON;
+}
+
+gint
+_gegl_float_epsilon_equal (float v1, float v2)
+{
+  register float diff = v1 - v2;
+
+  return diff > -GEGL_FLOAT_EPSILON && diff < GEGL_FLOAT_EPSILON;
+}
+
diff --git a/gegl/buffer/gegl-rectangle.h b/gegl/buffer/gegl-rectangle.h
new file mode 100644
index 000000000..c476425e5
--- /dev/null
+++ b/gegl/buffer/gegl-rectangle.h
@@ -0,0 +1,261 @@
+/* This file is part of GEGL
+ *
+ * GEGL is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * GEGL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GEGL; if not, see <https://www.gnu.org/licenses/>.
+ *
+ * Copyright 2003 Calvin Williamson
+ */
+
+
+#ifndef __GEGL_RECTANGLE_H__
+#define __GEGL_RECTANGLE_H__
+
+G_BEGIN_DECLS
+
+
+GType gegl_rectangle_get_type (void) G_GNUC_CONST;
+#define GEGL_TYPE_RECTANGLE   (gegl_rectangle_get_type())
+
+#ifndef __cplusplus
+
+#define  GEGL_RECTANGLE(x,y,w,h) (&((GeglRectangle){(x), (y),   (w), (h)}))
+
+#else
+
+static inline GeglRectangle
+_gegl_rectangle_helper (gint x,
+                               gint y,
+                               gint width,
+                               gint height)
+{
+  GeglRectangle result = {x, y, width, height};
+  return result;
+}
+
+#define  GEGL_RECTANGLE(x,y,w,h) \
+  ((GeglRectangle *) &(const GeglRectangle &) ::_gegl_rectangle_helper (x, y, w, h))
+
+#endif /* __cplusplus */
+
+/***
+ * GeglRectangle:
+ *
+ * GeglRectangles are used in #gegl_node_get_bounding_box and #gegl_node_blit
+ * for specifying rectangles.
+ *
+ * </p><pre>struct GeglRectangle
+ * {
+ *   gint x;
+ *   gint y;
+ *   gint width;
+ *   gint height;
+ * };</pre><p>
+ *
+ */
+
+/**
+ * gegl_rectangle_new:
+ * @x: upper left x coordinate
+ * @y: upper left y coordinate
+ * @width: width in pixels.
+ * @height: height in pixels.
+ *
+ * Creates a new rectangle set with the values from @x, @y, @width and @height.
+ */
+GeglRectangle *gegl_rectangle_new        (gint                 x,
+                                          gint                 y,
+                                          guint                width,
+                                          guint                height);
+
+/**
+ * gegl_rectangle_set:
+ * @rectangle: a #GeglRectangle
+ * @x: upper left x coordinate
+ * @y: upper left y coordinate
+ * @width: width in pixels.
+ * @height: height in pixels.
+ *
+ * Sets the @x, @y, @width and @height on @rectangle.
+ */
+void        gegl_rectangle_set           (GeglRectangle       *rectangle,
+                                          gint                 x,
+                                          gint                 y,
+                                          guint                width,
+                                          guint                height);
+
+/**
+ * gegl_rectangle_equal:
+ * @rectangle1: a #GeglRectangle
+ * @rectangle2: a #GeglRectangle
+ *
+ * Check if two #GeglRectangles are equal.
+ *
+ * Returns TRUE if @rectangle and @rectangle2 are equal.
+ */
+gboolean    gegl_rectangle_equal         (const GeglRectangle *rectangle1,
+                                          const GeglRectangle *rectangle2);
+
+/**
+ * gegl_rectangle_equal_coords:
+ * @rectangle: a #GeglRectangle
+ * @x: X coordinate
+ * @y: Y coordinate
+ * @width: width of rectangle
+ * @height: height of rectangle
+ *
+ * Check if a rectangle is equal to a set of parameters.
+ *
+ * Returns TRUE if @rectangle and @x,@y @width x @height are equal.
+ */
+gboolean    gegl_rectangle_equal_coords  (const GeglRectangle *rectangle,
+                                          gint                 x,
+                                          gint                 y,
+                                          gint                 width,
+                                          gint                 height);
+
+/**
+ * gegl_rectangle_is_empty:
+ * @rectangle: a #GeglRectangle
+ *
+ * Check if a rectangle has zero area.
+ *
+ * Returns TRUE if @rectangle height and width are both zero.
+ */
+gboolean    gegl_rectangle_is_empty     (const GeglRectangle *rectangle);
+
+/**
+ * gegl_rectangle_dup:
+ * @rectangle: the #GeglRectangle to duplicate
+ *
+ * Create a new copy of @rectangle.
+ *
+ * Return value: (transfer full): a #GeglRectangle
+ */
+GeglRectangle *gegl_rectangle_dup       (const GeglRectangle *rectangle);
+
+/**
+ * gegl_rectangle_copy:
+ * @destination: a #GeglRectangle
+ * @source: a #GeglRectangle
+ *
+ * Copies the rectangle information stored in @source over the information in
+ * @destination.
+ *
+ * @destination may point to the same object as @source.
+ */
+void        gegl_rectangle_copy          (GeglRectangle       *destination,
+                                          const GeglRectangle *source);
+
+/**
+ * gegl_rectangle_bounding_box:
+ * @destination: a #GeglRectangle
+ * @source1: a #GeglRectangle
+ * @source2: a #GeglRectangle
+ *
+ * Computes the bounding box of the rectangles @source1 and @source2 and stores the
+ * resulting bounding box in @destination.
+ *
+ * @destination may point to the same object as @source1 or @source2.
+ */
+void        gegl_rectangle_bounding_box  (GeglRectangle       *destination,
+                                          const GeglRectangle *source1,
+                                          const GeglRectangle *source2);
+
+/**
+ * gegl_rectangle_intersect:
+ * @dest: return location for the intersection of @src1 and @src2, or NULL.
+ * @src1: a #GeglRectangle
+ * @src2: a #GeglRectangle
+ *
+ * Calculates the intersection of two rectangles. If the rectangles do not
+ * intersect, dest's width and height are set to 0 and its x and y values
+ * are undefined.
+ *
+ * @dest may point to the same object as @src1 or @src2.
+ *
+ * Returns TRUE if the rectangles intersect.
+ */
+gboolean    gegl_rectangle_intersect     (GeglRectangle       *dest,
+                                          const GeglRectangle *src1,
+                                          const GeglRectangle *src2);
+
+/**
+ * gegl_rectangle_subtract_bounding_box:
+ * @destination: a #GeglRectangle
+ * @minuend: a #GeglRectangle
+ * @subtrahend: a #GeglRectangle
+ *
+ * Computes the bounding box of the area formed by subtracting @subtrahend
+ * from @minuend, and stores the result in @destination.
+ *
+ * @destination may point to the same object as @minuend or @subtrahend.
+ *
+ * Returns TRUE if the result is not empty.
+ */
+gboolean
+    gegl_rectangle_subtract_bounding_box (GeglRectangle       *destination,
+                                          const GeglRectangle *minuend,
+                                          const GeglRectangle *subtrahend);
+
+/**
+ * gegl_rectangle_contains:
+ * @parent: a #GeglRectangle
+ * @child: a #GeglRectangle
+ *
+ * Checks if the #GeglRectangle @child is fully contained within @parent.
+ *
+ * Returns TRUE if the @child is fully contained in @parent.
+ */
+gboolean    gegl_rectangle_contains      (const GeglRectangle *parent,
+                                          const GeglRectangle *child);
+
+/**
+ * gegl_rectangle_infinite_plane:
+ *
+ * Returns a GeglRectangle that represents an infininte plane.
+ */
+GeglRectangle gegl_rectangle_infinite_plane (void);
+
+/**
+ * gegl_rectangle_is_infinite_plane:
+ * @rectangle: A GeglRectangle.
+ *
+ * Returns TRUE if the GeglRectangle represents an infininte plane,
+ * FALSE otherwise.
+ */
+gboolean gegl_rectangle_is_infinite_plane (const GeglRectangle *rectangle);
+
+/**
+ * gegl_rectangle_dump:
+ * @rectangle: A GeglRectangle.
+ *
+ * For debugging purposes, not stable API.
+ */
+void     gegl_rectangle_dump              (const GeglRectangle *rectangle);
+
+
+
+
+#define GEGL_FLOAT_EPSILON            (1e-5)
+#define GEGL_FLOAT_IS_ZERO(value)     (_gegl_float_epsilon_zero ((value)))
+#define GEGL_FLOAT_EQUAL(v1, v2)      (_gegl_float_epsilon_equal ((v1), (v2)))
+
+gint        _gegl_float_epsilon_zero  (float     value);
+gint        _gegl_float_epsilon_equal (float     v1,
+                                              float     v2);
+
+
+
+G_END_DECLS
+
+#endif /* __GEGL_UTILS_H__ */
diff --git a/gegl/buffer/gegl-sampler-cubic.c b/gegl/buffer/gegl-sampler-cubic.c
index 6ea47f8e1..b67a625c8 100644
--- a/gegl/buffer/gegl-sampler-cubic.c
+++ b/gegl/buffer/gegl-sampler-cubic.c
@@ -21,7 +21,7 @@
 #include <string.h>
 #include <math.h>
 
-#include "gegl.h"
+#include "gegl-buffer.h"
 #include "gegl-buffer-formats.h"
 #include "gegl-sampler-cubic.h"
 
diff --git a/gegl/buffer/gegl-sampler-linear.c b/gegl/buffer/gegl-sampler-linear.c
index 25aa4622b..a96391bb1 100644
--- a/gegl/buffer/gegl-sampler-linear.c
+++ b/gegl/buffer/gegl-sampler-linear.c
@@ -21,7 +21,7 @@
 #include "config.h"
 #include <math.h>
 
-#include "gegl.h"
+#include "gegl-buffer.h"
 #include "gegl-buffer-formats.h"
 #include "gegl-sampler-linear.h"
 
diff --git a/gegl/buffer/gegl-sampler-lohalo.c b/gegl/buffer/gegl-sampler-lohalo.c
index 0c2f6e331..8bb31f7f3 100644
--- a/gegl/buffer/gegl-sampler-lohalo.c
+++ b/gegl/buffer/gegl-sampler-lohalo.c
@@ -114,7 +114,7 @@
 #include "config.h"
 #include <math.h>
 
-#include "gegl.h"
+#include "gegl-buffer.h"
 #include "gegl-buffer-formats.h"
 #include "gegl-sampler-lohalo.h"
 
diff --git a/gegl/buffer/gegl-sampler-nearest.c b/gegl/buffer/gegl-sampler-nearest.c
index 2f924eebd..ca29e748e 100644
--- a/gegl/buffer/gegl-sampler-nearest.c
+++ b/gegl/buffer/gegl-sampler-nearest.c
@@ -19,7 +19,7 @@
 #include <math.h>
 #include <string.h>
 
-#include "gegl.h"
+#include "gegl-buffer.h"
 #include "gegl-buffer-formats.h"
 #include "gegl-buffer-types.h"
 #include "gegl-buffer.h"
@@ -100,7 +100,7 @@ gegl_sampler_get_pixel (GeglSampler    *sampler,
 {
   GeglSamplerNearest *nearest_sampler = (GeglSamplerNearest*)(sampler);
   GeglBuffer *buffer = sampler->buffer;
-  const GeglBufferRectangle *abyss = &buffer->abyss;
+  const GeglRectangle *abyss = &buffer->abyss;
   guchar              *buf   = data;
 
   if (y <  abyss->y ||
diff --git a/gegl/buffer/gegl-sampler-nohalo.c b/gegl/buffer/gegl-sampler-nohalo.c
index e7c590333..fda400318 100644
--- a/gegl/buffer/gegl-sampler-nohalo.c
+++ b/gegl/buffer/gegl-sampler-nohalo.c
@@ -151,7 +151,7 @@
 #include "config.h"
 #include <math.h>
 
-#include "gegl.h"
+#include "gegl-buffer.h"
 #include "gegl-buffer-formats.h"
 #include "gegl-sampler-nohalo.h"
 
diff --git a/gegl/buffer/gegl-sampler.c b/gegl/buffer/gegl-sampler.c
index f4513a92a..89e7ddeb8 100644
--- a/gegl/buffer/gegl-sampler.c
+++ b/gegl/buffer/gegl-sampler.c
@@ -24,9 +24,8 @@
 #include <string.h>
 #include <math.h>
 
-#include "gegl.h"
-#include "gegl-buffer-types.h"
 #include "gegl-buffer.h"
+#include "gegl-buffer-types.h"
 #include "gegl-buffer-private.h"
 
 #include "gegl-sampler-nearest.h"
@@ -68,9 +67,9 @@ static void set_property            (GObject             *gobject,
 static void set_buffer              (GeglSampler         *self,
                                      GeglBuffer          *buffer);
 
-static void buffer_contents_changed (GeglBuffer                *buffer,
-                                     const GeglBufferRectangle *changed_rect,
-                                     gpointer                   userdata);
+static void buffer_contents_changed (GeglBuffer          *buffer,
+                                     const GeglRectangle *changed_rect,
+                                     gpointer             userdata);
 
 static void constructed (GObject *sampler);
 
@@ -127,8 +126,8 @@ gegl_sampler_init (GeglSampler *sampler)
   gint i = 0;
   sampler->buffer = NULL;
   do {
-    GeglBufferRectangle context_rect      = {0,0,1,1};
-    GeglBufferRectangle sampler_rectangle = {0,0,0,0};
+    GeglRectangle context_rect      = {0,0,1,1};
+    GeglRectangle sampler_rectangle = {0,0,0,0};
     sampler->level[i].sampler_buffer = NULL;
     sampler->level[i].context_rect   = context_rect;
     sampler->level[i].sampler_rectangle = sampler_rectangle;
@@ -163,14 +162,14 @@ gegl_sampler_get (GeglSampler       *self,
   if (self->lvel)
   {
     double factor = 1.0 / (1 << self->lvel);
-    GeglBufferRectangle rect={floorf (x * factor), floorf (y * factor),1,1};
+    GeglRectangle rect={floorf (x * factor), floorf (y * factor),1,1};
     gegl_buffer_get (self->buffer, &rect, factor, self->format, output, GEGL_AUTO_ROWSTRIDE, repeat_mode);
     return;
   }
 
   if (gegl_buffer_ext_flush)
     {
-      GeglBufferRectangle rect={x,y,1,1};
+      GeglRectangle rect={x,y,1,1};
       gegl_buffer_ext_flush (self->buffer, &rect);
     }
   self->get (self, x, y, scale, output, repeat_mode);
@@ -269,7 +268,7 @@ gegl_sampler_get_from_mipmap (GeglSampler    *sampler,
 
   if (gegl_buffer_ext_flush)
     {
-      GeglBufferRectangle rect = {x, y, 1, 1};
+      GeglRectangle rect = {x, y, 1, 1};
       gegl_buffer_ext_flush (sampler->buffer, &rect);
     }
 
@@ -431,7 +430,7 @@ _gegl_buffer_sample_at_level (GeglBuffer        *buffer,
   if (sampler_type == GEGL_SAMPLER_NEAREST &&
       level == 0)
     {
-      GeglBufferRectangle rect = {x, y, 1, 1};
+      GeglRectangle rect = {x, y, 1, 1};
       gegl_buffer_get (buffer, &rect, 1.0,
                        format, dest, GEGL_AUTO_ROWSTRIDE,
                        repeat_mode);
@@ -521,16 +520,16 @@ gegl_buffer_sampler_new (GeglBuffer      *buffer,
 }
 
 
-const GeglBufferRectangle*
+const GeglRectangle*
 gegl_sampler_get_context_rect (GeglSampler *sampler)
 {
   return &(sampler->level[0].context_rect);
 }
 
 static void
-buffer_contents_changed (GeglBuffer                *buffer,
-                         const GeglBufferRectangle *changed_rect,
-                         gpointer                   userdata)
+buffer_contents_changed (GeglBuffer          *buffer,
+                         const GeglRectangle *changed_rect,
+                         gpointer             userdata)
 {
   GeglSampler *self = GEGL_SAMPLER (userdata);
   int i;
diff --git a/gegl/buffer/gegl-sampler.h b/gegl/buffer/gegl-sampler.h
index fd691a0ac..ea86eb5ee 100644
--- a/gegl/buffer/gegl-sampler.h
+++ b/gegl/buffer/gegl-sampler.h
@@ -50,13 +50,13 @@ typedef struct _GeglSamplerClass GeglSamplerClass;
 
 typedef struct GeglSamplerLevel
 {
-  GeglBufferRectangle  context_rect;
-  gpointer             sampler_buffer;
-  GeglBufferRectangle  sampler_rectangle;
-  gint                 last_x;
-  gint                 last_y;
-  float                delta_x;
-  float                delta_y;
+  GeglRectangle  context_rect;
+  gpointer       sampler_buffer;
+  GeglRectangle  sampler_rectangle;
+  gint           last_x;
+  gint           last_y;
+  float          delta_x;
+  float          delta_y;
 } GeglSamplerLevel;
 
 struct _GeglSampler
@@ -107,13 +107,13 @@ gfloat * _gegl_sampler_get_ptr        (GeglSampler     *sampler,
                                        gint             y,
                                        GeglAbyssPolicy  repeat_mode);
 
-static inline GeglBufferRectangle _gegl_sampler_compute_rectangle (
+static inline GeglRectangle _gegl_sampler_compute_rectangle (
                                       GeglSampler *sampler,
                                       gint         x,
                                       gint         y,
                                       gint         level_no)
 {
-  GeglBufferRectangle rectangle;
+  GeglRectangle rectangle;
   GeglSamplerLevel *level = &sampler->level[level_no];
 
   rectangle.width  = level->context_rect.width + 2;
diff --git a/gegl/buffer/gegl-tile-backend-buffer.c b/gegl/buffer/gegl-tile-backend-buffer.c
index 0f64221be..2a8f67e43 100644
--- a/gegl/buffer/gegl-tile-backend-buffer.c
+++ b/gegl/buffer/gegl-tile-backend-buffer.c
@@ -304,7 +304,7 @@ gegl_tile_backend_buffer_emit_changed_signal (GeglTileBackendBuffer *tile_backen
 
   if (buffer->changed_signal_connections)
     {
-      GeglBufferRectangle rect;
+      GeglRectangle rect;
 
       rect.width  = buffer->tile_width  >> z;
       rect.height = buffer->tile_height >> z;
diff --git a/gegl/buffer/gegl-tile-backend-file-async.c b/gegl/buffer/gegl-tile-backend-file-async.c
index ae3f06d46..6d14d6347 100644
--- a/gegl/buffer/gegl-tile-backend-file-async.c
+++ b/gegl/buffer/gegl-tile-backend-file-async.c
@@ -44,7 +44,7 @@
 #include <glib/gprintf.h>
 #include <glib/gstdio.h>
 
-#include "gegl.h"
+#include "gegl-buffer.h"
 #include "gegl-buffer-backend.h"
 #include "gegl-tile-backend.h"
 #include "gegl-tile-backend-file.h"
@@ -523,7 +523,7 @@ gegl_tile_backend_file_write_header (GeglTileBackendFile *self)
 {
   GeglFileBackendThreadParams *params = g_new0 (GeglFileBackendThreadParams, 1);
   guchar *new_source = g_malloc (256);
-  GeglBufferRectangle roi = gegl_tile_backend_get_extent ((GeglTileBackend *)self);
+  GeglRectangle roi = gegl_tile_backend_get_extent ((GeglTileBackend *)self);
 
   gegl_tile_backend_file_ensure_exist (self);
 
@@ -1088,7 +1088,7 @@ gegl_tile_backend_file_load_index (GeglTileBackendFile *self,
             {
               GeglTileStorage *storage =
                 (void*)gegl_tile_backend_peek_storage (backend);
-              GeglBufferRectangle rect;
+              GeglRectangle rect;
               g_hash_table_remove (self->index, existing);
 
               gegl_tile_source_refetch (GEGL_TILE_SOURCE (storage),
@@ -1193,7 +1193,7 @@ gegl_tile_backend_file_constructed (GObject *object)
       backend->priv->tile_size   = backend->priv->tile_width *
                                     backend->priv->tile_height *
                                     backend->priv->px_size;
-      backend->priv->extent      = (GeglBufferRectangle) {self->header.x,
+      backend->priv->extent      = (GeglRectangle) {self->header.x,
                                                     self->header.y,
                                                     self->header.width,
                                                     self->header.height};
diff --git a/gegl/buffer/gegl-tile-backend-swap.c b/gegl/buffer/gegl-tile-backend-swap.c
index 94b670682..f0dce9d01 100644
--- a/gegl/buffer/gegl-tile-backend-swap.c
+++ b/gegl/buffer/gegl-tile-backend-swap.c
@@ -35,7 +35,7 @@
 #include <glib/gprintf.h>
 #include <glib/gstdio.h>
 
-#include "gegl.h"
+#include "gegl-buffer.h"
 #include "gegl-buffer-types.h"
 #include "gegl-buffer-backend.h"
 #include "gegl-buffer-private.h"
diff --git a/gegl/buffer/gegl-tile-backend.c b/gegl/buffer/gegl-tile-backend.c
index 958b84c32..03e5021a8 100644
--- a/gegl/buffer/gegl-tile-backend.c
+++ b/gegl/buffer/gegl-tile-backend.c
@@ -295,13 +295,13 @@ gegl_tile_backend_get_format (GeglTileBackend *tile_backend)
 
 
 void
-gegl_tile_backend_set_extent (GeglTileBackend           *tile_backend,
-                              const GeglBufferRectangle *rectangle)
+gegl_tile_backend_set_extent (GeglTileBackend     *tile_backend,
+                              const GeglRectangle *rectangle)
 {
   tile_backend->priv->extent = *rectangle;
 }
 
-GeglBufferRectangle
+GeglRectangle
 gegl_tile_backend_get_extent (GeglTileBackend *tile_backend)
 {
   return tile_backend->priv->extent;
diff --git a/gegl/buffer/gegl-tile-backend.h b/gegl/buffer/gegl-tile-backend.h
index 03070c14f..d82b02e57 100644
--- a/gegl/buffer/gegl-tile-backend.h
+++ b/gegl/buffer/gegl-tile-backend.h
@@ -103,14 +103,15 @@ GeglTileSource *gegl_tile_backend_peek_storage  (GeglTileBackend *tile_backend);
  * backend with the width/height information when constructing proxy
  * GeglBuffers to interact with other systems
  */
-void  gegl_tile_backend_set_extent    (GeglTileBackend           *tile_backend,
-                                       const GeglBufferRectangle *rectangle);
+void  gegl_tile_backend_set_extent    (GeglTileBackend     *tile_backend,
+                                       const GeglRectangle *rectangle);
+
 
 /**
  * gegl_tile_backend_get_extent: (skip)
  * @tile_backend: a #GeglTileBackend
  */
-GeglBufferRectangle gegl_tile_backend_get_extent (GeglTileBackend *tile_backend);
+GeglRectangle gegl_tile_backend_get_extent (GeglTileBackend *tile_backend);
 
 /**
  * gegl_tile_backend_set_flush_on_destroy:
diff --git a/gegl/buffer/gegl-tile-handler.c b/gegl/buffer/gegl-tile-handler.c
index c61f245e8..86318b869 100644
--- a/gegl/buffer/gegl-tile-handler.c
+++ b/gegl/buffer/gegl-tile-handler.c
@@ -223,8 +223,8 @@ gegl_tile_handler_dup_tile (GeglTileHandler *handler,
 }
 
 void
-gegl_tile_handler_damage_rect (GeglTileHandler           *handler,
-                               const GeglBufferRectangle *rect)
+gegl_tile_handler_damage_rect (GeglTileHandler     *handler,
+                               const GeglRectangle *rect)
 {
   GeglTileSource *source;
   gint            tile_width;
diff --git a/gegl/buffer/gegl-tile-handler.h b/gegl/buffer/gegl-tile-handler.h
index 7f0029631..72e77a05e 100644
--- a/gegl/buffer/gegl-tile-handler.h
+++ b/gegl/buffer/gegl-tile-handler.h
@@ -101,8 +101,8 @@ GeglTile * gegl_tile_handler_dup_tile    (GeglTileHandler *handler,
                                           gint             y,
                                           gint             z);
 
-void       gegl_tile_handler_damage_rect (GeglTileHandler           *handler,
-                                          const GeglBufferRectangle *rect);
+void       gegl_tile_handler_damage_rect (GeglTileHandler     *handler,
+                                          const GeglRectangle *rect);
 
 G_END_DECLS
 
diff --git a/gegl/buffer/gegl-tile.c b/gegl/buffer/gegl-tile.c
index 5d9cd0852..eeab7e73f 100644
--- a/gegl/buffer/gegl-tile.c
+++ b/gegl/buffer/gegl-tile.c
@@ -219,7 +219,7 @@ gegl_tile_unclone (GeglTile *tile)
 
               goto end;
             }
-
+          // XXX : should not use aligned calloc
           tile->n_clones     = gegl_calloc (INLINE_N_ELEMENTS_DATA_OFFSET +
                                             tile->size, 1);
         }
diff --git a/gegl/gegl-enums.c b/gegl/gegl-enums.c
index 0ba2013ac..a9a219534 100644
--- a/gegl/gegl-enums.c
+++ b/gegl/gegl-enums.c
@@ -22,63 +22,6 @@
 #include "gegl-enums.h"
 
 
-GType
-gegl_abyss_policy_get_type (void)
-{
-  static GType etype = 0;
-
-  if (etype == 0)
-    {
-      static GEnumValue values[] = {
-        { GEGL_ABYSS_NONE,  N_("None"),  "none"  },
-        { GEGL_ABYSS_CLAMP, N_("Clamp"), "clamp" },
-        { GEGL_ABYSS_LOOP,  N_("Loop"),  "loop"  },
-        { GEGL_ABYSS_BLACK, N_("Black"), "black" },
-        { GEGL_ABYSS_WHITE, N_("White"), "white" },
-        // we do not really want this one introspected/translated,
-        // will this bite us?
-        //{ GEGL_BUFFER_NEAREST, N_("Nearest"), "nearest" },
-        { 0, NULL, NULL }
-      };
-      gint i;
-
-      for (i = 0; i < G_N_ELEMENTS (values); i++)
-        if (values[i].value_name)
-          values[i].value_name =
-            dgettext (GETTEXT_PACKAGE, values[i].value_name);
-
-      etype = g_enum_register_static ("GeglAbyssPolicy", values);
-    }
-
-  return etype;
-}
-
-GType
-gegl_access_mode_get_type (void)
-{
-  static GType ftype = 0;
-
-  if (ftype == 0)
-    {
-      static GFlagsValue values[] = {
-        { GEGL_ACCESS_READ,      N_("Read"),        "read"      },
-        { GEGL_ACCESS_WRITE,     N_("Write"),       "write"     },
-        { GEGL_ACCESS_READWRITE, N_("Read/Write"), "readwrite" },
-        { 0, NULL, NULL }
-      };
-      gint i;
-
-      for (i = 0; i < G_N_ELEMENTS (values); i++)
-        if (values[i].value_name)
-          values[i].value_name =
-            dgettext (GETTEXT_PACKAGE, values[i].value_name);
-
-      ftype = g_flags_register_static ("GeglAccessMode", values);
-    }
-
-  return ftype;
-}
-
 GType
 gegl_dither_method_get_type (void)
 {
@@ -164,30 +107,3 @@ gegl_orientation_get_type (void)
   return etype;
 }
 
-GType
-gegl_sampler_type_get_type (void)
-{
-  static GType etype = 0;
-
-  if (etype == 0)
-    {
-      static GEnumValue values[] = {
-        { GEGL_SAMPLER_NEAREST, N_("Nearest"), "nearest" },
-        { GEGL_SAMPLER_LINEAR,  N_("Linear"),  "linear"  },
-        { GEGL_SAMPLER_CUBIC,   N_("Cubic"),   "cubic"   },
-        { GEGL_SAMPLER_NOHALO,  N_("NoHalo"),  "nohalo"  },
-        { GEGL_SAMPLER_LOHALO,  N_("LoHalo"),  "lohalo"  },
-        { 0, NULL, NULL }
-      };
-      gint i;
-
-      for (i = 0; i < G_N_ELEMENTS (values); i++)
-        if (values[i].value_name)
-          values[i].value_name =
-            dgettext (GETTEXT_PACKAGE, values[i].value_name);
-
-      etype = g_enum_register_static ("GeglSamplerType", values);
-    }
-
-  return etype;
-}
diff --git a/gegl/gegl-enums.h b/gegl/gegl-enums.h
index d93d4b89d..80ff8c3e5 100644
--- a/gegl/gegl-enums.h
+++ b/gegl/gegl-enums.h
@@ -36,46 +36,6 @@
 
 G_BEGIN_DECLS
 
-typedef enum {
-  /* this enum should be renamed GeglBufferFlags, since it contains
-   * multiple flags - and possibly more in the future
-   */
-
-  /* XXX: API tidying of the following would be to make them be
-   *      GEGL_BUFFER_EDGE_NONE or GEGL_BUFFER_REPEAT_NONE instead.
-  */
-  GEGL_ABYSS_NONE  = 0,
-  GEGL_ABYSS_CLAMP = 1,
-  GEGL_ABYSS_LOOP  = 2,
-  GEGL_ABYSS_BLACK = 3,
-  GEGL_ABYSS_WHITE = 4,
-
-  GEGL_BUFFER_FILTER_AUTO     = 0,
-  /* auto gives bilinear for scales <1.0 box for <2.0 and nearest above */
-  GEGL_BUFFER_FILTER_BILINEAR = 16,
-  GEGL_BUFFER_FILTER_NEAREST  = 32,
-  GEGL_BUFFER_FILTER_BOX      = 48,
-  GEGL_BUFFER_FILTER_ALL      = (GEGL_BUFFER_FILTER_BILINEAR|
-                                 GEGL_BUFFER_FILTER_NEAREST|
-                                 GEGL_BUFFER_FILTER_BOX),
-} GeglAbyssPolicy;
-
-GType gegl_abyss_policy_get_type (void) G_GNUC_CONST;
-
-#define GEGL_TYPE_ABYSS_POLICY (gegl_abyss_policy_get_type ())
-
-
-typedef enum {
-  GEGL_ACCESS_READ      = 1 << 0,
-  GEGL_ACCESS_WRITE     = 1 << 1,
-  GEGL_ACCESS_READWRITE = (GEGL_ACCESS_READ | GEGL_ACCESS_WRITE)
-} GeglAccessMode;
-
-GType gegl_access_mode_get_type (void) G_GNUC_CONST;
-
-#define GEGL_TYPE_ACCESS_MODE (gegl_access_mode_get_type ())
-
-
 typedef enum {
   GEGL_DITHER_NONE,
   GEGL_DITHER_FLOYD_STEINBERG,
@@ -112,19 +72,6 @@ GType gegl_orientation_get_type (void) G_GNUC_CONST;
 
 #define GEGL_TYPE_ORIENTATION (gegl_orientation_get_type ())
 
-
-typedef enum {
-  GEGL_SAMPLER_NEAREST,
-  GEGL_SAMPLER_LINEAR,
-  GEGL_SAMPLER_CUBIC,
-  GEGL_SAMPLER_NOHALO,
-  GEGL_SAMPLER_LOHALO
-} GeglSamplerType;
-
-GType gegl_sampler_type_get_type (void) G_GNUC_CONST;
-
-#define GEGL_TYPE_SAMPLER_TYPE (gegl_sampler_type_get_type ())
-
 G_END_DECLS
 
 #endif /* __GEGL_ENUMS_H__ */
diff --git a/gegl/gegl-types.h b/gegl/gegl-types.h
index 7d9c2ed43..f25f26bbb 100644
--- a/gegl/gegl-types.h
+++ b/gegl/gegl-types.h
@@ -61,8 +61,6 @@ GType gegl_stats_get_type (void) G_GNUC_CONST;
 #define GEGL_STATS(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEGL_TYPE_STATS, GeglStats))
 #define GEGL_IS_STATS(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEGL_TYPE_STATS))
 
-
-
 typedef struct _GeglCurve         GeglCurve;
 typedef struct _GeglPath          GeglPath;
 typedef struct _GeglColor         GeglColor;
@@ -97,34 +95,6 @@ GType gegl_random_get_type  (void) G_GNUC_CONST;
 
 #include <gegl-buffer.h>
 
-typedef struct _GeglBufferRectangle     GeglRectangle;
-
-GType gegl_rectangle_get_type (void) G_GNUC_CONST;
-#define GEGL_TYPE_RECTANGLE   (gegl_rectangle_get_type())
-
-#ifndef __cplusplus
-
-#define  GEGL_RECTANGLE(x,y,w,h) (&((GeglRectangle){(x), (y),   (w), (h)}))
-
-#else
-
-static inline GeglRectangle
-_gegl_rectangle_helper (gint x,
-                        gint y,
-                        gint width,
-                        gint height)
-{
-  GeglRectangle result = {x, y, width, height};
-
-  return result;
-}
-
-#define  GEGL_RECTANGLE(x,y,w,h) \
-  ((GeglRectangle *) &(const GeglRectangle &) ::_gegl_rectangle_helper (x, y, w, h))
-
-#endif /* __cplusplus */
-
-
 G_END_DECLS
 
 #endif /* __GEGL_TYPES_H__ */
diff --git a/gegl/gegl-utils.c b/gegl/gegl-utils.c
index 849a05541..9e241055a 100644
--- a/gegl/gegl-utils.c
+++ b/gegl/gegl-utils.c
@@ -26,348 +26,6 @@
 #include "gegl-utils.h"
 #include "gegl-types-internal.h"
 
-gint
-_gegl_float_epsilon_zero (float value)
-{
-  return value > -GEGL_FLOAT_EPSILON && value < GEGL_FLOAT_EPSILON;
-}
-
-gint
-_gegl_float_epsilon_equal (float v1, float v2)
-{
-  register float diff = v1 - v2;
-
-  return diff > -GEGL_FLOAT_EPSILON && diff < GEGL_FLOAT_EPSILON;
-}
-
-GeglRectangle *
-gegl_rectangle_new (gint           x,
-                    gint           y,
-                    guint          w,
-                    guint          h)
-{
-  GeglRectangle *r = g_new (GeglRectangle, 1);
-
-  r->x      = x;
-  r->y      = y;
-  r->width  = w;
-  r->height = h;
-
-  return r;
-}
-
-void
-gegl_rectangle_set (GeglRectangle *r,
-                    gint           x,
-                    gint           y,
-                    guint          w,
-                    guint          h)
-{
-  r->x      = x;
-  r->y      = y;
-  r->width  = w;
-  r->height = h;
-}
-
-void
-gegl_rectangle_bounding_box (GeglRectangle       *dest,
-                             const GeglRectangle *src1,
-                             const GeglRectangle *src2)
-{
-  gboolean s1_has_area = src1->width && src1->height;
-  gboolean s2_has_area = src2->width && src2->height;
-
-  if (!s1_has_area && !s2_has_area)
-    gegl_rectangle_set (dest, 0, 0, 0, 0);
-  else if (!s1_has_area)
-    gegl_rectangle_copy (dest, src2);
-  else if (!s2_has_area)
-    gegl_rectangle_copy (dest, src1);
-  else
-    {
-      gint x1 = MIN (src1->x, src2->x);
-      gint x2 = MAX (src1->x + src1->width, src2->x + src2->width);
-      gint y1 = MIN (src1->y, src2->y);
-      gint y2 = MAX (src1->y + src1->height, src2->y + src2->height);
-
-      dest->x      = x1;
-      dest->y      = y1;
-      dest->width  = x2 - x1;
-      dest->height = y2 - y1;
-    }
-}
-
-gboolean
-gegl_rectangle_intersect (GeglRectangle       *dest,
-                          const GeglRectangle *src1,
-                          const GeglRectangle *src2)
-{
-  gint x1, x2, y1, y2;
-
-  x1 = MAX (src1->x, src2->x);
-  x2 = MIN (src1->x + src1->width, src2->x + src2->width);
-
-  if (x2 <= x1)
-    {
-      if (dest)
-        gegl_rectangle_set (dest, 0, 0, 0, 0);
-      return FALSE;
-    }
-
-  y1 = MAX (src1->y, src2->y);
-  y2 = MIN (src1->y + src1->height, src2->y + src2->height);
-
-  if (y2 <= y1)
-    {
-      if (dest)
-        gegl_rectangle_set (dest, 0, 0, 0, 0);
-      return FALSE;
-    }
-
-  if (dest)
-    gegl_rectangle_set (dest, x1, y1, x2 - x1, y2 - y1);
-  return TRUE;
-}
-
-gboolean
-gegl_rectangle_subtract_bounding_box (GeglRectangle       *dest,
-                                      const GeglRectangle *minuend,
-                                      const GeglRectangle *subtrahend)
-{
-  gint mx1, mx2;
-  gint my1, my2;
-
-  gint sx1, sx2;
-  gint sy1, sy2;
-
-  mx1 = minuend->x;
-  mx2 = minuend->x + minuend->width;
-  my1 = minuend->y;
-  my2 = minuend->y + minuend->height;
-
-  sx1 = subtrahend->x;
-  sx2 = subtrahend->x + subtrahend->width;
-  sy1 = subtrahend->y;
-  sy2 = subtrahend->y + subtrahend->height;
-
-  if (sx1 <= mx1 && sx2 >= mx2)
-    {
-      if (sy1 <= my1) my1 = MAX (my1, sy2);
-      if (sy2 >= my2) my2 = MIN (my2, sy1);
-    }
-  else if (sy1 <= my1 && sy2 >= my2)
-    {
-      if (sx1 <= mx1) mx1 = MAX (mx1, sx2);
-      if (sx2 >= mx2) mx2 = MIN (mx2, sx1);
-    }
-
-  if (mx1 < mx2 && my1 < my2)
-    {
-      gegl_rectangle_set (dest, mx1, my1, mx2 - mx1, my2 - my1);
-      return TRUE;
-    }
-  else
-    {
-      gegl_rectangle_set (dest, 0, 0, 0, 0);
-      return FALSE;
-    }
-}
-
-void
-gegl_rectangle_copy (GeglRectangle       *to,
-                     const GeglRectangle *from)
-{
-  to->x      = from->x;
-  to->y      = from->y;
-  to->width  = from->width;
-  to->height = from->height;
-}
-
-gboolean
-gegl_rectangle_contains (const GeglRectangle *r,
-                         const GeglRectangle *s)
-{
-  g_return_val_if_fail (r && s, FALSE);
-
-  if (s->x >= r->x &&
-      s->y >= r->y &&
-      (s->x + s->width) <= (r->x + r->width) &&
-      (s->y + s->height) <= (r->y + r->height))
-    return TRUE;
-  else
-    return FALSE;
-}
-
-gboolean
-gegl_rectangle_equal (const GeglRectangle *r,
-                      const GeglRectangle *s)
-{
-  g_return_val_if_fail (r && s, FALSE);
-
-  if (r->x == s->x &&
-      r->y == s->y &&
-      r->width == s->width &&
-      r->height == s->height)
-    return TRUE;
-  else
-    return FALSE;
-}
-
-gboolean
-gegl_rectangle_equal_coords (const GeglRectangle *r,
-                             gint                 x,
-                             gint                 y,
-                             gint                 w,
-                             gint                 h)
-{
-  g_return_val_if_fail (r, FALSE);
-
-  if (r->x == x &&
-      r->y == y &&
-      r->width == w &&
-      r->height == h)
-    return TRUE;
-  else
-    return FALSE;
-}
-
-gboolean
-gegl_rectangle_is_empty (const GeglRectangle *r)
-{
-  g_return_val_if_fail (r != NULL, FALSE);
-  return r->width == 0 && r->height == 0;
-}
-
-GeglRectangle *
-gegl_rectangle_dup (const GeglRectangle *rectangle)
-{
-  GeglRectangle *result = g_new (GeglRectangle, 1);
-
-  *result = *rectangle;
-
-  return result;
-}
-
-GeglRectangle
-gegl_rectangle_infinite_plane (void)
-{
-  GeglRectangle infinite_plane_rect = {G_MININT / 2, G_MININT / 2, G_MAXINT, G_MAXINT};
-  return infinite_plane_rect;
-}
-
-gboolean
-gegl_rectangle_is_infinite_plane (const GeglRectangle *rectangle)
-{
-  return (rectangle->x      == G_MININT / 2 &&
-          rectangle->y      == G_MININT / 2 &&
-          rectangle->width  == G_MAXINT     &&
-          rectangle->height == G_MAXINT);
-}
-
-void
-gegl_rectangle_dump (const GeglRectangle *rectangle)
-{
-  g_print ("%d, %d, %d×%d\n",
-           rectangle->x,
-           rectangle->y,
-           rectangle->width,
-           rectangle->height);
-}
-
-GType
-gegl_rectangle_get_type (void)
-{
-  static GType our_type = 0;
-
-  if (our_type == 0)
-    our_type = g_boxed_type_register_static (g_intern_static_string ("GeglRectangle"),
-                                             (GBoxedCopyFunc) gegl_rectangle_dup,
-                                             (GBoxedFreeFunc) g_free);
-  return our_type;
-}
-
-#define GEGL_ALIGN 16
-G_STATIC_ASSERT (GEGL_ALIGN <= G_MAXUINT8);
-
-/* utility call that makes sure allocations are 16 byte aligned.
- * making RGBA float buffers have aligned access for pixels.
- */
-gpointer gegl_malloc (gsize size)
-{
-  gchar *mem;
-  gchar *ret;
-  gint   offset;
-
-  mem    = g_malloc (size + GEGL_ALIGN);
-  offset = GEGL_ALIGN - GPOINTER_TO_UINT(mem) % GEGL_ALIGN;
-  ret    = (gpointer)(mem + offset);
-
-  /* store the offset to the real malloc one byte in front of this malloc */
-  *(guint8*)(ret-1)=offset;
-  return (gpointer) ret;
-}
-
-gpointer gegl_calloc (gsize size, int n_memb)
-{
-  gchar *ret = gegl_malloc (size * n_memb);
-  memset (ret, 0, size * n_memb);
-  return ret;
-}
-
-void
-gegl_free (gpointer buf)
-{
-  g_assert (buf);
-  g_free ((gchar*)buf - *((guint8*)buf -1));
-}
-
-void
-gegl_memset_pattern (void * restrict       dst_ptr,
-                     const void * restrict src_ptr,
-                     gint                  pattern_size,
-                     gint                  count)
-{
-  guchar       *dst = dst_ptr;
-  const guchar *src = src_ptr;
-
-  /* g_assert (pattern_size > 0 && count >= 0); */
-
-  if (pattern_size == 1 || count == 0)
-    {
-      memset (dst, *src, count);
-    }
-  else
-    {
-      gsize block_size;
-      gsize remaining_size;
-
-      block_size = pattern_size,
-
-      memcpy (dst, src, block_size);
-      src  = dst;
-      dst += block_size;
-
-      remaining_size = (count - 1) * block_size;
-
-      while (block_size < remaining_size)
-        {
-          memcpy (dst, src, block_size);
-          dst += block_size;
-
-          remaining_size -= block_size;
-
-          /* limit the block size, so that we don't saturate the cache.
-           * 
-           * FIXME: optimal limit could use more benchmarking.
-           */
-          if (block_size <= 2048)
-            block_size *= 2;
-        }
-
-      memcpy (dst, src, remaining_size);
-    }
-}
-
 
 void
 gegl_buffer_set_color (GeglBuffer          *dst,
diff --git a/gegl/gegl-utils.h b/gegl/gegl-utils.h
index f9331ee43..ae7d4bc1e 100644
--- a/gegl/gegl-utils.h
+++ b/gegl/gegl-utils.h
@@ -22,250 +22,6 @@
 
 G_BEGIN_DECLS
 
-/***
- * GeglRectangle:
- *
- * GeglRectangles are used in #gegl_node_get_bounding_box and #gegl_node_blit
- * for specifying rectangles.
- *
- * </p><pre>struct GeglRectangle
- * {
- *   gint x;
- *   gint y;
- *   gint width;
- *   gint height;
- * };</pre><p>
- *
- */
-
-/**
- * gegl_rectangle_new:
- * @x: upper left x coordinate
- * @y: upper left y coordinate
- * @width: width in pixels.
- * @height: height in pixels.
- *
- * Creates a new rectangle set with the values from @x, @y, @width and @height.
- */
-GeglRectangle *gegl_rectangle_new        (gint                 x,
-                                          gint                 y,
-                                          guint                width,
-                                          guint                height);
-
-/**
- * gegl_rectangle_set:
- * @rectangle: a #GeglRectangle
- * @x: upper left x coordinate
- * @y: upper left y coordinate
- * @width: width in pixels.
- * @height: height in pixels.
- *
- * Sets the @x, @y, @width and @height on @rectangle.
- */
-void        gegl_rectangle_set           (GeglRectangle       *rectangle,
-                                          gint                 x,
-                                          gint                 y,
-                                          guint                width,
-                                          guint                height);
-
-/**
- * gegl_rectangle_equal:
- * @rectangle1: a #GeglRectangle
- * @rectangle2: a #GeglRectangle
- *
- * Check if two #GeglRectangles are equal.
- *
- * Returns TRUE if @rectangle and @rectangle2 are equal.
- */
-gboolean    gegl_rectangle_equal         (const GeglRectangle *rectangle1,
-                                          const GeglRectangle *rectangle2);
-
-/**
- * gegl_rectangle_equal_coords:
- * @rectangle: a #GeglRectangle
- * @x: X coordinate
- * @y: Y coordinate
- * @width: width of rectangle
- * @height: height of rectangle
- *
- * Check if a rectangle is equal to a set of parameters.
- *
- * Returns TRUE if @rectangle and @x,@y @width x @height are equal.
- */
-gboolean    gegl_rectangle_equal_coords  (const GeglRectangle *rectangle,
-                                          gint                 x,
-                                          gint                 y,
-                                          gint                 width,
-                                          gint                 height);
-
-/**
- * gegl_rectangle_is_empty:
- * @rectangle: a #GeglRectangle
- *
- * Check if a rectangle has zero area.
- *
- * Returns TRUE if @rectangle height and width are both zero.
- */
-gboolean    gegl_rectangle_is_empty     (const GeglRectangle *rectangle);
-
-/**
- * gegl_rectangle_dup:
- * @rectangle: the #GeglRectangle to duplicate
- *
- * Create a new copy of @rectangle.
- *
- * Return value: (transfer full): a #GeglRectangle
- */
-GeglRectangle *gegl_rectangle_dup       (const GeglRectangle *rectangle);
-
-/**
- * gegl_rectangle_copy:
- * @destination: a #GeglRectangle
- * @source: a #GeglRectangle
- *
- * Copies the rectangle information stored in @source over the information in
- * @destination.
- *
- * @destination may point to the same object as @source.
- */
-void        gegl_rectangle_copy          (GeglRectangle       *destination,
-                                          const GeglRectangle *source);
-
-/**
- * gegl_rectangle_bounding_box:
- * @destination: a #GeglRectangle
- * @source1: a #GeglRectangle
- * @source2: a #GeglRectangle
- *
- * Computes the bounding box of the rectangles @source1 and @source2 and stores the
- * resulting bounding box in @destination.
- *
- * @destination may point to the same object as @source1 or @source2.
- */
-void        gegl_rectangle_bounding_box  (GeglRectangle       *destination,
-                                          const GeglRectangle *source1,
-                                          const GeglRectangle *source2);
-
-/**
- * gegl_rectangle_intersect:
- * @dest: return location for the intersection of @src1 and @src2, or NULL.
- * @src1: a #GeglRectangle
- * @src2: a #GeglRectangle
- *
- * Calculates the intersection of two rectangles. If the rectangles do not
- * intersect, dest's width and height are set to 0 and its x and y values
- * are undefined.
- *
- * @dest may point to the same object as @src1 or @src2.
- *
- * Returns TRUE if the rectangles intersect.
- */
-gboolean    gegl_rectangle_intersect     (GeglRectangle       *dest,
-                                          const GeglRectangle *src1,
-                                          const GeglRectangle *src2);
-
-/**
- * gegl_rectangle_subtract_bounding_box:
- * @destination: a #GeglRectangle
- * @minuend: a #GeglRectangle
- * @subtrahend: a #GeglRectangle
- *
- * Computes the bounding box of the area formed by subtracting @subtrahend
- * from @minuend, and stores the result in @destination.
- *
- * @destination may point to the same object as @minuend or @subtrahend.
- *
- * Returns TRUE if the result is not empty.
- */
-gboolean
-    gegl_rectangle_subtract_bounding_box (GeglRectangle       *destination,
-                                          const GeglRectangle *minuend,
-                                          const GeglRectangle *subtrahend);
-
-/**
- * gegl_rectangle_contains:
- * @parent: a #GeglRectangle
- * @child: a #GeglRectangle
- *
- * Checks if the #GeglRectangle @child is fully contained within @parent.
- *
- * Returns TRUE if the @child is fully contained in @parent.
- */
-gboolean    gegl_rectangle_contains      (const GeglRectangle *parent,
-                                          const GeglRectangle *child);
-
-/**
- * gegl_rectangle_infinite_plane:
- *
- * Returns a GeglRectangle that represents an infininte plane.
- */
-GeglRectangle gegl_rectangle_infinite_plane (void);
-
-/**
- * gegl_rectangle_is_infinite_plane:
- * @rectangle: A GeglRectangle.
- *
- * Returns TRUE if the GeglRectangle represents an infininte plane,
- * FALSE otherwise.
- */
-gboolean gegl_rectangle_is_infinite_plane (const GeglRectangle *rectangle);
-
-/**
- * gegl_rectangle_dump:
- * @rectangle: A GeglRectangle.
- *
- * For debugging purposes, not stable API.
- */
-void     gegl_rectangle_dump              (const GeglRectangle *rectangle);
-
-
-/***
- * Aligned memory:
- *
- * GEGL provides functions to allocate and free buffers that are guaranteed to
- * be on 16 byte aligned memory addresses.
- */
-
-/**
- * gegl_malloc: (skip)
- * @n_bytes: the number of bytes to allocte.
- *
- * Allocates @n_bytes of memory. If n_bytes is 0 it returns NULL.
- *
- * Returns a pointer to the allocated memory.
- */
-gpointer gegl_malloc                  (gsize    n_bytes) G_GNUC_MALLOC;
-
-/**
- * gegl_free: (skip)
- * @mem: the memory to free.
- *
- * Frees the memory pointed to by @mem, if @mem is NULL it will warn and abort.
- */
-void     gegl_free                    (gpointer mem);
-
-/**
- * gegl_calloc: (skip)
- * @size: size of items to allocate
- * @n_memb: number of members
- *
- * allocated 0'd memory.
- */
-gpointer gegl_calloc (gsize size, int n_memb) G_GNUC_MALLOC;
-
-/**
- * gegl_memset_pattern: (skip)
- * @dst_ptr: pointer to copy to
- * @src_ptr: pointer to copy from
- * @pattern_size: the length of @src_ptr
- * @count: number of copies
- *
- * Fill @dst_ptr with @count copies of the bytes in @src_ptr.
- */
-void gegl_memset_pattern              (void *       dst_ptr,
-                                       const void * src_ptr,
-                                       gint         pattern_size,
-                                       gint         count);
 
 
 #define GEGL_FLOAT_EPSILON            (1e-5)
@@ -356,9 +112,9 @@ GeglNode *gegl_node_new_from_serialized (const gchar *chaindata,
  *
  * Sets the region covered by rect to the specified color.
  */
-void            gegl_buffer_set_color         (GeglBuffer                *buffer,
-                                               const GeglBufferRectangle *rect,
-                                               GeglColor                 *color);
+void            gegl_buffer_set_color         (GeglBuffer          *buffer,
+                                               const GeglRectangle *rect,
+                                               GeglColor           *color);
 
 
 G_END_DECLS
diff --git a/gegl/graph/gegl-cache.c b/gegl/graph/gegl-cache.c
index 035d1fdf1..aaafca55c 100644
--- a/gegl/graph/gegl-cache.c
+++ b/gegl/graph/gegl-cache.c
@@ -28,6 +28,7 @@
 #include "gegl-types-internal.h"
 #include "gegl-cache.h"
 #include "gegl-region.h"
+#include "gegl-buffer.h" /* for GeglRectangle XXX ... */
 
 enum
 {
diff --git a/gegl/graph/gegl-cache.h b/gegl/graph/gegl-cache.h
index c4a05b158..587f334ca 100644
--- a/gegl/graph/gegl-cache.h
+++ b/gegl/graph/gegl-cache.h
@@ -19,6 +19,7 @@
 #ifndef __GEGL_CACHE_H__
 #define __GEGL_CACHE_H__
 
+#include "gegl.h"
 #include "gegl-types-internal.h"
 #include "gegl-buffer.h"
 #include "gegl-buffer-private.h"



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]