mirror of https://github.com/GNOME/gimp.git
added new method gimp_histogram_duplicate().
2008-07-22 Sven Neumann <sven@gimp.org> * app/base/gimphistogram.[ch]: added new method gimp_histogram_duplicate(). * app/widgets/gimphistogrameditor.c (gimp_histogram_editor_frozen_update): instead of recalculating the histogram, use a duplicate for the background histogram. svn path=/trunk/; revision=26270
This commit is contained in:
parent
48e6da318d
commit
4368010863
11
ChangeLog
11
ChangeLog
|
@ -1,8 +1,17 @@
|
|||
2008-07-22 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/base/gimphistogram.[ch]: added new method
|
||||
gimp_histogram_duplicate().
|
||||
|
||||
* app/widgets/gimphistogrameditor.c
|
||||
(gimp_histogram_editor_frozen_update): instead of recalculating
|
||||
the histogram, use a duplicate for the background histogram.
|
||||
|
||||
2008-07-22 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/widgets/gimphistogrameditor.c (gimp_histogram_editor_set_image):
|
||||
reverted last change, it did not plug the leak.
|
||||
|
||||
|
||||
2008-07-22 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/gui/session.c (session_init): plugged a small memory leak.
|
||||
|
|
|
@ -102,6 +102,39 @@ gimp_histogram_unref (GimpHistogram *histogram)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_histogram_duplicate:
|
||||
* @histogram: a %GimpHistogram
|
||||
*
|
||||
* Creates a duplicate of @histogram. The duplicate has a reference
|
||||
* count of 1 and contains the values from @histogram.
|
||||
*
|
||||
* Return value: a newly allocated %GimpHistogram
|
||||
**/
|
||||
GimpHistogram *
|
||||
gimp_histogram_duplicate (GimpHistogram *histogram)
|
||||
{
|
||||
GimpHistogram *dup;
|
||||
|
||||
g_return_val_if_fail (histogram != NULL, NULL);
|
||||
|
||||
dup = gimp_histogram_new ();
|
||||
|
||||
#ifdef ENABLE_MP
|
||||
g_static_mutex_lock (&histogram->mutex);
|
||||
#endif
|
||||
|
||||
dup->n_channels = histogram->n_channels;
|
||||
dup->values[0] = g_memdup (histogram->values[0],
|
||||
sizeof (gdouble) * dup->n_channels * 256);
|
||||
|
||||
#ifdef ENABLE_MP
|
||||
g_static_mutex_unlock (&histogram->mutex);
|
||||
#endif
|
||||
|
||||
return dup;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_histogram_calculate (GimpHistogram *histogram,
|
||||
PixelRegion *region,
|
||||
|
|
|
@ -23,9 +23,12 @@
|
|||
|
||||
|
||||
GimpHistogram * gimp_histogram_new (void);
|
||||
|
||||
GimpHistogram * gimp_histogram_ref (GimpHistogram *histogram);
|
||||
void gimp_histogram_unref (GimpHistogram *histogram);
|
||||
|
||||
GimpHistogram * gimp_histogram_duplicate (GimpHistogram *histogram);
|
||||
|
||||
void gimp_histogram_calculate (GimpHistogram *histogram,
|
||||
PixelRegion *region,
|
||||
PixelRegion *mask);
|
||||
|
|
|
@ -365,6 +365,24 @@ gimp_histogram_editor_layer_changed (GimpImage *image,
|
|||
gimp_histogram_editor_name_update (editor);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_histogram_editor_validate (GimpHistogramEditor *editor)
|
||||
{
|
||||
if (! editor->valid && editor->histogram)
|
||||
{
|
||||
if (editor->drawable)
|
||||
gimp_drawable_calculate_histogram (editor->drawable, editor->histogram);
|
||||
else
|
||||
gimp_histogram_calculate (editor->histogram, NULL, NULL);
|
||||
|
||||
gimp_histogram_editor_info_update (editor);
|
||||
|
||||
editor->valid = TRUE;
|
||||
}
|
||||
|
||||
return editor->valid;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_histogram_editor_frozen_update (GimpHistogramEditor *editor,
|
||||
const GParamSpec *pspec)
|
||||
|
@ -375,10 +393,8 @@ gimp_histogram_editor_frozen_update (GimpHistogramEditor *editor,
|
|||
{
|
||||
if (! editor->bg_histogram)
|
||||
{
|
||||
editor->bg_histogram = gimp_histogram_new ();
|
||||
|
||||
gimp_drawable_calculate_histogram (editor->drawable,
|
||||
editor->bg_histogram);
|
||||
if (gimp_histogram_editor_validate (editor))
|
||||
editor->bg_histogram = gimp_histogram_duplicate (editor->histogram);
|
||||
|
||||
gimp_histogram_view_set_background (view, editor->bg_histogram);
|
||||
}
|
||||
|
@ -538,17 +554,7 @@ gimp_histogram_editor_info_update (GimpHistogramEditor *editor)
|
|||
static gboolean
|
||||
gimp_histogram_view_expose (GimpHistogramEditor *editor)
|
||||
{
|
||||
if (! editor->valid && editor->histogram)
|
||||
{
|
||||
if (editor->drawable)
|
||||
gimp_drawable_calculate_histogram (editor->drawable, editor->histogram);
|
||||
else
|
||||
gimp_histogram_calculate (editor->histogram, NULL, NULL);
|
||||
|
||||
editor->valid = TRUE;
|
||||
|
||||
gimp_histogram_editor_info_update (editor);
|
||||
}
|
||||
gimp_histogram_editor_validate (editor);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue