[Xr] What happended to the idea of getting rid of the xrs argument?

Bill Spitzak spitzak at d2.com
Thu Jun 12 09:18:54 PDT 2003

On Wednesday 11 June 2003 07:57 pm, David Forster wrote:

> void SwfRender(XrState* xrs, SwfAnimation *swf, int time);

My main concern with this solution is that it requires the existence of 
XrState to be declared in the header files for almost every part of the 
toolkit. I have some worry that this will make it difficult to emulate Xr on 
Windows, which I would like to do, so that fltk programs can use Xr directly 
but be portable to Windows. This problem can be mostly eliminated by 
declaring that XrState really is a structure (not a C++ class, macro, or 
typedef). Then a header file can say "struct XrState" instead of including 
the Xr.h header.

> In fact, as an aside, this might be a good example where I want thread
> safety.  I might not want to block all other rendering while my SWF
> render strains over a complex animation.  So I'd have my SwfRender()
> loop run on it's own thread with it's own XrState*.

Absolutley, any static XrState must be per-thread, just like it is in OpenGL. 
One advantage I see of having the Xr library do this is that the method used 
for this is hidden inside the implementation and can be changed per platform, 
as thread-local variables are not standardized yet. If I use a global XrState 
I will probably not be thread-safe.

> I'm actully working on some code where I might use a global XrState*
> object, and have written my own wrapper.  You can grab it at:
> ftp://forster.homeunix.net/pub/xrs/Xrs.h

Actually this looks like a reasonable solution, because the names of the 
functions are agreed on, which would make cut & paste work. I could in fact 
make fltk declare the "xrs" functions on Windows and use this on X. Fltk 
would provide a small header that does the Windows emulation, and declares 
your current/push/pop macros and then includes your header. Note in my case 
the xrs calls will work before the first push is done, as I expect I will use 
a single xrs and do SetTargetSurface on it to change windows, unless somebody 
tells me that that is a bad idea.

                   ,~,~,~,~ ~ ~ ~ ~
     /\_       _|_========___         Bill Spitzak
 ~~~/\/\\~~~~~~\____________/~~~~~~~~ spitzak at d2.com

More information about the cairo mailing list