Commit 51710aa3 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

changed GimpImageMapApplyFunc to be compatible with PixelProcessorFunc.

2005-02-15  Sven Neumann  <sven@gimp.org>

	* app/core/gimpimagemap.[ch]: changed GimpImageMapApplyFunc to
	be compatible with PixelProcessorFunc.

	* app/base/color-balance.[ch]
	* app/base/colorize.[ch]
	* app/base/gimplut.[ch]
	* app/base/hue-saturation.[ch]
	* app/base/threshold.[ch]: removed wrappers that used to
	shift parameters around to match GimpImageMapApplyFunc and
	PixelProcessorFunc signatures.

	* app/tools/gimpbrightnesscontrasttool.c
	* app/tools/gimpcolorbalancetool.c
	* app/tools/gimpcurvestool.c
	* app/tools/gimplevelstool.c
	* app/tools/gimpposterizetool.c
	* app/tools/gimpthresholdtool.c: changed accordingly.

	* tools/pdbgen/pdb/color.pdb: use pixel_region_process_parallel()
	for all color operations.

	* app/pdb/color_cmds.c: regenerated.
parent 9d5cb909
2005-02-15 Sven Neumann <sven@gimp.org>
* app/core/gimpimagemap.[ch]: changed GimpImageMapApplyFunc to
be compatible with PixelProcessorFunc.
* app/base/color-balance.[ch]
* app/base/colorize.[ch]
* app/base/gimplut.[ch]
* app/base/hue-saturation.[ch]
* app/base/threshold.[ch]: removed wrappers that used to
shift parameters around to match GimpImageMapApplyFunc and
PixelProcessorFunc signatures.
* app/tools/gimpbrightnesscontrasttool.c
* app/tools/gimpcolorbalancetool.c
* app/tools/gimpcurvestool.c
* app/tools/gimplevelstool.c
* app/tools/gimpposterizetool.c
* app/tools/gimpthresholdtool.c: changed accordingly.
* tools/pdbgen/pdb/color.pdb: use pixel_region_process_parallel()
for all color operations.
* app/pdb/color_cmds.c: regenerated.
2005-02-15 Sven Neumann <sven@gimp.org>
* app/main.c (gimp_init_malloc): added a comment about the use of
......
......@@ -147,20 +147,17 @@ color_balance_create_lookup_tables (ColorBalance *cb)
}
void
color_balance (PixelRegion *srcPR,
PixelRegion *destPR,
gpointer data)
color_balance (ColorBalance *cb,
PixelRegion *srcPR,
PixelRegion *destPR)
{
ColorBalance *cb;
guchar *src, *s;
const guchar *src, *s;
guchar *dest, *d;
gboolean alpha;
gint r, g, b;
gint r_n, g_n, b_n;
gint w, h;
cb = (ColorBalance *) data;
h = srcPR->h;
src = srcPR->data;
dest = destPR->data;
......
......@@ -38,9 +38,9 @@ void color_balance_init (ColorBalance *cb);
void color_balance_range_reset (ColorBalance *cb,
GimpTransferMode range);
void color_balance_create_lookup_tables (ColorBalance *cb);
void color_balance (PixelRegion *srcPR,
PixelRegion *destPR,
gpointer data);
void color_balance (ColorBalance *cb,
PixelRegion *srcPR,
PixelRegion *destPR);
#endif /* __COLOR_BALANCE_H__ */
......@@ -74,15 +74,15 @@ colorize_calculate (Colorize *colorize)
}
void
colorize (PixelRegion *srcPR,
PixelRegion *destPR,
Colorize *colorize)
colorize (Colorize *colorize,
PixelRegion *srcPR,
PixelRegion *destPR)
{
guchar *src, *s;
guchar *dest, *d;
gboolean alpha;
gint w, h;
gint lum;
const guchar *src, *s;
guchar *dest, *d;
gboolean alpha;
gint w, h;
gint lum;
/* Set the transfer arrays (for speed) */
h = srcPR->h;
......
......@@ -38,9 +38,9 @@ struct _Colorize
void colorize_init (Colorize *colorize);
void colorize_calculate (Colorize *colorize);
void colorize (PixelRegion *srcPR,
PixelRegion *destPR,
Colorize *colorize);
void colorize (Colorize *colorize,
PixelRegion *srcPR,
PixelRegion *destPR);
#endif /* __COLORIZE_H__ */
......@@ -102,9 +102,10 @@ gimp_lut_process (GimpLut *lut,
PixelRegion *srcPR,
PixelRegion *destPR)
{
guint h, width, src_r_i, dest_r_i;
guchar *src, *dest;
guchar *lut0 = NULL, *lut1 = NULL, *lut2 = NULL, *lut3 = NULL;
const guchar *src;
guchar *dest;
guchar *lut0 = NULL, *lut1 = NULL, *lut2 = NULL, *lut3 = NULL;
guint h, width, src_r_i, dest_r_i;
if (lut->nchannels > 0)
lut0 = lut->luts[0];
......@@ -119,7 +120,7 @@ gimp_lut_process (GimpLut *lut,
src = srcPR->data;
dest = destPR->data;
width = srcPR->w;
src_r_i = srcPR->rowstride - (srcPR->bytes * srcPR->w);
src_r_i = srcPR->rowstride - (srcPR->bytes * srcPR->w);
dest_r_i = destPR->rowstride - (destPR->bytes * srcPR->w);
if (src_r_i == 0 && dest_r_i == 0)
......@@ -253,11 +254,3 @@ gimp_lut_process_inline (GimpLut *lut,
src += src_r_i;
}
}
void
gimp_lut_process_2 (PixelRegion *srcPR,
PixelRegion *destPR,
GimpLut *lut)
{
gimp_lut_process (lut, srcPR, destPR);
}
......@@ -68,15 +68,5 @@ void gimp_lut_process (GimpLut *lut,
void gimp_lut_process_inline (GimpLut *lut,
PixelRegion *src_destPR);
/* gimp_lut_process_2 is the same as gimp_lut_process but the lut
* parameter is last instead of first. this is necesary because
* pixel_region_process_paralell sends the user_data as the 1st
* parameter, and the image_map functions send user_data as the last
* parameter
*/
void gimp_lut_process_2 (PixelRegion *srcPR,
PixelRegion *destPR,
GimpLut *lut);
#endif /* __GIMP_LUT_H__ */
......@@ -98,16 +98,16 @@ hue_saturation_calculate_transfers (HueSaturation *hs)
}
void
hue_saturation (PixelRegion *srcPR,
PixelRegion *destPR,
HueSaturation *hs)
hue_saturation (HueSaturation *hs,
PixelRegion *srcPR,
PixelRegion *destPR)
{
guchar *src, *s;
guchar *dest, *d;
gint alpha;
gint w, h;
gint r, g, b;
gint hue;
const guchar *src, *s;
guchar *dest, *d;
gboolean alpha;
gint w, h;
gint r, g, b;
gint hue;
/* Set the transfer arrays (for speed) */
h = srcPR->h;
......
......@@ -36,9 +36,9 @@ void hue_saturation_init (HueSaturation *hs);
void hue_saturation_partition_reset (HueSaturation *hs,
GimpHueRange partition);
void hue_saturation_calculate_transfers (HueSaturation *hs);
void hue_saturation (PixelRegion *srcPR,
PixelRegion *destPR,
HueSaturation *hs);
void hue_saturation (HueSaturation *hs,
PixelRegion *srcPR,
PixelRegion *destPR);
#endif /* __HUE_SATURATION_H__ */
......@@ -27,26 +27,16 @@
void
threshold_2 (gpointer data,
PixelRegion *srcPR,
PixelRegion *destPR)
threshold (Threshold *tr,
PixelRegion *srcPR,
PixelRegion *destPR)
{
threshold (srcPR, destPR, data);
}
void
threshold (PixelRegion *srcPR,
PixelRegion *destPR,
gpointer data)
{
Threshold *tr;
guchar *src, *s;
guchar *dest, *d;
gint has_alpha, alpha;
gint w, h, b;
gint value;
tr = (Threshold *) data;
const guchar *src, *s;
guchar *dest, *d;
gboolean has_alpha;
gint alpha;
gint w, h, b;
gint value;
h = srcPR->h;
src = srcPR->data;
......@@ -67,10 +57,14 @@ threshold (PixelRegion *srcPR,
value = MAX (s[RED_PIX], s[GREEN_PIX]);
value = MAX (value, s[BLUE_PIX]);
value = (value >= tr->low_threshold && value <= tr->high_threshold ) ? 255 : 0;
value = (value >= tr->low_threshold &&
value <= tr->high_threshold ) ? 255 : 0;
}
else
value = (s[GRAY_PIX] >= tr->low_threshold && s[GRAY_PIX] <= tr->high_threshold) ? 255 : 0;
{
value = (s[GRAY_PIX] >= tr->low_threshold &&
s[GRAY_PIX] <= tr->high_threshold) ? 255 : 0;
}
for (b = 0; b < alpha; b++)
d[b] = value;
......
......@@ -28,16 +28,9 @@ struct _Threshold
};
/* this function just re-orders the arguments so we can use
* pixel_regions_process_paralell
*/
void threshold_2 (gpointer data,
void threshold (Threshold *tr,
PixelRegion *srcPR,
PixelRegion *destPR);
void threshold (PixelRegion *srcPR,
PixelRegion *destPR,
gpointer data);
#endif /* __THRESHOLD_H__ */
......@@ -543,9 +543,8 @@ gimp_image_map_do (GimpImageMap *image_map)
{
gint x, y, w, h;
image_map->apply_func (&image_map->srcPR,
&image_map->destPR,
image_map->user_data);
image_map->apply_func (image_map->user_data,
&image_map->srcPR, &image_map->destPR);
x = image_map->destPR.x;
y = image_map->destPR.y;
......
......@@ -23,9 +23,9 @@
#include "gimpobject.h"
typedef void (* GimpImageMapApplyFunc) (PixelRegion *srcPR,
PixelRegion *destPR,
gpointer data);
typedef void (* GimpImageMapApplyFunc) (gpointer data,
PixelRegion *srcPR,
PixelRegion *destPR);
#define GIMP_TYPE_IMAGE_MAP (gimp_image_map_get_type ())
......
......@@ -131,7 +131,8 @@ brightness_contrast_invoker (Gimp *gimp,
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
x, y, width, height, TRUE);
pixel_regions_process_parallel ((PixelProcessorFunc) gimp_lut_process,
pixel_regions_process_parallel ((PixelProcessorFunc)
gimp_lut_process,
lut, 2, &srcPR, &destPR);
gimp_lut_free (lut);
......@@ -448,7 +449,8 @@ posterize_invoker (Gimp *gimp,
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
x, y, width, height, TRUE);
pixel_regions_process_parallel ((PixelProcessorFunc) gimp_lut_process,
pixel_regions_process_parallel ((PixelProcessorFunc)
gimp_lut_process,
lut, 2, &srcPR, &destPR);
gimp_lut_free (lut);
......@@ -736,7 +738,8 @@ curves_spline_invoker (Gimp *gimp,
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
x, y, width, height, TRUE);
pixel_regions_process_parallel ((PixelProcessorFunc) gimp_lut_process,
pixel_regions_process_parallel ((PixelProcessorFunc)
gimp_lut_process,
lut, 2, &srcPR, &destPR);
gimp_lut_free (lut);
......@@ -861,7 +864,8 @@ curves_explicit_invoker (Gimp *gimp,
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
x, y, width, height, TRUE);
pixel_regions_process_parallel ((PixelProcessorFunc) gimp_lut_process,
pixel_regions_process_parallel ((PixelProcessorFunc)
gimp_lut_process,
lut, 2, &srcPR, &destPR);
gimp_lut_free (lut);
......@@ -965,9 +969,8 @@ color_balance_invoker (Gimp *gimp,
/* The application should occur only within selection bounds */
if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
{
ColorBalance cb;
PixelRegionIterator *pr;
PixelRegion srcPR, destPR;
ColorBalance cb;
PixelRegion srcPR, destPR;
color_balance_init (&cb);
......@@ -984,12 +987,8 @@ color_balance_invoker (Gimp *gimp,
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
x, y, width, height, TRUE);
for (pr = pixel_regions_register (2, &srcPR, &destPR);
pr;
pr = pixel_regions_process (pr))
{
color_balance (&srcPR, &destPR, &cb);
}
pixel_regions_process_parallel ((PixelProcessorFunc) color_balance,
&cb, 2, &srcPR, &destPR);
gimp_drawable_merge_shadow (drawable, TRUE, _("Color Balance"));
gimp_drawable_update (drawable, x, y, width, height);
......@@ -1092,9 +1091,8 @@ colorize_invoker (Gimp *gimp,
/* The application should occur only within selection bounds */
if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
{
Colorize colors;
PixelRegionIterator *pr;
PixelRegion srcPR, destPR;
Colorize colors;
PixelRegion srcPR, destPR;
colorize_init (&colors);
......@@ -1109,12 +1107,8 @@ colorize_invoker (Gimp *gimp,
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
x, y, width, height, TRUE);
for (pr = pixel_regions_register (2, &srcPR, &destPR);
pr;
pr = pixel_regions_process (pr))
{
colorize (&srcPR, &destPR, &colors);
}
pixel_regions_process_parallel ((PixelProcessorFunc) colorize,
&colors, 2, &srcPR, &destPR);
gimp_drawable_merge_shadow (drawable, TRUE, _("Colorize"));
gimp_drawable_update (drawable, x, y, width, height);
......@@ -1368,9 +1362,8 @@ hue_saturation_invoker (Gimp *gimp,
/* The application should occur only within selection bounds */
if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
{
HueSaturation hs;
PixelRegionIterator *pr;
PixelRegion srcPR, destPR;
HueSaturation hs;
PixelRegion srcPR, destPR;
hue_saturation_init (&hs);
......@@ -1386,12 +1379,8 @@ hue_saturation_invoker (Gimp *gimp,
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
x, y, width, height, TRUE);
for (pr = pixel_regions_register (2, &srcPR, &destPR);
pr;
pr = pixel_regions_process (pr))
{
hue_saturation (&srcPR, &destPR, &hs);
}
pixel_regions_process_parallel ((PixelProcessorFunc) hue_saturation,
&hs, 2, &srcPR, &destPR);
gimp_drawable_merge_shadow (drawable, TRUE, _("Hue-Saturation"));
gimp_drawable_update (drawable, x, y, width, height);
......@@ -1497,7 +1486,7 @@ threshold_invoker (Gimp *gimp,
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
x, y, width, height, TRUE);
pixel_regions_process_parallel ((PixelProcessorFunc) threshold_2,
pixel_regions_process_parallel ((PixelProcessorFunc) threshold,
&tr, 2, &srcPR, &destPR);
gimp_drawable_merge_shadow (drawable, TRUE, _("Threshold"));
......
......@@ -204,7 +204,7 @@ gimp_brightness_contrast_tool_map (GimpImageMapTool *image_map_tool)
bc_tool->contrast / 127.0,
gimp_drawable_bytes (image_map_tool->drawable));
gimp_image_map_apply (image_map_tool->image_map,
(GimpImageMapApplyFunc) gimp_lut_process_2,
(GimpImageMapApplyFunc) gimp_lut_process,
bc_tool->lut);
}
......
......@@ -211,7 +211,7 @@ gimp_color_balance_tool_map (GimpImageMapTool *image_map_tool)
color_balance_create_lookup_tables (cb_tool->color_balance);
gimp_image_map_apply (image_map_tool->image_map,
color_balance,
(GimpImageMapApplyFunc) color_balance,
cb_tool->color_balance);
}
......
......@@ -431,7 +431,7 @@ gimp_curves_tool_map (GimpImageMapTool *image_map_tool)
gimp_drawable_bytes (image_map_tool->drawable));
gimp_image_map_apply (image_map_tool->image_map,
(GimpImageMapApplyFunc) gimp_lut_process_2,
(GimpImageMapApplyFunc) gimp_lut_process,
tool->lut);
}
......
......@@ -320,7 +320,7 @@ gimp_levels_tool_map (GimpImageMapTool *image_map_tool)
GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool);
gimp_image_map_apply (image_map_tool->image_map,
(GimpImageMapApplyFunc) gimp_lut_process_2,
(GimpImageMapApplyFunc) gimp_lut_process,
tool->lut);
}
......
......@@ -195,7 +195,7 @@ gimp_posterize_tool_map (GimpImageMapTool *image_map_tool)
posterize_tool->levels,
gimp_drawable_bytes (image_map_tool->drawable));
gimp_image_map_apply (image_map_tool->image_map,
(GimpImageMapApplyFunc) gimp_lut_process_2,
(GimpImageMapApplyFunc) gimp_lut_process,
posterize_tool->lut);
}
......
......@@ -231,7 +231,7 @@ gimp_threshold_tool_map (GimpImageMapTool *image_map_tool)
GimpThresholdTool *t_tool = GIMP_THRESHOLD_TOOL (image_map_tool);
gimp_image_map_apply (image_map_tool->image_map,
threshold,
(GimpImageMapApplyFunc) threshold,
t_tool->threshold);
}
......
......@@ -73,7 +73,8 @@ HELP
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
x, y, width, height, TRUE);
pixel_regions_process_parallel ((PixelProcessorFunc) gimp_lut_process,
pixel_regions_process_parallel ((PixelProcessorFunc)
gimp_lut_process,
lut, 2, &srcPR, &destPR);
gimp_lut_free (lut);
......@@ -247,7 +248,8 @@ HELP
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
x, y, width, height, TRUE);
pixel_regions_process_parallel ((PixelProcessorFunc) gimp_lut_process,
pixel_regions_process_parallel ((PixelProcessorFunc)
gimp_lut_process,
lut, 2, &srcPR, &destPR);
gimp_lut_free (lut);
......@@ -432,7 +434,8 @@ HELP
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
x, y, width, height, TRUE);
pixel_regions_process_parallel ((PixelProcessorFunc) gimp_lut_process,
pixel_regions_process_parallel ((PixelProcessorFunc)
gimp_lut_process,
lut, 2, &srcPR, &destPR);
gimp_lut_free (lut);
......@@ -516,7 +519,8 @@ HELP
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
x, y, width, height, TRUE);
pixel_regions_process_parallel ((PixelProcessorFunc) gimp_lut_process,
pixel_regions_process_parallel ((PixelProcessorFunc)
gimp_lut_process,
lut, 2, &srcPR, &destPR);
gimp_lut_free (lut);
......@@ -576,9 +580,8 @@ HELP
/* The application should occur only within selection bounds */
if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
{
ColorBalance cb;
PixelRegionIterator *pr;
PixelRegion srcPR, destPR;
ColorBalance cb;
PixelRegion srcPR, destPR;
color_balance_init (&cb);
......@@ -595,12 +598,8 @@ HELP
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
x, y, width, height, TRUE);
for (pr = pixel_regions_register (2, &srcPR, &destPR);
pr;
pr = pixel_regions_process (pr))
{
color_balance (&srcPR, &destPR, &cb);
}
pixel_regions_process_parallel ((PixelProcessorFunc) color_balance,
&cb, 2, &srcPR, &destPR);
gimp_drawable_merge_shadow (drawable, TRUE, _("Color Balance"));
gimp_drawable_update (drawable, x, y, width, height);
......@@ -649,9 +648,8 @@ HELP
/* The application should occur only within selection bounds */
if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
{
Colorize colors;
PixelRegionIterator *pr;
PixelRegion srcPR, destPR;
Colorize colors;
PixelRegion srcPR, destPR;
colorize_init (&colors);
......@@ -666,12 +664,8 @@ HELP
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
x, y, width, height, TRUE);
for (pr = pixel_regions_register (2, &srcPR, &destPR);
pr;
pr = pixel_regions_process (pr))
{
colorize (&srcPR, &destPR, &colors);
}
pixel_regions_process_parallel ((PixelProcessorFunc) colorize,
&colors, 2, &srcPR, &destPR);
gimp_drawable_merge_shadow (drawable, TRUE, _("Colorize"));
gimp_drawable_update (drawable, x, y, width, height);
......@@ -810,9 +804,8 @@ HELP
/* The application should occur only within selection bounds */
if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
{
HueSaturation hs;
PixelRegionIterator *pr;
PixelRegion srcPR, destPR;
HueSaturation hs;
PixelRegion srcPR, destPR;
hue_saturation_init (&hs);
......@@ -828,12 +821,8 @@ HELP
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
x, y, width, height, TRUE);
for (pr = pixel_regions_register (2, &srcPR, &destPR);
pr;
pr = pixel_regions_process (pr))
{
hue_saturation (&srcPR, &destPR, &hs);
}
pixel_regions_process_parallel ((PixelProcessorFunc) hue_saturation,
&hs, 2, &srcPR, &destPR);
gimp_drawable_merge_shadow (drawable, TRUE, _("Hue-Saturation"));
gimp_drawable_update (drawable, x, y, width, height);
......@@ -890,7 +879,7 @@ HELP
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
x, y, width, height, TRUE);
pixel_regions_process_parallel ((PixelProcessorFunc) threshold_2,
pixel_regions_process_parallel ((PixelProcessorFunc) threshold,
&tr, 2, &srcPR, &destPR);
gimp_drawable_merge_shadow (drawable, TRUE, _("Threshold"));
......@@ -908,9 +897,9 @@ CODE
"core/gimpdrawable.h" "core/gimpimage.h"
"gimp-intl.h");
@procs = qw(brightness_contrast levels levels_auto levels_stretch posterize desaturate
equalize invert curves_spline curves_explicit color_balance
colorize histogram hue_saturation threshold);
@procs = qw(brightness_contrast levels levels_auto levels_stretch posterize
desaturate equalize invert curves_spline curves_explicit
color_balance colorize histogram hue_saturation threshold);
%exports = (app => [@procs], lib => [@procs]);
$desc = 'Color';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment