[gimp] app: actually commit the rest of the patch...



commit e254fd7c4d5df6071bde5dd30ea42ba3ff51a7cb
Author: Michael Natterer <mitch gimp org>
Date:   Sat May 26 12:42:52 2012 +0200

    app: actually commit the rest of the patch...

 app/gegl/Makefile.am       |    2 +
 app/gegl/gimp-gegl-types.h |    3 ++
 app/paint/gimppaintcore.c  |   54 ++++++++++++++++++++++++++++++++++++-------
 app/paint/gimppaintcore.h  |    2 +
 4 files changed, 52 insertions(+), 9 deletions(-)
---
diff --git a/app/gegl/Makefile.am b/app/gegl/Makefile.am
index 329bae9..00f1bad 100644
--- a/app/gegl/Makefile.am
+++ b/app/gegl/Makefile.am
@@ -34,6 +34,8 @@ libappgegl_a_sources = \
 	gimp-gegl-tile-compat.h		\
 	gimp-gegl-utils.c		\
 	gimp-gegl-utils.h		\
+	gimpapplicator.c		\
+	gimpapplicator.h		\
 	gimptilebackendtilemanager.c	\
 	gimptilebackendtilemanager.h
 
diff --git a/app/gegl/gimp-gegl-types.h b/app/gegl/gimp-gegl-types.h
index 24f7ab1..f49b6c4 100644
--- a/app/gegl/gimp-gegl-types.h
+++ b/app/gegl/gimp-gegl-types.h
@@ -28,4 +28,7 @@
 #include "operations/operations-types.h"
 
 
+typedef struct _GimpApplicator GimpApplicator;
+
+
 #endif /* __GIMP_GEGL_TYPES_H__ */
diff --git a/app/paint/gimppaintcore.c b/app/paint/gimppaintcore.c
index 05fcbaa..839f6bb 100644
--- a/app/paint/gimppaintcore.c
+++ b/app/paint/gimppaintcore.c
@@ -27,12 +27,14 @@
 #include "paint-types.h"
 
 #include "gegl/gimp-gegl-loops.h"
+#include "gegl/gimp-gegl-nodes.h"
 #include "gegl/gimp-gegl-utils.h"
+#include "gegl/gimpapplicator.h"
 
 #include "core/gimp.h"
 #include "core/gimp-apply-operation.h"
 #include "core/gimp-utils.h"
-#include "core/gimpdrawable.h"
+#include "core/gimpchannel.h"
 #include "core/gimpimage.h"
 #include "core/gimpimage-undo.h"
 #include "core/gimppickable.h"
@@ -396,6 +398,34 @@ gimp_paint_core_start (GimpPaintCore     *core,
   core->last_paint.x = -1e6;
   core->last_paint.y = -1e6;
 
+  {
+    GimpImage   *image;
+    GimpChannel *mask;
+    GeglBuffer  *mask_buffer = NULL;
+    gint         offset_x    = 0;
+    gint         offset_y    = 0;
+
+    image = gimp_item_get_image (item);
+    mask  = gimp_image_get_mask (image);
+
+    /*  don't apply the mask to itself and don't apply an empty mask  */
+    if (GIMP_DRAWABLE (mask) == drawable || gimp_channel_is_empty (mask))
+      mask = NULL;
+
+    if (mask)
+      {
+        mask_buffer = gimp_drawable_get_buffer (GIMP_DRAWABLE (mask));
+
+        gimp_item_get_offset (item, &offset_x, &offset_y);
+      }
+
+    core->applicator =
+      gimp_applicator_new (gimp_drawable_get_buffer (drawable),
+                           gimp_drawable_get_active_mask (drawable),
+                           mask_buffer,
+                           -offset_x, -offset_y);
+  }
+
   /*  Freeze the drawable preview so that it isn't constantly updated.  */
   gimp_viewable_preview_freeze (GIMP_VIEWABLE (drawable));
 
@@ -413,6 +443,12 @@ gimp_paint_core_finish (GimpPaintCore *core,
   g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
   g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
 
+  if (core->applicator)
+    {
+      g_object_unref (core->applicator);
+      core->applicator = NULL;
+    }
+
   if (core->stroke_buffer)
     {
       g_array_free (core->stroke_buffer, TRUE);
@@ -750,17 +786,17 @@ gimp_paint_core_paste (GimpPaintCore            *core,
                             core->paint_buffer,
                             GEGL_RECTANGLE (0, 0, width, height),
                             paint_opacity);
+
+      base_buffer = gimp_drawable_get_buffer (drawable);
     }
 
   /*  apply the paint area to the image  */
-  gimp_drawable_apply_buffer (drawable,
-                              core->paint_buffer,
-                              GEGL_RECTANGLE (0, 0, width, height),
-                              FALSE, NULL,
-                              image_opacity, paint_mode,
-                              base_buffer, /*  specify an alternative src1  */
-                              core->paint_buffer_x,
-                              core->paint_buffer_y);
+  gimp_applicator_apply (core->applicator,
+                         base_buffer,
+                         core->paint_buffer,
+                         core->paint_buffer_x,
+                         core->paint_buffer_y,
+                         image_opacity, paint_mode);
 
   /*  Update the undo extents  */
   core->x1 = MIN (core->x1, core->paint_buffer_x);
diff --git a/app/paint/gimppaintcore.h b/app/paint/gimppaintcore.h
index ebd11c5..1fd4fea 100644
--- a/app/paint/gimppaintcore.h
+++ b/app/paint/gimppaintcore.h
@@ -64,6 +64,8 @@ struct _GimpPaintCore
   gint         paint_buffer_y;
 
   GArray      *stroke_buffer;
+
+  GimpApplicator *applicator;
 };
 
 struct _GimpPaintCoreClass



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