FS#5591 - Speeds up some list scrolling by a factor of ~12

Attached to Project: Rockbox
Opened by Thomas Paul Diffenbach (tpdiffenbach) - Saturday, 24 June 2006, 06:18 GMT
Last edited by Jonathan Gordon (jdgordon) - Saturday, 04 August 2007, 10:01 GMT
Task Type Patches
Category User Interface
Status Closed
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


This patch optimizes apps/gui/list.c, function gui_list_draw.

Previously, all lists were always redrawn in their entirety. With this patch, when the list's start position (the item at the top of the list) hasn't changed, only the /lines/ changed are updated. In almost all cases, that means only two lines are updated, the line the cursor is leaving and the line to cursor is moving to. When a list's start position changes, or when a new list is shown, the whole list is re-drawn using the original cvs code.

Provision is made to handle the "pointer" cursor as well as the standard inverted bar cursor.

The speed increase depends on the font used; the smaller the font, the more lines have to be drawn to fill the screen, and so the greater the speed savings. Here's a non-controlled sample of the average speeds of the regular and the optimized list redrawing, in microseconds, for several font sizes, on my Ipod Video (G5, 60GB, using only 32MB of memory, that is, build 15):

Font Height Average Unoptimized Average Optimized Ratio of Unoptimized/Optimized
5 123039.71 4555.51 27.01
7 128322.65 15404.24 8.33
14 116112.13 7363.98 15.77
16 128704.18 8046.00 16.00
24 130604.73 20603.50 6.34

For ipods, there's an often mentioned problem of music play stopping when lists are scrolled. This will not fix the problem, but will alleviate it quite a bit.

Please perform the following experiment before using this patch in build. Using your current build, play a song, then go to the menu and rapidly scroll up and down the list until the music stops playing. Then try the same using a build with this patch. Then do a logfdump (Menu|Info|Debug|logfdump), and mail the file logf.txt in your device's .rockbox directory to:
gui_list_opt AT

This task depends upon

Closed by  Jonathan Gordon (jdgordon)
Saturday, 04 August 2007, 10:01 GMT
Reason for closing:  Out of Date
Comment by Thomas Paul Diffenbach (tpdiffenbach) - Saturday, 24 June 2006, 07:40 GMT
Dave Chapman (linuxstb) notes that the original patch will work only on PP5020 ipods, and only on builds with logf support.

For all other builds, or if you're unsure your build supports the original patch, use this second patch.
Comment by Mikael Magnusson (mikaelh) - Tuesday, 27 June 2006, 00:33 GMT
there are some dos line endings in both patches, you might want to watch out for that in the future.
Comment by Thomas Paul Diffenbach (tpdiffenbach) - Tuesday, 27 June 2006, 00:59 GMT
Thanks for pointing that out. I'll double-check in the future.
Comment by Nicolas Pennequin (nicolas_p) - Tuesday, 22 August 2006, 01:25 GMT
How's this patch coming along ? Is it finished ? Is it worth committing ?
It looks rather promising... Couldn't it fix some cases where playback was halted by long scrolls ?
I haven't had time to test it but i'll try as soon as possible.
Comment by Thomas Paul Diffenbach (tpdiffenbach) - Wednesday, 23 August 2006, 01:23 GMT
It's still in beta; sorry, I've been on vacation or otherwise occupied. I'll soon update it.
Comment by Ryan Sawhill (ryran) - Wednesday, 23 August 2006, 04:36 GMT
Awesome! Glad to hear! :)
Comment by Jesus Climent (mooch) - Monday, 11 September 2006, 20:57 GMT
Any progress?