Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize rendering runs of spaces when only the foreground changes
cmatrix is somewhat of a pathological case for our infrastructure: it prints out a bunch of green and white characters and then updates them a million times a second. It also maintains a column of space between every green character. When it prints this column, it prints it in "default" or "white". This ends up making runs of text that look like this: (def: G=green B=bright white W=white *=matrix char =space) G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W G W As characters trickle in: G*W G*W G*W G*W G*W G*W G*W B*W G*W G*W G*W G*W G*W G*W G*W G W G*W G*W G*W B*W G*W G*W G*W G W G*W B*W G*W G W G*W G*W G*W G*W G*W G W G*W G W G*W B*W G*W G*W B*W G W G*W G W G*W G W B*W G*W G W G W G*W G W G*W G W G W B*W G W G W B*W G W G*W G W G W G W Every one of those color transitions causes us to break up the run of text and start rendering it again. This impacts GDI, Direct2D *and* ConPTY. The problem is, printing a space doesn't **use** the foreground color! This commit introduces an optimization. When we're about to break a text cluster becuase its attributes changed, we make sure that it's not just filled with spaces and differs only in the foreground parameter. This lets us optimize both the rendering _and_ the PTY output to look like this: G* * * * * * * B* G* * * * * * * G* * * B* * * * G* B* * * * * * G* * * B* * * B* * * B* * G * * B* G B* * Text will be printed at best line-by-line and at worst only when the visible properties of the screen actually change. This speeds up cmatrix remarkably.
- Loading branch information