add typedef GimpImageMapApplyFunc here.

2008-01-09  Michael Natterer  <mitch@gimp.org>

	* app/core/core-types.h: add typedef GimpImageMapApplyFunc here.

	* app/core/gimpimagemap.[ch] (gimp_image_map_new): add apply_func
	and apply_data parameters.

	(gimp_image_map_apply): remove them here and add a GeglRectangle
	parameter which is the visible area of the affected drawable.

	* app/tools/gimpimagemaptool.[ch]: keep apply_func and apply_data
	around in the GimpImageMapTool struct.

	(gimp_image_map_tool_create_map): pass them to gimp_image_map_new().

	(gimp_image_map_tool_map): call gimp_image_map_apply() here and
	pass the drawable's visible rectangle.

	* app/tools/gimpbrightnesscontrasttool.c
	* app/tools/gimpcolorbalancetool.c
	* app/tools/gimpcolorizetool.c
	* app/tools/gimpcurvestool.c
	* app/tools/gimphuesaturationtool.c
	* app/tools/gimplevelstool.c
	* app/tools/gimpposterizetool.c
	* app/tools/gimpthresholdtool.c (init): set apply_func and
	apply_data in the parent instance.

	(map): remove calls to gimp_image_map_apply().


svn path=/trunk/; revision=24573
This commit is contained in:
Michael Natterer 2008-01-09 01:06:46 +00:00 committed by Michael Natterer
parent a1c270c096
commit dc65f5fc20
14 changed files with 144 additions and 69 deletions

View File

@ -1,3 +1,33 @@
2008-01-09 Michael Natterer <mitch@gimp.org>
* app/core/core-types.h: add typedef GimpImageMapApplyFunc here.
* app/core/gimpimagemap.[ch] (gimp_image_map_new): add apply_func
and apply_data parameters.
(gimp_image_map_apply): remove them here and add a GeglRectangle
parameter which is the visible area of the affected drawable.
* app/tools/gimpimagemaptool.[ch]: keep apply_func and apply_data
around in the GimpImageMapTool struct.
(gimp_image_map_tool_create_map): pass them to gimp_image_map_new().
(gimp_image_map_tool_map): call gimp_image_map_apply() here and
pass the drawable's visible rectangle.
* app/tools/gimpbrightnesscontrasttool.c
* app/tools/gimpcolorbalancetool.c
* app/tools/gimpcolorizetool.c
* app/tools/gimpcurvestool.c
* app/tools/gimphuesaturationtool.c
* app/tools/gimplevelstool.c
* app/tools/gimpposterizetool.c
* app/tools/gimpthresholdtool.c (init): set apply_func and
apply_data in the parent instance.
(map): remove calls to gimp_image_map_apply().
2008-01-08 Sven Neumann <sven@gimp.org>
* plug-ins/psd/psd-image-res-load.[ch]

View File

@ -165,15 +165,19 @@ typedef struct _GimpScanConvert GimpScanConvert;
/* functions */
typedef void (* GimpInitStatusFunc) (const gchar *text1,
const gchar *text2,
gdouble percentage);
typedef void (* GimpInitStatusFunc) (const gchar *text1,
const gchar *text2,
gdouble percentage);
typedef gboolean (* GimpObjectFilterFunc) (const GimpObject *object,
gpointer user_data);
typedef gboolean (* GimpObjectFilterFunc) (const GimpObject *object,
gpointer user_data);
typedef gint64 (* GimpMemsizeFunc) (gpointer instance,
gint64 *gui_size);
typedef gint64 (* GimpMemsizeFunc) (gpointer instance,
gint64 *gui_size);
typedef void (* GimpImageMapApplyFunc) (gpointer apply_data,
PixelRegion *srcPR,
PixelRegion *destPR);
/* structs */

View File

