Thread
:
[Announce] SVGClock for Diablo
View Single Post
Addison
2010-02-06 , 15:34
Posts: 3,811 | Thanked: 1,151 times | Joined on Oct 2007 @ East Lansing, MI
#
44
Apparently, I guess I made a new friend today.
All credit goes to this one guy named Marius Gedminas.
Here's what he had to.say on your clock build.
Four things come into mind:
** The background and foreground never changes; instead of rendering the SVG every time, render them into an offscreen buffer and blit the cached image in your expose event.
Something like
http://old.nabble.com/Cairo-double-b...d22493956.html
but don't draw to the image surface on every frame; cache it if the widget size hasn't changed.
** Use timeout_add_seconds rather than timeout_add, that should be slightly more battery-efficient (multiple apps will get scheduled to wake up at the same time, rather than staggered throughout the second).
-- see
http://library.gnome.org/devel/pygob...ut-add-seconds
** clip the drawing in the expose event handler to just the dirty area:
# Create the cairo context
cr = self.window.cairo_create()
# Restrict Cairo to the exposed area; avoid extra work
cr.rectangle(event.area.x, event.area.y,
event.area.width, event.area.height)
cr.clip()
-- from
http://www.tortall.net/mu/wiki/PyGTKCairoTutorial
This will probably not matter much for Maemo where all windows are not overlapping, but then you can
** compute the dirty area in your timer interrupt and use queue_draw_area instead of queue_draw
This will let you draw less on every frame.
Hope that helps!
Quote & Reply
|
The Following User Says Thank You to Addison For This Useful Post:
shin
Addison
View Public Profile
Send a private message to Addison
Find all posts by Addison