[gimp/goat-invasion: 390/526] app: port GimpSourceCore and its classes to painting to the paint_buffer



commit 55c14f2173df95c812dc5ebd9712dce846ea34e4
Author: Michael Natterer <mitch gimp org>
Date:   Sun Apr 1 21:02:49 2012 +0200

    app: port GimpSourceCore and its classes to painting to the paint_buffer

 app/paint/gimpclone.c            |   22 ++++++--------
 app/paint/gimpheal.c             |   57 ++++++++++++++++++--------------------
 app/paint/gimpperspectiveclone.c |   16 ++++++----
 app/paint/gimpsourcecore.c       |   48 ++++++++++++++++++++------------
 app/paint/gimpsourcecore.h       |   10 +++++-
 5 files changed, 85 insertions(+), 68 deletions(-)
---
diff --git a/app/paint/gimpclone.c b/app/paint/gimpclone.c
index 0445180..078ae20 100644
--- a/app/paint/gimpclone.c
+++ b/app/paint/gimpclone.c
@@ -61,7 +61,9 @@ static void       gimp_clone_motion (GimpSourceCore   *source_core,
                                      GeglRectangle    *src_rect,
                                      gint              src_offset_x,
                                      gint              src_offset_y,
-                                     TempBuf          *paint_area,
+                                     GeglBuffer       *paint_buffer,
+                                     gint              paint_buffer_x,
+                                     gint              paint_buffer_y,
                                      gint              paint_area_offset_x,
                                      gint              paint_area_offset_y,
                                      gint              paint_area_width,
@@ -141,7 +143,9 @@ gimp_clone_motion (GimpSourceCore   *source_core,
                    GeglRectangle    *src_rect,
                    gint              src_offset_x,
                    gint              src_offset_y,
-                   TempBuf          *paint_area,
+                   GeglBuffer       *paint_buffer,
+                   gint              paint_buffer_x,
+                   gint              paint_buffer_y,
                    gint              paint_area_offset_x,
                    gint              paint_area_offset_y,
                    gint              paint_area_width,
@@ -153,13 +157,9 @@ gimp_clone_motion (GimpSourceCore   *source_core,
   GimpContext        *context        = GIMP_CONTEXT (paint_options);
   GimpImage          *image          = gimp_item_get_image (GIMP_ITEM (drawable));
   GimpDynamicsOutput *force_output;
-  GeglBuffer         *dest_buffer;
   gdouble             fade_point;
   gdouble             force;
 
-  dest_buffer = gimp_temp_buf_create_buffer (paint_area,
-                                             gimp_drawable_get_format_with_alpha (drawable));
-
   switch (options->clone_type)
     {
     case GIMP_IMAGE_CLONE:
@@ -169,7 +169,7 @@ gimp_clone_motion (GimpSourceCore   *source_core,
                                           src_rect->y,
                                           paint_area_width,
                                           paint_area_height),
-                          dest_buffer,
+                          paint_buffer,
                           GIMP_GEGL_RECT (paint_area_offset_x,
                                           paint_area_offset_y,
                                           0, 0));
@@ -182,14 +182,14 @@ gimp_clone_motion (GimpSourceCore   *source_core,
         GimpPattern *pattern    = gimp_context_get_pattern (context);
         GeglBuffer  *src_buffer = gimp_pattern_create_buffer (pattern);
 
-        gegl_buffer_set_pattern (dest_buffer,
+        gegl_buffer_set_pattern (paint_buffer,
                                  GIMP_GEGL_RECT (paint_area_offset_x,
                                                  paint_area_offset_y,
                                                  paint_area_width,
                                                  paint_area_height),
                                  src_buffer,
-                                 - paint_area->x - src_offset_x,
-                                 - paint_area->y - src_offset_y);
+                                 - paint_buffer_x - src_offset_x,
+                                 - paint_buffer_y - src_offset_y);
 
         /* XXX: move this to FINISH */
         g_object_unref (src_buffer);
@@ -197,8 +197,6 @@ gimp_clone_motion (GimpSourceCore   *source_core,
       break;
     }
 
-  g_object_unref (dest_buffer);
-
   force_output = gimp_dynamics_get_output (GIMP_BRUSH_CORE (paint_core)->dynamics,
                                            GIMP_DYNAMICS_OUTPUT_FORCE);
 
diff --git a/app/paint/gimpheal.c b/app/paint/gimpheal.c
index 1200fcc..39c5c66 100644
--- a/app/paint/gimpheal.c
+++ b/app/paint/gimpheal.c
@@ -26,8 +26,6 @@
 
 #include "paint-types.h"
 
-#include "paint-funcs/paint-funcs.h"
-
 #include "base/pixel-region.h"
 #include "base/temp-buf.h"
 
@@ -108,7 +106,9 @@ static void         gimp_heal_motion             (GimpSourceCore   *source_core,
                                                   GeglRectangle    *src_rect,
                                                   gint              src_offset_x,
                                                   gint              src_offset_y,
-                                                  TempBuf          *paint_area,
+                                                  GeglBuffer       *paint_buffer,
+                                                  gint              paint_buffer_x,
+                                                  gint              paint_buffer_y,
                                                   gint              paint_area_offset_x,
                                                   gint              paint_area_offset_y,
                                                   gint              paint_area_width,
@@ -447,7 +447,9 @@ gimp_heal_motion (GimpSourceCore   *source_core,
                   GeglRectangle    *src_rect,
                   gint              src_offset_x,
                   gint              src_offset_y,
-                  TempBuf          *paint_area,
+                  GeglBuffer       *paint_buffer,
+                  gint              paint_buffer_x,
+                  gint              paint_buffer_y,
                   gint              paint_area_offset_x,
                   gint              paint_area_offset_y,
                   gint              paint_area_width,
@@ -460,6 +462,7 @@ gimp_heal_motion (GimpSourceCore   *source_core,
   GimpImage          *image      = gimp_item_get_image (GIMP_ITEM (drawable));
   TempBuf            *src_temp_buf;
   TempBuf            *dest_temp_buf;
+  GeglBuffer         *dest_buffer;
   PixelRegion         srcPR;
   PixelRegion         destPR;
   const TempBuf      *mask_buf;
@@ -498,24 +501,21 @@ gimp_heal_motion (GimpSourceCore   *source_core,
     g_object_unref (tmp);
   }
 
-  {
-    GeglBuffer *tmp;
+  dest_temp_buf = temp_buf_new (gegl_buffer_get_width  (paint_buffer),
+                                gegl_buffer_get_height (paint_buffer),
+                                gimp_drawable_bytes_with_alpha (drawable),
+                                0, 0, NULL);
 
-    dest_temp_buf = temp_buf_new (paint_area->width,
-                                  paint_area->height,
-                                  gimp_drawable_bytes_with_alpha (drawable),
-                                  0, 0, NULL);
-
-    tmp = gimp_temp_buf_create_buffer (dest_temp_buf,
-                                       gimp_drawable_get_format_with_alpha (drawable));
+  dest_buffer =
+    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,
-                                      paint_area->width, paint_area->height),
-                      tmp,
-                      GIMP_GEGL_RECT (0, 0, 0, 0));
-    g_object_unref (tmp);
-  }
+  gegl_buffer_copy (gimp_drawable_get_buffer (drawable),
+                    GIMP_GEGL_RECT (paint_buffer_x, paint_buffer_y,
+                                    gegl_buffer_get_width  (paint_buffer),
+                                    gegl_buffer_get_height (paint_buffer)),
+                    dest_buffer,
+                    GIMP_GEGL_RECT (0, 0, 0, 0));
 
   /* check that srcPR, tempPR, destPR, and mask_buf are the same size */
   if (src_temp_buf->width  != dest_temp_buf->width  ||
@@ -543,16 +543,13 @@ gimp_heal_motion (GimpSourceCore   *source_core,
   /* heal destPR using srcPR */
   gimp_heal_region (&destPR, &srcPR, mask_buf);
 
-  pixel_region_init_temp_buf (&srcPR, dest_temp_buf,
-                              0, 0,
-                              mask_buf->width, mask_buf->height);
-  pixel_region_init_temp_buf (&destPR, paint_area,
-                              paint_area_offset_x,
-                              paint_area_offset_y,
-                              paint_area_width,
-                              paint_area_height);
-
-  copy_region (&srcPR, &destPR);
+  gegl_buffer_copy (dest_buffer,
+                    GIMP_GEGL_RECT (0, 0, mask_buf->width, mask_buf->height),
+                    paint_buffer,
+                    GIMP_GEGL_RECT (paint_area_offset_x,
+                                    paint_area_offset_y,
+                                    paint_area_width,
+                                    paint_area_height));
 
   /* replace the canvas with our healed data */
   gimp_brush_core_replace_canvas (GIMP_BRUSH_CORE (paint_core), drawable,
diff --git a/app/paint/gimpperspectiveclone.c b/app/paint/gimpperspectiveclone.c
index f8f6f63..37bb3d5 100644
--- a/app/paint/gimpperspectiveclone.c
+++ b/app/paint/gimpperspectiveclone.c
@@ -64,7 +64,9 @@ static GeglBuffer * gimp_perspective_clone_get_source (GimpSourceCore   *source_
                                                        GimpPickable     *src_pickable,
                                                        gint              src_offset_x,
                                                        gint              src_offset_y,
-                                                       TempBuf          *paint_area,
+                                                       GeglBuffer       *paint_buffer,
+                                                       gint              paint_buffer_x,
+                                                       gint              paint_buffer_y,
                                                        gint             *paint_area_offset_x,
                                                        gint             *paint_area_offset_y,
                                                        gint             *paint_area_width,
@@ -337,7 +339,9 @@ gimp_perspective_clone_get_source (GimpSourceCore   *source_core,
                                    GimpPickable     *src_pickable,
                                    gint              src_offset_x,
                                    gint              src_offset_y,
-                                   TempBuf          *paint_area,
+                                   GeglBuffer       *paint_buffer,
+                                   gint              paint_buffer_x,
+                                   gint              paint_buffer_y,
                                    gint             *paint_area_offset_x,
                                    gint             *paint_area_offset_y,
                                    gint             *paint_area_width,
@@ -358,10 +362,10 @@ gimp_perspective_clone_get_source (GimpSourceCore   *source_core,
   src_format_alpha = gimp_pickable_get_format_with_alpha (src_pickable);
 
   /* Destination coordinates that will be painted */
-  x1d = paint_area->x;
-  y1d = paint_area->y;
-  x2d = paint_area->x + paint_area->width;
-  y2d = paint_area->y + paint_area->height;
+  x1d = paint_buffer_x;
+  y1d = paint_buffer_y;
+  x2d = paint_buffer_x + gegl_buffer_get_width  (paint_buffer);
+  y2d = paint_buffer_y + gegl_buffer_get_height (paint_buffer);
 
   /* Boundary box for source pixels to copy: Convert all the vertex of
    * the box to paint in destination area to its correspondent in
diff --git a/app/paint/gimpsourcecore.c b/app/paint/gimpsourcecore.c
index 6fa09b7..4124d4d 100644
--- a/app/paint/gimpsourcecore.c
+++ b/app/paint/gimpsourcecore.c
@@ -85,7 +85,9 @@ static GeglBuffer *
                                                   GimpPickable     *src_pickable,
                                                   gint              src_offset_x,
                                                   gint              src_offset_y,
-                                                  TempBuf          *paint_area,
+                                                  GeglBuffer       *paint_buffer,
+                                                  gint              paint_buffer_x,
+                                                  gint              paint_buffer_y,
                                                   gint             *paint_area_offset_x,
                                                   gint             *paint_area_offset_y,
                                                   gint             *paint_area_width,
@@ -356,7 +358,9 @@ gimp_source_core_motion (GimpSourceCore   *source_core,
   GeglRectangle       src_rect;
   gint                src_offset_x;
   gint                src_offset_y;
-  TempBuf            *paint_area;
+  GeglBuffer         *paint_buffer;
+  gint                paint_buffer_x;
+  gint                paint_buffer_y;
   gint                paint_area_offset_x;
   gint                paint_area_offset_y;
   gint                paint_area_width;
@@ -401,15 +405,17 @@ gimp_source_core_motion (GimpSourceCore   *source_core,
       gimp_pickable_flush (src_pickable);
     }
 
-  paint_area = gimp_paint_core_get_paint_area (paint_core, drawable,
-                                               paint_options, coords);
-  if (! paint_area)
+  paint_buffer = gimp_paint_core_get_paint_buffer (paint_core, drawable,
+                                                   paint_options, coords,
+                                                   &paint_buffer_x,
+                                                   &paint_buffer_y);
+  if (! paint_buffer)
     return;
 
   paint_area_offset_x = 0;
   paint_area_offset_y = 0;
-  paint_area_width    = paint_area->width;
-  paint_area_height   = paint_area->height;
+  paint_area_width    = gegl_buffer_get_width  (paint_buffer);
+  paint_area_height   = gegl_buffer_get_height (paint_buffer);
 
   if (options->use_source)
     {
@@ -420,7 +426,9 @@ gimp_source_core_motion (GimpSourceCore   *source_core,
                                                               src_pickable,
                                                               src_offset_x,
                                                               src_offset_y,
-                                                              paint_area,
+                                                              paint_buffer,
+                                                              paint_buffer_x,
+                                                              paint_buffer_y,
                                                               &paint_area_offset_x,
                                                               &paint_area_offset_y,
                                                               &paint_area_width,
@@ -430,8 +438,8 @@ gimp_source_core_motion (GimpSourceCore   *source_core,
         return;
     }
 
-  /*  Set the paint area to transparent  */
-  temp_buf_data_clear (paint_area);
+  /*  Set the paint buffer to transparent  */
+  gegl_buffer_clear (paint_buffer, NULL);
 
   GIMP_SOURCE_CORE_GET_CLASS (source_core)->motion (source_core,
                                                     drawable,
@@ -443,7 +451,9 @@ gimp_source_core_motion (GimpSourceCore   *source_core,
                                                     &src_rect,
                                                     src_offset_x,
                                                     src_offset_y,
-                                                    paint_area,
+                                                    paint_buffer,
+                                                    paint_buffer_x,
+                                                    paint_buffer_y,
                                                     paint_area_offset_x,
                                                     paint_area_offset_y,
                                                     paint_area_width,
@@ -460,7 +470,9 @@ gimp_source_core_real_get_source (GimpSourceCore   *source_core,
                                   GimpPickable     *src_pickable,
                                   gint              src_offset_x,
                                   gint              src_offset_y,
-                                  TempBuf          *paint_area,
+                                  GeglBuffer       *paint_buffer,
+                                  gint              paint_buffer_x,
+                                  gint              paint_buffer_y,
                                   gint             *paint_area_offset_x,
                                   gint             *paint_area_offset_y,
                                   gint             *paint_area_width,
@@ -475,10 +487,10 @@ gimp_source_core_real_get_source (GimpSourceCore   *source_core,
   gint               x, y;
   gint               width, height;
 
-  if (! gimp_rectangle_intersect (paint_area->x + src_offset_x,
-                                  paint_area->y + src_offset_y,
-                                  paint_area->width,
-                                  paint_area->height,
+  if (! gimp_rectangle_intersect (paint_buffer_x + src_offset_x,
+                                  paint_buffer_y + src_offset_y,
+                                  gegl_buffer_get_width  (paint_buffer),
+                                  gegl_buffer_get_height (paint_buffer),
                                   0, 0,
                                   gegl_buffer_get_width  (src_buffer),
                                   gegl_buffer_get_height (src_buffer),
@@ -508,8 +520,8 @@ gimp_source_core_real_get_source (GimpSourceCore   *source_core,
         dest_buffer = gimp_paint_core_get_orig_image (GIMP_PAINT_CORE (source_core));
     }
 
-  *paint_area_offset_x = x - (paint_area->x + src_offset_x);
-  *paint_area_offset_y = y - (paint_area->y + src_offset_y);
+  *paint_area_offset_x = x - (paint_buffer_x + src_offset_x);
+  *paint_area_offset_y = y - (paint_buffer_y + src_offset_y);
   *paint_area_width    = width;
   *paint_area_height   = height;
 
diff --git a/app/paint/gimpsourcecore.h b/app/paint/gimpsourcecore.h
index e581b70..059dd98 100644
--- a/app/paint/gimpsourcecore.h
+++ b/app/paint/gimpsourcecore.h
@@ -60,7 +60,10 @@ struct _GimpSourceCoreClass
                                GimpPickable     *src_pickable,
                                gint              src_offset_x,
                                gint              src_offset_y,
-                               TempBuf          *paint_area,
+                               GeglBuffer       *paint_buffer,
+                               gint              paint_buffer_x,
+                               gint              paint_buffer_y,
+                               /* offsets *into* the paint_buffer: */
                                gint             *paint_area_offset_x,
                                gint             *paint_area_offset_y,
                                gint             *paint_area_width,
@@ -77,7 +80,10 @@ struct _GimpSourceCoreClass
                                GeglRectangle    *src_rect,
                                gint              src_offset_x,
                                gint              src_offset_y,
-                               TempBuf          *paint_area,
+                               GeglBuffer       *paint_buffer,
+                               gint              paint_buffer_x,
+                               gint              paint_buffer_y,
+                               /* offsets *into* the paint_buffer: */
                                gint              paint_area_offset_x,
                                gint              paint_area_offset_y,
                                gint              paint_area_width,



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