From fd7a1a5d6d5b8be488997209a0b655a7ad2e617c Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 8 May 2021 21:31:18 -0400 Subject: [PATCH] sixel_destroy: be more precise with damage #1616 --- src/lib/sixel.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/lib/sixel.c b/src/lib/sixel.c index ee24f000b..07c46aa53 100644 --- a/src/lib/sixel.c +++ b/src/lib/sixel.c @@ -698,9 +698,23 @@ int sixel_destroy(const notcurses* nc, const ncpile* p, FILE* out, sprixel* s){ for(int xx = startx ; xx < startx + s->dimx && xx < p->dimx ; ++xx){ int ridx = (yy - stdn->absy) * p->dimx + (xx - stdn->absx); struct crender *r = &p->crender[ridx]; - // FIXME this probably overdoes it -- look at kitty_destroy() if(!r->sprixel){ - r->s.damaged = 1; + if(s->n){ +//fprintf(stderr, "CHECKING %d/%d\n", yy - s->movedfromy, xx - s->movedfromx); + sprixcell_e state = sprixel_state(s, yy - s->movedfromy + s->n->absy - stdn->absy, + xx - s->movedfromx + s->n->absx - stdn->absx); + if(state == SPRIXCELL_OPAQUE_SIXEL || state == SPRIXCELL_MIXED_SIXEL){ + r->s.damaged = 1; + }else if(s->invalidated == SPRIXEL_MOVED){ + // ideally, we wouldn't damage our annihilated sprixcells, but if + // we're being annihilated only during this cycle, we need to go + // ahead and damage it. + r->s.damaged = 1; + } + }else{ + // need this to damage cells underneath a sprixel we're removing + r->s.damaged = 1; + } } } }