[cairo] Text Grid Performance

Gerdus van Zyl gerdusvanzyl at gmail.com
Thu Feb 7 00:02:57 PST 2008


I have again gone over my application with a fine tooth comb and found
some problems like not reusing the offscreen surface, etc. Also
stripped down the code, predictably it's faster.
What I did not expect was the large difference between using pango and
the toy text API.
pango - 0.08s - 11fps (much better than last time)
toyapi - 0.03s - 30fps (perfect)

Is there a way to speed up pango? I would love to use pango everywhere
since the toyapi is so limited. Otherwise i will just use the toyapi
where speed is of the essence and pango everywhere else. See my text
code below that gave the results above:

ctx.set_source_rgb(0,0,0)
if True:
    ctx.select_font_face("Arial",cairo.FONT_SLANT_NORMAL,
cairo.FONT_WEIGHT_NORMAL)
    ctx.set_font_size(10)
    ctx.move_to(5,10)
    ctx.show_text(self.text)
else:
    ctx.move_to(0,0)
    cr = pangocairo.CairoContext(ctx)
    layout = cr.create_layout()
    layout.set_text(self.text)
    layout.set_font_description(pango.FontDescription("Arial, 8"))
    cr.show_layout(layout)

Thank you.

~GerdusVZ


More information about the cairo mailing list