diff --git a/src/lib/internal.h b/src/lib/internal.h index e13c38249..77fa3a6af 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -147,7 +147,7 @@ typedef enum { // reconstruction of annihilated cells, valid only for SPRIXCELL_ANNIHILATED. typedef struct tament { sprixcell_e state; - uint8_t auxvector; // palette entries for sixel, alphas for kitty + uint8_t* auxvector; // palette entries for sixel, alphas for kitty } tament; // a sprixel represents a bitmap, using whatever local protocol is available. @@ -959,6 +959,9 @@ sprixel* sprixel_by_id(const ncpile* n, uint32_t id); void sprixel_invalidate(sprixel* s, int y, int x); void sprixel_movefrom(sprixel* s, int y, int x); +// create an auxiliary vector suitable for a sprixcell, and zero it out +uint8_t* sprixel_auxiliary_vector(const sprixel* s); + int sixel_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, const blitterargs* bargs); @@ -991,7 +994,7 @@ sprixel_debug(FILE* out, const sprixel* s){ // precondition: s->invalidated is SPRIXEL_INVALIDATED or SPRIXEL_MOVED. static inline int sprite_draw(const notcurses* n, const ncpile* p, sprixel* s, FILE* out){ -sprixel_debug(stderr, s); +//sprixel_debug(stderr, s); return n->tcache.pixel_draw(n, p, s, out); } diff --git a/src/lib/kitty.c b/src/lib/kitty.c index 39b68c111..36d30a4d1 100644 --- a/src/lib/kitty.c +++ b/src/lib/kitty.c @@ -289,6 +289,7 @@ int kitty_wipe(const notcurses* nc, sprixel* s, int ycell, int xcell){ //fprintf(stderr, "CACHED WIPE %d %d/%d\n", s->id, ycell, xcell); return 0; // already annihilated, needn't draw glyph in kitty } + uint8_t* auxvec = sprixel_auxiliary_vector(s); //fprintf(stderr, "NEW WIPE %d %d/%d\n", s->id, ycell, xcell); const int totalpixels = s->pixy * s->pixx; const int xpixels = nc->tcache.cellpixx; @@ -343,6 +344,7 @@ int kitty_wipe(const notcurses* nc, sprixel* s, int ycell, int xcell){ if(--targy == 0){ // FIXME make sure state is MIXED if we had any transparency s->n->tam[s->dimx * ycell + xcell].state = state; + s->n->tam[s->dimx * ycell + xcell].auxvector = auxvec; return 0; } thisrow = targx; @@ -361,6 +363,7 @@ int kitty_wipe(const notcurses* nc, sprixel* s, int ycell, int xcell){ } ++c; } + free(auxvec); return -1; } diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index e8a540978..55e022747 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -269,7 +269,14 @@ void free_plane(ncplane* p){ if(p->sprite){ sprixel_hide(p->sprite); } - free(p->tam); + if(p->tam){ + for(int y = 0 ; y < p->leny ; ++y){ + for(int x = 0 ; x < p->lenx ; ++x){ + free(p->tam[y * p->lenx + x].auxvector); + } + } + free(p->tam); + } egcpool_dump(&p->pool); free(p->name); free(p->fb); diff --git a/src/lib/render.c b/src/lib/render.c index e43057f41..a3402d7d6 100644 --- a/src/lib/render.c +++ b/src/lib/render.c @@ -178,7 +178,7 @@ paint_sprixel(ncplane* p, struct crender* rvec, int starty, int startx, crender->sprixel = s; } if(sprixel_state(s, absy, absx) == SPRIXCELL_ANNIHILATED){ -fprintf(stderr, "REBUILDING AT %d/%d\n", y, x); +//fprintf(stderr, "REBUILDING AT %d/%d\n", y, x); sprite_rebuild(nc, s, y, x); } } diff --git a/src/lib/sprite.c b/src/lib/sprite.c index 9dc16879f..c608832d8 100644 --- a/src/lib/sprite.c +++ b/src/lib/sprite.c @@ -153,3 +153,10 @@ int sprite_init(const notcurses* nc){ } return nc->tcache.pixel_init(nc->ttyfd); } + +uint8_t* sprixel_auxiliary_vector(const sprixel* s){ + int pixels = s->cellpxy * s->cellpxx; + uint8_t* ret = malloc(sizeof(*ret) * pixels); + memset(ret, 0, sizeof(*ret) * pixels); + return ret; +} diff --git a/src/tests/visual.cpp b/src/tests/visual.cpp index 3ffef7983..60844afd1 100644 --- a/src/tests/visual.cpp +++ b/src/tests/visual.cpp @@ -50,7 +50,6 @@ TEST_CASE("Visual") { }; auto newn = ncvisual_render(nc_, ncv, &vopts); CHECK(0 == notcurses_render(nc_)); -sleep(2); CHECK(0 == ncvisual_inflate(ncv, 3)); CHECK(6 == ncv->rows); CHECK(6 == ncv->cols); @@ -79,7 +78,6 @@ sleep(2); CHECK(0 == notcurses_render(nc_)); CHECK(0 == ncplane_destroy(newn)); CHECK(0 == ncplane_destroy(enewn)); -sleep(2); ncvisual_destroy(ncv); }