[cairo] Reducing CPU usage in News Ticker Implementation

Gerdus van Zyl gerdusvanzyl at gmail.com
Fri Aug 31 03:09:41 PDT 2007


Is it necesary to render the text every draw request? so far I know
text rendering/calculation is very expensive.

I suggest rendering to an buffer
eg:

when the text changes
surf = cr.get_target()
self.buffer = surf.create_similar(cairo.CONTENT_COLOR,max_width,max_height)

ctx = cairo.Context(surfb)
ctx.show_layout(self.layout)

then render buffer on expose:
cr.set_source_surface(self.buffer,0,0)
cr.paint()

~Gerdus van Zyl

On 31/08/2007, Darwin Bautista <djclue917 at gmail.com> wrote:
> The problem is that
> the ticker consumes a lot of CPU when the Pango layout is relatively
> big (377 character-long text, DejaVu Serif Semi-Condensed 40) since X
> performs a lot of redrawing every second (e.g., 50 redraws/second if
> the scroll timeout is set to 20ms).


More information about the cairo mailing list