Review Request: Analog clock painting performance

Alain Boyer alainboyer at gmail.com
Thu Dec 4 18:38:37 CET 2008


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://reviewboard.vidsolbach.de/r/290/
-----------------------------------------------------------

(Updated 2008-12-04 09:38:37.771802)


Review request for Plasma.


Summary
-------

This patch attempts to speed up the analog clock painting performance. Essentially, it caches the QRects of the theme elements and streamlines some of the painting code.

The speedup is explained below, however I think we can do even better. For example, we could draw the hour and minute hands and shadows to a pixmap and then use that when only the second hand needs an update. I'm not sure if this is the way to go? Comments or suggestions?

Update: With the recent changes to Plasma::Svg, I have updated this patch. My apologies to the email noise, I'm still learning how to use RB.

This patch contains two changes. First, the drawHand() method has been modified to draw the shadow as well as the hand. Second, a background (face, hour hand, minute hand) and foreground (screw, glass) pixmap cache have been added. This greatly improves performance (see below) when the second hand is enabled. Is this a sane thing to do? Does using a cache lead to any re-painting issues I have not foreseen?


Diffs
-----

  /trunk/KDE/kdebase/workspace/plasma/applets/analog-clock/clock.h
  /trunk/KDE/kdebase/workspace/plasma/applets/analog-clock/clock.cpp

Diff: http://reviewboard.vidsolbach.de/r/290/diff


Testing
-------

Valgrind tells me that this patch introduces a 1.46 speedup to the drawHand() method. This contributes to a 1.40 speedup of paintInterface(). Not bad.

Another way of looking at it, paintInterface() used to spend 63% of its time actually painting (m_theme->paint()). Now, paintInterface() spends 98% of its time painting. Hence, painting is now the bottleneck.

Update: To test the performance, I ran the clock applet through Valgrind for 2 minutes. With the second hand enabled, a speedup of 2.69 is gained. With the second hand disabled, a speedup of 1.22 is gained.


Thanks,

Alain



More information about the Plasma-devel mailing list