This is an attempt at improving the rendering speed of interactive scrolling.
Today, this is done by memmoving the scrolled part of the pixmap. The fewer lines we're scrolling, the more data we have to memmove. Thus, normal single-line scrolling is slow.
The idea implemented here is this: what if we can scroll without moving any data? What if we instead can move the buffer pointers to point to the new top of the pixmap?
That part is actually pretty easy (for forward scrolling); we just have to increase the file size of the backing memory FD and create a new mmapping along with a new pixmap image instance and a new Wayland SHM buffer.
The problem is of course that this would consume an insane amount of memory.
So, is there some way to deal with this? Turns out the answer is yes. We can punch a "hole" from the beginning of the memfd file to the new start offset using fallocate(2) with FALLOC_FL_PUNCH_HOLE.
For small shifts of the offset, this turns out to be very fast. But it is on the other hand very slow when the offset is shifted by a large amount.
Luckily, this is precisely the opposite of the memmove method, which means we can memmove() when scrolling a large number of lines, and the new fallocate() based method when scrolling a small number of lines.
Another draw back of the new method is that the scrolled in area is completely uninitialized. This means we need to repair the bottom scroll region (when forward scrolling), and re-paint the window margins. This too can be very slow and thus we take this into account when determining which method to use.
TODO:
- implement backward scrolling
- investigate if it's worth restoring/repairing the scrolled out scrolling region too (right now, the new method is disabled if the scrolled out region is not empty)
- implement restoration of scrolled out region
Closes #4