[cairo] Create a new backend

Carl Worth cworth at cworth.org
Fri Jan 26 11:57:02 PST 2007

On Fri, 26 Jan 2007 16:41:04 -0300, "german rodriguez" wrote:
> I want to know how could I create a new backend for cairo.

To start with, I'm quite curious: What's the motivation for your new
backend? What are you wanting to do that you can't do with any
existing backend?

> backend for drawing things. I didn't find any documentation which
> allow me to understand it, could you instruct me in how to do it??
> For example, if had a set of interfaces to implement and what that
> interface had to do?

We've not ever documented the "create a new backend" process fully,
(which frankly still leaves me somewhat dumbfounded that people have
successfully contributed original backends).

It sounds like you've found the definition of the interface to
implement, (namely the definition of "struct _cairo_surface_backend"
in cairioint.h). Some of those interface functions are even
documented, (many aren't).

What's also not documented well is what subsets of the interface could
be implemented and still get a fully-functioning backend. There are
at least three different styles that could be taken here (and which is
correct depends a lot on what your backend needs to do). Three source
files that are quite small and each implementing a different kind of
minimal backend are:


And of course there are the other existing surfaces which can be used
as examples, (but as you have found, they can often be harder to read).

> I wasn't able to find in cairo_xlib_* anything like a call to a
> function XDrawLine(...) which would mean that the function was used to
> draw into a X11 Drawable.

The cairo-xlib-surface.c file contains all the rendering code for the
xlib backend. It doesn't ever call into functions like XDrawLine since
they are wholly unsuited for what cairo wants to do, (for example,
drawing curved, antialiased, translucent lines). Instead, cairo's xlib
backend builds on the render extension, (see calls to functions such
as XRenderCompositeTrapezoids), or if that doesn't exist, it falls
back to computing desired results with client-side code in pixman,
(the same as used by cairo's image backend), and then pushing those
results to X with XPutImage.

Does that help you understand what's going on?

Welcome to cairo development, we hope you have a lot of fun with it!


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20070126/1418404d/attachment.pgp

More information about the cairo mailing list