mirror of https://github.com/GNOME/gimp.git
Fixed bug #103561:
2003-01-15 Sven Neumann <sven@gimp.org> Fixed bug #103561: * app/base/gimphistogram.[ch]: cleaned up multi-processor code, added a GimpBaseConfig parameter to gimp_histogram_new(). * app/core/gimpdrawable-equalize.c * app/pdb/color_cmds.c * app/tools/gimphistogramtool.c * app/tools/gimplevelstool.c * app/tools/gimpthresholdtool.c * tools/pdbgen/pdb/color.pdb: changed accordingly. * app/base/pixel-processor.c: some cleanup to the multi-processor code; use the global base_config variable :(
This commit is contained in:
parent
967861bbaf
commit
bb9a49ab08
17
ChangeLog
17
ChangeLog
|
@ -1,3 +1,20 @@
|
|||
2003-01-15 Sven Neumann <sven@gimp.org>
|
||||
|
||||
Fixed bug #103561:
|
||||
|
||||
* app/base/gimphistogram.[ch]: cleaned up multi-processor code,
|
||||
added a GimpBaseConfig parameter to gimp_histogram_new().
|
||||
|
||||
* app/core/gimpdrawable-equalize.c
|
||||
* app/pdb/color_cmds.c
|
||||
* app/tools/gimphistogramtool.c
|
||||
* app/tools/gimplevelstool.c
|
||||
* app/tools/gimpthresholdtool.c
|
||||
* tools/pdbgen/pdb/color.pdb: changed accordingly.
|
||||
|
||||
* app/base/pixel-processor.c: some cleanup to the multi-processor
|
||||
code; use the global base_config variable :(
|
||||
|
||||
2003-01-14 Manish Singh <yosh@gimp.org>
|
||||
|
||||
* app/core/gimpchannel.h
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#ifdef ENABLE_MP
|
||||
#include <pthread.h>
|
||||
#endif /* ENABLE_MP */
|
||||
#endif
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
|
@ -39,16 +39,16 @@
|
|||
|
||||
struct _GimpHistogram
|
||||
{
|
||||
gint bins;
|
||||
gdouble **values;
|
||||
gint n_channels;
|
||||
gint bins;
|
||||
gdouble **values;
|
||||
gint n_channels;
|
||||
|
||||
#ifdef ENABLE_MP
|
||||
pthread_mutex_t mutex;
|
||||
gint nthreads;
|
||||
gint num_slots;
|
||||
gdouble ***tmp_values;
|
||||
gchar *tmp_slots;
|
||||
#endif /* ENABLE_MP */
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
@ -65,19 +65,24 @@ static void gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
|
|||
/* public functions */
|
||||
|
||||
GimpHistogram *
|
||||
gimp_histogram_new (void)
|
||||
gimp_histogram_new (GimpBaseConfig *config)
|
||||
{
|
||||
GimpHistogram *histogram;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_BASE_CONFIG (config), NULL);
|
||||
|
||||
histogram = g_new0 (GimpHistogram, 1);
|
||||
|
||||
histogram->bins = 0;
|
||||
histogram->values = NULL;
|
||||
histogram->n_channels = 0;
|
||||
|
||||
#ifdef ENABLE_MP
|
||||
histogram->nthreads = 0;
|
||||
histogram->tmp_values = NULL;
|
||||
histogram->tmp_slots = NULL;
|
||||
pthread_mutex_init (&histogram->mutex, NULL);
|
||||
|
||||
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;
|
||||
|
@ -88,6 +93,13 @@ gimp_histogram_free (GimpHistogram *histogram)
|
|||
{
|
||||
g_return_if_fail (histogram != NULL);
|
||||
|
||||
#ifdef ENABLE_MP
|
||||
pthread_mutex_destroy (&histogram->mutex);
|
||||
|
||||
g_free (histogram->tmp_values);
|
||||
g_free (histogram->tmp_slots);
|
||||
#endif
|
||||
|
||||
gimp_histogram_free_values (histogram);
|
||||
g_free (histogram);
|
||||
}
|
||||
|
@ -98,9 +110,6 @@ gimp_histogram_calculate (GimpHistogram *histogram,
|
|||
PixelRegion *mask)
|
||||
{
|
||||
gint i, j;
|
||||
#ifdef ENABLE_MP
|
||||
gint k;
|
||||
#endif
|
||||
|
||||
g_return_if_fail (histogram != NULL);
|
||||
g_return_if_fail (region != NULL);
|
||||
|
@ -108,17 +117,15 @@ gimp_histogram_calculate (GimpHistogram *histogram,
|
|||
gimp_histogram_alloc_values (histogram, region->bytes);
|
||||
|
||||
#ifdef ENABLE_MP
|
||||
pthread_mutex_init (&histogram->mutex, NULL);
|
||||
histogram->tmp_slots = g_new0 (gchar, base_config->num_processors);
|
||||
histogram->tmp_values = g_new0 (gdouble **, base_config->num_processors);
|
||||
|
||||
for (i = 0; i < base_config->num_processors; i++)
|
||||
for (i = 0; i < histogram->num_slots; i++)
|
||||
{
|
||||
histogram->tmp_values[i] = g_new0 (double *, histogram->n_channels);
|
||||
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++)
|
||||
|
@ -131,24 +138,25 @@ gimp_histogram_calculate (GimpHistogram *histogram,
|
|||
for (j = 0; j < 256; j++)
|
||||
histogram->values[i][j] = 0.0;
|
||||
|
||||
pixel_regions_process_parallel ((p_func)gimp_histogram_calculate_sub_region,
|
||||
pixel_regions_process_parallel ((p_func) gimp_histogram_calculate_sub_region,
|
||||
histogram, 2, region, mask);
|
||||
|
||||
#ifdef ENABLE_MP
|
||||
/* add up all the tmp buffers and free their memmory */
|
||||
for (i = 0; i < base_config->num_processors; i++)
|
||||
for (i = 0; i < histogram->num_slots; i++)
|
||||
{
|
||||
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];
|
||||
|
||||
g_free (histogram->tmp_values[i][j]);
|
||||
}
|
||||
|
||||
g_free (histogram->tmp_values[i]);
|
||||
}
|
||||
|
||||
g_free (histogram->tmp_values);
|
||||
g_free (histogram->tmp_slots);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -322,6 +330,7 @@ gimp_histogram_free_values (GimpHistogram *histogram)
|
|||
{
|
||||
for (i = 0; i < histogram->n_channels; i++)
|
||||
g_free (histogram->values[i]);
|
||||
|
||||
g_free (histogram->values);
|
||||
histogram->values = NULL;
|
||||
}
|
||||
|
@ -342,14 +351,16 @@ gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
|
|||
|
||||
/* find an unused temporary slot to put our results in and lock it */
|
||||
pthread_mutex_lock (&histogram->mutex);
|
||||
{
|
||||
while (histogram->tmp_slots[slot])
|
||||
slot++;
|
||||
values = histogram->tmp_values[slot];
|
||||
histogram->tmp_slots[slot] = 1;
|
||||
}
|
||||
|
||||
while (histogram->tmp_slots[slot])
|
||||
slot++;
|
||||
|
||||
values = histogram->tmp_values[slot];
|
||||
histogram->tmp_slots[slot] = 1;
|
||||
|
||||
pthread_mutex_unlock (&histogram->mutex);
|
||||
#else /* !ENABLE_MP */
|
||||
|
||||
#else
|
||||
values = histogram->values;
|
||||
#endif
|
||||
|
||||
|
@ -400,10 +411,12 @@ gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
|
|||
values[2][s[1]] += masked;
|
||||
values[3][s[2]] += masked;
|
||||
max = (s[0] > s[1]) ? s[0] : s[1];
|
||||
|
||||
if (s[2] > max)
|
||||
values[0][s[2]] += masked;
|
||||
else
|
||||
values[0][max] += masked;
|
||||
|
||||
s += 3;
|
||||
m += 1;
|
||||
}
|
||||
|
@ -418,10 +431,12 @@ gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
|
|||
values[3][s[2]] += masked;
|
||||
values[4][s[3]] += masked;
|
||||
max = (s[0] > s[1]) ? s[0] : s[1];
|
||||
|
||||
if (s[2] > max)
|
||||
values[0][s[2]] += masked;
|
||||
else
|
||||
values[0][max] += masked;
|
||||
|
||||
s += 3;
|
||||
m += 1;
|
||||
}
|
||||
|
@ -467,10 +482,12 @@ gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
|
|||
values[2][s[1]] += 1.0;
|
||||
values[3][s[2]] += 1.0;
|
||||
max = (s[0] > s[1]) ? s[0] : s[1];
|
||||
|
||||
if (s[2] > max)
|
||||
values[0][s[2]] += 1.0;
|
||||
else
|
||||
values[0][max] += 1.0;
|
||||
|
||||
s += 3;
|
||||
}
|
||||
break;
|
||||
|
@ -483,10 +500,12 @@ gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
|
|||
values[3][s[2]] += 1.0;
|
||||
values[4][s[3]] += 1.0;
|
||||
max = (s[0] > s[1]) ? s[0] : s[1];
|
||||
|
||||
if (s[2] > max)
|
||||
values[0][s[2]] += 1.0;
|
||||
else
|
||||
values[0][max] += 1.0;
|
||||
|
||||
s += 4;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -22,37 +22,37 @@
|
|||
#define __GIMP_HISTOGRAM_H__
|
||||
|
||||
|
||||
GimpHistogram * gimp_histogram_new (void);
|
||||
void gimp_histogram_free (GimpHistogram *histogram);
|
||||
GimpHistogram * gimp_histogram_new (GimpBaseConfig *config);
|
||||
void gimp_histogram_free (GimpHistogram *histogram);
|
||||
|
||||
void gimp_histogram_calculate (GimpHistogram *historgam,
|
||||
PixelRegion *region,
|
||||
PixelRegion *mask);
|
||||
void gimp_histogram_calculate (GimpHistogram *historgam,
|
||||
PixelRegion *region,
|
||||
PixelRegion *mask);
|
||||
|
||||
gdouble gimp_histogram_get_maximum (GimpHistogram *histogram,
|
||||
GimpHistogramChannel channel);
|
||||
gdouble gimp_histogram_get_count (GimpHistogram *histogram,
|
||||
gint start,
|
||||
gint end);
|
||||
gdouble gimp_histogram_get_mean (GimpHistogram *histogram,
|
||||
GimpHistogramChannel channel,
|
||||
gint start,
|
||||
gint end);
|
||||
gint gimp_histogram_get_median (GimpHistogram *histogram,
|
||||
GimpHistogramChannel channel,
|
||||
gint start,
|
||||
gint end);
|
||||
gdouble gimp_histogram_get_std_dev (GimpHistogram *histogram,
|
||||
GimpHistogramChannel channel,
|
||||
gint start,
|
||||
gint end);
|
||||
gdouble gimp_histogram_get_value (GimpHistogram *histogram,
|
||||
GimpHistogramChannel channel,
|
||||
gint bin);
|
||||
gdouble gimp_histogram_get_channel (GimpHistogram *histogram,
|
||||
GimpHistogramChannel channel,
|
||||
gint bin);
|
||||
gint gimp_histogram_nchannels (GimpHistogram *histogram);
|
||||
gdouble gimp_histogram_get_maximum (GimpHistogram *histogram,
|
||||
GimpHistogramChannel channel);
|
||||
gdouble gimp_histogram_get_count (GimpHistogram *histogram,
|
||||
gint start,
|
||||
gint end);
|
||||
gdouble gimp_histogram_get_mean (GimpHistogram *histogram,
|
||||
GimpHistogramChannel channel,
|
||||
gint start,
|
||||
gint end);
|
||||
gint gimp_histogram_get_median (GimpHistogram *histogram,
|
||||
GimpHistogramChannel channel,
|
||||
gint start,
|
||||
gint end);
|
||||
gdouble gimp_histogram_get_std_dev (GimpHistogram *histogram,
|
||||
GimpHistogramChannel channel,
|
||||
gint start,
|
||||
gint end);
|
||||
gdouble gimp_histogram_get_value (GimpHistogram *histogram,
|
||||
GimpHistogramChannel channel,
|
||||
gint bin);
|
||||
gdouble gimp_histogram_get_channel (GimpHistogram *histogram,
|
||||
GimpHistogramChannel channel,
|
||||
gint bin);
|
||||
gint gimp_histogram_nchannels (GimpHistogram *histogram);
|
||||
|
||||
|
||||
#endif /* __GIMP_HISTOGRAM_H__ */
|
||||
|
|
|
@ -22,10 +22,7 @@
|
|||
|
||||
#ifdef ENABLE_MP
|
||||
#include <pthread.h>
|
||||
#define IF_THREAD(statement) statement
|
||||
#else /* !ENABLE_MP */
|
||||
#define IF_THREAD(statement)
|
||||
#endif /* ENABLE_MP */
|
||||
#endif
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
|
@ -40,6 +37,11 @@
|
|||
#include "tile.h"
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#warning FIXME: extern GimpBaseConfig *base_config;
|
||||
#endif
|
||||
extern GimpBaseConfig *base_config;
|
||||
|
||||
|
||||
typedef void (* p1_func) (gpointer ,
|
||||
PixelRegion *);
|
||||
|
@ -62,8 +64,12 @@ struct _PixelProcessor
|
|||
gpointer data;
|
||||
p_func f;
|
||||
PixelRegionIterator *PRI;
|
||||
IF_THREAD(pthread_mutex_t mutex;)
|
||||
|
||||
#ifdef ENABLE_MP
|
||||
pthread_mutex_t mutex;
|
||||
gint nthreads;
|
||||
#endif
|
||||
|
||||
gint n_regions;
|
||||
PixelRegion *r[4];
|
||||
|
||||
|
@ -72,7 +78,7 @@ struct _PixelProcessor
|
|||
};
|
||||
|
||||
|
||||
IF_THREAD(
|
||||
#ifdef ENABLE_MP
|
||||
static void *
|
||||
do_parallel_regions (PixelProcessor *p_s)
|
||||
{
|
||||
|
@ -110,34 +116,35 @@ do_parallel_regions (PixelProcessor *p_s)
|
|||
switch(p_s->n_regions)
|
||||
{
|
||||
case 1:
|
||||
((p1_func)p_s->f)(p_s->data,
|
||||
p_s->r[0] ? &tr[0] : NULL);
|
||||
((p1_func) p_s->f) (p_s->data,
|
||||
p_s->r[0] ? &tr[0] : NULL);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
((p2_func)p_s->f)(p_s->data,
|
||||
p_s->r[0] ? &tr[0] : NULL,
|
||||
p_s->r[1] ? &tr[1] : NULL);
|
||||
((p2_func) p_s->f) (p_s->data,
|
||||
p_s->r[0] ? &tr[0] : NULL,
|
||||
p_s->r[1] ? &tr[1] : NULL);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
((p3_func)p_s->f)(p_s->data,
|
||||
p_s->r[0] ? &tr[0] : NULL,
|
||||
p_s->r[1] ? &tr[1] : NULL,
|
||||
p_s->r[2] ? &tr[2] : NULL);
|
||||
((p3_func) p_s->f) (p_s->data,
|
||||
p_s->r[0] ? &tr[0] : NULL,
|
||||
p_s->r[1] ? &tr[1] : NULL,
|
||||
p_s->r[2] ? &tr[2] : NULL);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
((p4_func)p_s->f)(p_s->data,
|
||||
p_s->r[0] ? &tr[0] : NULL,
|
||||
p_s->r[1] ? &tr[1] : NULL,
|
||||
p_s->r[2] ? &tr[2] : NULL,
|
||||
p_s->r[3] ? &tr[3] : NULL);
|
||||
((p4_func) p_s->f) (p_s->data,
|
||||
p_s->r[0] ? &tr[0] : NULL,
|
||||
p_s->r[1] ? &tr[1] : NULL,
|
||||
p_s->r[2] ? &tr[2] : NULL,
|
||||
p_s->r[3] ? &tr[3] : NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_message("do_parallel_regions: Bad number of regions %d\n",
|
||||
p_s->n_regions);
|
||||
g_warning ("do_parallel_regions: Bad number of regions %d\n",
|
||||
p_s->n_regions);
|
||||
break;
|
||||
}
|
||||
|
||||
pthread_mutex_lock (&p_s->mutex);
|
||||
|
@ -146,16 +153,17 @@ do_parallel_regions (PixelProcessor *p_s)
|
|||
if (p_s->r[i])
|
||||
{
|
||||
if (tr[i].tiles)
|
||||
tile_release(tr[i].curtile, tr[i].dirty);
|
||||
tile_release (tr[i].curtile, tr[i].dirty);
|
||||
}
|
||||
|
||||
if (p_s->progress_report_func &&
|
||||
!p_s->progress_report_func(p_s->progress_report_data,
|
||||
p_s->r[0]->x, p_s->r[0]->y,
|
||||
p_s->r[0]->w, p_s->r[0]->h))
|
||||
!p_s->progress_report_func (p_s->progress_report_data,
|
||||
p_s->r[0]->x, p_s->r[0]->y,
|
||||
p_s->r[0]->w, p_s->r[0]->h))
|
||||
cont = 0;
|
||||
|
||||
}
|
||||
|
||||
while (cont && p_s->PRI &&
|
||||
(p_s->PRI = pixel_regions_process (p_s->PRI)));
|
||||
|
||||
|
@ -165,7 +173,7 @@ do_parallel_regions (PixelProcessor *p_s)
|
|||
|
||||
return NULL;
|
||||
}
|
||||
)
|
||||
#endif
|
||||
|
||||
/* do_parallel_regions_single is just like do_parallel_regions
|
||||
* except that all the mutex and tile locks have been removed
|
||||
|
@ -181,46 +189,47 @@ do_parallel_regions_single (PixelProcessor *p_s)
|
|||
gint cont = 1;
|
||||
|
||||
do
|
||||
{
|
||||
switch (p_s->n_regions)
|
||||
{
|
||||
case 1:
|
||||
((p1_func)p_s->f)(p_s->data,
|
||||
p_s->r[0]);
|
||||
break;
|
||||
switch (p_s->n_regions)
|
||||
{
|
||||
case 1:
|
||||
((p1_func) p_s->f) (p_s->data,
|
||||
p_s->r[0]);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
((p2_func) p_s->f) (p_s->data,
|
||||
p_s->r[0],
|
||||
p_s->r[1]);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
((p2_func)p_s->f)(p_s->data,
|
||||
p_s->r[0],
|
||||
p_s->r[1]);
|
||||
break;
|
||||
case 3:
|
||||
((p3_func) p_s->f) (p_s->data,
|
||||
p_s->r[0],
|
||||
p_s->r[1],
|
||||
p_s->r[2]);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
((p4_func) p_s->f) (p_s->data,
|
||||
p_s->r[0],
|
||||
p_s->r[1],
|
||||
p_s->r[2],
|
||||
p_s->r[3]);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
((p3_func)p_s->f)(p_s->data,
|
||||
p_s->r[0],
|
||||
p_s->r[1],
|
||||
p_s->r[2]);
|
||||
break;
|
||||
default:
|
||||
g_warning ("do_parallel_regions_single: Bad number of regions %d\n",
|
||||
p_s->n_regions);
|
||||
}
|
||||
|
||||
case 4:
|
||||
((p4_func)p_s->f)(p_s->data,
|
||||
p_s->r[0],
|
||||
p_s->r[1],
|
||||
p_s->r[2],
|
||||
p_s->r[3]);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_message("do_parallel_regions_single: Bad number of regions %d\n",
|
||||
p_s->n_regions);
|
||||
if (p_s->progress_report_func &&
|
||||
!p_s->progress_report_func (p_s->progress_report_data,
|
||||
p_s->r[0]->x, p_s->r[0]->y,
|
||||
p_s->r[0]->w, p_s->r[0]->h))
|
||||
cont = 0;
|
||||
}
|
||||
|
||||
if (p_s->progress_report_func)
|
||||
if (!p_s->progress_report_func (p_s->progress_report_data,
|
||||
p_s->r[0]->x, p_s->r[0]->y,
|
||||
p_s->r[0]->w, p_s->r[0]->h))
|
||||
cont = 0;
|
||||
}
|
||||
while (cont && p_s->PRI &&
|
||||
(p_s->PRI = pixel_regions_process (p_s->PRI)));
|
||||
|
||||
|
@ -232,9 +241,9 @@ do_parallel_regions_single (PixelProcessor *p_s)
|
|||
static void
|
||||
pixel_regions_do_parallel (PixelProcessor *p_s)
|
||||
{
|
||||
IF_THREAD(
|
||||
#ifdef ENABLE_MP
|
||||
gint nthreads;
|
||||
|
||||
|
||||
nthreads = MIN (base_config->num_processors, MAX_THREADS);
|
||||
|
||||
/* make sure we have at least one tile per thread */
|
||||
|
@ -244,8 +253,8 @@ pixel_regions_do_parallel (PixelProcessor *p_s)
|
|||
|
||||
if (nthreads > 1)
|
||||
{
|
||||
gint i;
|
||||
pthread_t threads[MAX_THREADS];
|
||||
gint i;
|
||||
pthread_t threads[MAX_THREADS];
|
||||
pthread_attr_t pthread_attr;
|
||||
|
||||
pthread_attr_init (&pthread_attr);
|
||||
|
@ -260,17 +269,20 @@ pixel_regions_do_parallel (PixelProcessor *p_s)
|
|||
{
|
||||
gint ret;
|
||||
|
||||
if ((ret = pthread_join(threads[i], NULL)))
|
||||
if ((ret = pthread_join (threads[i], NULL)))
|
||||
{
|
||||
g_printerr ("pixel_regions_do_parallel:: pthread_join returned: %d\n", ret);
|
||||
g_printerr ("pixel_regions_do_parallel: "
|
||||
"pthread_join returned: %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
if (p_s->nthreads != 0)
|
||||
g_printerr ("pixel_regions_do_prarallel: we lost a thread\n");
|
||||
}
|
||||
else
|
||||
)
|
||||
do_parallel_regions_single (p_s);
|
||||
#endif
|
||||
|
||||
do_parallel_regions_single (p_s);
|
||||
}
|
||||
|
||||
static PixelProcessor *
|
||||
|
@ -318,8 +330,8 @@ pixel_regions_real_process_parallel (p_func f,
|
|||
break;
|
||||
|
||||
default:
|
||||
g_message ("pixel_regions_real_process_parallel: Bad number of regions %d\n",
|
||||
p_s->n_regions);
|
||||
g_warning ("pixel_regions_real_process_parallel:"
|
||||
"Bad number of regions %d\n", p_s->n_regions);
|
||||
}
|
||||
|
||||
if (!p_s->PRI)
|
||||
|
@ -328,13 +340,14 @@ pixel_regions_real_process_parallel (p_func f,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* Why would we wan't to set dirty_tiles to 0 here? */
|
||||
/* IF_THREAD(p_s->PRI->dirty_tiles = 0;) */
|
||||
p_s->f = f;
|
||||
p_s->data = data;
|
||||
p_s->n_regions = num_regions;
|
||||
IF_THREAD (pthread_mutex_init(&(p_s->mutex), NULL);)
|
||||
|
||||
#ifdef ENABLE_MP
|
||||
pthread_mutex_init (&p_s->mutex, NULL);
|
||||
p_s->nthreads = 0;
|
||||
#endif
|
||||
|
||||
p_s->progress_report_data = report_data;
|
||||
p_s->progress_report_func = report_func;
|
||||
|
@ -344,6 +357,10 @@ pixel_regions_real_process_parallel (p_func f,
|
|||
if (p_s->PRI)
|
||||
return p_s;
|
||||
|
||||
#ifdef ENABLE_MP
|
||||
pthread_mutex_destroy (&p_s->mutex);
|
||||
#endif
|
||||
|
||||
pixel_processor_free (p_s);
|
||||
|
||||
return NULL;
|
||||
|
@ -397,6 +414,7 @@ pixel_processor_stop (PixelProcessor *pp)
|
|||
pixel_regions_process_stop (pp->PRI);
|
||||
pp->PRI = NULL;
|
||||
}
|
||||
|
||||
pixel_processor_free (pp);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
#include "base/pixel-processor.h"
|
||||
#include "base/pixel-region.h"
|
||||
|
||||
#include "config/gimpbaseconfig.h"
|
||||
|
||||
#include "gimp.h"
|
||||
#include "gimpdrawable.h"
|
||||
#include "gimpdrawable-equalize.h"
|
||||
#include "gimpdrawable-histogram.h"
|
||||
|
@ -36,7 +39,7 @@
|
|||
|
||||
void
|
||||
gimp_drawable_equalize (GimpDrawable *drawable,
|
||||
gboolean mask_only)
|
||||
gboolean mask_only)
|
||||
{
|
||||
PixelRegion srcPR, destPR;
|
||||
guchar *mask;
|
||||
|
@ -45,8 +48,8 @@ gimp_drawable_equalize (GimpDrawable *drawable,
|
|||
gint x1, y1, x2, y2;
|
||||
GimpHistogram *hist;
|
||||
GimpLut *lut;
|
||||
GimpImage *gimage;
|
||||
|
||||
g_return_if_fail (drawable != NULL);
|
||||
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
||||
|
||||
mask = NULL;
|
||||
|
@ -55,7 +58,9 @@ gimp_drawable_equalize (GimpDrawable *drawable,
|
|||
has_alpha = gimp_drawable_has_alpha (drawable);
|
||||
alpha = has_alpha ? (bytes - 1) : bytes;
|
||||
|
||||
hist = gimp_histogram_new ();
|
||||
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
|
||||
|
||||
hist = gimp_histogram_new (GIMP_BASE_CONFIG (gimage->gimp->config));
|
||||
gimp_drawable_calculate_histogram (drawable, hist);
|
||||
|
||||
/* Build equalization LUT */
|
||||
|
@ -77,7 +82,5 @@ gimp_drawable_equalize (GimpDrawable *drawable,
|
|||
|
||||
gimp_drawable_merge_shadow (drawable, TRUE);
|
||||
|
||||
gimp_drawable_update (drawable,
|
||||
x1, y1,
|
||||
(x2 - x1), (y2 - y1));
|
||||
gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
|
||||
}
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
#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"
|
||||
#include "core/gimpdrawable-invert.h"
|
||||
|
@ -948,7 +950,8 @@ histogram_invoker (Gimp *gimp,
|
|||
x1 + off_x, y1 + off_y, (x2 - x1), (y2 - y1), FALSE);
|
||||
|
||||
/* Apply the image transformation to the pixels */
|
||||
histogram = gimp_histogram_new ();
|
||||
histogram = gimp_histogram_new (GIMP_BASE_CONFIG (gimp->config));
|
||||
|
||||
if (no_mask)
|
||||
gimp_histogram_calculate (histogram, &srcPR, NULL);
|
||||
else
|
||||
|
@ -963,7 +966,8 @@ histogram_invoker (Gimp *gimp,
|
|||
median = gimp_histogram_get_median (histogram, channel,
|
||||
start_range, end_range);
|
||||
pixels = gimp_histogram_get_count (histogram, 0, 255);
|
||||
count = gimp_histogram_get_count (histogram, start_range, end_range);
|
||||
count = gimp_histogram_get_count (histogram,
|
||||
start_range, end_range);
|
||||
percentile = count / pixels;
|
||||
|
||||
gimp_histogram_free (histogram);
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
#include "base/gimphistogram.h"
|
||||
#include "base/pixel-region.h"
|
||||
|
||||
#include "config/gimpbaseconfig.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
@ -335,7 +338,7 @@ histogram_tool_dialog_new (GimpToolInfo *tool_info)
|
|||
|
||||
htd = g_new0 (HistogramToolDialog, 1);
|
||||
htd->channel = GIMP_HISTOGRAM_VALUE;
|
||||
htd->hist = gimp_histogram_new ();
|
||||
htd->hist = gimp_histogram_new (GIMP_BASE_CONFIG (tool_info->gimp->config));
|
||||
|
||||
/* The shell and main vbox */
|
||||
htd->shell =
|
||||
|
|
|
@ -39,10 +39,14 @@
|
|||
#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"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimagemap.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
#include "widgets/gimpenummenu.h"
|
||||
#include "widgets/gimphistogramview.h"
|
||||
|
@ -219,14 +223,17 @@ static void
|
|||
gimp_levels_tool_init (GimpLevelsTool *l_tool)
|
||||
{
|
||||
GimpImageMapTool *image_map_tool;
|
||||
Gimp *gimp;
|
||||
|
||||
image_map_tool = GIMP_IMAGE_MAP_TOOL (l_tool);
|
||||
|
||||
image_map_tool->shell_desc = _("Adjust Color Levels");
|
||||
|
||||
gimp = GIMP_TOOL (l_tool)->tool_info->gimp;
|
||||
|
||||
l_tool->lut = gimp_lut_new ();
|
||||
l_tool->levels = g_new0 (Levels, 1);
|
||||
l_tool->hist = gimp_histogram_new ();
|
||||
l_tool->hist = gimp_histogram_new (GIMP_BASE_CONFIG (gimp->config));
|
||||
l_tool->channel = GIMP_HISTOGRAM_VALUE;
|
||||
l_tool->active_picker = NULL;
|
||||
|
||||
|
|
|
@ -27,10 +27,14 @@
|
|||
#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"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimagemap.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
#include "widgets/gimphistogrambox.h"
|
||||
#include "widgets/gimphistogramview.h"
|
||||
|
@ -147,13 +151,16 @@ static void
|
|||
gimp_threshold_tool_init (GimpThresholdTool *t_tool)
|
||||
{
|
||||
GimpImageMapTool *image_map_tool;
|
||||
Gimp *gimp;
|
||||
|
||||
image_map_tool = GIMP_IMAGE_MAP_TOOL (t_tool);
|
||||
|
||||
image_map_tool->shell_desc = _("Apply Threshold");
|
||||
|
||||
t_tool->threshold = g_new0 (Threshold, 1);
|
||||
t_tool->hist = gimp_histogram_new ();
|
||||
gimp = GIMP_TOOL (t_tool)->tool_info->gimp;
|
||||
|
||||
t_tool->threshold = g_new0 (Threshold, 1);
|
||||
t_tool->hist = gimp_histogram_new (GIMP_BASE_CONFIG (gimp->config));
|
||||
|
||||
t_tool->threshold->low_threshold = 127;
|
||||
t_tool->threshold->high_threshold = 255;
|
||||
|
|
|
@ -564,6 +564,7 @@ HELP
|
|||
}
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("config/gimpbaseconfig.h" "core/gimp.h") ],
|
||||
vars => [ 'PixelRegion srcPR, maskPR', 'int x1, y1, x2, y2',
|
||||
'GimpHistogram *histogram', 'int off_x, off_y',
|
||||
'gboolean no_mask', 'GimpChannel *mask' ],
|
||||
|
@ -588,7 +589,8 @@ HELP
|
|||
x1 + off_x, y1 + off_y, (x2 - x1), (y2 - y1), FALSE);
|
||||
|
||||
/* Apply the image transformation to the pixels */
|
||||
histogram = gimp_histogram_new ();
|
||||
histogram = gimp_histogram_new (GIMP_BASE_CONFIG (gimp->config));
|
||||
|
||||
if (no_mask)
|
||||
gimp_histogram_calculate (histogram, &srcPR, NULL);
|
||||
else
|
||||
|
@ -603,7 +605,8 @@ HELP
|
|||
median = gimp_histogram_get_median (histogram, channel,
|
||||
start_range, end_range);
|
||||
pixels = gimp_histogram_get_count (histogram, 0, 255);
|
||||
count = gimp_histogram_get_count (histogram, start_range, end_range);
|
||||
count = gimp_histogram_get_count (histogram,
|
||||
start_range, end_range);
|
||||
percentile = count / pixels;
|
||||
|
||||
gimp_histogram_free (histogram);
|
||||
|
|
Loading…
Reference in New Issue