[kitty] pull remove out of destroy, rename destroy scrub #1865

pull/1895/head
nick black 3 years ago committed by Nick Black
parent 3763739b9f
commit 3608d6a2d6

@ -779,8 +779,8 @@ sprixel* sprixel_alloc(ncplane* n, int dimy, int dimx);
sprixel* sprixel_recycle(ncplane* n);
// takes ownership of s on success.
int sprixel_load(sprixel* spx, char* s, int bytes, int pixy, int pixx, int parse_start);
int sixel_destroy(const notcurses* nc, const ncpile* p, FILE* out, sprixel* s);
int kitty_destroy(const notcurses* nc, const ncpile* p, FILE* out, sprixel* s);
int sixel_scrub(const ncpile* p, sprixel* s);
int kitty_scrub(const ncpile* p, sprixel* s);
int kitty_remove(int id, FILE* out);
int kitty_clear_all(FILE* fp);
int sixel_init(const tinfo* t, int fd);
@ -809,11 +809,13 @@ int sixel_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx,
int kitty_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx,
const blitterargs* bargs, int bpp);
// update any necessary cells underneath the sprixel pursuant to its removal.
// for sixel, this *achieves* the removal, and is performed on every cell.
static inline int
sprite_destroy(const notcurses* nc, const ncpile* p, FILE* out, sprixel* s){
sprite_scrub(const notcurses* n, const ncpile* p, sprixel* s){
//fprintf(stderr, "Destroying sprite %u\n", s->id);
//sprixel_debug(s, stderr);
return nc->tcache.pixel_destroy(nc, p, out, s);
return n->tcache.pixel_scrub(p, s);
}
// precondition: s->invalidated is SPRIXEL_INVALIDATED or SPRIXEL_MOVED.

@ -579,11 +579,7 @@ int kitty_remove(int id, FILE* out){
// removes the kitty bitmap graphic identified by s->id, and damages those
// cells which weren't SPRIXCEL_OPAQUE
int kitty_destroy(const notcurses* nc __attribute__ ((unused)),
const ncpile* p, FILE* out, sprixel* s){
if(kitty_remove(s->id, out)){
return -1;
}
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){
for(int xx = s->movedfromx ; xx < s->movedfromx + s->dimx && xx < p->dimx ; ++xx){

@ -844,7 +844,7 @@ clean_sprixels(notcurses* nc, ncpile* p, FILE* out){
while( (s = *parent) ){
if(s->invalidated == SPRIXEL_HIDE){
//fprintf(stderr, "OUGHT HIDE %d [%dx%d] %p\n", s->id, s->dimy, s->dimx, s);
if(sprite_destroy(nc, p, out, s)){
if(sprite_scrub(nc, p, s)){
return -1;
}
if( (*parent = s->next) ){
@ -857,7 +857,7 @@ clean_sprixels(notcurses* nc, ncpile* p, FILE* out){
//fprintf(stderr, "1 MOVING BITMAP %d STATE %d AT %d/%d for %p\n", s->id, s->invalidated, y + nc->margin_t, x + nc->margin_l, s->n);
// without this, kitty flickers
if(s->invalidated == SPRIXEL_MOVED){
sprite_destroy(nc, p, out, s);
sprite_scrub(nc, p, s);
}
if(goto_location(nc, out, y + nc->margin_t, x + nc->margin_l) == 0){
int r = sprite_redraw(nc, p, s, out);

@ -794,10 +794,8 @@ int sixel_blit(ncplane* n, int linesize, const void* data, int leny, int lenx,
// to, though, if we've got a new sixel ready to go where the old sixel was
// (though we'll still need to if the new sprixcell not opaque, and the
// old and new sprixcell are different in any transparent pixel).
int sixel_destroy(const notcurses* nc, const ncpile* p, FILE* out, sprixel* s){
int sixel_scrub(const ncpile* p, sprixel* s){
//fprintf(stderr, "DESTROYING %d %d %p at %d/%d (%d/%d)\n", s->id, s->invalidated, s->n, s->movedfromy, s->movedfromx, s->dimy, s->dimx);
(void)nc;
(void)out;
int starty = s->movedfromy;
int startx = s->movedfromx;
for(int yy = starty ; yy < starty + s->dimy && yy < p->dimy ; ++yy){

@ -53,7 +53,7 @@ setup_sixel_bitmaps(tinfo* ti, int fd, bool invert80){
}
ti->pixel_draw = sixel_draw;
ti->pixel_remove = NULL;
ti->pixel_destroy = sixel_destroy;
ti->pixel_scrub = sixel_scrub;
ti->pixel_wipe = sixel_wipe;
ti->pixel_shutdown = sixel_shutdown;
ti->pixel_rebuild = sixel_rebuild;
@ -67,7 +67,7 @@ setup_sixel_bitmaps(tinfo* ti, int fd, bool invert80){
static inline void
setup_kitty_bitmaps(tinfo* ti, int fd, int sixel_maxy_pristine){
ti->pixel_wipe = kitty_wipe;
ti->pixel_destroy = kitty_destroy;
ti->pixel_scrub = kitty_scrub;
ti->pixel_remove = kitty_remove;
ti->pixel_draw = kitty_draw;
ti->pixel_move = kitty_move;

@ -133,7 +133,7 @@ typedef struct tinfo {
int (*pixel_draw)(const struct ncpile* p, struct sprixel* s, FILE* out);
// execute move (erase old graphic, place at new location) if non-NULL
int (*pixel_move)(const struct ncpile* p, struct sprixel* s, FILE* out);
int (*pixel_destroy)(const struct notcurses* nc, const struct ncpile* p, FILE* out, struct sprixel* s);
int (*pixel_scrub)(const struct ncpile* p, struct sprixel* s);
int (*pixel_shutdown)(FILE* fp); // called during context shutdown
int (*pixel_clear_all)(FILE* fp); // called during context startup
uint8_t* (*pixel_trans_auxvec)(const struct tinfo* ti); // create tranparent auxvec

Loading…
Cancel
Save