rlkd@opusys.UUCP (R.L.K.Dattatri) (04/29/89)
We recently implemented a color version of X (R3) on a EGA and VGA
for a System V UNIX. Since the color version was pretty slow to say
the least (that too on a MC88000) we went about some speed ups.
The most important (I feel) speed up is in the file cfbmskbits.h
and cfbmskbits.c. There is a macro PFILL that shifts and ORs
a pattern to propagate a bit pattern to all of the bytes in a pixel.
If it is a 4 bit deep display it will have to propagate the pattern
into 4 bytes and for a 8 bit deep display the propagation is to 8 bytes.
For a 4 bit display the possible values for the bit pattern are only 16
and for the 8 bit display it is 256.
Instead of doing the shifts and ORs, I have a look up table of 16 and 256
entries. This table contains the complete word pattern that results
from the shifts and ORs. So for any value of the bit pattern I just use
the pattern value as an index into the table and use the value their as
the result of PFILL.
The following code fragment illustrates the point:
This is for a 4 bit display.
/* cfbmskbits.h */
long PFILLtab[] =
{ 0x00000000,
0x11111111,
0x22222222,
0x33333333,
0x44444444,
0x55555555,
0x66666666,
0x77777777,
0x88888888,
0x99999999,
0xaaaaaaaa,
0xbbbbbbbb,
0xcccccccc,
0xdddddddd,
0xeeeeeeee,
0xffffffff
};
/* now redefine PFILL macro as follows
PMSK is the pixel index mask already defined
and is 0x0F for a 4 bit display
*/
#define PFILL(p) (PFILLtab[(p) & PMSK])
For a 8 bit (n bit) display you will need a 256 entry table (2**n).
If it is hard to fill this table by hand, then use the code in PFILL
(one that is already there in cfbmskbits.h) and write a small loop to do the
rest.
This macro is heavily used in all pixel operations.
ANYBODY HAVE SIMILAR SPEED UP EXPERIENCE ?
R.L.K. Dattatri
Opus Systems
rlkd!opusys