From: ama@marley.Eng.Sun.COM (Al Amaral - SunSelect)
Newsgroups: comp.windows.x
Subject: Re: An Open Challenge (it can't be done!)
Date: 22 Dec 1992 19:21:55 GMT
Organization: Sun Microsystems Inc. - BDC
NNTP-Posting-Host: marley.east.sun.com
Keywords: xor cursors images biscuits

In article <78716@hydra.gatech.EDU> gt4417a@prism.gatech.EDU (SKELTON,JOEL PHILLIP) writes:
>
>Here's the short form:
> - 8 bit image in backing pixmap used to update window
> - Image drawn in 8 bit X window
> - Want to draw diagonal lines on top of image that can
>   be removed quickly (i.e. replace them with the data they so
>   recently covered)
> - Can't do server extensions (too many platforms to support)
>Betcha can't do it!
>Joel Skelton   --    North Avenue Trade School, Dept. of Round Things


Hmmm, I used to work on a window system/machine which actually had such a
mechanism in hardware.  We used it to draw our cursors.  It would draw a 
stroked area, saving the pixels which were touched in offscreen memory.
We could then redraw the stroked area, and replace the pixels which were 
originally under the cursor.  Too bad it's not in X.

Anyway, I'll take a whack at this one.  I have no idea how fast this will be,
it'll probably be terribly slow, but I think it can be done...  I know you
said "Can't do server extensions", but I assume you mean new, custom, server
extensions, not ones that probably already are supported on your servers.

What about using a shaped window as your stroked polygon, rather than lines.
You would draw the lines into a bitmap, which would then be used as as a 
ShapeMask for the Shape extension.  You could overlay the window with the
shaped window, then copy the whole shaped source window into a pixmap.
This should only copy the stroked areas.  You can then unmap the shaped
window and draw the lines into the original window, or just clear the
shaped window to a single color (whichever is faster).  To restore the
graphics you just do another copy from the pixmap onto the shaped window.

Of course, with this method you'll havt to deselect expose events while
you are doing this else you'll get tons of expose events when you reshape
the shaped window.  You'll also probably be severly speed constrained by 
how fast the server can turn the bitmap into clip regions as the shape
of the polygon changes.

You should be able to do the same thing without the shape extension altogether
as you have the pixels in a server pixmap already.  To restore you could just 
draw the lines into a bitmap and use it for a clipmask in a GC and do a 
copyarea.  This might actually be much faster, but again, you'll be 
severely speed constrained by how fast the server can turn the clipmask 
into a cliplist...  If only the clip mask were used directly, instead of 
having to be turned into a bazillion little rectangles.

Given the amount of time each redraw will take using either of these methods
you'll undoubtedly need to do some kind of motion event compression, as trying
to draw with each new mouse position (assuming you're dragging the lines)
will back up most servers quite badly...

Hope this helps.

--
--------------------------------------------------------------
Al Amaral				Al.Amaral@East.Sun.COM
Newsgroups: comp.windows.x