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:

committed by
Sven Neumann

parent
48e6da318d
commit
4368010863
@ -1,3 +1,12 @@
|
|||||||
|
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>
|
2008-07-22 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* app/widgets/gimphistogrameditor.c (gimp_histogram_editor_set_image):
|
* app/widgets/gimphistogrameditor.c (gimp_histogram_editor_set_image):
|
||||||
|
@ -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
|
void
|
||||||
gimp_histogram_calculate (GimpHistogram *histogram,
|
gimp_histogram_calculate (GimpHistogram *histogram,
|
||||||
PixelRegion *region,
|
PixelRegion *region,
|
||||||
|
@ -23,9 +23,12 @@
|
|||||||
|
|
||||||
|
|
||||||
GimpHistogram * gimp_histogram_new (void);
|
GimpHistogram * gimp_histogram_new (void);
|
||||||
|
|
||||||
GimpHistogram * gimp_histogram_ref (GimpHistogram *histogram);
|
GimpHistogram * gimp_histogram_ref (GimpHistogram *histogram);
|
||||||
void gimp_histogram_unref (GimpHistogram *histogram);
|
void gimp_histogram_unref (GimpHistogram *histogram);
|
||||||
|
|
||||||
|
GimpHistogram * gimp_histogram_duplicate (GimpHistogram *histogram);
|
||||||
|
|
||||||
void gimp_histogram_calculate (GimpHistogram *histogram,
|
void gimp_histogram_calculate (GimpHistogram *histogram,
|
||||||
PixelRegion *region,
|
PixelRegion *region,
|
||||||
PixelRegion *mask);
|
PixelRegion *mask);
|
||||||
|
@ -365,6 +365,24 @@ gimp_histogram_editor_layer_changed (GimpImage *image,
|
|||||||
gimp_histogram_editor_name_update (editor);
|
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
|
static void
|
||||||
gimp_histogram_editor_frozen_update (GimpHistogramEditor *editor,
|
gimp_histogram_editor_frozen_update (GimpHistogramEditor *editor,
|
||||||
const GParamSpec *pspec)
|
const GParamSpec *pspec)
|
||||||
@ -375,10 +393,8 @@ gimp_histogram_editor_frozen_update (GimpHistogramEditor *editor,
|
|||||||
{
|
{
|
||||||
if (! editor->bg_histogram)
|
if (! editor->bg_histogram)
|
||||||
{
|
{
|
||||||
editor->bg_histogram = gimp_histogram_new ();
|
if (gimp_histogram_editor_validate (editor))
|
||||||
|
editor->bg_histogram = gimp_histogram_duplicate (editor->histogram);
|
||||||
gimp_drawable_calculate_histogram (editor->drawable,
|
|
||||||
editor->bg_histogram);
|
|
||||||
|
|
||||||
gimp_histogram_view_set_background (view, editor->bg_histogram);
|
gimp_histogram_view_set_background (view, editor->bg_histogram);
|
||||||
}
|
}
|
||||||
@ -538,17 +554,7 @@ gimp_histogram_editor_info_update (GimpHistogramEditor *editor)
|
|||||||
static gboolean
|
static gboolean
|
||||||
gimp_histogram_view_expose (GimpHistogramEditor *editor)
|
gimp_histogram_view_expose (GimpHistogramEditor *editor)
|
||||||
{
|
{
|
||||||
if (! editor->valid && editor->histogram)
|
gimp_histogram_editor_validate (editor);
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user