@ -295,15 +295,18 @@ gimp_image_map_get_pixel_at (GimpPickable *pickable,
}
GimpImageMap *
gimp_image_map_new (GimpDrawable *drawable,
const gchar *undo_desc,
GeglNode *operation)
gimp_image_map_new (GimpDrawable *drawable,
const gchar *undo_desc,
GeglNode *operation,
GimpImageMapApplyFunc apply_func,
gpointer apply_data)
{
GimpImageMap *image_map;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
g_return_val_if_fail (operation == NULL || GEGL_IS_NODE (operation), NULL);
g_return_val_if_fail (operation != NULL || apply_func != NULL, NULL);
image_map = g_object_new (GIMP_TYPE_IMAGE_MAP, NULL);
@ -313,25 +316,25 @@ gimp_image_map_new (GimpDrawable *drawable,
if (operation)
image_map->operation = g_object_ref (operation);
image_map->apply_func = apply_func;
image_map->apply_data = apply_data;
gimp_viewable_preview_freeze (GIMP_VIEWABLE (drawable));
return image_map;
}
void
gimp_image_map_apply (GimpImageMap *image_map,
GimpImageMapApplyFunc apply_func,
gpointer apply_data)
gimp_image_map_apply (GimpImageMap *image_map,
const GeglRectangle *visible)
{
GeglRectangle rect;
gint undo_offset_x, undo_offset_y;
gint undo_width, undo_height;
gint undo_offset_x;
gint undo_offset_y;
gint undo_width;
gint undo_height;
g_return_if_fail (GIMP_IS_IMAGE_MAP (image_map));
g_return_if_fail (apply_func != NULL);
image_map->apply_func = apply_func;
image_map->apply_data = apply_data;
/* If we're still working, remove the timer */
if (image_map->idle_id)

View File

@ -23,11 +23,6 @@
#include "gimpobject.h"
typedef void (* GimpImageMapApplyFunc) (gpointer data,
PixelRegion *srcPR,
PixelRegion *destPR);
#define GIMP_TYPE_IMAGE_MAP (gimp_image_map_get_type ())
#define GIMP_IMAGE_MAP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_IMAGE_MAP, GimpImageMap))
#define GIMP_IMAGE_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_IMAGE_MAP, GimpImageMapClass))
@ -57,11 +52,12 @@ GType gimp_image_map_get_type (void) G_GNUC_CONST;
GimpImageMap * gimp_image_map_new (GimpDrawable *drawable,
const gchar *undo_desc,
GeglNode *operation);
void gimp_image_map_apply (GimpImageMap *image_map,
GeglNode *operation,
GimpImageMapApplyFunc apply_func,
gpointer apply_data);
void gimp_image_map_apply (GimpImageMap *image_map,
const GeglRectangle *visible);
void gimp_image_map_commit (GimpImageMap *image_map);
void gimp_image_map_clear (GimpImageMap *image_map);
void gimp_image_map_abort (GimpImageMap *image_map);

View File

@ -130,9 +130,14 @@ gimp_brightness_contrast_tool_class_init (GimpBrightnessContrastToolClass *klass
static void
gimp_brightness_contrast_tool_init (GimpBrightnessContrastTool *bc_tool)
{
GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (bc_tool);
bc_tool->brightness = 0.0;
bc_tool->contrast = 0.0;
bc_tool->lut = gimp_lut_new ();
im_tool->apply_func = (GimpImageMapApplyFunc) gimp_lut_process;
im_tool->apply_data = bc_tool->lut;
}
static void
@ -212,9 +217,6 @@ gimp_brightness_contrast_tool_map (GimpImageMapTool *im_tool)
bc_tool->brightness / 255.0,
bc_tool->contrast / 127.0,
gimp_drawable_bytes (im_tool->drawable));
gimp_image_map_apply (im_tool->image_map,
(GimpImageMapApplyFunc) gimp_lut_process,
bc_tool->lut);
}

View File

@ -111,10 +111,15 @@ gimp_color_balance_tool_class_init (GimpColorBalanceToolClass *klass)
static void
gimp_color_balance_tool_init (GimpColorBalanceTool *cb_tool)
{
GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (cb_tool);
cb_tool->color_balance = g_slice_new0 (ColorBalance);
cb_tool->transfer_mode = GIMP_MIDTONES;
color_balance_init (cb_tool->color_balance);
im_tool->apply_func = (GimpImageMapApplyFunc) color_balance;
im_tool->apply_data = cb_tool->color_balance;
}
static void
@ -164,9 +169,6 @@ gimp_color_balance_tool_map (GimpImageMapTool *im_tool)
GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (im_tool);
color_balance_create_lookup_tables (cb_tool->color_balance);
gimp_image_map_apply (im_tool->image_map,
(GimpImageMapApplyFunc) color_balance,
cb_tool->color_balance);
}

