[cairo] surfaces and backends

Mike Emmel mike.emmel at gmail.com
Sat May 21 08:08:59 PDT 2005


Look like your trying to sneak the g type system and GObject in.
Why don't you just do a simple api that could map onto GObject
if someone wanted ?
It would be nice if the Cairo implemention could be GObject based
if wanted. With some work this could be a compile time option.

On 5/21/05, Owen Taylor <otaylor at redhat.com> wrote:
> 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:
> >
> >       _cairo_surface_is_image
> >       _cairo_surface_is_win32
> >       _cairo_surface_is_xcb
> >       _cairo_surface_is_xlib
> >
> > 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:
> 
>  if (cairo_surface_is_image())
>  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:
> 
> enum {
>    CAIRO_IMAGE_SURFACE_TYPE,
>    CAIRO_XLIB_SURFACE_TYPE,
>    [...]
>    CAIRO_FT_FONT_FACE_TYPE,
> } CairoTypeID;
> 
> 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
> easily add:
> 
>  CairoTypeID cairo_create_type_id ();
> 
> Or whatever if the need arises.
> 
> Regards,
>                                                 Owen
> 
> 
> 
> BodyID:84513834.2.n.logpart (stored separately)
> 
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://lists.freedesktop.org/mailman/listinfo/cairo
> 
> 
>



More information about the cairo mailing list