gimp r25650 - in trunk: . app/core
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r25650 - in trunk: . app/core
- Date: Tue, 13 May 2008 12:32:38 +0100 (BST)
Author: neo
Date: Tue May 13 11:32:38 2008
New Revision: 25650
URL: http://svn.gnome.org/viewvc/gimp?rev=25650&view=rev
Log:
2008-05-13 Sven Neumann <sven gimp org>
* app/core/gimpcurve-map.[ch] (gimp_curve_map_pixels): introduced
an enum to clean up the code. Optimize another not so uncommon case.
Modified:
trunk/ChangeLog
trunk/app/core/gimpcurve-map.c
trunk/app/core/gimpcurve-map.h
Modified: trunk/app/core/gimpcurve-map.c
==============================================================================
--- trunk/app/core/gimpcurve-map.c (original)
+++ trunk/app/core/gimpcurve-map.c Tue May 13 11:32:38 2008
@@ -28,6 +28,17 @@
#include "gimpcurve-map.h"
+enum
+{
+ CURVE_NONE = 0,
+ CURVE_COLORS = 1 << 0,
+ CURVE_RED = 1 << 1,
+ CURVE_GREEN = 1 << 2,
+ CURVE_BLUE = 1 << 3,
+ CURVE_ALPHA = 1 << 4
+};
+
+
gdouble
gimp_curve_map_value (GimpCurve *curve,
gdouble value)
@@ -66,7 +77,7 @@
}
void
-gimp_curve_map_pixels (GimpCurve *curve_all,
+gimp_curve_map_pixels (GimpCurve *curve_colors,
GimpCurve *curve_red,
GimpCurve *curve_green,
GimpCurve *curve_blue,
@@ -75,32 +86,32 @@
gfloat *dest,
glong samples)
{
- guint mask = 0;
+ guint mask = CURVE_NONE;
- g_return_if_fail (GIMP_IS_CURVE (curve_all));
+ g_return_if_fail (GIMP_IS_CURVE (curve_colors));
g_return_if_fail (GIMP_IS_CURVE (curve_red));
g_return_if_fail (GIMP_IS_CURVE (curve_green));
g_return_if_fail (GIMP_IS_CURVE (curve_blue));
g_return_if_fail (GIMP_IS_CURVE (curve_alpha));
- mask |= (gimp_curve_is_identity (curve_all) ? 0 : 1) << 0;
- mask |= (gimp_curve_is_identity (curve_red) ? 0 : 1) << 1;
- mask |= (gimp_curve_is_identity (curve_green) ? 0 : 1) << 2;
- mask |= (gimp_curve_is_identity (curve_blue) ? 0 : 1) << 3;
- mask |= (gimp_curve_is_identity (curve_alpha) ? 0 : 1) << 4;
+ if (! gimp_curve_is_identity (curve_colors)) mask |= CURVE_COLORS;
+ if (! gimp_curve_is_identity (curve_red)) mask |= CURVE_RED;
+ if (! gimp_curve_is_identity (curve_green)) mask |= CURVE_GREEN;
+ if (! gimp_curve_is_identity (curve_blue)) mask |= CURVE_BLUE;
+ if (! gimp_curve_is_identity (curve_alpha)) mask |= CURVE_ALPHA;
switch (mask)
{
- case 0: /* all curves are identity, nothing to do */
+ case CURVE_NONE:
break;
- case 1: /* only the overall curve needs to be applied */
+ case CURVE_COLORS:
while (samples--)
{
- dest[0] = gimp_curve_map_value (curve_all, src[0]);
- dest[1] = gimp_curve_map_value (curve_all, src[1]);
- dest[2] = gimp_curve_map_value (curve_all, src[2]);
- /* don't apply the overall curve to the alpha channel */
+ dest[0] = gimp_curve_map_value (curve_colors, src[0]);
+ dest[1] = gimp_curve_map_value (curve_colors, src[1]);
+ dest[2] = gimp_curve_map_value (curve_colors, src[2]);
+ /* don't apply the colors curve to the alpha channel */
dest[3] = src[3];
src += 4;
@@ -108,7 +119,7 @@
}
break;
- case 2: /* only the red curve needs to be applied */
+ case CURVE_RED:
while (samples--)
{
dest[0] = gimp_curve_map_value (curve_red, src[0]);
@@ -121,7 +132,7 @@
}
break;
- case 4: /* only the green curve needs to be applied */
+ case CURVE_GREEN:
while (samples--)
{
dest[0] = src[0];
@@ -134,7 +145,7 @@
}
break;
- case 8: /* only the blue curve needs to be applied */
+ case CURVE_BLUE:
while (samples--)
{
dest[0] = src[0];
@@ -147,7 +158,7 @@
}
break;
- case 16: /* only the alpha curve needs to be applied */
+ case CURVE_ALPHA:
while (samples--)
{
dest[0] = src[0];
@@ -160,19 +171,32 @@
}
break;
+ case (CURVE_RED | CURVE_GREEN | CURVE_BLUE):
+ while (samples--)
+ {
+ dest[0] = gimp_curve_map_value (curve_red, src[0]);
+ dest[1] = gimp_curve_map_value (curve_green, src[1]);
+ dest[2] = gimp_curve_map_value (curve_blue, src[2]);
+ dest[3] = src[3];
+
+ src += 4;
+ dest += 4;
+ }
+ break;
+
default: /* apply all curves */
while (samples--)
{
- dest[0] = gimp_curve_map_value (curve_all,
+ dest[0] = gimp_curve_map_value (curve_colors,
gimp_curve_map_value (curve_red,
src[0]));
- dest[1] = gimp_curve_map_value (curve_all,
+ dest[1] = gimp_curve_map_value (curve_colors,
gimp_curve_map_value (curve_green,
src[1]));
- dest[2] = gimp_curve_map_value (curve_all,
+ dest[2] = gimp_curve_map_value (curve_colors,
gimp_curve_map_value (curve_blue,
src[2]));
- /* don't apply the overall curve to the alpha channel */
+ /* don't apply the colors curve to the alpha channel */
dest[3] = gimp_curve_map_value (curve_alpha, src[3]);
src += 4;
Modified: trunk/app/core/gimpcurve-map.h
==============================================================================
--- trunk/app/core/gimpcurve-map.h (original)
+++ trunk/app/core/gimpcurve-map.h Tue May 13 11:32:38 2008
@@ -22,7 +22,7 @@
gdouble gimp_curve_map_value (GimpCurve *curve,
gdouble value);
-void gimp_curve_map_pixels (GimpCurve *curve_all,
+void gimp_curve_map_pixels (GimpCurve *curve_colors,
GimpCurve *curve_red,
GimpCurve *curve_green,
GimpCurve *curve_blue,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]