Invalidation improvements
Now that we have #26 (closed) in place (always invalidate and redraw entire lines), we should see if we can improve / simplify in any of these directions (and perhaps even automagically fix or at least get closer to fixing #4 (closed)):
-
Let's try to understand (and document!) why in
invalidate_rows()
andinvalidate_all()
we handle differently the case when there's an active terminal (not necessarily the current one?) or not. In the former case, we maintain ourselves the list of rectangles to be invalidated, and pass it to GTK with a delay. Can't we pass it to GTK directly and let it do this maintenance? It will delay the update anyway according to the frame clock. Is it perhaps a leftover from GTK v1 or v2 days? -
Now that we invalidate entire rows, we should also invalidate the side paddings of those rows to correctly clean up after overflowing glyphs. (Needs a bit of change since when we maintain the list of rectangles ourselves (as per the previous bullet point), those rectangles are relative to the cell grid (paddings excluded).)
-
If we still need to maintain ourselves (and maybe join) a list of rectangles that we'll pass to GTK at once, instead of maintaining actual cairo rectangles, we could just have a bitmap for the rows. Makes bookkeeping, especially finding their union much easier.
-
Currently we invalidate 1 more pixel upwards and downwards (to handle a bit of overflow, plus perhaps the outline rectangle cursor as well). If rows k and k+2 are invalidated, once we get to painting the contents, in the first round draw_rows() is called for rows k-1, k and k+1, this results in row k (and a bit of context) being updated. Then it's called again for rows k+1, k+2 and k+3, resulting in a visual update of row k+2 (and a bit of context). This means that we process the intermediate row k+1 twice. Should we combine these? If we convert to bitmaps (as per the previous bullet point), essentially we'd need to flip the bit for every row whose both neighbors have the bit set. If we remain at cairo rectangles, see if we should invalidate by half a line extra to the top and bottom (with proper rounding) so that they touch each other and then GTK combines them to a single rectangle (does it?).