[comp.windows.news] setlinewidth and overlay canvases

alexandr@surya.cad.mcc.com (Mark Alexandre) (03/15/90)

Does anyone know whether it is a feature or a bug that setting
the line width seems to have no effect when drawing on an overlay
canvas?  That is, the thickness of any line does not change when
stroked, regardless of what value has been given to 'setlinewidth'.

I didn't find any mention of this fact in the NeWS 2.0 Programmer's
Guide, section 2.5, which deals with overlay canvases.  Is this
hardware dependent?  Would there be performance problems if the
line width were set rather large?

I am running NeWS 2.0 (X/NeWS) on a Sun 4/110.

Mark  Alexandre@MCC.com

rxb@ASC.SLB.COM (Rafael Bracho) (03/16/90)

>Does anyone know whether it is a feature or a bug that setting
>the line width seems to have no effect when drawing on an overlay
>canvas?  That is, the thickness of any line does not change when
>stroked, regardless of what value has been given to 'setlinewidth'.

It is a feature.  Overlay canvases are ambiguously defined on purpose,
to allow for efficient (perhaps hardware-dependent) implementations.
It was rumoured that some of their restrictions may be lifted in the
future (e.g., ability to set the color, perhaps line width, etc.).

					-Rafael

naughton@wind.eng.sun.com (Patrick Naughton) (03/16/90)

In article <9003151602.AA06773.rxb@plutonium.ASC.SLB.COM>,
rxb@ASC.SLB.COM (Rafael Bracho) writes:
> >Does anyone know whether it is a feature or a bug that setting
> >the line width seems to have no effect when drawing on an overlay
> >canvas?  That is, the thickness of any line does not change when
> >stroked, regardless of what value has been given to 'setlinewidth'.
> 
> It is a feature.  Overlay canvases are ambiguously defined on purpose,
> to allow for efficient (perhaps hardware-dependent) implementations.
> It was rumoured that some of their restrictions may be lifted in the
> future (e.g., ability to set the color, perhaps line width, etc.).
> 
> 					-Rafael

The overlay code does indeed ignore the linewidth, dash pattern, color, etc.,
on paths... Here's how overlays work:

An overlay canvas maintains a list of paths and strings to display.  The only
way to add a string to this list is with the 'show' operator, and the only
way to add a path is with the 'stroke' operator.  A notable exception is that
paths cannot be 'fill'ed.  This was done for the same reason that wide lines
were left out.  Overlays are implemented by simply rendering the display list
using the XOR rasterop mode each time the canvas which has the overlay is
written to.  If large filled areas were allowed, rather than the current one
pixel wide lines, there would be excessive screen flashing.  On future graphics
hardware which has one or more hardware overlay planes, this restriction can
be removed.  This is why the definition of what happens in the overlay canvases
has been left ambiguous.

    ______________________________________________________________________
    Patrick J. Naughton				    ARPA: naughton@sun.com
    Window Systems Group			    UUCP: ...!sun!naughton
    Sun Microsystems, Inc.			    AT&T: (415) 336 - 1080

ps. while we're talking about overlays... here's a little hack which shows
    off rotated OpenFonts in the overlay plane...  Click the middle button
    to change the string, and give it a few spins to let the font cache
    fill up with the glyphs.

%!PS-NeWS2.0
%%Title: OpenFonts rotated text demo
%%Creator: Patrick Naughton
%%CreationDate: Thu Mar 15 11:40:15 PST 1990
%%EndComments

/fontfamily /Palatino-Roman def
/fontsize 64 def
/angle 60 def
/strings [
    (Open)
    (Fonts)
    (are)
    (very)
    (cool)
    (!!!!)
] def

%%EndProlog

fboverlay setcanvas
fontfamily findfont fontsize scalefont setfont

/drag createevent dup begin
    /Name /MouseDragged def
    /Canvas fboverlay def
    /Exclusivity true def
end def
/click createevent dup begin
    /Name /LeftMouseButton def
    /Action null def
    /Exclusivity true def
    /Canvas null def
end def
/flip createevent dup begin
    /Name /MiddleMouseButton def
    /Action [ /UpTransition /DownTransition ] def
    /Exclusivity true def
    /Canvas null def
end def

/update {
    erasepage
    x y translate
    angle rotate
    0 0 moveto
    strings idx get
    false {
	false charpath strokepath stroke
    } {
	cshow
    } ifelse
} def

currentcursorlocation
/y exch def /x exch def
/idx 0 def
update
drag expressinterest
click expressinterest
flip expressinterest
{
    awaitevent dup begin
	Name {
	    /MiddleMouseButton {
		/Action get /DownTransition eq {
		    /idx idx 1 add strings length mod store
		    update
		} if
	    }
	    /MouseDragged {
		pop
		/x XLocation store
		/y YLocation store
		update
	    }
	    /LeftMouseButton {
		pop
		exit
	    }
	} case
    end
} loop
erasepage
drag revokeinterest
click revokeinterest
flip revokeinterest