[gimp] plug-ins: port screenshot cursor drawing to GEGL
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins: port screenshot cursor drawing to GEGL
- Date: Mon, 7 May 2012 23:44:43 +0000 (UTC)
commit 54bb3c4473f47f9a37e58df484a49715677cc61b
Author: Michael Natterer <mitch gimp org>
Date: Tue May 8 01:44:13 2012 +0200
plug-ins: port screenshot cursor drawing to GEGL
plug-ins/common/Makefile.am | 1 +
plug-ins/common/plugin-defs.pl | 2 +-
plug-ins/common/screenshot.c | 41 ++++++++++++++++++++++-----------------
3 files changed, 25 insertions(+), 19 deletions(-)
---
diff --git a/plug-ins/common/Makefile.am b/plug-ins/common/Makefile.am
index 151caa1..506abfa 100644
--- a/plug-ins/common/Makefile.am
+++ b/plug-ins/common/Makefile.am
@@ -2225,6 +2225,7 @@ screenshot_LDADD = \
$(libgimpcolor) \
$(libgimpbase) \
$(GTK_LIBS) \
+ $(GEGL_LIBS) \
$(SCREENSHOT_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
diff --git a/plug-ins/common/plugin-defs.pl b/plug-ins/common/plugin-defs.pl
index 369bf29..3bae369 100644
--- a/plug-ins/common/plugin-defs.pl
+++ b/plug-ins/common/plugin-defs.pl
@@ -116,7 +116,7 @@
'ripple' => { ui => 1 },
'rotate' => {},
'sample-colorize' => { ui => 1 },
- 'screenshot' => { ui => 1, optional => 1, libs => 'SCREENSHOT_LIBS', cflags => 'XFIXES_CFLAGS' },
+ 'screenshot' => { ui => 1, optional => 1, libs => 'SCREENSHOT_LIBS', cflags => 'XFIXES_CFLAGS', gegl => 1 },
'sharpen' => { ui => 1 },
'shift' => { ui => 1 },
'sinus' => { ui => 1 },
diff --git a/plug-ins/common/screenshot.c b/plug-ins/common/screenshot.c
index 0896ad0..f77e81e 100644
--- a/plug-ins/common/screenshot.c
+++ b/plug-ins/common/screenshot.c
@@ -285,6 +285,8 @@ run (const gchar *name,
INIT_I18N ();
+ gegl_init (NULL, NULL);
+
/* how are we running today? */
switch (run_mode)
{
@@ -843,12 +845,12 @@ add_cursor_image (gint32 image,
GdkDisplay *display)
{
#ifdef HAVE_XFIXES
- XFixesCursorImage *cursor;
- GimpDrawable *drawable;
- GimpPixelRgn rgn;
- gpointer pr;
- gint32 layer;
- gint32 active;
+ XFixesCursorImage *cursor;
+ GeglBuffer *buffer;
+ GeglBufferIterator *iter;
+ GeglRectangle *roi;
+ gint32 layer;
+ gint32 active;
cursor = XFixesGetCursorImage (GDK_DISPLAY_XDISPLAY (display));
@@ -861,25 +863,28 @@ add_cursor_image (gint32 image,
cursor->width, cursor->height,
GIMP_RGBA_IMAGE, 100.0, GIMP_NORMAL_MODE);
- drawable = gimp_drawable_get (layer);
+ buffer = gimp_drawable_get_buffer (layer);
- gimp_pixel_rgn_init (&rgn, drawable,
- 0, 0, drawable->width, drawable->height, TRUE, FALSE);
+ iter = gegl_buffer_iterator_new (buffer,
+ GEGL_RECTANGLE (0, 0,
+ gimp_drawable_width (layer),
+ gimp_drawable_height (layer)),
+ 0, babl_format ("R'G'B'A u8"),
+ GEGL_BUFFER_READWRITE, GEGL_ABYSS_NONE);
+ roi = &iter->roi[0];
- for (pr = gimp_pixel_rgns_register (1, &rgn);
- pr != NULL;
- pr = gimp_pixel_rgns_process (pr))
+ while (gegl_buffer_iterator_next (iter))
{
- const gulong *src = cursor->pixels + rgn.y * cursor->width + rgn.x;
- guchar *dest = rgn.data;
+ const gulong *src = cursor->pixels + roi->y * cursor->width + roi->x;
+ guchar *dest = iter->data[0];
gint x, y;
- for (y = 0; y < rgn.h; y++)
+ for (y = 0; y < roi->height; y++)
{
const gulong *s = src;
guchar *d = dest;
- for (x = 0; x < rgn.w; x++)
+ for (x = 0; x < roi->width; x++)
{
/* the cursor pixels are pre-multiplied ARGB */
guint a = (*s >> 24) & 0xff;
@@ -897,11 +902,11 @@ add_cursor_image (gint32 image,
}
src += cursor->width;
- dest += rgn.rowstride;
+ dest += 4 * roi->width;
}
}
- gimp_drawable_detach (drawable);
+ g_object_unref (buffer);
gimp_image_insert_layer (image, layer, -1, -1);
gimp_layer_set_offsets (layer,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]