[Xr] Dealing with groups in Xr

Carl Worth cworth at east.isi.edu
Tue Apr 22 11:43:35 PDT 2003


Long ago, on a mailing list far, far away
On Nov 21, Owen Taylor wrote:
 >  * It looks like the temporary surface created for XrPushGroup
 >    will always have the same format as the parent surface;
 >    I don't think this is right ...
 > 
 >  * I think it's probably necessary to be able to XrPushgroup
 >    with a restricted size; the overhead of creating a full
 >    size temporary pixmap could be sunstantial.
 >  
 >  * It looks to me like on XrPopGroup, the group is composited
 >    with the current alpha at the end of drawing the group,
 >    rather than the alpha before pushing the group; I think this
 >    is wrong - operations inside PushGroup/PopGroup shouldn't  
 >    affect drawing onto the parent surface.

Clearly, the Push/PopGroup functionality had a lot of problems.

I've now dropped these functions from Xr.

The new surface management support provides mechanism for replacing
calls to the old functions. The idiom is a change from:

	XrPushGroup (xrs);

	/* Drawing operations for the group ... */

	/* Setup group compositing state (eg. set alpha) ... */

	XrPopGroup (xrs);

to:

	XrSurface *group;

	group = XrSurfaceCreateNextTo (XrGetTargetSurface (xrs),
				       XrFormatARGB32, width, height);
	XrSave (xrs);

	XrSetTargetSurface (xrs, group);

	/* Drawing operations for the group ... */

	XrRestore (xrs);

	/* Setup group compositing state (eg. set alpha) ... */

	XrShowSurface (xrs, group, 0, 0, width, height);

This approach should address the three points made by Owen above. And
I feel pretty good about the mechanism enabled here.

Obviously, the fix comes at a cost of increased verbosity, (sometimes
a bit worse than shown since the "Setup group compositing state" may
need to be wrapped in a Save/Restore block). Perhaps there's room for
a convenience function in here somewhere to make a common case less
painful.

The xrtest module in CVS contains Owen's original xrknockout program
with the above modification applied three times. It works, but it
seems less readable to me.

Suggestions and feedback are welcome as always.

-Carl

-- 
Carl Worth                                        
USC Information Sciences Institute                      cworth at isi.edu





More information about the cairo mailing list