[Mono-winforms-list] swf

Peter Dennis Bartok peter@novonyx.com
Mon, 1 Nov 2004 10:08:17 -0700

>could you please fill me in a few paragraphs how (and why) does SWF 
>to libgdiplus?
Sure, I'll try.

Because we need a way to actually draw controls. There are two choices:
1) Using a native API and tieing that native API straight into SWF.
2) Using System.Drawing

Option 1 has serious drawbacks, for example, if you were to create your own 
control you'd have to use the internal drawing API as well, which would 
require it to be public, which would make us loose signature compatibility. 
And, it'd be a large amount of code to write and maintain, and you'd have to 
figure out how to make it compatible with System.Drawing, because an app 
might want to draw something into the control...

1) We create windows (controls)
2) We receive an expose event for the window and translate that into a 
WM_PAINT for the SWF WndProc
3) Control.cs calls XplatUI.PaintEventStart to get a PaintEvent structure.
4) XplatUI.PaintEventStart calls Graphics.FromHwnd(IntPtr), which in turn 
calls GdipCreateFromXDrawable_linux(). Note that we are 'using' a documented 
System.Drawing API call that is marked as internal by Microsoft to pass our 
X drawable to System.Drawing.
5) If not running on Win32, System.Drawing calls a cairo function to pass 
the drawable and get a graphics context back.
6) We store the graphics context in the PaintEvent structure and pass it 
back to the WndProc
7) Control.WndProc uses the PaintEvent structure to call OnPaint
8) The control will use the graphics context to draw itself

1) Same as X11 1)-3)
2) XplatUI.PaintEventStart calls Win32 BeginPaint to get the DC
3) XplatUI.PaintEventStart then calls Graphics.FromHdc to get the graphics 
context to draw
4) Graphics.FromHdc will get the graphics object from Microsoft's GDI+ 
5) the rest is the same as X11 6)-8)

SWF connects to libgdiplus through System.Drawing. System.Drawing is mostly 
a wrapper for GDI+ calls, with a few special cases to deal with the platform 
you are running on, because if you run our System.Drawing on Win32, it will 
use Microsoft's native GDI+ library, not ours (which uses cairo).

Hope this helps