Memoization of which lines are visible in each staff.

Building block for #192.