[comp.windows.ms.programmer] Drawing Speed

rob@pcad.UUCP (Ralph Brown) (11/15/90)

Hopefully this isn't a reposting.

I'm looking at Win 3.0 for a heavy graphics application and have done some
drawing timings which seem pretty odd. Perhaps I've just overlooked some
obvious setting for the PEN or GC which will make it all fine, if so, please
let me know.

On a 20 MHz 386 with EGA (640x480x16 colors) I got the following times for
drawing 50000 lines 130x4 horizontally:

Using a pen width 4 and LineTo,Moveto  - 272 Sec.

Using a NULL_PEN and BLACK_BRUSH and
        Polygon                        - 146 Sec.

Using the stock BLACK_PEN and drawing
        adjacent lines with LineTo     -  90 Sec.

Using the stock BLACK_PEN and adjacent
        lines with Polyline            -  56 Sec.

Using NULL_PEN and BLACK_BRUSH and
        Rectangle                      -  31 Sec.

It appears that the pen does something like redrawing the 4 unit diameter
circle repeatedly at each point on the line which isn't very efficient.

While I could use rectangles for horizontal and vertical lines, it won't
help much for diagonals or for arcs.

Thanks,
Ralph Brown - PCAD Westford Ma.

jls@hsv3.UUCP (James Seidman) (11/15/90)

In article <319@pcad.UUCP> rob@pcad.UUCP (Ralph Brown) writes:
>I'm looking at Win 3.0 for a heavy graphics application and have done some
>drawing timings which seem pretty odd. Perhaps I've just overlooked some
>obvious setting for the PEN or GC which will make it all fine, if so, please
>let me know.
>[...]
>Using NULL_PEN and BLACK_BRUSH and
>        Rectangle                      -  31 Sec.

One thing which might be even faster than this (but maybe not...) is to
use FillRect() instead of Rectangle().  Even though you have the overhead
of filling up a RECT structure, you don't have the time spent drawing
the rectangle's border.  (I don't know how smart the system is, and if
it jumps over all that stuff if using NULL_PEN.  Considering how smart
it was about the 4-pixel wide pen, I wouldn't hold my breath.)  I know
that when I had a series of different colored rectangles to draw,
FillRect was much faster because I didn't have to keep selecting different
brushes into the device context.

-- 
Jim Seidman (Drax), the accidental engineer.
"It doesn't have to work... they'll be paralyzed just from laughing at me."
							- Dr. Who, _Shada_
UUCP: ames!vsi1!hsv3!jls	         INTERNET: hsv3.UUCP!jls@apple.com

rob@pcad.UUCP (Ralph Brown) (11/16/90)

In article <5787@hsv3.UUCP>, jls@hsv3.UUCP (James Seidman) writes:
> One thing which might be even faster than this (but maybe not...) is to
> use FillRect() instead of Rectangle()...

Using rectangles including filling the structure took 33 Sec. about
the same as Rectangle.

The problem with rectangles is that they don't work for diagonals, arcs,
etc. However I did try polygon regions, for a horizontal rectangle
(defined with CreatePolygonRgn I got:

Creating and destroying the region consisting of the
         entire line each time                          - 528 Sec.

Just creating it once and reusing it (Cheating)         -  33 Sec.

Creating a 4x4 region once, doing OffsetRgn to do the
         complete lines (SetViewportOrg same).          - 947 Sec.

Thanks, keep those cards and letters coming,

        Ralph