gimp r26270 - in trunk: . app/base app/widgets
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26270 - in trunk: . app/base app/widgets
- Date: Tue, 22 Jul 2008 09:29:35 +0000 (UTC)
Author: neo
Date: Tue Jul 22 09:29:35 2008
New Revision: 26270
URL: http://svn.gnome.org/viewvc/gimp?rev=26270&view=rev
Log:
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.
Modified:
trunk/ChangeLog
trunk/app/base/gimphistogram.c
trunk/app/base/gimphistogram.h
trunk/app/widgets/gimphistogrameditor.c
Modified: trunk/app/base/gimphistogram.c
==============================================================================
--- trunk/app/base/gimphistogram.c (original)
+++ trunk/app/base/gimphistogram.c Tue Jul 22 09:29:35 2008
@@ -102,6 +102,39 @@
}
}
+/**
+ * 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,
Modified: trunk/app/base/gimphistogram.h
==============================================================================
--- trunk/app/base/gimphistogram.h (original)
+++ trunk/app/base/gimphistogram.h Tue Jul 22 09:29:35 2008
@@ -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);
Modified: trunk/app/widgets/gimphistogrameditor.c
==============================================================================
--- trunk/app/widgets/gimphistogrameditor.c (original)
+++ trunk/app/widgets/gimphistogrameditor.c Tue Jul 22 09:29:35 2008
@@ -365,6 +365,24 @@
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 @@
{
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 @@
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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]