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>
|
||||
|
||||
* app/base/pixel-processor.[ch]: define the maximum number of
|
||||
|
|
|
@ -26,8 +26,6 @@
|
|||
|
||||
#include "base-types.h"
|
||||
|
||||
#include "config/gimpbaseconfig.h"
|
||||
|
||||
#include "gimphistogram.h"
|
||||
#include "pixel-processor.h"
|
||||
#include "pixel-region.h"
|
||||
|
@ -35,50 +33,39 @@
|
|||
|
||||
struct _GimpHistogram
|
||||
{
|
||||
gint bins;
|
||||
gdouble **values;
|
||||
gint n_channels;
|
||||
gint bins;
|
||||
gdouble **values;
|
||||
gint n_channels;
|
||||
|
||||
#ifdef ENABLE_MP
|
||||
GStaticMutex mutex;
|
||||
gint num_slots;
|
||||
gdouble ***tmp_values;
|
||||
gchar *tmp_slots;
|
||||
GStaticMutex mutex;
|
||||
gdouble **tmp_values[GIMP_MAX_NUM_THREADS];
|
||||
gchar tmp_slots[GIMP_MAX_NUM_THREADS];
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_histogram_alloc_values (GimpHistogram *histogram,
|
||||
gint bytes);
|
||||
static void gimp_histogram_free_values (GimpHistogram *histogram);
|
||||
static void gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
|
||||
PixelRegion *region,
|
||||
PixelRegion *mask);
|
||||
static void gimp_histogram_alloc_values (GimpHistogram *histogram,
|
||||
gint bytes);
|
||||
static void gimp_histogram_free_values (GimpHistogram *histogram);
|
||||
static void gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
|
||||
PixelRegion *region,
|
||||
PixelRegion *mask);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
GimpHistogram *
|
||||
gimp_histogram_new (GimpBaseConfig *config)
|
||||
gimp_histogram_new (void)
|
||||
{
|
||||
GimpHistogram *histogram;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_BASE_CONFIG (config), NULL);
|
||||
|
||||
histogram = g_new0 (GimpHistogram, 1);
|
||||
GimpHistogram *histogram = g_new0 (GimpHistogram, 1);
|
||||
|
||||
histogram->bins = 0;
|
||||
histogram->values = NULL;
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -87,11 +74,6 @@ gimp_histogram_free (GimpHistogram *histogram)
|
|||
{
|
||||
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);
|
||||
g_free (histogram);
|
||||
}
|
||||
|
@ -113,24 +95,6 @@ gimp_histogram_calculate (GimpHistogram *histogram,
|
|||
|
||||
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 (j = 0; j < 256; j++)
|
||||
histogram->values[i][j] = 0.0;
|
||||
|
@ -141,19 +105,23 @@ gimp_histogram_calculate (GimpHistogram *histogram,
|
|||
|
||||
#ifdef ENABLE_MP
|
||||
/* 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++)
|
||||
{
|
||||
for (j = 0; j < histogram->n_channels; j++)
|
||||
if (histogram->tmp_values[i])
|
||||
{
|
||||
gint k;
|
||||
for (j = 0; j < histogram->n_channels; j++)
|
||||
{
|
||||
gint k;
|
||||
|
||||
for (k = 0; k < 256; k++)
|
||||
histogram->values[j][k] += histogram->tmp_values[i][j][k];
|
||||
for (k = 0; k < 256; k++)
|
||||
histogram->values[j][k] += histogram->tmp_values[i][j][k];
|
||||
|
||||
g_free (histogram->tmp_values[i][j]);
|
||||
g_free (histogram->tmp_values[i][j]);
|
||||
}
|
||||
|
||||
g_free (histogram->tmp_values[i]);
|
||||
histogram->tmp_values[i] = NULL;
|
||||
}
|
||||
|
||||
g_free (histogram->tmp_values[i]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -470,6 +438,18 @@ gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
|
|||
|
||||
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
|
||||
values = histogram->values;
|
||||
#endif
|
||||
|
@ -627,7 +607,6 @@ gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
|
|||
|
||||
#ifdef ENABLE_MP
|
||||
/* unlock this slot */
|
||||
/* we shouldn't have to use mutex locks here */
|
||||
g_static_mutex_lock (&histogram->mutex);
|
||||
|
||||
histogram->tmp_slots[slot] = 0;
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#define __GIMP_HISTOGRAM_H__
|
||||
|
||||
|
||||
GimpHistogram * gimp_histogram_new (GimpBaseConfig *config);
|
||||
GimpHistogram * gimp_histogram_new (void);
|
||||
void gimp_histogram_free (GimpHistogram *histogram);
|
||||
|
||||
void gimp_histogram_calculate (GimpHistogram *histogram,
|
||||
|
|
|
@ -28,8 +28,6 @@
|
|||
#include "base/pixel-processor.h"
|
||||
#include "base/pixel-region.h"
|
||||
|
||||
#include "config/gimpbaseconfig.h"
|
||||
|
||||
#include "gimp.h"
|
||||
#include "gimpdrawable.h"
|
||||
#include "gimpdrawable-equalize.h"
|
||||
|
@ -59,7 +57,7 @@ gimp_drawable_equalize (GimpDrawable *drawable,
|
|||
if (! gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
|
||||
return;
|
||||
|
||||
hist = gimp_histogram_new (GIMP_BASE_CONFIG (gimage->gimp->config));
|
||||
hist = gimp_histogram_new ();
|
||||
gimp_drawable_calculate_histogram (drawable, hist);
|
||||
|
||||
/* Build equalization LUT */
|
||||
|
|
|
@ -31,8 +31,6 @@
|
|||
#include "base/pixel-processor.h"
|
||||
#include "base/pixel-region.h"
|
||||
|
||||
#include "config/gimpbaseconfig.h"
|
||||
|
||||
#include "gimp.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpdrawable.h"
|
||||
|
@ -133,7 +131,7 @@ gimp_drawable_levels_stretch (GimpDrawable *drawable,
|
|||
return;
|
||||
|
||||
/* Build the histogram */
|
||||
hist = gimp_histogram_new (GIMP_BASE_CONFIG (context->gimp->config));
|
||||
hist = gimp_histogram_new ();
|
||||
|
||||
gimp_drawable_calculate_histogram (drawable, hist);
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#include "base/pixel-processor.h"
|
||||
#include "base/pixel-region.h"
|
||||
#include "base/threshold.h"
|
||||
#include "config/gimpbaseconfig.h"
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpdrawable-desaturate.h"
|
||||
#include "core/gimpdrawable-equalize.h"
|
||||
|
@ -1214,9 +1213,7 @@ histogram_invoker (Gimp *gimp,
|
|||
|
||||
if (success)
|
||||
{
|
||||
GimpHistogram *histogram;
|
||||
|
||||
histogram = gimp_histogram_new (GIMP_BASE_CONFIG (gimp->config));
|
||||
GimpHistogram *histogram = gimp_histogram_new ();
|
||||
|
||||
gimp_drawable_calculate_histogram (drawable, histogram);
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
|
||||
#include "tools-types.h"
|
||||
|
||||
#include "config/gimpbaseconfig.h"
|
||||
#include "config/gimpguiconfig.h"
|
||||
|
||||
#include "base/curves.h"
|
||||
|
@ -281,11 +280,7 @@ gimp_curves_tool_initialize (GimpTool *tool,
|
|||
}
|
||||
|
||||
if (! c_tool->hist)
|
||||
{
|
||||
Gimp *gimp = GIMP_TOOL (c_tool)->tool_info->gimp;
|
||||
|
||||
c_tool->hist = gimp_histogram_new (GIMP_BASE_CONFIG (gimp->config));
|
||||
}
|
||||
c_tool->hist = gimp_histogram_new ();
|
||||
|
||||
curves_init (c_tool->curves);
|
||||
|
||||
|
|
|
@ -34,8 +34,6 @@
|
|||
#include "base/gimplut.h"
|
||||
#include "base/levels.h"
|
||||
|
||||
#include "config/gimpbaseconfig.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpdrawable-histogram.h"
|
||||
|
@ -283,11 +281,7 @@ gimp_levels_tool_initialize (GimpTool *tool,
|
|||
}
|
||||
|
||||
if (! l_tool->hist)
|
||||
{
|
||||
Gimp *gimp = tool->tool_info->gimp;
|
||||
|
||||
l_tool->hist = gimp_histogram_new (GIMP_BASE_CONFIG (gimp->config));
|
||||
}
|
||||
l_tool->hist = gimp_histogram_new ();
|
||||
|
||||
levels_init (l_tool->levels);
|
||||
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
#include "base/gimphistogram.h"
|
||||
#include "base/threshold.h"
|
||||
|
||||
#include "config/gimpbaseconfig.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpdrawable-histogram.h"
|
||||
|
@ -200,11 +198,7 @@ gimp_threshold_tool_initialize (GimpTool *tool,
|
|||
}
|
||||
|
||||
if (!t_tool->hist)
|
||||
{
|
||||
Gimp *gimp = GIMP_TOOL (t_tool)->tool_info->gimp;
|
||||
|
||||
t_tool->hist = gimp_histogram_new (GIMP_BASE_CONFIG (gimp->config));
|
||||
}
|
||||
t_tool->hist = gimp_histogram_new ();
|
||||
|
||||
t_tool->threshold->color = gimp_drawable_is_rgb (drawable);
|
||||
t_tool->threshold->low_threshold = 127;
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
#include "base/gimphistogram.h"
|
||||
#include "base/pixel-region.h"
|
||||
|
||||
#include "config/gimpbaseconfig.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpdrawable-histogram.h"
|
||||
|
@ -291,8 +289,7 @@ gimp_histogram_editor_set_image (GimpImageEditor *image_editor,
|
|||
|
||||
if (gimage)
|
||||
{
|
||||
editor->histogram =
|
||||
gimp_histogram_new (GIMP_BASE_CONFIG (gimage->gimp->config));
|
||||
editor->histogram = gimp_histogram_new ();
|
||||
|
||||
gimp_histogram_view_set_histogram (view, editor->histogram);
|
||||
|
||||
|
|
|
@ -733,8 +733,7 @@ HELP
|
|||
}
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("config/gimpbaseconfig.h" "core/gimp.h"
|
||||
"core/gimpdrawable-histogram.h") ],
|
||||
headers => [ qw("core/gimp.h" "core/gimpdrawable-histogram.h") ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
if (! gimp_item_is_attached (GIMP_ITEM (drawable)) ||
|
||||
|
@ -747,9 +746,7 @@ HELP
|
|||
|
||||
if (success)
|
||||
{
|
||||
GimpHistogram *histogram;
|
||||
|
||||
histogram = gimp_histogram_new (GIMP_BASE_CONFIG (gimp->config));
|
||||
GimpHistogram *histogram = gimp_histogram_new ();
|
||||
|
||||
gimp_drawable_calculate_histogram (drawable, histogram);
|
||||
|
||||
|
|
Loading…
Reference in New Issue