[cairo] Win32 API thoughts
Owen Taylor
otaylor at redhat.com
Fri Jan 21 12:42:45 PST 2005
The initial API I have is incredibly simple:
void cairo_set_target_win32 (cairo_t *cr,
HDC hdc);
cairo_surface_t *cairo_win32_surface_create (HDC hdc);
I chose the name 'win32' rather than 'gdi' because I don't want to
imply anything about the internal implementation. If we later have a
Direct3D based accelerated implementation it should just drop in place
under the same public API.
Of course, win32 is a bit of a strange name is running Win64, but it
is widely known, and the '32' is present in various places in the
Windows API. (gdi32.dll, for example.) It also matches the naming
conventions of the Windows-spefic API in Pango and GTK+.
The usage of the above to handle a paint event, is, for example,
in response to WM_PAINT
hdc = BeginPaint (hWnd, &paint_struct);
cr = cairo_create ();
cairo_set_target_win32 (cr, hdc);
/* Draw */
cairo_destroy (hdc);
EndPaint hWand, &paint_struct);
I think the above API is almost completely general. GDI+ has a
constructor for Graphics that takes a handle to a printer device;
that apparently allows them to do a bit of printer-driver specific
optimization. It's probably also necessary if we want to have
cairo_surface_show_page() show a page when writing to a GDI printer.
Convenience functions could be also be added, e.g.:
- Do the BeginPaint/EndPaint, taking a boolean double_buffer
parameter.
- Create an off-screen drawing surface, making the optimum
DIB/DDB/Image choice.
- Create from a HWND or a HBITMAP.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050121/0ea7a1b6/attachment.pgp
More information about the cairo
mailing list