[gimp/goat-invasion: 170/241] app: port the entire GimpScanConvert API to GeglBuffer



commit 2e6f4995c7a4669ece91873a714989938c6ebc45
Author: Michael Natterer <mitch gimp org>
Date:   Tue Mar 20 23:34:11 2012 +0100

    app: port the entire GimpScanConvert API to GeglBuffer

 app/core/gimpchannel-select.c        |    3 +-
 app/core/gimpdrawable-stroke.c       |   34 +++++-----
 app/core/gimpscanconvert.c           |  107 +++++++++++++++-------------------
 app/core/gimpscanconvert.h           |   10 ++--
 app/tools/gimpforegroundselecttool.c |    4 +-
 app/tools/gimpiscissorstool.c        |    2 +-
 6 files changed, 75 insertions(+), 85 deletions(-)
---
diff --git a/app/core/gimpchannel-select.c b/app/core/gimpchannel-select.c
index db26dbc..612f0f0 100644
--- a/app/core/gimpchannel-select.c
+++ b/app/core/gimpchannel-select.c
@@ -236,8 +236,9 @@ gimp_channel_select_scan_convert (GimpChannel     *channel,
   add_on = gimp_channel_new_mask (gimp_item_get_image (item),
                                   gimp_item_get_width  (item),
                                   gimp_item_get_height (item));
+
   gimp_scan_convert_render (scan_convert,
-                            gimp_drawable_get_tiles (GIMP_DRAWABLE (add_on)),
+                            gimp_drawable_get_write_buffer (GIMP_DRAWABLE (add_on)),
                             offset_x, offset_y, antialias);
 
   if (feather)
diff --git a/app/core/gimpdrawable-stroke.c b/app/core/gimpdrawable-stroke.c
index d6ed131..b30a250 100644
--- a/app/core/gimpdrawable-stroke.c
+++ b/app/core/gimpdrawable-stroke.c
@@ -284,18 +284,18 @@ gimp_drawable_stroke_scan_convert (GimpDrawable    *drawable,
                                    gboolean         do_stroke,
                                    gboolean         push_undo)
 {
-  GimpContext *context = GIMP_CONTEXT (options);
-  GimpImage   *image   = gimp_item_get_image (GIMP_ITEM (drawable));
-  TileManager *base;
-  TileManager *mask;
-  GeglBuffer  *base_buffer;
-  GeglBuffer  *mask_buffer;
-  GeglNode    *apply_opacity;
-  gint         x, y, w, h;
-  gint         bytes;
-  gint         off_x;
-  gint         off_y;
-  PixelRegion  basePR;
+  GimpContext   *context = GIMP_CONTEXT (options);
+  GimpImage     *image   = gimp_item_get_image (GIMP_ITEM (drawable));
+  TileManager   *base;
+  GeglBuffer    *base_buffer;
+  GeglBuffer    *mask_buffer;
+  GeglNode      *apply_opacity;
+  GeglRectangle  rect = { 0, };
+  gint           x, y, w, h;
+  gint           bytes;
+  gint           off_x;
+  gint           off_y;
+  PixelRegion    basePR;
 
   /*  must call gimp_channel_is_empty() instead of relying on
    *  gimp_item_mask_intersect() because the selection pretends to
@@ -342,18 +342,19 @@ gimp_drawable_stroke_scan_convert (GimpDrawable    *drawable,
                                 gimp_stroke_options_get_dash_info (stroke_options));
     }
 
-  /* fill a 1-bpp Tilemanager with black, this will describe the shape
+  /* fill a 1-bpp GeglBuffer with black, this will describe the shape
    * of the stroke.
    */
-  mask = tile_manager_new (w, h, 1);
-  mask_buffer = gimp_tile_manager_create_buffer (mask, NULL, TRUE);
+  rect.width  = w;
+  rect.height = h;
+  mask_buffer = gegl_buffer_new (&rect, babl_format ("Y u8"));
 
   gegl_buffer_clear (mask_buffer, NULL);
 
   /* render the stroke into it */
   gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
 
-  gimp_scan_convert_render (scan_convert, mask,
+  gimp_scan_convert_render (scan_convert, mask_buffer,
                             x + off_x, y + off_y,
                             gimp_fill_options_get_antialias (options));
 
@@ -411,7 +412,6 @@ gimp_drawable_stroke_scan_convert (GimpDrawable    *drawable,
                               gimp_context_get_paint_mode (context),
                               NULL, NULL, x, y);
 
-  tile_manager_unref (mask);
   tile_manager_unref (base);
 
   gimp_drawable_update (drawable, x, y, w, h);
diff --git a/app/core/gimpscanconvert.c b/app/core/gimpscanconvert.c
index 5e1b31f..ccc0927 100644
--- a/app/core/gimpscanconvert.c
+++ b/app/core/gimpscanconvert.c
@@ -28,8 +28,6 @@
 
 #include "core-types.h"
 
-#include "base/tile-manager.h"
-
 #include "gegl/gimp-gegl-utils.h"
 
 #include "gimpbezierdesc.h"
@@ -330,35 +328,35 @@ gimp_scan_convert_stroke (GimpScanConvert *sc,
 
 /**
  * gimp_scan_convert_render:
- * @sc:           a #GimpScanConvert context
- * @tile_manager: the #TileManager to render to
- * @off_x:        horizontal offset into the @tile_manager
- * @off_y:        vertical offset into the @tile_manager
- * @antialias:    whether to apply antialiasiing
+ * @sc:        a #GimpScanConvert context
+ * @bufferr:   the #GeglBuffer to render to
+ * @off_x:     horizontal offset into the @buffer
+ * @off_y:     vertical offset into the @buffer
+ * @antialias: whether to apply antialiasiing
  *
  * This is a wrapper around gimp_scan_convert_render_full() that replaces the
- * content of the @tile_manager with a rendered form of the path passed in.
+ * content of the @buffer with a rendered form of the path passed in.
  *
  * You cannot add additional polygons after this command.
  */
 void
 gimp_scan_convert_render (GimpScanConvert *sc,
-                          TileManager     *tile_manager,
+                          GeglBuffer      *buffer,
                           gint             off_x,
                           gint             off_y,
                           gboolean         antialias)
 {
-  gimp_scan_convert_render_full (sc, tile_manager, off_x, off_y,
+  gimp_scan_convert_render_full (sc, buffer, off_x, off_y,
                                  TRUE, antialias, 255);
 }
 
 /**
  * gimp_scan_convert_render_value:
- * @sc:           a #GimpScanConvert context
- * @tile_manager: the #TileManager to render to
- * @off_x:        horizontal offset into the @tile_manager
- * @off_y:        vertical offset into the @tile_manager
- * @value:        value to use for covered pixels
+ * @sc:     a #GimpScanConvert context
+ * @buffer: the #GeglBuffer to render to
+ * @off_x:  horizontal offset into the @buffer
+ * @off_y:  vertical offset into the @buffer
+ * @value:  value to use for covered pixels
  *
  * This is a wrapper around gimp_scan_convert_render_full() that
  * doesn't do antialiasing but gives control over the value that
@@ -369,93 +367,89 @@ gimp_scan_convert_render (GimpScanConvert *sc,
  */
 void
 gimp_scan_convert_render_value (GimpScanConvert *sc,
-                                TileManager     *tile_manager,
+                                GeglBuffer      *buffer,
                                 gint             off_x,
                                 gint             off_y,
                                 guchar           value)
 {
-  gimp_scan_convert_render_full (sc, tile_manager, off_x, off_y,
+  gimp_scan_convert_render_full (sc, buffer, off_x, off_y,
                                  TRUE, FALSE, value);
 }
 
 /**
  * gimp_scan_convert_compose:
- * @sc:           a #GimpScanConvert context
- * @tile_manager: the #TileManager to render to
- * @off_x:        horizontal offset into the @tile_manager
- * @off_y:        vertical offset into the @tile_manager
+ * @sc:     a #GimpScanConvert context
+ * @buffer: the #GeglBuffer to render to
+ * @off_x:  horizontal offset into the @buffer
+ * @off_y:  vertical offset into the @buffer
  *
  * This is a wrapper around of gimp_scan_convert_render_full() that composes
- * the (aliased) scan conversion on top of the content of the @tile_manager.
+ * the (aliased) scan conversion on top of the content of the @buffer.
  *
  * You cannot add additional polygons after this command.
  */
 void
 gimp_scan_convert_compose (GimpScanConvert *sc,
-                           TileManager     *tile_manager,
+                           GeglBuffer      *buffer,
                            gint             off_x,
                            gint             off_y)
 {
-  gimp_scan_convert_render_full (sc, tile_manager, off_x, off_y,
+  gimp_scan_convert_render_full (sc, buffer, off_x, off_y,
                                  FALSE, FALSE, 255);
 }
 
 /**
  * gimp_scan_convert_compose_value:
- * @sc:           a #GimpScanConvert context
- * @tile_manager: the #TileManager to render to
- * @off_x:        horizontal offset into the @tile_manager
- * @off_y:        vertical offset into the @tile_manager
- * @value:        value to use for covered pixels
+ * @sc:     a #GimpScanConvert context
+ * @buffer: the #GeglBuffer to render to
+ * @off_x:  horizontal offset into the @buffer
+ * @off_y:  vertical offset into the @buffer
+ * @value:  value to use for covered pixels
  *
  * This is a wrapper around gimp_scan_convert_render_full() that
  * composes the (aliased) scan conversion with value @value on top of the
- * content of the @tile_manager.
+ * content of the @buffer.
  *
  * You cannot add additional polygons after this command.
  */
 void
 gimp_scan_convert_compose_value (GimpScanConvert *sc,
-                                 TileManager     *tile_manager,
+                                 GeglBuffer      *buffer,
                                  gint             off_x,
                                  gint             off_y,
                                  gint             value)
 {
-  gimp_scan_convert_render_full (sc, tile_manager, off_x, off_y,
+  gimp_scan_convert_render_full (sc, buffer, off_x, off_y,
                                  FALSE, FALSE, value);
 }
 
 /**
  * gimp_scan_convert_render_full:
- * @sc:           a #GimpScanConvert context
- * @tiles:        the #TileManager to render to
- * @off_x:        horizontal offset into the @tiles
- * @off_y:        vertical offset into the @tiles
- * @replace:      if true the original content of the @tiles gets
- *                destroyed
- * @antialias:    if true the rendering happens antialiased
- * @value:        value to use for covered pixels
+ * @sc:        a #GimpScanConvert context
+ * @buffer:    the #GeglBuffer to render to
+ * @off_x:     horizontal offset into the @buffer
+ * @off_y:     vertical offset into the @buffer
+ * @replace:   if true the original content of the @buffer gets estroyed
+ * @antialias: if true the rendering happens antialiased
+ * @value:     value to use for covered pixels
  *
- * This function renders the area described by the path to the @tiles,
- * taking the offset @off_x and @off_y in the tilemanager into account.
- * The rendering can happen antialiased and be rendered on top of existing
- * content or replacing it completely. The @value specifies the opacity value
- * to be used for the objects in the @sc.
- *
- * This function expects a tile manager of depth 1.
+ * This function renders the area described by the path to the
+ * @buffer, taking the offset @off_x and @off_y in the buffer into
+ * account.  The rendering can happen antialiased and be rendered on
+ * top of existing content or replacing it completely. The @value
+ * specifies the opacity value to be used for the objects in the @sc.
  *
  * You cannot add additional polygons after this command.
  */
 void
 gimp_scan_convert_render_full (GimpScanConvert *sc,
-                               TileManager     *tiles,
+                               GeglBuffer      *buffer,
                                gint             off_x,
                                gint             off_y,
                                gboolean         replace,
                                gboolean         antialias,
                                guchar           value)
 {
-  GeglBuffer         *buffer;
   const Babl         *format;
   GeglBufferIterator *iter;
   GeglRectangle      *roi;
@@ -467,13 +461,12 @@ gimp_scan_convert_render_full (GimpScanConvert *sc,
   gint                width, height;
 
   g_return_if_fail (sc != NULL);
-  g_return_if_fail (tiles != NULL);
-  g_return_if_fail (tile_manager_bpp (tiles) == 1);
+  g_return_if_fail (GEGL_IS_BUFFER (buffer));
 
   x      = 0;
   y      = 0;
-  width  = tile_manager_width (tiles);
-  height = tile_manager_height (tiles);
+  width  = gegl_buffer_get_width  (buffer);
+  height = gegl_buffer_get_height (buffer);
 
   if (sc->clip && ! gimp_rectangle_intersect (x, y, width, height,
                                               sc->clip_x, sc->clip_y,
@@ -485,10 +478,8 @@ gimp_scan_convert_render_full (GimpScanConvert *sc,
   path.data     = (cairo_path_data_t *) sc->path_data->data;
   path.num_data = sc->path_data->len;
 
-  buffer = gimp_tile_manager_create_buffer (tiles, NULL, TRUE);
-  format = gegl_buffer_get_format (buffer);
-
-  bpp = babl_format_get_bytes_per_pixel (format);
+  format = babl_format ("Y u8");
+  bpp    = babl_format_get_bytes_per_pixel (format);
 
   iter = gegl_buffer_iterator_new (buffer, NULL, format,
                                    GEGL_BUFFER_WRITE);
@@ -598,6 +589,4 @@ gimp_scan_convert_render_full (GimpScanConvert *sc,
             }
         }
     }
-
-  g_object_unref (buffer);
 }
diff --git a/app/core/gimpscanconvert.h b/app/core/gimpscanconvert.h
index d1972da..b717ed2 100644
--- a/app/core/gimpscanconvert.h
+++ b/app/core/gimpscanconvert.h
@@ -43,7 +43,7 @@ void      gimp_scan_convert_stroke             (GimpScanConvert   *sc,
                                                 gdouble            dash_offset,
                                                 GArray            *dash_info);
 void      gimp_scan_convert_render_full        (GimpScanConvert   *sc,
-                                                TileManager       *tile_manager,
+                                                GeglBuffer        *buffer,
                                                 gint               off_x,
                                                 gint               off_y,
                                                 gboolean           replace,
@@ -51,21 +51,21 @@ void      gimp_scan_convert_render_full        (GimpScanConvert   *sc,
                                                 guchar             value);
 
 void      gimp_scan_convert_render             (GimpScanConvert   *sc,
-                                                TileManager       *tile_manager,
+                                                GeglBuffer        *buffer,
                                                 gint               off_x,
                                                 gint               off_y,
                                                 gboolean           antialias);
 void      gimp_scan_convert_render_value       (GimpScanConvert   *sc,
-                                                TileManager       *tile_manager,
+                                                GeglBuffer        *buffer,
                                                 gint               off_x,
                                                 gint               off_y,
                                                 guchar             value);
 void      gimp_scan_convert_compose            (GimpScanConvert   *sc,
-                                                TileManager       *tile_manager,
+                                                GeglBuffer        *buffer,
                                                 gint               off_x,
                                                 gint               off_y);
 void      gimp_scan_convert_compose_value      (GimpScanConvert   *sc,
-                                                TileManager       *tile_manager,
+                                                GeglBuffer        *buffer,
                                                 gint               off_x,
                                                 gint               off_y,
                                                 gint               value);
diff --git a/app/tools/gimpforegroundselecttool.c b/app/tools/gimpforegroundselecttool.c
index ec909f9..65a0b31 100644
--- a/app/tools/gimpforegroundselecttool.c
+++ b/app/tools/gimpforegroundselecttool.c
@@ -633,7 +633,7 @@ gimp_foreground_select_tool_select (GimpFreeSelectTool *free_sel,
                            "foreground-extraction", NULL);
 
   gimp_scan_convert_render_value (scan_convert,
-                                  gimp_drawable_get_tiles (GIMP_DRAWABLE (mask)),
+                                  gimp_drawable_get_write_buffer (GIMP_DRAWABLE (mask)),
                                   0, 0, 128);
   gimp_scan_convert_free (scan_convert);
 
@@ -789,7 +789,7 @@ gimp_foreground_select_tool_stroke (GimpChannel    *mask,
                             GIMP_JOIN_ROUND, GIMP_CAP_ROUND, 10.0,
                             0.0, NULL);
   gimp_scan_convert_compose_value (scan_convert,
-                             gimp_drawable_get_tiles (GIMP_DRAWABLE (mask)),
+                             gimp_drawable_get_write_buffer (GIMP_DRAWABLE (mask)),
                              0, 0, stroke->background ? 0 : 255);
   gimp_scan_convert_free (scan_convert);
 }
diff --git a/app/tools/gimpiscissorstool.c b/app/tools/gimpiscissorstool.c
index 8392fea..d6b617f 100644
--- a/app/tools/gimpiscissorstool.c
+++ b/app/tools/gimpiscissorstool.c
@@ -542,7 +542,7 @@ iscissors_convert (GimpIscissorsTool *iscissors,
                                            gimp_image_get_width  (image),
                                            gimp_image_get_height (image));
   gimp_scan_convert_render (sc,
-                            gimp_drawable_get_tiles (GIMP_DRAWABLE (iscissors->mask)),
+                            gimp_drawable_get_write_buffer (GIMP_DRAWABLE (iscissors->mask)),
                             0, 0, options->antialias);
   gimp_scan_convert_free (sc);
 }



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