Simplify things a bit and enable gegl-only color correction tools (without

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

	Simplify things a bit and enable gegl-only color correction
	tools (without legacy functions).

	* app/tools/gimpimagemaptool.c (gimp_image_map_tool_create_map):
	always create the operation if ::get_operation() is implemented
	and always use it when creating the GimpImageMap if there is no
	legacy apply_func.

	* app/tools/gimpbrightnesscontrasttool.c
	* app/tools/gimpcolorbalancetool.c
	* app/tools/gimpcolorizetool.c
	* app/tools/gimplevelstool.c
	* app/tools/gimpposterizetool.c
	* app/tools/gimpthresholdtool.c (map): set the operation's
	properties unconditionally since it always exists now if we also
	implement ::get_operation().


svn path=/trunk/; revision=24588
This commit is contained in:
Michael Natterer 2008-01-10 13:12:44 +00:00 committed by Michael Natterer
parent 91788fe393
commit dac333f72d
8 changed files with 85 additions and 85 deletions

View File

@ -1,3 +1,22 @@
2008-01-10 Michael Natterer <mitch@gimp.org>
Simplify things a bit and enable gegl-only color correction
tools (without legacy functions).
* app/tools/gimpimagemaptool.c (gimp_image_map_tool_create_map):
always create the operation if ::get_operation() is implemented
and always use it when creating the GimpImageMap if there is no
legacy apply_func.
* app/tools/gimpbrightnesscontrasttool.c
* app/tools/gimpcolorbalancetool.c
* app/tools/gimpcolorizetool.c
* app/tools/gimplevelstool.c
* app/tools/gimpposterizetool.c
* app/tools/gimpthresholdtool.c (map): set the operation's
properties unconditionally since it always exists now if we also
implement ::get_operation().
2008-01-10 Michael Natterer <mitch@gimp.org>
* app/gegl/Makefile.am

View File

@ -196,22 +196,18 @@ static void
gimp_brightness_contrast_tool_map (GimpImageMapTool *im_tool)
{
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (im_tool);
gdouble brightness;
gdouble contrast;
if (im_tool->operation)
{
gdouble brightness;
gdouble contrast;
brightness = bc_tool->brightness / 256.0;
contrast = (bc_tool->contrast < 0 ?
(bc_tool->contrast + 127.0) / 127.0 :
bc_tool->contrast * 4.0 / 127.0 + 1);
brightness = bc_tool->brightness / 256.0;
contrast = (bc_tool->contrast < 0 ?
(bc_tool->contrast + 127.0) / 127.0 :
bc_tool->contrast * 4.0 / 127.0 + 1);
gegl_node_set (im_tool->operation,
"brightness", brightness,
"contrast", contrast,
NULL);
}
gegl_node_set (im_tool->operation,
"brightness", brightness,
"contrast", contrast,
NULL);
brightness_contrast_lut_setup (bc_tool->lut,
bc_tool->brightness / 255.0,

View File

@ -177,30 +177,26 @@ static void
gimp_color_balance_tool_map (GimpImageMapTool *image_map_tool)
{
GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (image_map_tool);
ColorBalance *cb = cb_tool->color_balance;
GimpTransferMode range;
if (image_map_tool->operation)
for (range = GIMP_SHADOWS; range <= GIMP_HIGHLIGHTS; range++)
{
ColorBalance *cb = cb_tool->color_balance;
GimpTransferMode range;
for (range = GIMP_SHADOWS; range <= GIMP_HIGHLIGHTS; range++)
{
gegl_node_set (image_map_tool->operation,
"range", range,
NULL);
gegl_node_set (image_map_tool->operation,
"cyan-red", cb->cyan_red[range] / 256.0,
"magenta-green", cb->magenta_green[range] / 256.0,
"yellow-blue", cb->yellow_blue[range] / 256.0,
NULL);
}
gegl_node_set (image_map_tool->operation,
"range", range,
NULL);
gegl_node_set (image_map_tool->operation,
"preserve-luminosity", cb->preserve_luminosity,
"cyan-red", cb->cyan_red[range] / 256.0,
"magenta-green", cb->magenta_green[range] / 256.0,
"yellow-blue", cb->yellow_blue[range] / 256.0,
NULL);
}
gegl_node_set (image_map_tool->operation,
"preserve-luminosity", cb->preserve_luminosity,
NULL);
color_balance_create_lookup_tables (cb_tool->color_balance);
}

View File

@ -171,14 +171,11 @@ gimp_colorize_tool_map (GimpImageMapTool *image_map_tool)
{
GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (image_map_tool);
if (image_map_tool->operation)
{
gegl_node_set (image_map_tool->operation,
"hue", col_tool->colorize->hue,
"saturation", col_tool->colorize->saturation,
"lightness", col_tool->colorize->lightness,
NULL);
}
gegl_node_set (image_map_tool->operation,
"hue", col_tool->colorize->hue,
"saturation", col_tool->colorize->saturation,
"lightness", col_tool->colorize->lightness,
NULL);
colorize_calculate (col_tool->colorize);
}

View File

@ -468,6 +468,7 @@ static void
gimp_image_map_tool_create_map (GimpImageMapTool *tool)
{
GimpCoreConfig *config = GIMP_TOOL (tool)->tool_info->gimp->config;
gboolean use_gegl;
if (tool->image_map)
{
@ -475,14 +476,16 @@ gimp_image_map_tool_create_map (GimpImageMapTool *tool)
g_object_unref (tool->image_map);
}
if (config->use_gegl && ! tool->operation &&
GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->get_operation)
if (GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->get_operation)
tool->operation = GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->get_operation (tool);
g_assert (tool->operation || tool->apply_func);
use_gegl = (config->use_gegl || ! tool->apply_func);
tool->image_map = gimp_image_map_new (tool->drawable,
GIMP_TOOL (tool)->tool_info->blurb,
config->use_gegl ?
tool->operation : NULL,
use_gegl ? tool->operation : NULL,
tool->apply_func,
tool->apply_data);

View File

@ -269,39 +269,34 @@ gimp_levels_tool_get_operation (GimpImageMapTool *im_tool)
static void
gimp_levels_tool_map (GimpImageMapTool *image_map_tool)
{
GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool);
GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool);
GimpHistogramChannel channel;
if (image_map_tool->operation)
for (channel = GIMP_HISTOGRAM_VALUE;
channel <= GIMP_HISTOGRAM_ALPHA;
channel++)
{
Levels *levels = tool->levels;
GimpHistogramChannel channel;
/* FIXME: hack */
if (! tool->color && channel == 1)
gegl_node_set (image_map_tool->operation,
"channel", GIMP_HISTOGRAM_ALPHA,
NULL);
else
gegl_node_set (image_map_tool->operation,
"channel", channel,
NULL);
for (channel = GIMP_HISTOGRAM_VALUE;
channel <= GIMP_HISTOGRAM_ALPHA;
channel++)
{
/* FIXME: hack */
if (! tool->color && channel == 1)
gegl_node_set (image_map_tool->operation,
"channel", GIMP_HISTOGRAM_ALPHA,
NULL);
else
gegl_node_set (image_map_tool->operation,
"channel", channel,
NULL);
gegl_node_set (image_map_tool->operation,
"gamma", tool->levels->gamma[channel],
"low-input", tool->levels->low_input[channel] / 255.0,
"high-input", tool->levels->high_input[channel] / 255.0,
"low-output", tool->levels->low_output[channel] / 255.0,
"high-output", tool->levels->high_output[channel] / 255.0,
NULL);
gegl_node_set (image_map_tool->operation,
"gamma", levels->gamma[channel],
"low-input", levels->low_input[channel] / 255.0,
"high-input", levels->high_input[channel] / 255.0,
"low-output", levels->low_output[channel] / 255.0,
"high-output", levels->high_output[channel] / 255.0,
NULL);
/* FIXME: hack */
if (! tool->color && channel == 1)
break;
}
/* FIXME: hack */
if (! tool->color && channel == 1)
break;
}
gimp_lut_setup (tool->lut,

View File

@ -174,12 +174,9 @@ gimp_posterize_tool_map (GimpImageMapTool *image_map_tool)
{
GimpPosterizeTool *posterize_tool = GIMP_POSTERIZE_TOOL (image_map_tool);
if (image_map_tool->operation)
{
gegl_node_set (image_map_tool->operation,
"levels", posterize_tool->levels,
NULL);
}
gegl_node_set (image_map_tool->operation,
"levels", posterize_tool->levels,
NULL);
posterize_lut_setup (posterize_tool->lut,
posterize_tool->levels,

View File

@ -198,13 +198,10 @@ gimp_threshold_tool_map (GimpImageMapTool *image_map_tool)
{
GimpThresholdTool *t_tool = GIMP_THRESHOLD_TOOL (image_map_tool);
if (image_map_tool->operation)
{
gegl_node_set (image_map_tool->operation,
"low", t_tool->threshold->low_threshold / 255.0,
"high", t_tool->threshold->high_threshold / 255.0,
NULL);
}
gegl_node_set (image_map_tool->operation,
"low", t_tool->threshold->low_threshold / 255.0,
"high", t_tool->threshold->high_threshold / 255.0,
NULL);
}