From 8c72ad9bd733534e9d04c9864480ef3dd80dfd51 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Mon, 19 Nov 2012 00:10:17 +0100 Subject: [PATCH] plug-ins: port file-psp to GEGL --- plug-ins/common/Makefile.am | 1 + plug-ins/common/file-psp.c | 36 ++++++++++++++++------------------ plug-ins/common/plugin-defs.pl | 2 +- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/plug-ins/common/Makefile.am b/plug-ins/common/Makefile.am index bd510f6e0a..17fad500df 100644 --- a/plug-ins/common/Makefile.am +++ b/plug-ins/common/Makefile.am @@ -1390,6 +1390,7 @@ file_psp_LDADD = \ $(libgimpcolor) \ $(libgimpbase) \ $(GTK_LIBS) \ + $(GEGL_LIBS) \ $(Z_LIBS) \ $(RT_LIBS) \ $(INTLLIBS) \ diff --git a/plug-ins/common/file-psp.c b/plug-ins/common/file-psp.c index 5c8982a75a..9b0af768db 100644 --- a/plug-ins/common/file-psp.c +++ b/plug-ins/common/file-psp.c @@ -1131,15 +1131,17 @@ psp_zfree (void *opaque, } static int -read_channel_data (FILE *f, - PSPimage *ia, - guchar **pixels, - guint bytespp, - guint offset, - GimpDrawable *drawable, - guint32 compressed_len) +read_channel_data (FILE *f, + PSPimage *ia, + guchar **pixels, + guint bytespp, + guint offset, + GeglBuffer *buffer, + guint32 compressed_len) { - gint i, y, width = drawable->width, height = drawable->height; + gint i, y; + gint width = gegl_buffer_get_width (buffer); + gint height = gegl_buffer_get_height (buffer); gint npixels = width * height; guchar *buf; guchar *buf2 = NULL; /* please the compiler */ @@ -1300,8 +1302,7 @@ read_layer_block (FILE *f, guint16 bitmap_type, channel_type; gint width, height, bytespp, offset; guchar **pixels, *pixel; - GimpDrawable *drawable; - GimpPixelRgn pixel_rgn; + GeglBuffer *buffer; block_start = ftell (f); @@ -1494,11 +1495,7 @@ read_layer_block (FILE *f, pixels[i] = pixel + width * bytespp * i; } - drawable = gimp_drawable_get (layer_ID); - gimp_pixel_rgn_init (&pixel_rgn, drawable, 0, 0, - width, height, TRUE, FALSE); - - gimp_tile_cache_size (gimp_tile_height () * width * bytespp); + buffer = gimp_drawable_get_buffer (layer_ID); /* Read the layer channel sub-blocks */ while (ftell (f) < sub_block_start + sub_total_len) @@ -1570,7 +1567,7 @@ read_layer_block (FILE *f, if (!null_layer) if (read_channel_data (f, ia, pixels, bytespp, - offset, drawable, compressed_len) == -1) + offset, buffer, compressed_len) == -1) { return -1; } @@ -1581,10 +1578,10 @@ read_layer_block (FILE *f, } } - gimp_pixel_rgn_set_rect (&pixel_rgn, pixel, 0, 0, width, height); + gegl_buffer_set (buffer, GEGL_RECTANGLE (0, 0, width, height), 0, + NULL, pixel, GEGL_AUTO_ROWSTRIDE); - gimp_drawable_flush (drawable); - gimp_drawable_detach (drawable); + g_object_unref (buffer); g_free (pixels); g_free (pixel); @@ -1913,6 +1910,7 @@ run (const gchar *name, GError *error = NULL; INIT_I18N (); + gegl_init (NULL, NULL); run_mode = param[0].data.d_int32; diff --git a/plug-ins/common/plugin-defs.pl b/plug-ins/common/plugin-defs.pl index a687697b84..7aaebc8a15 100644 --- a/plug-ins/common/plugin-defs.pl +++ b/plug-ins/common/plugin-defs.pl @@ -67,7 +67,7 @@ 'file-pdf-load' => { ui => 1, optional => 1, libs => 'POPPLER_LIBS', cflags => 'POPPLER_CFLAGS' }, 'file-pdf-save' => { ui => 1, optional => 1, libs => 'CAIRO_PDF_LIBS', cflags => 'CAIRO_PDF_CFLAGS' }, 'file-ps' => { ui => 1, optional => 1, libs => 'GS_LIBS' }, - 'file-psp' => { ui => 1, optional => 1, libs => 'Z_LIBS' }, + 'file-psp' => { ui => 1, gegl => 1, optional => 1, libs => 'Z_LIBS' }, 'file-raw' => { ui => 1 }, 'file-sunras' => { ui => 1 }, 'file-svg' => { ui => 1, optional => 1, libs => 'SVG_LIBS', cflags => 'SVG_CFLAGS' },