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

----------------------------------------------------------------------
 Modified Files:
 	ChangeLog app/paint_funcs.c
     speed up to color_pixels (4-7X on a mips r4000)
 ----------------------------------------------------------------------
This commit is contained in:
jaycox 1998-07-19 17:37:14 +00:00
parent 56a2e76f73
commit f0426ac257
3 changed files with 113 additions and 16 deletions

View File

@ -1,3 +1,8 @@
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

View File

@ -366,9 +366,53 @@ color_pixels (unsigned char *dest,
unsigned char *color,
int w,
int 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++)
@ -377,6 +421,8 @@ color_pixels (unsigned char *dest,
dest += bytes;
}
}
}
}
void

View File

@ -366,9 +366,53 @@ color_pixels (unsigned char *dest,
unsigned char *color,
int w,
int 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++)
@ -377,6 +421,8 @@ color_pixels (unsigned char *dest,
dest += bytes;
}
}
}
}
void