View File

@ -109,9 +109,14 @@ gimp_colorize_tool_class_init (GimpColorizeToolClass *klass)
static void
gimp_colorize_tool_init (GimpColorizeTool *col_tool)
{
GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (col_tool);
col_tool->colorize = g_slice_new0 (Colorize);
colorize_init (col_tool->colorize);
im_tool->apply_func = (GimpImageMapApplyFunc) colorize;
im_tool->apply_data = col_tool->colorize;
}
static void
@ -176,10 +181,6 @@ gimp_colorize_tool_map (GimpImageMapTool *image_map_tool)
}
colorize_calculate (col_tool->colorize);
gimp_image_map_apply (image_map_tool->image_map,
(GimpImageMapApplyFunc) colorize,
col_tool->colorize);
}

View File

@ -171,7 +171,8 @@ gimp_curves_tool_class_init (GimpCurvesToolClass *klass)
static void
gimp_curves_tool_init (GimpCurvesTool *tool)
{
gint i;
GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (tool);
gint i;
for (i = 0; i < G_N_ELEMENTS (tool->curve); i++)
{
@ -187,6 +188,9 @@ gimp_curves_tool_init (GimpCurvesTool *tool)
for (i = 0; i < G_N_ELEMENTS (tool->col_value); i++)
tool->col_value[i] = -1;
im_tool->apply_func = (GimpImageMapApplyFunc) gimp_lut_process;
im_tool->apply_data = tool->lut;
}
static void
@ -411,10 +415,6 @@ gimp_curves_tool_map (GimpImageMapTool *image_map_tool)
(GimpLutFunc) curves_lut_func,
&curves,
gimp_drawable_bytes (image_map_tool->drawable));
gimp_image_map_apply (image_map_tool->image_map,
(GimpImageMapApplyFunc) gimp_lut_process,
tool->lut);
}

View File

