[Sugar-devel] [Dextrose] [PATCH v5 sugar] Pulsing icon delayed by 5 seconds or so SL#2080

Martin Dengler martin at martindengler.com
Fri Oct 29 04:12:56 EDT 2010


On Thu, Oct 28, 2010 at 03:44:37PM -0300, Gonzalo Odiard wrote:
> I think the problem is the code is rendering the svg icon every time
> the color is changed.

Indeed.  As James Cameron pointed out, we're setting the stroke and
fill in rapid succession, resulting in two calls to render().

> There are not cache or cairo operation used to avoid this.

Perhaps CanvasIcon's _emit_paint_needed_icon_area can check some
dirty flag that gets reset upon paint()?  I'm not an expert, and it
sounds like there might be lots of races to worry about.

However it's easier just to replace the calls to set_stroke_color() and
set_fill_color() with set_xo_color(), which does both and then calls
_emit_paint_needed_icon_area().

So I did that[1], and using a small script[2] to just launch the
pulsing icon window using the sugar emulator, we can compare before[3]
and after[4]: The code change halves the number of times we call
_emit_paint_needed_icon_area, and that is borne out by the experiment:
_emit_paint_needed_icon_area is called 196 times in 10 seconds before
the patch, and 99 times afterwards.  Correspondingly, render_cairo()
is called half as much.

I'd love any feedback.

> Gonzalo

Martin

1. http://www.martindengler.com/tmp/sl.o-2080/pulsingicon.py-set-new-colors-in-one-go-to-avoid-multiple-calls-to-SVG-rendering.patch

2. http://www.martindengler.com/tmp/sl.o-2080/profile-pulsingicon.py

3. http://www.martindengler.com/tmp/sl.o-2080/pulsingicon.py-stats-graph-before.png

4. http://www.martindengler.com/tmp/sl.o-2080/pulsingicon.py-stats-graph-after.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: not available
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20101029/f77339a0/attachment.pgp>


More information about the Sugar-devel mailing list