Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize rendering runs of spaces when there is no visual change #4877

Merged
merged 4 commits into from
Mar 13, 2020

Commits on Mar 12, 2020

  1. 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.
    DHowett committed Mar 12, 2020
    Configuration menu
    Copy the full SHA
    a857291 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    621581d View commit details
    Browse the repository at this point in the history
  3. don't forget grid lines

    DHowett committed Mar 12, 2020
    Configuration menu
    Copy the full SHA
    04c65ec View commit details
    Browse the repository at this point in the history
  4. okay.

    DHowett committed Mar 12, 2020
    Configuration menu
    Copy the full SHA
    f9150c2 View commit details
    Browse the repository at this point in the history