@ -129,10 +129,15 @@ gimp_hue_saturation_tool_class_init (GimpHueSaturationToolClass *klass)
static void
gimp_hue_saturation_tool_init (GimpHueSaturationTool *hs_tool)
{
GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (hs_tool);
hs_tool->hue_saturation = g_slice_new0 (HueSaturation);
hs_tool->hue_partition = GIMP_ALL_HUES;
hue_saturation_init (hs_tool->hue_saturation);
im_tool->apply_func = (GimpImageMapApplyFunc) hue_saturation;
im_tool->apply_data = hs_tool->hue_saturation;
}
static void
@ -179,11 +184,6 @@ gimp_hue_saturation_tool_initialize (GimpTool *tool,
static void
gimp_hue_saturation_tool_map (GimpImageMapTool *image_map_tool)
{
GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (image_map_tool);
gimp_image_map_apply (image_map_tool->image_map,
(GimpImageMapApplyFunc) hue_saturation,
hs_tool->hue_saturation);
}

View File

@ -49,6 +49,8 @@
#include "widgets/gimpwidgets-utils.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpdisplayshell-transform.h"
#include "gimpcoloroptions.h"
#include "gimpimagemaptool.h"
@ -421,7 +423,33 @@ gimp_image_map_tool_pick_color (GimpColorTool *color_tool,
static void
gimp_image_map_tool_map (GimpImageMapTool *tool)
{
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (GIMP_TOOL (tool)->display->shell);
GimpItem *item = GIMP_ITEM (tool->drawable);
gint x, y;
gint w, h;
gint off_x, off_y;
GeglRectangle visible;
GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->map (tool);
gimp_display_shell_untransform_viewport (shell, &x, &y, &w, &h);
gimp_item_offsets (item, &off_x, &off_y);
gimp_rectangle_intersect (x, y, w, h,
off_x,
off_y,
gimp_item_width (item),
gimp_item_height (item),
&visible.x,
&visible.y,
&visible.width,
&visible.height);
visible.x -= off_x;
visible.y -= off_y;
gimp_image_map_apply (tool->image_map, &visible);
}
static void
@ -454,7 +482,9 @@ gimp_image_map_tool_create_map (GimpImageMapTool *tool)
tool->image_map = gimp_image_map_new (tool->drawable,
GIMP_TOOL (tool)->tool_info->blurb,
config->use_gegl ?
tool->operation : NULL);
tool->operation : NULL,
tool->apply_func,
tool->apply_data);
g_signal_connect (tool->image_map, "flush",
G_CALLBACK (gimp_image_map_tool_flush),

View File

@ -41,20 +41,24 @@ typedef struct _GimpImageMapToolClass GimpImageMapToolClass;
struct _GimpImageMapTool
{
GimpColorTool parent_instance;
GimpColorTool parent_instance;
GimpDrawable *drawable;
GeglNode *operation;
GimpImageMap *image_map;
GimpDrawable *drawable;
GeglNode *operation;
GimpImageMapApplyFunc apply_func;
gpointer apply_data;
GimpImageMap *image_map;
/* dialog */
GtkWidget *shell;
GtkWidget *main_vbox;
GtkWidget *load_button;
GtkWidget *save_button;
GtkWidget *shell;
GtkWidget *main_vbox;
GtkWidget *load_button;
GtkWidget *save_button;
/* settings file dialog */
GtkWidget *settings_dialog;
GtkWidget *settings_dialog;
};
struct _GimpImageMapToolClass

View File

@ -175,6 +175,8 @@ gimp_levels_tool_class_init (GimpLevelsToolClass *klass)
static void
gimp_levels_tool_init (GimpLevelsTool *tool)
{
GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (tool);
tool->lut = gimp_lut_new ();
tool->levels = g_slice_new0 (Levels);
tool->hist = NULL;
@ -182,6 +184,9 @@ gimp_levels_tool_init (GimpLevelsTool *tool)
tool->active_picker = NULL;
levels_init (tool->levels);
im_tool->apply_func = (GimpImageMapApplyFunc) gimp_lut_process;
im_tool->apply_data = tool->lut;
}
static void
@ -293,10 +298,6 @@ gimp_levels_tool_map (GimpImageMapTool *image_map_tool)
(GimpLutFunc) levels_lut_func,
tool->levels,
gimp_drawable_bytes (image_map_tool->drawable));
gimp_image_map_apply (image_map_tool->image_map,
(GimpImageMapApplyFunc) gimp_lut_process,
tool->lut);
}

View File

@ -106,8 +106,13 @@ gimp_posterize_tool_class_init (GimpPosterizeToolClass *klass)
static void
gimp_posterize_tool_init (GimpPosterizeTool *posterize_tool)
{
GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (posterize_tool);
posterize_tool->levels = POSTERIZE_DEFAULT_LEVELS;
posterize_tool->lut = gimp_lut_new ();
im_tool->apply_func = (GimpImageMapApplyFunc) gimp_lut_process;
im_tool->apply_data = posterize_tool->lut;
}
static void
@ -179,10 +184,6 @@ gimp_posterize_tool_map (GimpImageMapTool *image_map_tool)
posterize_lut_setup (posterize_tool->lut,
posterize_tool->levels,
gimp_drawable_bytes (image_map_tool->drawable));
gimp_image_map_apply (image_map_tool->image_map,
(GimpImageMapApplyFunc) gimp_lut_process,
posterize_tool->lut);
}

View File

@ -111,11 +111,16 @@ gimp_threshold_tool_class_init (GimpThresholdToolClass *klass)
static void
gimp_threshold_tool_init (GimpThresholdTool *t_tool)
{
GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (t_tool);
t_tool->threshold = g_slice_new0 (Threshold);
t_tool->hist = NULL;
t_tool->threshold->low_threshold = 127;
t_tool->threshold->high_threshold = 255;
im_tool->apply_func = (GimpImageMapApplyFunc) threshold;
im_tool->apply_data = t_tool->threshold;
}
static void
@ -200,10 +205,6 @@ gimp_threshold_tool_map (GimpImageMapTool *image_map_tool)
"high", t_tool->threshold->high_threshold / 255.0,
NULL);
}
gimp_image_map_apply (image_map_tool->image_map,
(GimpImageMapApplyFunc) threshold,
t_tool->threshold);
}