Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/clock.py
diff options
context:
space:
mode:
Diffstat (limited to 'clock.py')
-rwxr-xr-xclock.py26
1 files changed, 19 insertions, 7 deletions
diff --git a/clock.py b/clock.py
index 3e66185..bb793cb 100755
--- a/clock.py
+++ b/clock.py
@@ -525,6 +525,9 @@ class ClockFace(gtk.DrawingArea):
# Black
self._COLOR_BLACK = "#000000"
+ # cache backgrounds
+ self._nice_background_cache = None
+
# gtk.Widget signals
self.connect("expose-event", self._expose_cb)
self.connect("size-allocate", self._size_allocate_cb)
@@ -737,13 +740,22 @@ class ClockFace(gtk.DrawingArea):
"""
# We transform the background SVG
cr = self.window.cairo_create()
- scale_x = self._radius * 2.0 / self._svg_handle.props.width
- scale_y = self._radius * 2.0 / self._svg_handle.props.height
- matrix = cairo.Matrix(xx=scale_x, yy=scale_y,
- x0=self._center_x - self._radius,
- y0=self._center_y - self._radius)
- cr.transform(matrix)
- self._svg_handle.render_cairo(cr)
+
+ if self._nice_background_cache == None:
+ self._nice_background_cache = cr.get_target().create_similar(
+ cairo.CONTENT_COLOR_ALPHA, self._radius * 2,
+ self._radius * 2)
+ cache_ctx = cairo.Context(self._nice_background_cache)
+ scale_x = self._radius * 2.0 / self._svg_handle.props.width
+ scale_y = self._radius * 2.0 / self._svg_handle.props.height
+ matrix = cairo.Matrix(xx=scale_x, yy=scale_y)
+ cache_ctx.transform(matrix)
+ self._svg_handle.render_cairo(cache_ctx)
+
+ cr.translate(self._center_x - self._radius,
+ self._center_y - self._radius)
+ cr.set_source_surface(self._nice_background_cache)
+ cr.paint()
def _draw_nice_clock(self):
"""Draw the nice clock.