[cairo] CAIROMM: surfaces

Jonathon Jongsma jonathon.jongsma at gmail.com
Wed Jan 11 14:05:47 PST 2006

On 1/11/06, Murray Cumming <murrayc at murrayc.com> wrote:
> On Wed, 2006-01-11 at 13:34 -0600, Jonathon Jongsma wrote:
> > To me it seems like it's essential to the API.  Take GTK+ for example.
> >  It determines which platform it's being compiled for and, for
> > unix/X11, it calls cairo_xlib_surface_create(), and for win32 it calls
> > cairo_win32_surface_create().
> Yes, that makes sense. But is cairo_win32_surface_create() really
> declared and defined in cairo on linux?

No, it's only declared and defined if the base cairo library was
compiled with support for that particular surface, and a linux box is
unlikely to have windows support.  But on a windows machine, both
Win32Surface and XlibSurface might be available at the same time.
 Because of this, all of these surface backends would have to be
protected  with #ifdef CAIRO_HAS_XXX_SURFACE because they won't all be
available on every platform.

> How is an xlib surface different than an Image surface? Why isn't there
> a cairo_platform_surface_create()?

That's one thing that I'm kind of unclear about.  The cairo manual
says image surfaces are just 'memory buffers" or a "bitmap image in
memory".  I know that image surfaces can be saved as .png files if
libpng is installed, but I don't know if there's any way to display
them onscreen easily (or at all).  I'm also not clear whether they're
meant to be a base 'class' for the other surfaces or whether they're
something else entirely.  For example, is
cairo_image_surface_get_width() supposed to be valid to call on an
XlibSurface?  The documentation is pretty sparse on this.  Can one of
the cairo developers help clarify this a bit??

> I am convinced, though I'd like the documentation to say when you'd want
> to use each class.

That's a good idea.  I've got implementations and basic tests working
for pdf, ps, and svg so far.  I'll try to get this stuff worked into a
suitable patch and document it properly.


More information about the cairo mailing list