slight speedup for 180-degrees

2000-06-18  Sven Neumann  <sven@gimp.org>

	* plug-ins/common/rotate.c: slight speedup for 180-degrees
This commit is contained in:
Sven Neumann 2000-06-18 12:26:44 +00:00 committed by Sven Neumann
parent 552c8da0ea
commit e544a24cbd
2 changed files with 61 additions and 63 deletions

View File

@ -1,3 +1,7 @@
2000-06-18 Sven Neumann <sven@gimp.org>
* plug-ins/common/rotate.c: slight speedup for 180-degrees
2000-05-20 Nick Lamb <njl195@zepler.org.uk> 2000-05-20 Nick Lamb <njl195@zepler.org.uk>
* devel-docs/parasites.txt * devel-docs/parasites.txt

View File

@ -1,20 +1,10 @@
/*
* Rotate plug-in v0.9
* by Sven Neumann <sven@gimp.org> and Adam D. Moss <adam@gimp.org>
*
* Any suggestions, bug-reports or patches are very welcome.
*
* A lot of changes in version 0.3 were inspired by (or even simply
* copied from) the similar rotators-plug-in by Adam D. Moss.
*
* As I still prefer my version I have not stopped developing it.
* Probably this will result in one plug-in that includes the advantages
* of both approaches.
*/
/* The GIMP -- an image manipulation program /* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis * Copyright (C) 1995 Spencer Kimball and Peter Mattis
* *
* Rotate plug-in v1.0
* Copyright 1997-2000 by Sven Neumann <sven@gimp.org>
* & Adam D. Moss <adam@gimp.org>
*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
@ -44,6 +34,8 @@
* (10/09/99) v0.8 rotate guides too * (10/09/99) v0.8 rotate guides too
* (11/13/99) v0.9 merge rotators and rotate plug-ins * (11/13/99) v0.9 merge rotators and rotate plug-ins
* -> drop the dialog, register directly into menus instead * -> drop the dialog, register directly into menus instead
* (06/18/00) v1.0 speed up 180° rotations,
* declare version 1.0 for gimp-1.2 release
*/ */
/* TODO List /* TODO List
@ -64,7 +56,7 @@
/* Defines */ /* Defines */
#define PLUG_IN_VERSION "v0.9 (1999/11/13)" #define PLUG_IN_VERSION "v1.0 (2000/06/18)"
#define PLUG_IN_IMAGE_TYPES "RGB*, INDEXED*, GRAY*" #define PLUG_IN_IMAGE_TYPES "RGB*, INDEXED*, GRAY*"
#define PLUG_IN_AUTHOR "Sven Neumann <sven@gimp.org>, Adam D. Moss <adam@gimp.org>" #define PLUG_IN_AUTHOR "Sven Neumann <sven@gimp.org>, Adam D. Moss <adam@gimp.org>"
#define PLUG_IN_COPYRIGHT "Sven Neumann, Adam D. Moss" #define PLUG_IN_COPYRIGHT "Sven Neumann, Adam D. Moss"
@ -91,23 +83,23 @@ static RotateValues rotvals =
static void query (void); static void query (void);
static void run (gchar *name, static void run (gchar *name,
gint nparams, gint nparams,
GParam *param, GimpParam *param,
gint *nreturn_vals, gint *nreturn_vals,
GParam **return_vals); GimpParam **return_vals);
static void rotate (void); static void rotate (void);
static void rotate_drawable (GDrawable *drawable); static void rotate_drawable (GimpDrawable *drawable);
static void rotate_compute_offsets (gint *offsetx, static void rotate_compute_offsets (gint *offsetx,
gint *offsety, gint *offsety,
gint image_width, gint image_width,
gint image_height, gint image_height,
gint width, gint width,
gint height); gint height);
/* Global Variables */ /* Global Variables */
GPlugInInfo PLUG_IN_INFO = GimpPlugInInfo PLUG_IN_INFO =
{ {
NULL, /* init_proc */ NULL, /* init_proc */
NULL, /* quit_proc */ NULL, /* quit_proc */
@ -116,8 +108,8 @@ GPlugInInfo PLUG_IN_INFO =
}; };
/* the image and drawable that will be used later */ /* the image and drawable that will be used later */
static GDrawable *active_drawable = NULL; static GimpDrawable *active_drawable = NULL;
static gint32 image_ID = -1; static gint32 image_ID = -1;
/* Functions */ /* Functions */
@ -126,7 +118,7 @@ MAIN ()
static void static void
query (void) query (void)
{ {
static GParamDef args[] = static GimpParamDef args[] =
{ {
{ PARAM_INT32, "run_mode", "Interactive, non-interactive"}, { PARAM_INT32, "run_mode", "Interactive, non-interactive"},
{ PARAM_IMAGE, "image", "Input image" }, { PARAM_IMAGE, "image", "Input image" },
@ -136,7 +128,7 @@ query (void)
}; };
static gint nargs = sizeof (args) / sizeof (args[0]); static gint nargs = sizeof (args) / sizeof (args[0]);
static GParamDef menuargs[] = static GimpParamDef menuargs[] =
{ {
{ PARAM_INT32, "run_mode", "Interactive, non-interactive" }, { PARAM_INT32, "run_mode", "Interactive, non-interactive" },
{ PARAM_IMAGE, "image", "Input image" }, { PARAM_IMAGE, "image", "Input image" },
@ -229,21 +221,21 @@ query (void)
} }
static void static void
run (gchar *name, run (gchar *name,
gint nparams, gint nparams,
GParam *param, GimpParam *param,
gint *nreturn_vals, gint *nreturn_vals,
GParam **return_vals) GimpParam **return_vals)
{ {
/* Get the runmode from the in-parameters */ /* Get the runmode from the in-parameters */
GRunModeType run_mode = param[0].data.d_int32; GimpRunModeType run_mode = param[0].data.d_int32;
/* status variable, use it to check for errors in invocation usualy only /* status variable, use it to check for errors in invocation usualy only
during non-interactive calling */ during non-interactive calling */
GStatusType status = STATUS_SUCCESS; GimpPDBStatusType status = STATUS_SUCCESS;
/*always return at least the status to the caller. */ /*always return at least the status to the caller. */
static GParam values[1]; static GimpParam values[1];
/* initialize the return of the status */ /* initialize the return of the status */
values[0].type = PARAM_STATUS; values[0].type = PARAM_STATUS;
@ -251,7 +243,7 @@ run (gchar *name,
*nreturn_vals = 1; *nreturn_vals = 1;
*return_vals = values; *return_vals = values;
INIT_I18N(); INIT_I18N ();
/* get image and drawable */ /* get image and drawable */
image_ID = param[1].data.d_int32; image_ID = param[1].data.d_int32;
@ -329,6 +321,7 @@ run (gchar *name,
if (run_mode != RUN_NONINTERACTIVE) if (run_mode != RUN_NONINTERACTIVE)
gimp_displays_flush (); gimp_displays_flush ();
} }
values[0].data.d_status = status; values[0].data.d_status = status;
} }
@ -376,12 +369,15 @@ rotate_compute_offsets (gint *offsetx,
static void static void
rotate_drawable (GDrawable *drawable) rotate_drawable (GDrawable *drawable)
{ {
GPixelRgn srcPR, destPR; GimpPixelRgn srcPR, destPR;
gint width, height, longside, bytes; gint width, height;
gint row, col, byte; gint longside;
gint offsetx, offsety; gint bytes;
gint was_preserve_transparency = FALSE; gint row, col;
guchar *buffer, *src_row, *dest_row; gint offsetx, offsety;
gboolean was_preserve_transparency = FALSE;
guchar *buffer;
guchar *src_row, *dest_row;
/* initialize */ /* initialize */
@ -400,7 +396,7 @@ rotate_drawable (GDrawable *drawable)
if (rotvals.angle == 2) /* we're rotating by 180° */ if (rotvals.angle == 2) /* we're rotating by 180° */
{ {
gimp_tile_cache_ntiles (2 * (width / gimp_tile_width()) + 1); gimp_tile_cache_ntiles (2 * (width / gimp_tile_width() + 1));
gimp_pixel_rgn_init (&srcPR, drawable, 0, 0, width, height, gimp_pixel_rgn_init (&srcPR, drawable, 0, 0, width, height,
FALSE, FALSE); FALSE, FALSE);
@ -415,11 +411,9 @@ rotate_drawable (GDrawable *drawable)
gimp_pixel_rgn_get_row (&srcPR, src_row, 0, row, width); gimp_pixel_rgn_get_row (&srcPR, src_row, 0, row, width);
for (col = 0; col < width; col++) for (col = 0; col < width; col++)
{ {
for (byte = 0; byte < bytes; byte++) memcpy (dest_row + col * bytes,
{ src_row + (width - 1 - col) * bytes,
dest_row[col * bytes + byte] = bytes);
src_row[(width - col - 1) * bytes + byte];
}
} }
gimp_pixel_rgn_set_row (&destPR, dest_row, 0, (height - row - 1), gimp_pixel_rgn_set_row (&destPR, dest_row, 0, (height - row - 1),
width); width);
@ -444,8 +438,8 @@ rotate_drawable (GDrawable *drawable)
drawable = gimp_drawable_get (drawable->id); drawable = gimp_drawable_get (drawable->id);
gimp_drawable_flush (drawable); gimp_drawable_flush (drawable);
gimp_tile_cache_ntiles ( ((longside/gimp_tile_width())+1) + gimp_tile_cache_ntiles ( (longside / gimp_tile_width () + 1) +
((longside/gimp_tile_height())+1) ); (longside / gimp_tile_height () + 1) );
gimp_pixel_rgn_init (&srcPR, drawable, 0, 0, longside, longside, gimp_pixel_rgn_init (&srcPR, drawable, 0, 0, longside, longside,
FALSE, FALSE); FALSE, FALSE);
@ -511,14 +505,14 @@ rotate_drawable (GDrawable *drawable)
static void static void
rotate (void) rotate (void)
{ {
GDrawable *drawable; GimpDrawable *drawable;
gint32 *layers; gint32 *layers;
gint i; gint i;
gint nlayers; gint nlayers;
gint32 guide_ID; gint32 guide_ID;
GuideInfo *guide; GuideInfo *guide;
GList *guides = NULL; GList *guides = NULL;
GList *list; GList *list;
if (rotvals.angle == 0) return; if (rotvals.angle == 0) return;