sixel_scrub: be a bit more cautious about our jiggery-pokery

pull/2011/head
nick black 3 years ago
parent c482d89dba
commit ac7902a940
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -816,7 +816,7 @@ sprixel_state(const sprixel* s, int y, int x){
const ncplane* stdn = notcurses_stdplane_const(ncplane_notcurses_const(s->n));
int localy = y - (s->n->absy - stdn->absy);
int localx = x - (s->n->absx - stdn->absx);
//fprintf(stderr, "TAM %d at %d/%d (%d/%d)\n", s->n->tam[localy * s->dimx + localx].state, localy, localx, y, x);
//fprintf(stderr, "TAM %d at %d/%d (%d/%d, %d/%d)\n", s->n->tam[localy * s->dimx + localx].state, localy, localx, y, x, s->dimy, s->dimx);
assert(localy >= 0);
assert(localy < s->dimy);
assert(localx >= 0);

@ -996,7 +996,7 @@ int kitty_remove(int id, FILE* out){
return 0;
}
// damages cells underneath the graphic which weren't SPRIXCELL_OPAQUE
// damages cells underneath the graphic which were OPAQUE
int kitty_scrub(const ncpile* p, sprixel* s){
//fprintf(stderr, "FROM: %d/%d state: %d s->n: %p\n", s->movedfromy, s->movedfromx, s->invalidated, s->n);
for(int yy = s->movedfromy ; yy < s->movedfromy + s->dimy && yy < p->dimy ; ++yy){

@ -755,12 +755,9 @@ int sixel_blit(ncplane* n, int linesize, const void* data, int leny, int lenx,
// if we have a sprixel attached to this plane, see if we can reuse it
// (we need the same dimensions) and thus immediately apply its T-A table.
if(n->tam){
//fprintf(stderr, "IT'S A REUSE %d %d\n", rows, cols);
if(n->leny == rows && n->lenx == cols){
tam = n->tam;
reuse = true;
}else{
// FIXME free up old TAM (well, shrink it anyway)
}
}
if(!reuse){
@ -806,9 +803,20 @@ int sixel_scrub(const ncpile* p, sprixel* s){
if(r->sprixel){
s = r->sprixel;
}
if(s->n){
sprixcell_e state = sprixel_state(s, yy - s->movedfromy,
xx - s->movedfromx);
if(!s->n){
// need this to damage cells underneath a sprixel we're removing
r->s.damaged = 1;
continue;
}
if(yy >= s->n->leny || yy - s->n->absy < 0){
r->s.damaged = 1;
continue;
}
if(xx >= s->n->lenx || xx - s->n->absx < 0){
r->s.damaged = 1;
continue;
}
sprixcell_e state = sprixel_state(s, yy, xx);
//fprintf(stderr, "CHECKING %d/%d state: %d %d/%d\n", yy - s->movedfromy - s->n->absy, xx - s->movedfromx - s->n->absx, state, yy, xx);
if(state == SPRIXCELL_TRANSPARENT || state == SPRIXCELL_MIXED_SIXEL){
r->s.damaged = 1;
@ -818,10 +826,6 @@ int sixel_scrub(const ncpile* p, sprixel* s){
// ahead and damage it.
r->s.damaged = 1;
}
}else{
// need this to damage cells underneath a sprixel we're removing
r->s.damaged = 1;
}
}
}
return 1;

Loading…
Cancel
Save