[gimp/goat-invasion: 349/608] app: use gimp_temp_buf_create_buffer() all over the place



commit e44dc3d1ba4658651a0dd50b1ef68f011e07c646
Author: Michael Natterer <mitch gimp org>
Date:   Sat Mar 31 16:19:46 2012 +0200

    app: use gimp_temp_buf_create_buffer() all over the place
    
    instead of creating linear buffers manually.

 app/core/gimpbrush-boundary.c |   14 +++++---------
 app/core/gimpbrushclipboard.c |   15 +++------------
 app/core/gimppattern.c        |   12 +-----------
 app/paint/gimpclone.c         |   11 ++---------
 app/paint/gimpheal.c          |   22 ++++------------------
 5 files changed, 15 insertions(+), 59 deletions(-)
---
diff --git a/app/core/gimpbrush-boundary.c b/app/core/gimpbrush-boundary.c
index 8d4c465..0ad883f 100644
--- a/app/core/gimpbrush-boundary.c
+++ b/app/core/gimpbrush-boundary.c
@@ -22,8 +22,6 @@
 
 #include "core-types.h"
 
-#include "base/temp-buf.h"
-
 #include "gegl/gimp-gegl-utils.h"
 
 #include "gimpbezierdesc.h"
@@ -50,16 +48,14 @@ gimp_brush_transform_boundary_exact (GimpBrush *brush,
       GimpBoundSeg  *bound_segs;
       gint           n_bound_segs;
 
-      buffer = gegl_buffer_linear_new_from_data (mask->data,
-                                                 babl_format ("Y u8"),
-                                                 GIMP_GEGL_RECT (0,0,mask->width,
-                                                                     mask->height),
-                                                 GEGL_AUTO_ROWSTRIDE,
-                                                 NULL, NULL);
+      buffer = gimp_temp_buf_create_buffer ((TempBuf *) mask,
+                                            babl_format ("Y u8"));
 
       bound_segs = gimp_boundary_find (buffer, NULL,
                                        GIMP_BOUNDARY_WITHIN_BOUNDS,
-                                       0, 0, mask->width, mask->height,
+                                       0, 0,
+                                       gegl_buffer_get_width  (buffer),
+                                       gegl_buffer_get_height (buffer),
                                        0,
                                        &n_bound_segs);
 
diff --git a/app/core/gimpbrushclipboard.c b/app/core/gimpbrushclipboard.c
index 21c8208..2487869 100644
--- a/app/core/gimpbrushclipboard.c
+++ b/app/core/gimpbrushclipboard.c
@@ -213,12 +213,8 @@ gimp_brush_clipboard_buffer_changed (Gimp      *gimp,
       /*  copy the alpha channel into the brush's mask  */
       if (GIMP_IMAGE_TYPE_HAS_ALPHA (type))
         {
-          dest_buffer =
-            gegl_buffer_linear_new_from_data (temp_buf_get_data (brush->mask),
-                                              babl_format ("A u8"),
-                                              &rect,
-                                              width * brush->mask->bytes,
-                                              NULL, NULL);
+          dest_buffer = gimp_temp_buf_create_buffer (brush->mask,
+                                                     babl_format ("A u8"));
 
           gegl_buffer_copy (buffer, NULL, dest_buffer, NULL);
 
@@ -231,12 +227,7 @@ gimp_brush_clipboard_buffer_changed (Gimp      *gimp,
         }
 
       /*  copy the color channels into the brush's pixmap  */
-      dest_buffer =
-        gegl_buffer_linear_new_from_data (temp_buf_get_data (brush->pixmap),
-                                          babl_format ("R'G'B' u8"),
-                                          &rect,
-                                          width * brush->pixmap->bytes,
-                                          NULL, NULL);
+      dest_buffer = gimp_temp_buf_create_buffer (brush->pixmap, NULL);
 
       gegl_buffer_copy (buffer, NULL, dest_buffer, NULL);
 
diff --git a/app/core/gimppattern.c b/app/core/gimppattern.c
index a54fa42..d53c93b 100644
--- a/app/core/gimppattern.c
+++ b/app/core/gimppattern.c
@@ -269,17 +269,7 @@ gimp_pattern_get_mask (const GimpPattern *pattern)
 GeglBuffer *
 gimp_pattern_create_buffer (const GimpPattern *pattern)
 {
-  gint width, height, bytes;
-
   g_return_val_if_fail (GIMP_IS_PATTERN (pattern), NULL);
 
-  width = pattern->mask->width;
-  height = pattern->mask->height;
-  bytes = pattern->mask->bytes;
-
-  return gegl_buffer_linear_new_from_data (temp_buf_get_data (pattern->mask),
-                                           gimp_bpp_to_babl_format (bytes),
-                                           GIMP_GEGL_RECT(0,0,width,height),
-                                           width * bytes,
-                                           NULL, NULL);
+  return gimp_temp_buf_create_buffer (pattern->mask, NULL);
 }
diff --git a/app/paint/gimpclone.c b/app/paint/gimpclone.c
index 8b7ad9f..0445180 100644
--- a/app/paint/gimpclone.c
+++ b/app/paint/gimpclone.c
@@ -157,15 +157,8 @@ gimp_clone_motion (GimpSourceCore   *source_core,
   gdouble             fade_point;
   gdouble             force;
 
-  dest_buffer =
-    gegl_buffer_linear_new_from_data (temp_buf_get_data (paint_area),
-                                      gimp_drawable_get_format_with_alpha (drawable),
-                                      GIMP_GEGL_RECT (0, 0,
-                                                      paint_area->width,
-                                                      paint_area->height),
-                                      paint_area->width *
-                                      paint_area->bytes,
-                                      NULL, NULL);
+  dest_buffer = gimp_temp_buf_create_buffer (paint_area,
+                                             gimp_drawable_get_format_with_alpha (drawable));
 
   switch (options->clone_type)
     {
diff --git a/app/paint/gimpheal.c b/app/paint/gimpheal.c
index 07a6e9b..38b0c94 100644
--- a/app/paint/gimpheal.c
+++ b/app/paint/gimpheal.c
@@ -490,15 +490,8 @@ gimp_heal_motion (GimpSourceCore   *source_core,
                                  gimp_drawable_bytes_with_alpha (drawable),
                                  0, 0, NULL);
 
-    tmp =
-      gegl_buffer_linear_new_from_data (temp_buf_get_data (src_temp_buf),
-                                        gimp_drawable_get_format_with_alpha (drawable),
-                                        GIMP_GEGL_RECT (0, 0,
-                                                        src_temp_buf->width,
-                                                        src_temp_buf->height),
-                                        src_temp_buf->width *
-                                        src_temp_buf->bytes,
-                                        NULL, NULL);
+    tmp = gimp_temp_buf_create_buffer (src_temp_buf,
+                                       gimp_drawable_get_format_with_alpha (drawable));
 
     gegl_buffer_copy (src_buffer, src_rect,
                       tmp, GIMP_GEGL_RECT (0, 0, 0, 0));
@@ -513,15 +506,8 @@ gimp_heal_motion (GimpSourceCore   *source_core,
                                   gimp_drawable_bytes_with_alpha (drawable),
                                   0, 0, NULL);
 
-    tmp =
-      gegl_buffer_linear_new_from_data (temp_buf_get_data (dest_temp_buf),
-                                        gimp_drawable_get_format_with_alpha (drawable),
-                                        GIMP_GEGL_RECT (0, 0,
-                                                        dest_temp_buf->width,
-                                                        dest_temp_buf->height),
-                                        dest_temp_buf->width *
-                                        dest_temp_buf->bytes,
-                                        NULL, NULL);
+    tmp = gimp_temp_buf_create_buffer (dest_temp_buf,
+                                       gimp_drawable_get_format_with_alpha (drawable));
 
     gegl_buffer_copy (gimp_drawable_get_buffer (drawable),
                       GIMP_GEGL_RECT (paint_area->x, paint_area->y,



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