general foreground elision #131

This commit is contained in:
nick black 2019-12-27 20:13:00 -05:00 committed by Nick Black
parent 5b322add56
commit e9890eefc0
2 changed files with 27 additions and 20 deletions

View File

@ -1339,7 +1339,7 @@ API const char* cell_extended_gcluster(const struct ncplane* n, const cell* c);
// FIXME do this at cell prep time and set a bit in the channels
static inline bool
cell_noforeground_p(const cell* c){
return cell_simple_p(c) || isspace(c->gcluster);
return cell_simple_p(c) && isspace(c->gcluster);
}
// True if the cell does not generate background pixels. Only the FULL BLOCK

View File

@ -540,7 +540,6 @@ notcurses_render_internal(notcurses* nc){
// * we are a no-foreground glyph, and the previous was default background, or
// * we are a no-background glyph, and the previous was default foreground
// FIXME move these into the cell bits
bool noforeground = cell_noforeground_p(&c);
bool nobackground = cell_nobackground_p(p, &c);
if((!noforeground && cell_fg_default_p(&c)) || (!nobackground && cell_bg_default_p(&c))){
@ -560,29 +559,37 @@ notcurses_render_internal(notcurses* nc){
// foreground set iff either:
// * the previous was non-default, and matches what we have now, or
// * we are a no-foreground glyph (iswspace() is true)
if(/*!noforeground &&*/ !cell_fg_default_p(&c)){
cell_get_fg_rgb(&c, &r, &g, &b);
if(nc->rstate.fgelidable && nc->rstate.lastr == r && nc->rstate.lastg == g && nc->rstate.lastb == b){
if(!cell_fg_default_p(&c)){
if(!noforeground){
cell_get_fg_rgb(&c, &r, &g, &b);
if(nc->rstate.fgelidable && nc->rstate.lastr == r && nc->rstate.lastg == g && nc->rstate.lastb == b){
++nc->stats.fgelisions;
}else{
term_fg_rgb8(nc, out, r, g, b);
++nc->stats.fgemissions;
nc->rstate.fgelidable = true;
}
nc->rstate.lastr = r; nc->rstate.lastg = g; nc->rstate.lastb = b;
nc->rstate.defaultelidable = false;
}else{
++nc->stats.fgelisions;
}else{
term_fg_rgb8(nc, out, r, g, b);
++nc->stats.fgemissions;
nc->rstate.fgelidable = true;
}
nc->rstate.lastr = r; nc->rstate.lastg = g; nc->rstate.lastb = b;
nc->rstate.defaultelidable = false;
}
if(!nobackground && !cell_bg_default_p(&c)){
cell_get_bg_rgb(&c, &br, &bg, &bb);
if(nc->rstate.bgelidable && nc->rstate.lastbr == br && nc->rstate.lastbg == bg && nc->rstate.lastbb == bb){
++nc->stats.bgelisions;
if(!cell_bg_default_p(&c)){
if(!nobackground){
cell_get_bg_rgb(&c, &br, &bg, &bb);
if(nc->rstate.bgelidable && nc->rstate.lastbr == br && nc->rstate.lastbg == bg && nc->rstate.lastbb == bb){
++nc->stats.bgelisions;
}else{
term_bg_rgb8(nc, out, br, bg, bb);
++nc->stats.bgemissions;
nc->rstate.bgelidable = true;
}
nc->rstate.lastbr = br; nc->rstate.lastbg = bg; nc->rstate.lastbb = bb;
nc->rstate.defaultelidable = false;
}else{
term_bg_rgb8(nc, out, br, bg, bb);
++nc->stats.bgemissions;
nc->rstate.bgelidable = true;
++nc->stats.bgelisions;
}
nc->rstate.lastbr = br; nc->rstate.lastbg = bg; nc->rstate.lastbb = bb;
nc->rstate.defaultelidable = false;
}
// fprintf(stderr, "[%02d/%02d] 0x%02x 0x%02x 0x%02x %p\n", y, x, r, g, b, p);
term_putc(out, p, &c);