mirror of https://github.com/GNOME/gimp.git
allocate temporary histogram slots on demand and provide an array with
2005-02-14 Sven Neumann <sven@gimp.org> * app/base/gimphistogram.[ch]: allocate temporary histogram slots on demand and provide an array with enough slots for the maximum number of threads. gimp_histogram_new() doesn't need a GimpBaseConfig parameter any longer. * app/core/gimpdrawable-equalize.c * app/core/gimpdrawable-levels.c * app/tools/gimpcurvestool.c * app/tools/gimplevelstool.c * app/tools/gimpthresholdtool.c * app/widgets/gimphistogrameditor.c * tools/pdbgen/pdb/color.pdb: changed accordingly. * app/pdb/color_cmds.c: regenerated.
This commit is contained in:
parent
9e6fd61f59
commit
1cb9714f02
17
ChangeLog
17
ChangeLog
|
@ -1,3 +1,20 @@
|
||||||
|
2005-02-14 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* app/base/gimphistogram.[ch]: allocate temporary histogram slots
|
||||||
|
on demand and provide an array with enough slots for the maximum
|
||||||
|
number of threads. gimp_histogram_new() doesn't need a
|
||||||
|
GimpBaseConfig parameter any longer.
|
||||||
|
|
||||||
|
* app/core/gimpdrawable-equalize.c
|
||||||
|
* app/core/gimpdrawable-levels.c
|
||||||
|
* app/tools/gimpcurvestool.c
|
||||||
|
* app/tools/gimplevelstool.c
|
||||||
|
* app/tools/gimpthresholdtool.c
|
||||||
|
* app/widgets/gimphistogrameditor.c
|
||||||
|
* tools/pdbgen/pdb/color.pdb: changed accordingly.
|
||||||
|
|
||||||
|
* app/pdb/color_cmds.c: regenerated.
|
||||||
|
|
||||||
2005-02-14 Sven Neumann <sven@gimp.org>
|
2005-02-14 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* app/base/pixel-processor.[ch]: define the maximum number of
|
* app/base/pixel-processor.[ch]: define the maximum number of
|
||||||
|
|
|
@ -26,8 +26,6 @@
|
||||||
|
|
||||||
#include "base-types.h"
|
#include "base-types.h"
|
||||||
|
|
||||||
#include "config/gimpbaseconfig.h"
|
|
||||||
|
|
||||||
#include "gimphistogram.h"
|
#include "gimphistogram.h"
|
||||||
#include "pixel-processor.h"
|
#include "pixel-processor.h"
|
||||||
#include "pixel-region.h"
|
#include "pixel-region.h"
|
||||||
|
@ -41,9 +39,8 @@ struct _GimpHistogram
|
||||||
|
|
||||||
#ifdef ENABLE_MP
|
#ifdef ENABLE_MP
|
||||||
GStaticMutex mutex;
|
GStaticMutex mutex;
|
||||||
gint num_slots;
|
gdouble **tmp_values[GIMP_MAX_NUM_THREADS];
|
||||||
gdouble ***tmp_values;
|
gchar tmp_slots[GIMP_MAX_NUM_THREADS];
|
||||||
gchar *tmp_slots;
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -61,24 +58,14 @@ static void gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
|
||||||
/* public functions */
|
/* public functions */
|
||||||
|
|
||||||
GimpHistogram *
|
GimpHistogram *
|
||||||
gimp_histogram_new (GimpBaseConfig *config)
|
gimp_histogram_new (void)
|
||||||
{
|
{
|
||||||
GimpHistogram *histogram;
|
GimpHistogram *histogram = g_new0 (GimpHistogram, 1);
|
||||||
|
|
||||||
g_return_val_if_fail (GIMP_IS_BASE_CONFIG (config), NULL);
|
|
||||||
|
|
||||||
histogram = g_new0 (GimpHistogram, 1);
|
|
||||||
|
|
||||||
histogram->bins = 0;
|
histogram->bins = 0;
|
||||||
histogram->values = NULL;
|
histogram->values = NULL;
|
||||||
histogram->n_channels = 0;
|
histogram->n_channels = 0;
|
||||||
|
|
||||||
#ifdef ENABLE_MP
|
|
||||||
histogram->num_slots = config->num_processors;
|
|
||||||
histogram->tmp_slots = g_new0 (gchar, histogram->num_slots);
|
|
||||||
histogram->tmp_values = g_new0 (gdouble **, histogram->num_slots);
|
|
||||||
#endif /* ENABLE_MP */
|
|
||||||
|
|
||||||
return histogram;
|
return histogram;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,11 +74,6 @@ gimp_histogram_free (GimpHistogram *histogram)
|
||||||
{
|
{
|
||||||
g_return_if_fail (histogram != NULL);
|
g_return_if_fail (histogram != NULL);
|
||||||
|
|
||||||
#ifdef ENABLE_MP
|
|
||||||
g_free (histogram->tmp_values);
|
|
||||||
g_free (histogram->tmp_slots);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
gimp_histogram_free_values (histogram);
|
gimp_histogram_free_values (histogram);
|
||||||
g_free (histogram);
|
g_free (histogram);
|
||||||
}
|
}
|
||||||
|
@ -113,24 +95,6 @@ gimp_histogram_calculate (GimpHistogram *histogram,
|
||||||
|
|
||||||
gimp_histogram_alloc_values (histogram, region->bytes);
|
gimp_histogram_alloc_values (histogram, region->bytes);
|
||||||
|
|
||||||
#ifdef ENABLE_MP
|
|
||||||
for (i = 0; i < histogram->num_slots; i++)
|
|
||||||
{
|
|
||||||
histogram->tmp_values[i] = g_new0 (gdouble *, histogram->n_channels);
|
|
||||||
histogram->tmp_slots[i] = 0;
|
|
||||||
|
|
||||||
for (j = 0; j < histogram->n_channels; j++)
|
|
||||||
{
|
|
||||||
gint k;
|
|
||||||
|
|
||||||
histogram->tmp_values[i][j] = g_new0 (gdouble, 256);
|
|
||||||
|
|
||||||
for (k = 0; k < 256; k++)
|
|
||||||
histogram->tmp_values[i][j][k] = 0.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i = 0; i < histogram->n_channels; i++)
|
for (i = 0; i < histogram->n_channels; i++)
|
||||||
for (j = 0; j < 256; j++)
|
for (j = 0; j < 256; j++)
|
||||||
histogram->values[i][j] = 0.0;
|
histogram->values[i][j] = 0.0;
|
||||||
|
@ -141,7 +105,9 @@ gimp_histogram_calculate (GimpHistogram *histogram,
|
||||||
|
|
||||||
#ifdef ENABLE_MP
|
#ifdef ENABLE_MP
|
||||||
/* add up all the tmp buffers and free their memmory */
|
/* add up all the tmp buffers and free their memmory */
|
||||||
for (i = 0; i < histogram->num_slots; i++)
|
for (i = 0; i < GIMP_MAX_NUM_THREADS; i++)
|
||||||
|
{
|
||||||
|
if (histogram->tmp_values[i])
|
||||||
{
|
{
|
||||||
for (j = 0; j < histogram->n_channels; j++)
|
for (j = 0; j < histogram->n_channels; j++)
|
||||||
{
|
{
|
||||||
|
@ -154,6 +120,8 @@ gimp_histogram_calculate (GimpHistogram *histogram,
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (histogram->tmp_values[i]);
|
g_free (histogram->tmp_values[i]);
|
||||||
|
histogram->tmp_values[i] = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -470,6 +438,18 @@ gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
|
||||||
|
|
||||||
g_static_mutex_unlock (&histogram->mutex);
|
g_static_mutex_unlock (&histogram->mutex);
|
||||||
|
|
||||||
|
if (! values)
|
||||||
|
{
|
||||||
|
gint j;
|
||||||
|
|
||||||
|
histogram->tmp_values[slot] = g_new0 (gdouble *, histogram->n_channels);
|
||||||
|
|
||||||
|
for (j = 0; j < histogram->n_channels; j++)
|
||||||
|
histogram->tmp_values[slot][j] = g_new0 (gdouble, 256);
|
||||||
|
|
||||||
|
values = histogram->tmp_values[slot];
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
values = histogram->values;
|
values = histogram->values;
|
||||||
#endif
|
#endif
|
||||||
|
@ -627,7 +607,6 @@ gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
|
||||||
|
|
||||||
#ifdef ENABLE_MP
|
#ifdef ENABLE_MP
|
||||||
/* unlock this slot */
|
/* unlock this slot */
|
||||||
/* we shouldn't have to use mutex locks here */
|
|
||||||
g_static_mutex_lock (&histogram->mutex);
|
g_static_mutex_lock (&histogram->mutex);
|
||||||
|
|
||||||
histogram->tmp_slots[slot] = 0;
|
histogram->tmp_slots[slot] = 0;
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#define __GIMP_HISTOGRAM_H__
|
#define __GIMP_HISTOGRAM_H__
|
||||||
|
|
||||||
|
|
||||||
GimpHistogram * gimp_histogram_new (GimpBaseConfig *config);
|
GimpHistogram * gimp_histogram_new (void);
|
||||||
void gimp_histogram_free (GimpHistogram *histogram);
|
void gimp_histogram_free (GimpHistogram *histogram);
|
||||||
|
|
||||||
void gimp_histogram_calculate (GimpHistogram *histogram,
|
void gimp_histogram_calculate (GimpHistogram *histogram,
|
||||||
|
|
|
@ -28,8 +28,6 @@
|
||||||
#include "base/pixel-processor.h"
|
#include "base/pixel-processor.h"
|
||||||
#include "base/pixel-region.h"
|
#include "base/pixel-region.h"
|
||||||
|
|
||||||
#include "config/gimpbaseconfig.h"
|
|
||||||
|
|
||||||
#include "gimp.h"
|
#include "gimp.h"
|
||||||
#include "gimpdrawable.h"
|
#include "gimpdrawable.h"
|
||||||
#include "gimpdrawable-equalize.h"
|
#include "gimpdrawable-equalize.h"
|
||||||
|
@ -59,7 +57,7 @@ gimp_drawable_equalize (GimpDrawable *drawable,
|
||||||
if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
|
if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
hist = gimp_histogram_new (GIMP_BASE_CONFIG (gimage->gimp->config));
|
hist = gimp_histogram_new ();
|
||||||
gimp_drawable_calculate_histogram (drawable, hist);
|
gimp_drawable_calculate_histogram (drawable, hist);
|
||||||
|
|
||||||
/* Build equalization LUT */
|
/* Build equalization LUT */
|
||||||
|
|
|
@ -31,8 +31,6 @@
|
||||||
#include "base/pixel-processor.h"
|
#include "base/pixel-processor.h"
|
||||||
#include "base/pixel-region.h"
|
#include "base/pixel-region.h"
|
||||||
|
|
||||||
#include "config/gimpbaseconfig.h"
|
|
||||||
|
|
||||||
#include "gimp.h"
|
#include "gimp.h"
|
||||||
#include "gimpcontext.h"
|
#include "gimpcontext.h"
|
||||||
#include "gimpdrawable.h"
|
#include "gimpdrawable.h"
|
||||||
|
@ -133,7 +131,7 @@ gimp_drawable_levels_stretch (GimpDrawable *drawable,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Build the histogram */
|
/* Build the histogram */
|
||||||
hist = gimp_histogram_new (GIMP_BASE_CONFIG (context->gimp->config));
|
hist = gimp_histogram_new ();
|
||||||
|
|
||||||
gimp_drawable_calculate_histogram (drawable, hist);
|
gimp_drawable_calculate_histogram (drawable, hist);
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
#include "base/pixel-processor.h"
|
#include "base/pixel-processor.h"
|
||||||
#include "base/pixel-region.h"
|
#include "base/pixel-region.h"
|
||||||
#include "base/threshold.h"
|
#include "base/threshold.h"
|
||||||
#include "config/gimpbaseconfig.h"
|
|
||||||
#include "core/gimp.h"
|
#include "core/gimp.h"
|
||||||
#include "core/gimpdrawable-desaturate.h"
|
#include "core/gimpdrawable-desaturate.h"
|
||||||
#include "core/gimpdrawable-equalize.h"
|
#include "core/gimpdrawable-equalize.h"
|
||||||
|
@ -1214,9 +1213,7 @@ histogram_invoker (Gimp *gimp,
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
GimpHistogram *histogram;
|
GimpHistogram *histogram = gimp_histogram_new ();
|
||||||
|
|
||||||
histogram = gimp_histogram_new (GIMP_BASE_CONFIG (gimp->config));
|
|
||||||
|
|
||||||
gimp_drawable_calculate_histogram (drawable, histogram);
|
gimp_drawable_calculate_histogram (drawable, histogram);
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
|
|
||||||
#include "tools-types.h"
|
#include "tools-types.h"
|
||||||
|
|
||||||
#include "config/gimpbaseconfig.h"
|
|
||||||
#include "config/gimpguiconfig.h"
|
#include "config/gimpguiconfig.h"
|
||||||
|
|
||||||
#include "base/curves.h"
|
#include "base/curves.h"
|
||||||
|
@ -281,11 +280,7 @@ gimp_curves_tool_initialize (GimpTool *tool,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! c_tool->hist)
|
if (! c_tool->hist)
|
||||||
{
|
c_tool->hist = gimp_histogram_new ();
|
||||||
Gimp *gimp = GIMP_TOOL (c_tool)->tool_info->gimp;
|
|
||||||
|
|
||||||
c_tool->hist = gimp_histogram_new (GIMP_BASE_CONFIG (gimp->config));
|
|
||||||
}
|
|
||||||
|
|
||||||
curves_init (c_tool->curves);
|
curves_init (c_tool->curves);
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,6 @@
|
||||||
#include "base/gimplut.h"
|
#include "base/gimplut.h"
|
||||||
#include "base/levels.h"
|
#include "base/levels.h"
|
||||||
|
|
||||||
#include "config/gimpbaseconfig.h"
|
|
||||||
|
|
||||||
#include "core/gimp.h"
|
#include "core/gimp.h"
|
||||||
#include "core/gimpdrawable.h"
|
#include "core/gimpdrawable.h"
|
||||||
#include "core/gimpdrawable-histogram.h"
|
#include "core/gimpdrawable-histogram.h"
|
||||||
|
@ -283,11 +281,7 @@ gimp_levels_tool_initialize (GimpTool *tool,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! l_tool->hist)
|
if (! l_tool->hist)
|
||||||
{
|
l_tool->hist = gimp_histogram_new ();
|
||||||
Gimp *gimp = tool->tool_info->gimp;
|
|
||||||
|
|
||||||
l_tool->hist = gimp_histogram_new (GIMP_BASE_CONFIG (gimp->config));
|
|
||||||
}
|
|
||||||
|
|
||||||
levels_init (l_tool->levels);
|
levels_init (l_tool->levels);
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,6 @@
|
||||||
#include "base/gimphistogram.h"
|
#include "base/gimphistogram.h"
|
||||||
#include "base/threshold.h"
|
#include "base/threshold.h"
|
||||||
|
|
||||||
#include "config/gimpbaseconfig.h"
|
|
||||||
|
|
||||||
#include "core/gimp.h"
|
#include "core/gimp.h"
|
||||||
#include "core/gimpdrawable.h"
|
#include "core/gimpdrawable.h"
|
||||||
#include "core/gimpdrawable-histogram.h"
|
#include "core/gimpdrawable-histogram.h"
|
||||||
|
@ -200,11 +198,7 @@ gimp_threshold_tool_initialize (GimpTool *tool,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!t_tool->hist)
|
if (!t_tool->hist)
|
||||||
{
|
t_tool->hist = gimp_histogram_new ();
|
||||||
Gimp *gimp = GIMP_TOOL (t_tool)->tool_info->gimp;
|
|
||||||
|
|
||||||
t_tool->hist = gimp_histogram_new (GIMP_BASE_CONFIG (gimp->config));
|
|
||||||
}
|
|
||||||
|
|
||||||
t_tool->threshold->color = gimp_drawable_is_rgb (drawable);
|
t_tool->threshold->color = gimp_drawable_is_rgb (drawable);
|
||||||
t_tool->threshold->low_threshold = 127;
|
t_tool->threshold->low_threshold = 127;
|
||||||
|
|
|
@ -27,8 +27,6 @@
|
||||||
#include "base/gimphistogram.h"
|
#include "base/gimphistogram.h"
|
||||||
#include "base/pixel-region.h"
|
#include "base/pixel-region.h"
|
||||||
|
|
||||||
#include "config/gimpbaseconfig.h"
|
|
||||||
|
|
||||||
#include "core/gimp.h"
|
#include "core/gimp.h"
|
||||||
#include "core/gimpdrawable.h"
|
#include "core/gimpdrawable.h"
|
||||||
#include "core/gimpdrawable-histogram.h"
|
#include "core/gimpdrawable-histogram.h"
|
||||||
|
@ -291,8 +289,7 @@ gimp_histogram_editor_set_image (GimpImageEditor *image_editor,
|
||||||
|
|
||||||
if (gimage)
|
if (gimage)
|
||||||
{
|
{
|
||||||
editor->histogram =
|
editor->histogram = gimp_histogram_new ();
|
||||||
gimp_histogram_new (GIMP_BASE_CONFIG (gimage->gimp->config));
|
|
||||||
|
|
||||||
gimp_histogram_view_set_histogram (view, editor->histogram);
|
gimp_histogram_view_set_histogram (view, editor->histogram);
|
||||||
|
|
||||||
|
|
|
@ -733,8 +733,7 @@ HELP
|
||||||
}
|
}
|
||||||
|
|
||||||
%invoke = (
|
%invoke = (
|
||||||
headers => [ qw("config/gimpbaseconfig.h" "core/gimp.h"
|
headers => [ qw("core/gimp.h" "core/gimpdrawable-histogram.h") ],
|
||||||
"core/gimpdrawable-histogram.h") ],
|
|
||||||
code => <<'CODE'
|
code => <<'CODE'
|
||||||
{
|
{
|
||||||
if (! gimp_item_is_attached (GIMP_ITEM (drawable)) ||
|
if (! gimp_item_is_attached (GIMP_ITEM (drawable)) ||
|
||||||
|
@ -747,9 +746,7 @@ HELP
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
GimpHistogram *histogram;
|
GimpHistogram *histogram = gimp_histogram_new ();
|
||||||
|
|
||||||
histogram = gimp_histogram_new (GIMP_BASE_CONFIG (gimp->config));
|
|
||||||
|
|
||||||
gimp_drawable_calculate_histogram (drawable, histogram);
|
gimp_drawable_calculate_histogram (drawable, histogram);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue