Commit 44fd2e0a authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

header cleanup, added some const qualifiers, converted tabs to spaces.

2004-04-15  Sven Neumann  <sven@gimp.org>

	* app/paint-funcs/paint-funcs.[ch]:
	* app/paint-funcs/paint-funcs-generic.h: header cleanup, added
	some const qualifiers, converted tabs to spaces. Fixes bug #140115
	for the HEAD branch.
parent 14a88500
2004-04-15 Sven Neumann <sven@gimp.org>
* app/paint-funcs/paint-funcs.[ch]:
* app/paint-funcs/paint-funcs-generic.h: header cleanup, added
some const qualifiers, converted tabs to spaces. Fixes bug #140115
for the HEAD branch.
2004-04-15 Michael Natterer <mitch@gimp.org>
Get rid of the "current_context" which was in fact just a bunch of
......
......@@ -65,14 +65,14 @@ struct apply_layer_mode_struct
CombinationMode combine;
};
static guchar add_lut[511];
static gint32 random_table[RANDOM_TABLE_SIZE];
static guchar add_lut[511];
static gint32 random_table[RANDOM_TABLE_SIZE];
void
color_pixels (guchar *dest,
const guchar *color,
guint w,
guint bytes)
const guchar *color,
guint w,
guint bytes)
{
/* dest % bytes and color % bytes must be 0 or we will crash
when bytes = 2 or 4.
......@@ -101,19 +101,19 @@ color_pixels (guchar *dest,
c0 = color[0];
c1 = color[1];
while (w--)
{
dest[0] = c0;
dest[1] = c1;
dest += 2;
}
{
dest[0] = c0;
dest[1] = c1;
dest += 2;
}
#else
shortc = ((const guint16 *) color)[0];
shortd = (guint16 *) dest;
while (w--)
{
*shortd = shortc;
shortd++;
}
{
*shortd = shortc;
shortd++;
}
#endif /* sparc || __sparc__ */
break;
......@@ -122,12 +122,12 @@ color_pixels (guchar *dest,
c1 = color[1];
c2 = color[2];
while (w--)
{
dest[0] = c0;
dest[1] = c1;
dest[2] = c2;
dest += 3;
}
{
dest[0] = c0;
dest[1] = c1;
dest[2] = c2;
dest += 3;
}
break;
case 4:
......@@ -137,30 +137,30 @@ color_pixels (guchar *dest,
c2 = color[2];
c3 = color[3];
while (w--)
{
dest[0] = c0;
dest[1] = c1;
dest[2] = c2;
dest[3] = c3;
dest += 4;
}
{
dest[0] = c0;
dest[1] = c1;
dest[2] = c2;
dest[3] = c3;
dest += 4;
}
#else
longc = ((const guint32 *) color)[0];
longd = (guint32 *) dest;
while (w--)
{
*longd = longc;
longd++;
}
{
*longd = longc;
longd++;
}
#endif /* sparc || __sparc__ */
break;
default:
while (w--)
{
memcpy (dest, color, bytes);
dest += bytes;
}
{
memcpy (dest, color, bytes);
dest += bytes;
}
}
}
......@@ -185,11 +185,11 @@ color_pixels_mask (guchar *dest,
case 2:
c0 = color[0];
while (w--)
{
dest[0] = c0;
dest[1] = *mask++;
dest += 2;
}
{
dest[0] = c0;
dest[1] = *mask++;
dest += 2;
}
break;
case 3:
......@@ -197,12 +197,12 @@ color_pixels_mask (guchar *dest,
c1 = color[1];
c2 = color[2];
while (w--)
{
dest[0] = c0;
dest[1] = c1;
dest[2] = c2;
dest += 3;
}
{
dest[0] = c0;
dest[1] = c1;
dest[2] = c2;
dest += 3;
}
break;
case 4:
......@@ -210,13 +210,13 @@ color_pixels_mask (guchar *dest,
c1 = color[1];
c2 = color[2];
while (w--)
{
dest[0] = c0;
dest[1] = c1;
dest[2] = c2;
dest[3] = *mask++;
dest += 4;
}
{
dest[0] = c0;
dest[1] = c1;
dest[2] = c2;
dest[3] = *mask++;
dest += 4;
}
break;
}
}
......@@ -259,14 +259,14 @@ pattern_pixels_mask (guchar *dest,
p = pat + ((i + x) % pattern->width) * pattern->bytes;
for (b = 0; b < alpha; b++)
dest[b] = p[b];
dest[b] = p[b];
if (HAS_ALPHA (bytes))
{
{
if (mask)
dest[alpha] = *mask++;
dest[alpha] = *mask++;
else
dest[alpha] = OPAQUE_OPACITY;
dest[alpha] = OPAQUE_OPACITY;
if (HAS_ALPHA (pattern->bytes))
dest[alpha] = (guchar) (dest[alpha] *
......@@ -335,12 +335,12 @@ blend_pixels (const guchar *src1,
inline void
shade_pixels (const guchar *src,
guchar *dest,
const guchar *col,
guchar blend,
guint w,
guint bytes,
guint has_alpha)
guchar *dest,
const guchar *col,
guchar blend,
guint w,
guint bytes,
gboolean has_alpha)
{
const guchar blend2 = (255 - blend);
const guint alpha = (has_alpha) ? bytes - 1 : bytes;
......@@ -349,10 +349,10 @@ shade_pixels (const guchar *src,
while (w--)
{
for (b = 0; b < alpha; b++)
dest[b] = (src[b] * blend2 + col[b] * blend) / 255;
dest[b] = (src[b] * blend2 + col[b] * blend) / 255;
if (has_alpha)
dest[alpha] = src[alpha]; /* alpha channel */
dest[alpha] = src[alpha]; /* alpha channel */
src += bytes;
dest += bytes;
......@@ -362,10 +362,10 @@ shade_pixels (const guchar *src,
inline void
extract_alpha_pixels (const guchar *src,
const guchar *mask,
guchar *dest,
guint w,
guint bytes)
const guchar *mask,
guchar *dest,
guint w,
guint bytes)
{
const guint alpha = bytes - 1;
gint tmp;
......@@ -393,11 +393,11 @@ extract_alpha_pixels (const guchar *src,
static inline void
darken_pixels (const guchar *src1,
const guchar *src2,
guchar *dest,
guint length,
guint bytes1,
guint bytes2)
const guchar *src2,
guchar *dest,
guint length,
guint bytes1,
guint bytes2)
{
const guint has_alpha1 = HAS_ALPHA (bytes1);
const guint has_alpha2 = HAS_ALPHA (bytes2);
......@@ -408,16 +408,16 @@ darken_pixels (const guchar *src1,
while (length--)
{
for (b = 0; b < alpha; b++)
{
s1 = src1[b];
s2 = src2[b];
dest[b] = (s1 < s2) ? s1 : s2;
}
{
s1 = src1[b];
s2 = src2[b];
dest[b] = (s1 < s2) ? s1 : s2;
}
if (has_alpha1 && has_alpha2)
dest[alpha] = MIN (src1[alpha], src2[alpha]);
dest[alpha] = MIN (src1[alpha], src2[alpha]);
else if (has_alpha2)
dest[alpha] = src2[alpha];
dest[alpha] = src2[alpha];
src1 += bytes1;
src2 += bytes2;
......@@ -428,11 +428,11 @@ darken_pixels (const guchar *src1,
static inline void
lighten_pixels (const guchar *src1,
const guchar *src2,
guchar *dest,
guint length,
guint bytes1,
guint bytes2)
const guchar *src2,
guchar *dest,
guint length,
guint bytes1,
guint bytes2)
{
const guint has_alpha1 = HAS_ALPHA (bytes1);
const guint has_alpha2 = HAS_ALPHA (bytes2);
......@@ -443,16 +443,16 @@ lighten_pixels (const guchar *src1,
while (length--)
{
for (b = 0; b < alpha; b++)
{
s1 = src1[b];
s2 = src2[b];
dest[b] = (s1 < s2) ? s2 : s1;
}
{
s1 = src1[b];
s2 = src2[b];
dest[b] = (s1 < s2) ? s2 : s1;
}
if (has_alpha1 && has_alpha2)
dest[alpha] = MIN (src1[alpha], src2[alpha]);
dest[alpha] = MIN (src1[alpha], src2[alpha]);
else if (has_alpha2)
dest[alpha] = src2[alpha];
dest[alpha] = src2[alpha];
src1 += bytes1;
src2 += bytes2;
......@@ -463,11 +463,11 @@ lighten_pixels (const guchar *src1,
static inline void
hue_only_pixels (const guchar *src1,
const guchar *src2,
guchar *dest,
guint length,
guint bytes1,
guint bytes2)
const guchar *src2,
guchar *dest,
guint length,
guint bytes1,
guint bytes2)
{
const guint has_alpha1 = HAS_ALPHA (bytes1);
const guint has_alpha2 = HAS_ALPHA (bytes2);
......@@ -490,9 +490,9 @@ hue_only_pixels (const guchar *src1,
dest[0] = r1; dest[1] = g1; dest[2] = b1;
if (has_alpha1 && has_alpha2)
dest[3] = MIN (src1[3], src2[3]);
dest[3] = MIN (src1[3], src2[3]);
else if (has_alpha2)
dest[3] = src2[3];
dest[3] = src2[3];
src1 += bytes1;
src2 += bytes2;
......@@ -503,11 +503,11 @@ hue_only_pixels (const guchar *src1,
static inline void
saturation_only_pixels (const guchar *src1,
const guchar *src2,
guchar *dest,
guint length,
guint bytes1,
guint bytes2)
const guchar *src2,
guchar *dest,
guint length,
guint bytes1,
guint bytes2)
{
const guint has_alpha1 = HAS_ALPHA (bytes1);
const guint has_alpha2 = HAS_ALPHA (bytes2);
......@@ -530,9 +530,9 @@ saturation_only_pixels (const guchar *src1,
dest[0] = r1; dest[1] = g1; dest[2] = b1;
if (has_alpha1 && has_alpha2)
dest[3] = MIN (src1[3], src2[3]);
dest[3] = MIN (src1[3], src2[3]);
else if (has_alpha2)
dest[3] = src2[3];
dest[3] = src2[3];
src1 += bytes1;
src2 += bytes2;
......@@ -543,11 +543,11 @@ saturation_only_pixels (const guchar *src1,
static inline void
value_only_pixels (const guchar *src1,
const guchar *src2,
guchar *dest,
guint length,
guint bytes1,
guint bytes2)
const guchar *src2,
guchar *dest,
guint length,
guint bytes1,
guint bytes2)
{
const guint has_alpha1 = HAS_ALPHA (bytes1);
const guint has_alpha2 = HAS_ALPHA (bytes2);
......@@ -570,9 +570,9 @@ value_only_pixels (const guchar *src1,
dest[0] = r1; dest[1] = g1; dest[2] = b1;
if (has_alpha1 && has_alpha2)
dest[3] = MIN (src1[3], src2[3]);
dest[3] = MIN (src1[3], src2[3]);
else if (has_alpha2)
dest[3] = src2[3];
dest[3] = src2[3];
src1 += bytes1;
src2 += bytes2;
......@@ -583,11 +583,11 @@ value_only_pixels (const guchar *src1,
static inline void
color_only_pixels (const guchar *src1,
const guchar *src2,
guchar *dest,
guint length,
guint bytes1,
guint bytes2)
const guchar *src2,
guchar *dest,
guint length,
guint bytes1,
guint bytes2)
{
const guint has_alpha1 = HAS_ALPHA (bytes1);
const guint has_alpha2 = HAS_ALPHA (bytes2);
......@@ -612,9 +612,9 @@ color_only_pixels (const guchar *src1,
dest[0] = r1; dest[1] = g1; dest[2] = b1;
if (has_alpha1 && has_alpha2)
dest[3] = MIN (src1[3], src2[3]);
dest[3] = MIN (src1[3], src2[3]);
else if (has_alpha2)
dest[3] = src2[3];
dest[3] = src2[3];
src1 += bytes1;
src2 += bytes2;
......@@ -625,11 +625,11 @@ color_only_pixels (const guchar *src1,
static inline void
multiply_pixels (const guchar *src1,
const guchar *src2,
guchar *dest,
guint length,
guint bytes1,
guint bytes2)
const guchar *src2,
guchar *dest,
guint length,
guint bytes1,
guint bytes2)
{
const guint has_alpha1 = HAS_ALPHA (bytes1);
const guint has_alpha2 = HAS_ALPHA (bytes2);
......@@ -639,53 +639,53 @@ multiply_pixels (const guchar *src1,
if (has_alpha1 && has_alpha2)
{
while (length --)
{
for (b = 0; b < alpha; b++)
dest[b] = INT_MULT(src1[b], src2[b], tmp);
{
for (b = 0; b < alpha; b++)
dest[b] = INT_MULT(src1[b], src2[b], tmp);
dest[alpha] = MIN (src1[alpha], src2[alpha]);
dest[alpha] = MIN (src1[alpha], src2[alpha]);
src1 += bytes1;
src2 += bytes2;
dest += bytes2;
}
src1 += bytes1;
src2 += bytes2;
dest += bytes2;
}
}
else if (has_alpha2)
{
while (length --)
{
for (b = 0; b < alpha; b++)
dest[b] = INT_MULT(src1[b], src2[b], tmp);
{
for (b = 0; b < alpha; b++)
dest[b] = INT_MULT(src1[b], src2[b], tmp);
dest[alpha] = src2[alpha];
dest[alpha] = src2[alpha];
src1 += bytes1;
src2 += bytes2;
dest += bytes2;
}
src1 += bytes1;
src2 += bytes2;
dest += bytes2;
}
}
else
{
while (length --)
{
for (b = 0; b < alpha; b++)
dest[b] = INT_MULT(src1[b], src2[b], tmp);
src1 += bytes1;
src2 += bytes2;
dest += bytes2;
}
{
for (b = 0; b < alpha; b++)
dest[b] = INT_MULT(src1[b], src2[b], tmp);
src1 += bytes1;
src2 += bytes2;
dest += bytes2;
}
}
}
static inline void
divide_pixels (const guchar *src1,
const guchar *src2,
guchar *dest,
guint length,
guint bytes1,
guint bytes2)
const guchar *src2,
guchar *dest,
guint length,
guint bytes1,
guint bytes2)
{
const guint has_alpha1 = HAS_ALPHA (bytes1);
const guint has_alpha2 = HAS_ALPHA (bytes2);
......@@ -695,15 +695,15 @@ divide_pixels (const guchar *src1,
while (length--)
{
for (b = 0; b < alpha; b++)
{
result = ((src1[b] * 256) / (1+src2[b]));
dest[b] = MIN (result, 255);
}
{
result = ((src1[b] * 256) / (1+src2[b]));
dest[b] = MIN (result, 255);
}
if (has_alpha1 && has_alpha2)
dest[alpha] = MIN (src1[alpha], src2[alpha]);
dest[alpha] = MIN (src1[alpha], src2[alpha]);
else if (has_alpha2)
dest[alpha] = src2[alpha];
dest[alpha] = src2[alpha];
src1 += bytes1;
src2 += bytes2;
......@@ -714,11 +714,11 @@ divide_pixels (const guchar *src1,
static inline void
screen_pixels (const guchar *src1,
const guchar *src2,
guchar *dest,
guint length,
guint bytes1,
guint bytes2)
const guchar *src2,
guchar *dest,
guint length,
guint bytes1,
guint bytes2)
{
const guint has_alpha1 = HAS_ALPHA (bytes1);
const guint has_alpha2 = HAS_ALPHA (bytes2);
......@@ -728,12 +728,12 @@ screen_pixels (const guchar *src1,
while (length --)
{
for (b = 0; b < alpha; b++)
dest[b] = 255 - INT_MULT((255 - src1[b]), (255 - src2[b]), tmp);
dest[b] = 255 - INT_MULT((255 - src1[b]), (255 - src2[b]), tmp);
if (has_alpha1 && has_alpha2)
dest[alpha] = MIN (src1[alpha], src2[alpha]);
dest[alpha] = MIN (src1[alpha], src2[alpha]);
else if (has_alpha2)
dest[alpha] = src2[alpha];
dest[alpha] = src2[alpha];
src1 += bytes1;
src2 += bytes2;
......@@ -744,11 +744,11 @@ screen_pixels (const guchar *src1,
static inline void
overlay_pixels (const guchar *src1,
const guchar *src2,
guchar *dest,
guint length,
guint bytes1,
guint bytes2)
const guchar *src2,
guchar *dest,
guint length,
guint bytes1,
guint bytes2)
{
const guint has_alpha1 = HAS_ALPHA (bytes1);
const guint has_alpha2 = HAS_ALPHA (bytes2);
......@@ -758,16 +758,16 @@ overlay_pixels (const guchar *src1,
while (length --)