Tag Archives: Cairo

Cairo slowness

I've been playing around with Cairo lately, and have hit a problem with drawing a repeated bitmap background onto a GtkDrawingArea (i.e. a GdkDrawable).

I've got some code which will do this, but it's slow to the point of being able to see each individual repetition of the bitmap being drawn. The bitmap I'm using isn't particularly big or complex (although I can't see what effect that should have), and there's not much I can remove from the code, so it's got to either be an X server setup problem, or a fundamental flaw with my approach. I favour the latter, since other Cairo applications draw blindingly fast on my machine.

cairo_t *cr;
cairo_surface_t *background_surface;
cairo_pattern_t *background_pattern;

background_surface = cairo_image_surface_create_from_png ("image.png");
background_pattern = cairo_pattern_create_for_surface (background_surface);
cairo_pattern_set_extend (background_pattern, CAIRO_EXTEND_REPEAT);

cr = gdk_cairo_create (GDK_DRAWABLE (my_gtk_drawing_area->window));

cairo_save (cr);
cairo_set_source (cr, background_pattern);
cairo_paint (cr);
cairo_restore (cr);

cairo_destroy (cr);
cairo_surface_destroy (background_surface);
cairo_pattern_destroy (background_pattern);

If anybody's got any idea what's wrong with this, I'd be grateful to know. :)

In other news, I apologise for my exceedingly prolonged absence from my own site. I couldn't think of anything to write about, and real life got in the way. :(

Firefox Cairo

You may wonder what's been keeping me busy for the past few weeks…but that's irrelevant, as the Firefox Cairo patches have, in the past few weeks, started to land. :D

This is a major step in a new direction for Firefox, with a change of rendering backend, and it certainly looks good. Although it's not up to speed yet (it's actually quite slow and jerky, but by no means intolerable), it already has support for native GTK widgets.

In related Firefox news, I have taken up bug triaging as a hobby, and I'm working through a (long) list of Firefox bug reports on Linux. It's now down to below 1000. :D

Most bug reports (about 70%) are complete rubbish, half of the remaining reports are duplicates, and the rest are real reports. I'm hoping to get around to helping fix some of them soon instead of just triaging; it's a goal of mine to submit a patch for Firefox. :)