mirror of https://github.com/GNOME/gimp.git
app: add gimp_histogram_clear_values() and use it
instead of abusing gimp_histogram_calculate() with a NULL region for that purpose; calculate() is about to go away.
This commit is contained in:
parent
cadd54823b
commit
df5ab0f551
|
@ -57,7 +57,6 @@ struct _GimpHistogram
|
|||
|
||||
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);
|
||||
|
@ -98,7 +97,7 @@ gimp_histogram_unref (GimpHistogram *histogram)
|
|||
|
||||
if (histogram->ref_count == 0)
|
||||
{
|
||||
gimp_histogram_free_values (histogram);
|
||||
gimp_histogram_clear_values (histogram);
|
||||
g_slice_free (GimpHistogram, histogram);
|
||||
}
|
||||
}
|
||||
|
@ -144,12 +143,7 @@ gimp_histogram_calculate (GimpHistogram *histogram,
|
|||
gint i;
|
||||
|
||||
g_return_if_fail (histogram != NULL);
|
||||
|
||||
if (! region)
|
||||
{
|
||||
gimp_histogram_free_values (histogram);
|
||||
return;
|
||||
}
|
||||
g_return_if_fail (region != NULL);
|
||||
|
||||
gimp_histogram_alloc_values (histogram, region->bytes);
|
||||
|
||||
|
@ -175,6 +169,23 @@ gimp_histogram_calculate (GimpHistogram *histogram,
|
|||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
gimp_histogram_clear_values (GimpHistogram *histogram)
|
||||
{
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (histogram != NULL);
|
||||
|
||||
for (i = 0; i < NUM_SLOTS; i++)
|
||||
if (histogram->values[i])
|
||||
{
|
||||
g_free (histogram->values[i]);
|
||||
histogram->values[i] = NULL;
|
||||
}
|
||||
|
||||
histogram->n_channels = 0;
|
||||
}
|
||||
|
||||
|
||||
#define HISTOGRAM_VALUE(c,i) (histogram->values[0][(c) * 256 + (i)])
|
||||
|
||||
|
@ -550,7 +561,7 @@ gimp_histogram_alloc_values (GimpHistogram *histogram,
|
|||
{
|
||||
if (bytes + 1 != histogram->n_channels)
|
||||
{
|
||||
gimp_histogram_free_values (histogram);
|
||||
gimp_histogram_clear_values (histogram);
|
||||
|
||||
histogram->n_channels = bytes + 1;
|
||||
|
||||
|
@ -558,21 +569,6 @@ gimp_histogram_alloc_values (GimpHistogram *histogram,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_histogram_free_values (GimpHistogram *histogram)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < NUM_SLOTS; i++)
|
||||
if (histogram->values[i])
|
||||
{
|
||||
g_free (histogram->values[i]);
|
||||
histogram->values[i] = NULL;
|
||||
}
|
||||
|
||||
histogram->n_channels = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
|
||||
PixelRegion *region,
|
||||
|
|
|
@ -32,6 +32,8 @@ void gimp_histogram_calculate (GimpHistogram *histogram,
|
|||
PixelRegion *region,
|
||||
PixelRegion *mask);
|
||||
|
||||
void gimp_histogram_clear_values (GimpHistogram *histogram);
|
||||
|
||||
gdouble gimp_histogram_get_maximum (GimpHistogram *histogram,
|
||||
GimpHistogramChannel channel);
|
||||
gdouble gimp_histogram_get_count (GimpHistogram *histogram,
|
||||
|
|
|
@ -372,7 +372,7 @@ gimp_histogram_editor_validate (GimpHistogramEditor *editor)
|
|||
if (editor->drawable)
|
||||
gimp_drawable_calculate_histogram (editor->drawable, editor->histogram);
|
||||
else
|
||||
gimp_histogram_calculate (editor->histogram, NULL, NULL);
|
||||
gimp_histogram_clear_values (editor->histogram);
|
||||
|
||||
gimp_histogram_editor_info_update (editor);
|
||||
|
||||
|
|
Loading…
Reference in New Issue