gimp r25646 - in trunk: . app/core
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r25646 - in trunk: . app/core
- Date: Tue, 13 May 2008 08:10:49 +0100 (BST)
Author: neo
Date: Tue May 13 07:10:48 2008
New Revision: 25646
URL: http://svn.gnome.org/viewvc/gimp?rev=25646&view=rev
Log:
2008-05-11 Sven Neumann <sven gimp org>
* app/core/gimpcurve.[ch]: keep a boolean flag to identify an
identity mapping. Set it to TRUE when the curve is reset.
* app/core/gimpcurve-map.c (gimp_curve_map_value): optimize for
the case where the curve is an identity mapping.
Modified:
trunk/ChangeLog
trunk/app/core/gimpcurve-map.c
trunk/app/core/gimpcurve.c
trunk/app/core/gimpcurve.h
Modified: trunk/app/core/gimpcurve-map.c
==============================================================================
--- trunk/app/core/gimpcurve-map.c (original)
+++ trunk/app/core/gimpcurve-map.c Tue May 13 07:10:48 2008
@@ -34,6 +34,11 @@
{
g_return_val_if_fail (GIMP_IS_CURVE (curve), 0.0);
+ if (curve->identity)
+ {
+ return value;
+ }
+
if (value < 0.0)
{
return curve->samples[0];
@@ -42,7 +47,7 @@
{
return curve->samples[curve->n_samples - 1];
}
- else /* interpolate the curve */
+ else /* interpolate the curve */
{
gint index = floor (value * (gdouble) (curve->n_samples - 1));
gdouble f = value * (gdouble) (curve->n_samples - 1) - index;
Modified: trunk/app/core/gimpcurve.c
==============================================================================
--- trunk/app/core/gimpcurve.c (original)
+++ trunk/app/core/gimpcurve.c Tue May 13 07:10:48 2008
@@ -161,6 +161,7 @@
static void
gimp_curve_init (GimpCurve *curve)
{
+ curve->identity = FALSE;
}
static void
@@ -316,7 +317,11 @@
static void
gimp_curve_dirty (GimpData *data)
{
- gimp_curve_calculate (GIMP_CURVE (data));
+ GimpCurve *curve = GIMP_CURVE (data);
+
+ curve->identity = FALSE;
+
+ gimp_curve_calculate (curve);
GIMP_DATA_CLASS (parent_class)->dirty (data);
}
@@ -410,6 +415,8 @@
g_object_thaw_notify (G_OBJECT (curve));
gimp_data_dirty (GIMP_DATA (curve));
+
+ curve->identity = TRUE;
}
void
@@ -660,6 +667,23 @@
gimp_data_dirty (GIMP_DATA (curve));
}
+/**
+ * gimp_curve_is_identity:
+ * @curve: a #GimpCurve object
+ *
+ * If this function returns %TRUE, then the curve maps each value to
+ * itself. If it returns %FALSE, then this assumption can not be made.
+ *
+ * Return value: %TRUE if the curve is an identity mapping, %FALSE otherwise.
+ **/
+gboolean
+gimp_curve_is_identity (GimpCurve *curve)
+{
+ g_return_val_if_fail (GIMP_IS_CURVE (curve), FALSE);
+
+ return curve->identity;
+}
+
void
gimp_curve_get_uchar (GimpCurve *curve,
gint n_samples,
@@ -684,10 +708,10 @@
static void
gimp_curve_calculate (GimpCurve *curve)
{
- gint i;
gint *points;
- gint num_pts;
- gint p1, p2, p3, p4;
+ gint i;
+ gint num_pts;
+ gint p1, p2, p3, p4;
if (GIMP_DATA (curve)->freeze_count > 0)
return;
@@ -721,6 +745,10 @@
for (i = boundary; i < curve->n_samples; i++)
curve->samples[i] = point.y;
}
+ else
+ {
+ curve->identity = TRUE;
+ }
for (i = 0; i < num_pts - 1; i++)
{
Modified: trunk/app/core/gimpcurve.h
==============================================================================
--- trunk/app/core/gimpcurve.h (original)
+++ trunk/app/core/gimpcurve.h Tue May 13 07:10:48 2008
@@ -45,6 +45,8 @@
gint n_samples;
gdouble *samples;
+
+ gboolean identity; /* whether the curve is an identiy mapping */
};
struct _GimpCurveClass
@@ -87,6 +89,8 @@
gdouble x,
gdouble y);
+gboolean gimp_curve_is_identity (GimpCurve *curve);
+
void gimp_curve_get_uchar (GimpCurve *curve,
gint n_samples,
guchar *samples);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]