[cairo] Inkscape + Cairo

Chris Wilson chris at chris-wilson.co.uk
Sun Apr 25 07:44:27 PDT 2010

On Sat, 24 Apr 2010 13:32:49 +0200, Krzysztof Kosiński <tweenk.pl at gmail.com> wrote:
> Hello

Hi Krzysztof,
> I submitted a GSoC proposal about converting Inkscape to Cairo-based
> rendering. I'm not exactly a Cairo expert :) so I could use some help
> in a few areas.

A noble goal, one which we would like to make as painless as possible. :)
> 1. I want to use hardware accelerated backends when available. Ideally
> in the longer term I would like to use cairo-gl on all platforms,
> since this would give me the opportunity to implement SVG filter
> effects in OpenCL and avoid any read-back using the gl_sharing
> extension (also called "OpenGL-OpenCL interoperability"). How can I
> create a cairo-gl surface to draw on a GTK widget? Would GtkGLExt help
> me in any way? I don't see a way to retrieve a GLXContext from it.

Starting at the deep end, I see. ;-)

If all you want is to accelerate the rendering, then rather than
replicate/replace the entire GdkX11 structure with a GdkGL hierarchy
(though many people would appreciate that done well) you could just
subvert the cairo-xlib backend to perform direct rendering where possible.
I am thinking along the lines of a
cairo_xlib_device_enable_direct_rendering() and then a check at the
beginning of each entry point like:
cairo_xlib_surface_paint() {
  if (surface->gl_proxy)
    return _cairo_surface_paint (surface->gl_proxy, args...);

For an example, look at the hack of how drm subverts xcb in
src/cairo-xcb-surface.c. That could very well be gl instead of drm. Though
this has nasty synchronisation issues, and additional per-process
overhead. Solve those and ensure that cairo-gl is truly faster than the
cairo-xlib you wish to replace, then you have something of broad appeal.

> 2. Is it at least theoreticaly possible to introduce a cross-platform
> API for creating cairo-gl surfaces tied to offscreen pixmaps? I guess
> WGL and CGL functions for cairo-gl would need to be added first.

Not really. The windowing specific parts of GL are deliberately
independent and so the interface to each platform must be separate. The
hope for platform independence is EGL, and there is a big push to provide
an EGL interface on all platforms.

> 3. Let's say I want to create a sub-surface of some other surface (for
> example, to draw only on the part of the image that needs redrawing
> after the user changed something in the document). Is
> cairo_surface_create_for_region available from applications?

Yes. But you will need to bump the cairo dependency to "cairo >= 1.9.6".

Hope this helps, and your enthusiasm for working with Cairo persists!

Chris Wilson, Intel Open Source Technology Centre

More information about the cairo mailing list