[Cairo] Recent portability improvements to cairo
Carl Worth
cworth at east.isi.edu
Tue Nov 4 08:01:53 PST 2003
Some people have expressed interest in porting cairo to graphics
systems other than X. There have been a few recent changes to cairo
that should make this much easier:
1) There has been a large cleanup of cairo.h and all of libic to
remove unnecessary dependencies on X header files.
2) The surface_backend interface has been cleaned up considerably. At
this point, the cairo_ps_surface.c file should serve as a good
model for doing an image-based surface backend.
So, here is a suggested plan for anyone who wants to port cairo to a
new graphics system "foo":
a) copy cairo_ps_surface.c to cairo_foo_surface.c, replacing each
occurrence of cairo_ps_surface with cairo_foo_surface.
You will notice that most of the cairo_foo_surface functions simply
defer to cairo_image_surface implementations. This is what I meant
by an image-based surface backend.
b) cairo_foo_surface_create will need a new prototype and
implementation to store foo-specific data in the surface.
c) There are only three surface backend functions that do any drawing:
fill_rectangles, composite, and composite_trapezoids. The cairo_foo
versions of these functions should be made to call the cairo_image
versions, then copy the appropriate portion of the image from
surface->image to the graphics system.
d) The implementations of cairo_foo_surface_copy/show_page can be
gutted ala the cairo_image_surface versions.
That's definitely the easiest way to get something up and running on
some other system. Later, the cairo_foo support may be improved by
directly using foo-specific routines (if any) for doing the
compositing, etc. For example, an OpenGL-based backend might want to
use hardware-supported triangle rasterization rather than the
software-based rasterization in cairo_image_surface_composite_trapezoids.
If the surface backend interface needs to be modified to match a
system better, we can do that as well. This interface is intentionally
an internal implementation detail so that we can rework it as
necessary.
Finally, there is some autoconf-related work that needs to be done so
that the set of backends to be compiled in can be selected by the
user. I would greatly appreciate contributions in this area from
someone knowledge about such things.
-Carl
More information about the cairo
mailing list