C (142/254)

From:Olaf Barthel
Date:06 Apr 00 at 08:54:09
Subject:Re: SetAPen benchmarks...

On Apr 06 Allan (Allan Odgaard) wrote:

> Hi there,
>
> Some days ago someone asked about SetAPen overhead. I've tested it and it's
> approximately five times faster to do this:
>
> if(GetAPen(rp) != mypen)
> SetAPen(rp, mypen)
>
> Than to always just setting the pen, assuming that the pen is already set.
> This was on my 40MHz 040, testing both AGA and P96 for CLUT and non CLUT
> screens. However, I could do around � million SetAPen's pr. second...

The next question would be "why doesn't SetAPen() check for the pen
number all by itself?". I can tell you the answer: it's for backwards,
or rather, bug compatibility. I'm not joking. Back in the Kickstart 1.3
days developers discovered that what SetAPen()/SetBPen()/SetDrMd() would
do was to work on the RastPort->minterms[] table and calculate new values
for every change of drawing options. Since this was a slow process, some
developers decided to cache the pen information stored in the minterms
table and just copy the cached data there instead of calling SetAPen(),
etc. It was faster, but it created a problem lateron when Commodore was
updating the OS. One of the ideas brought forward during that time was
to make SetAPen() and friends check the cached pen number and drawing
modes before deciding to recalculate the minterms table. The OS code
was changed to do just that, and lo and behold, suddenly some applications
started to have problems rendering text and graphics. Those applications,
Deluxe Paint was one of them, were poking minterm tables instead of
calling SetAPen(), etc. properly. When the operating system started to
rely upon the cached pen and drawing information to match the configuration
of the minterm table, it was actually using stale data that didn't match
the real configuration. In the end, it was decided that SetAPen() and
friends should not rely upon the cached pen and drawing information and
always recalculate the minterm table, no matter what.



Home: Olaf Barthel, Brabeckstrasse 35, D-30559 Hannover
Net: olsen@sourcery.han.de (Home), olsen@logicalline.com (Work)

------------------------------------------------------------------------
LOW RATE, NO WAIT!
Get a NextCard Visa, in 30 seconds! Get rates
as low as 2.9% Intro or 9.9% Fixed APR and no hidden fees.
Learn more at:
http://click.egroups.com/1/937/1/_/451227/_/955023652/
------------------------------------------------------------------------