[kitty] keep display distinct from draw #1865

pull/1895/head
nick black 3 years ago committed by Nick Black
parent 3f8dcfa357
commit 9a53379d36

@ -813,6 +813,8 @@ int kitty_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx,
// update any necessary cells underneath the sprixel pursuant to its removal.
// for sixel, this *achieves* the removal, and is performed on every cell.
// returns 1 if the graphic can be immediately freed (which is equivalent to
// asking whether it was sixel and there were no errors).
static inline int
sprite_scrub(const notcurses* n, const ncpile* p, sprixel* s){
//fprintf(stderr, "Destroying sprite %u\n", s->id);

@ -577,7 +577,7 @@ int kitty_blit(ncplane* n, int linesize, const void* data, int leny, int lenx,
}
int kitty_remove(int id, FILE* out){
//fprintf(stderr, "DESTROYING KITTY %d\n", id);
loginfo("Removing graphic %u\n", id);
if(fprintf(out, "\e_Ga=d,d=i,i=%d\e\\", id) < 0){
return -1;
}

@ -857,13 +857,17 @@ clean_sprixels(notcurses* nc, ncpile* p, FILE* out){
}
}else if(s->invalidated == SPRIXEL_HIDE){
//fprintf(stderr, "OUGHT HIDE %d [%dx%d] %p\n", s->id, s->dimy, s->dimx, s);
if(sprite_scrub(nc, p, s)){
int r = sprite_scrub(nc, p, s);
if(r < 0){
return -1;
}else if(r > 0){
if( (*parent = s->next) ){
s->next->prev = s->prev;
}
sprixel_free(s);
}else{
parent = &s->next;
}
if( (*parent = s->next) ){
s->next->prev = s->prev;
}
sprixel_free(s);
continue; // don't account as an elision
}
if(s->invalidated == SPRIXEL_MOVED || s->invalidated == SPRIXEL_INVALIDATED){
@ -919,10 +923,11 @@ static int64_t
rasterize_sprixels(notcurses* nc, ncpile* p, FILE* out){
int64_t bytesemitted = 0;
for(sprixel* s = p->sprixelcache ; s ; s = s->next){
//fprintf(stderr, "YARR HARR HARR SPIRXLE %u STATE %d\n", s->id, s->invalidated);
if(s->invalidated == SPRIXEL_INVALIDATED){
int y, x;
//fprintf(stderr, "3 DRAWING BITMAP %d STATE %d AT %d/%d for %p\n", s->id, s->invalidated, y + nc->margin_t, x + nc->margin_l, s->n);
int y,x;
ncplane_yx(s->n, &y, &x);
fprintf(stderr, "3 DRAWING BITMAP %d STATE %d AT %d/%d for %p\n", s->id, s->invalidated, y + nc->margin_t, x + nc->margin_l, s->n);
if(goto_location(nc, out, y + nc->margin_t, x + nc->margin_l)){
return -1;
}
@ -936,15 +941,20 @@ fprintf(stderr, "3 DRAWING BITMAP %d STATE %d AT %d/%d for %p\n", s->id, s->inva
}else if(s->invalidated == SPRIXEL_LOADED){
if(nc->tcache.pixel_commit){
int y,x;
ncplane_yx(s->n, &y, &x);
//fprintf(stderr, "3 DRAWING BITMAP %d STATE %d AT %d/%d for %p\n", s->id, s->invalidated, y + nc->margin_t, x + nc->margin_l, s->n);
if(goto_location(nc, out, y + nc->margin_t, x + nc->margin_l)){
return -1;
}
ncplane_yx(s->n, &y, &x);
if(goto_location(nc, out, y + nc->margin_t, x + nc->margin_l)){
return -1;
}
if(nc->tcache.pixel_commit(out, s) < 0){
return -1;
}
}
}else if(s->invalidated == SPRIXEL_HIDE){
if(nc->tcache.pixel_remove){
if(nc->tcache.pixel_remove(s->id, out) < 0){
return -1;
}
}
}
}
return bytesemitted;

@ -823,7 +823,7 @@ int sixel_scrub(const ncpile* p, sprixel* s){
}
}
}
return 0;
return 1;
}
// returns the number of bytes written
@ -850,7 +850,6 @@ int sixel_draw(const ncpile* p, sprixel* s, FILE* out){
return -1;
}
s->invalidated = SPRIXEL_QUIESCENT;
fprintf(stderr, "POSTDRAW: %d %d/%d\n", s->invalidated, s->movedfromy, s->movedfromx);
return s->glyphlen;
}

@ -41,6 +41,7 @@ void sprixel_debug(const sprixel* s, FILE* out){
// doesn't splice us out of any lists, just frees
void sprixel_free(sprixel* s){
if(s){
loginfo("Destroying sprixel %u\n", s->id);
if(s->n){
s->n->sprite = NULL;
}
@ -82,13 +83,12 @@ void sprixel_movefrom(sprixel* s, int y, int x){
void sprixel_hide(sprixel* s){
if(ncplane_pile(s->n) == NULL){ // ncdirect case; destroy now
//fprintf(stderr, "HIDING %d IMMEDIATELY\n", s->id);
sprixel_free(s);
return;
}
// otherwise, it'll be killed in the next rendering cycle.
if(s->invalidated != SPRIXEL_HIDE){
//fprintf(stderr, "HIDING %d\n", s->id);
loginfo("Marking sprixel %u hidden\n", s->id);
s->invalidated = SPRIXEL_HIDE;
s->movedfromy = ncplane_abs_y(s->n);
s->movedfromx = ncplane_abs_x(s->n);

@ -52,7 +52,6 @@ setup_sixel_bitmaps(tinfo* ti, int fd, bool invert80){
ti->pixel_init = sixel_init;
}
ti->pixel_draw = sixel_draw;
ti->pixel_remove = NULL;
ti->pixel_scrub = sixel_scrub;
ti->pixel_wipe = sixel_wipe;
ti->pixel_shutdown = sixel_shutdown;

Loading…
Cancel
Save