tada@athena.mit.edu (Michael Zehr) (02/22/88)
Probably most of you will think this is a dumb question, but ... I've worked a bit with a few different window systems, and I've made a few observations: most window systems have a few simple primatives like draw_line, draw_polygon, fill_polygon. However, I've yet to see routines like draw_vertical_line, draw_horizontal_line, draw_rectangle, etc. With lines, usually a fair number of them are drawn either horizontally or vertically. Are the draw_line routines implemented so efficiently that there wouldn't be much of a speed savings by special-casing h. and v. lines? Or is the current design philosophy to avoid special cases as much as possible? With respect to polygons and rectangles, I've done some work with programs that do nothing but tile areas with filled rectangles, and I've had to use 4-sided filled polygons. Obviously that takes a lot more computation than filling a rectangle. Does anyone know if the window system code has transparent special cases to handle calls like that? Or don't most people need it? Of is a lot of it done in hardware so that a draw_rectangle wouldn't use much less CPU time than a draw_polygon anyway? Thanks in advance for any information... Michael Zehr "My opinions are my own ... as is my spelling."
geoff@desint.UUCP (Geoff Kuenning) (02/25/88)
In article <3132@bloom-beacon.MIT.EDU> tada@athena.mit.edu (Michael Zehr) writes: > I've yet to see > routines like draw_vertical_line, draw_horizontal_line, > draw_rectangle, etc...Are the draw_line routines > implemented so efficiently that there wouldn't be much of a speed > savings by special-casing h. and v. lines? Or is the current design > philosophy to avoid special cases as much as possible? Current design avoids special cases at the user level, preferring them at a lower level. It's easy to detect horizontal and vertical lines on the fly (because one coordinate matches) and handle them separately. Horizontal ones are a very big win on software-driven systems, because you can set a whole memory unit (byte or word) all at once. > With respect to polygons and rectangles, I've done some work with > programs that do nothing but tile areas with filled rectangles, and > I've had to use 4-sided filled polygons. Obviously that takes a lot > more computation than filling a rectangle. Not necessarily; again this can easily be detected as a special case. However, the X Window System (there! I said it right! :-) has separate calls for drawing filled and unfilled rectangles. (But one could argue this is a bad idea, since it increases user-level complexity for little gain.) -- Geoff Kuenning geoff@ITcorp.com {uunet,trwrb}!desint!geoff
msc@ramoth.SGI.COM (Mark Callow) (02/27/88)
In article <3132@bloom-beacon.MIT.EDU>, tada@athena.mit.edu (Michael Zehr) writes: > > ... However, I've yet to see > routines like draw_vertical_line, draw_horizontal_line, > draw_rectangle, etc. With lines, usually a fair number of them are > drawn either horizontally or vertically. Are the draw_line routines > implemented so efficiently that there wouldn't be much of a speed > savings by special-casing h. and v. lines? Or is the current design > philosophy to avoid special cases as much as possible? Usually the implementors special case horizontal and vertical lines inside the draw-line primitive to save you the trouble. The implementors of the primitives typically know better than the user what should be treated as a special case on a given machine especially when dealing with hardware assists. -- From the TARDIS of Mark Callow msc@sgi.sgi.com, ...{ames,decwrl,sun}!sgi!msc "There is much virtue in a window. It is to a human being as a frame is to a painting, as a proscenium to a play. It strongly defines its content."