[gimp/goat-invasion: 355/608] app: port paintbrush and eraser to paint to GEGL buffers
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion: 355/608] app: port paintbrush and eraser to paint to GEGL buffers
- Date: Fri, 27 Apr 2012 20:55:13 +0000 (UTC)
commit 13a1e75f5c8ea9a585efc5eb87a89e15e4a2fc94
Author: Michael Natterer <mitch gimp org>
Date: Sat Mar 31 18:33:04 2012 +0200
app: port paintbrush and eraser to paint to GEGL buffers
app/paint/gimperaser.c | 29 +++++++++++++++--------------
app/paint/gimppaintbrush.c | 42 ++++++++++++++++++++++--------------------
2 files changed, 37 insertions(+), 34 deletions(-)
---
diff --git a/app/paint/gimperaser.c b/app/paint/gimperaser.c
index 3452d4c..1f9a905 100644
--- a/app/paint/gimperaser.c
+++ b/app/paint/gimperaser.c
@@ -21,9 +21,7 @@
#include "paint-types.h"
-#include "base/temp-buf.h"
-
-#include "paint-funcs/paint-funcs.h"
+#include "gegl/gimp-gegl-utils.h"
#include "core/gimp.h"
#include "core/gimpdrawable.h"
@@ -112,8 +110,11 @@ gimp_eraser_motion (GimpPaintCore *paint_core,
GimpDynamicsOutput *force_output;
gdouble fade_point;
gdouble opacity;
- TempBuf *area;
- guchar col[MAX_CHANNELS];
+ GeglBuffer *paint_buffer;
+ gint paint_buffer_x;
+ gint paint_buffer_y;
+ GimpRGB background;
+ GeglColor *color;
gdouble force;
opacity_output = gimp_dynamics_get_output (dynamics,
@@ -130,18 +131,18 @@ gimp_eraser_motion (GimpPaintCore *paint_core,
if (opacity == 0.0)
return;
- area = gimp_paint_core_get_paint_area (paint_core, drawable, paint_options,
- coords);
- if (! 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;
- gimp_context_get_background_pixel (context,
- gimp_drawable_get_format_with_alpha (drawable),
- col);
+ gimp_context_get_background (context, &background);
+ color = gimp_gegl_color_new (&background);
- /* color the pixels */
- color_pixels (temp_buf_get_data (area), col,
- area->width * area->height, area->bytes);
+ gegl_buffer_set_color (paint_buffer, NULL, color);
+ g_object_unref (color);
force_output = gimp_dynamics_get_output (dynamics,
GIMP_DYNAMICS_OUTPUT_FORCE);
diff --git a/app/paint/gimppaintbrush.c b/app/paint/gimppaintbrush.c
index 854781f..2684892 100644
--- a/app/paint/gimppaintbrush.c
+++ b/app/paint/gimppaintbrush.c
@@ -26,9 +26,7 @@
#include "paint-types.h"
-#include "base/temp-buf.h"
-
-#include "paint-funcs/paint-funcs.h"
+#include "gegl/gimp-gegl-utils.h"
#include "core/gimp.h"
#include "core/gimpbrush.h"
@@ -118,12 +116,13 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core,
GimpDynamicsOutput *force_output;
GimpImage *image;
GimpRGB gradient_color;
- TempBuf *area;
+ GeglBuffer *paint_buffer;
+ gint paint_buffer_x;
+ gint paint_buffer_y;
GimpPaintApplicationMode paint_appl_mode;
gdouble fade_point;
gdouble grad_point;
gdouble force;
- guchar pixel[MAX_CHANNELS];
image = gimp_item_get_image (GIMP_ITEM (drawable));
@@ -140,9 +139,11 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core,
if (opacity == 0.0)
return;
- area = gimp_paint_core_get_paint_area (paint_core, drawable, paint_options,
- coords);
- if (! 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_appl_mode = paint_options->application_mode;
@@ -162,16 +163,15 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core,
{
/* optionally take the color from the current gradient */
+ GeglColor *color;
+
opacity *= gradient_color.a;
gimp_rgb_set_alpha (&gradient_color, GIMP_OPACITY_OPAQUE);
- gimp_rgba_get_pixel (&gradient_color,
- gimp_drawable_get_format_with_alpha (drawable),
- pixel);
+ color = gimp_gegl_color_new (&gradient_color);
- color_pixels (temp_buf_get_data (area), pixel,
- area->width * area->height,
- area->bytes);
+ gegl_buffer_set_color (paint_buffer, NULL, color);
+ g_object_unref (color);
paint_appl_mode = GIMP_PAINT_INCREMENTAL;
}
@@ -180,6 +180,7 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core,
/* otherwise check if the brush has a pixmap and use that to
* color the area
*/
+ TempBuf *area = gimp_gegl_buffer_get_temp_buf (paint_buffer);
gimp_brush_core_color_area_with_pixmap (brush_core, drawable,
coords,
@@ -192,13 +193,14 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core,
{
/* otherwise fill the area with the foreground color */
- gimp_context_get_foreground_pixel (context,
- gimp_drawable_get_format_with_alpha (drawable),
- pixel);
+ GimpRGB foreground;
+ GeglColor *color;
+
+ gimp_context_get_foreground (context, &foreground);
+ color = gimp_gegl_color_new (&foreground);
- color_pixels (temp_buf_get_data (area), pixel,
- area->width * area->height,
- area->bytes);
+ gegl_buffer_set_color (paint_buffer, NULL, color);
+ g_object_unref (color);
}
force_output = gimp_dynamics_get_output (dynamics,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]