[cairo] surfaces and backends
otaylor at redhat.com
Sat May 21 08:01:22 PDT 2005
On Thu, 2005-05-19 at 16:57 -0700, Carl Worth wrote:
> On Wed, 16 Mar 2005 11:15:53 -0500, Owen Taylor wrote:
> > How do we identify surface types?
> > 1. Strings. cairo_surface_get_backend_name()
> > 2. Boolean predicate. cairo_surface_is_xlib()
> > 3. Opaque type object
> > cairo_type_t *cairo_surface_get_type()
> > cairo_type_t *cairo_xlib_surface_type()
> > 4. Global #defines
> > #define CAIRO_TYPE_XLIB_SURFACE 1
> > Not clear to me what's right.
> We've started running into the need for this internal to the cairo
> implementation and so far we are using option #2. I see the following
> in the code already:
> This seems perfectly workable to me. Anyone have an objection to
> filling this set out more completely and making it public?
I'm not too fond of this... a language binding implementation
of cairo_get_target() would have to do:
else if (cairo_surface_is_pdf())
else if (cairo_surface_is_ps())
else if (cairo_surface_is_xlib())
This isn't doesn't really matter for Cairo, since the number of
subclasses of any type is pretty limited. But it's not a scalable
approach, which makes me consider it non-standard.
What if we had:
CairoTypeID cairo_surface_get_type (cairo_surface_t *surface);
It looks superficially like the above doesn't work if we ever
add backend types defined outside of the Cairo core, but we can
CairoTypeID cairo_create_type_id ();
Or whatever if the need arises.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050521/5bf6f5cf/attachment.pgp
More information about the cairo