Commit f0426ac2 authored by jaycox's avatar jaycox
Browse files

----------------------------------------------------------------------


 ----------------------------------------------------------------------
 Modified Files:
 	ChangeLog app/paint_funcs.c
     speed up to color_pixels (4-7X on a mips r4000)
 ----------------------------------------------------------------------
parent 56a2e76f
Sun Jul 19 10:23:58 PDT 1998 Jay Cox <jaycox@earthlink.net>
* app/paint_funcs.c
new and improved color_pixels now 4-7 times as fast and 8-12
times as convoluted as original color_pixels.
Sun Jul 19 12:48:00 BST 1998 Adam D. Moss <adam@gimp.org>
* plug-ins/animationplay/animationplay.c: Adapted
......
......@@ -367,15 +367,61 @@ color_pixels (unsigned char *dest,
int w,
int bytes)
{
int b;
while (w--)
{
for (b = 0; b < bytes; b++)
dest[b] = color[b];
dest += bytes;
}
/* dest % bytes and color % bytes must be 0 or we will crash
when bytes = 2 or 4.
Is this safe to assume? Lets find out.
This is 4-7X as fast as the simple version.
*/
register unsigned char c0, c1, c2;
register guint32 *longd, longc;
register guint16 *shortd, shortc;
switch (bytes)
{
case 1:
memset(dest, *color, w);
break;
case 2:
shortc = ((guint16 *)color)[0];
shortd = (guint16 *)dest;
while (w--)
{
*shortd = shortc;
shortd++;
}
break;
case 3:
c0 = color[0];
c1 = color[1];
c2 = color[2];
while (w--)
{
dest[0] = c0;
dest[1] = c1;
dest[2] = c2;
dest += 3;
}
break;
case 4:
longc = ((guint32 *)color)[0];
longd = (guint32 *)dest;
while (w--)
{
*longd = longc;
longd++;
}
break;
default:
{
int b;
while (w--)
{
for (b = 0; b < bytes; b++)
dest[b] = color[b];
dest += bytes;
}
}
}
}
......
......@@ -367,15 +367,61 @@ color_pixels (unsigned char *dest,
int w,
int bytes)
{
int b;
while (w--)
{
for (b = 0; b < bytes; b++)
dest[b] = color[b];
dest += bytes;
}
/* dest % bytes and color % bytes must be 0 or we will crash
when bytes = 2 or 4.
Is this safe to assume? Lets find out.
This is 4-7X as fast as the simple version.
*/
register unsigned char c0, c1, c2;
register guint32 *longd, longc;
register guint16 *shortd, shortc;
switch (bytes)
{
case 1:
memset(dest, *color, w);
break;
case 2:
shortc = ((guint16 *)color)[0];
shortd = (guint16 *)dest;
while (w--)
{
*shortd = shortc;
shortd++;
}
break;
case 3:
c0 = color[0];
c1 = color[1];
c2 = color[2];
while (w--)
{
dest[0] = c0;
dest[1] = c1;
dest[2] = c2;
dest += 3;
}
break;
case 4:
longc = ((guint32 *)color)[0];
longd = (guint32 *)dest;
while (w--)
{
*longd = longc;
longd++;
}
break;
default:
{
int b;
while (w--)
{
for (b = 0; b < bytes; b++)
dest[b] = color[b];
dest += bytes;
}
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment