kitty: set up auxiliary vector #1440

This commit is contained in:
nick black 2021-04-26 00:33:29 -04:00 committed by Nick Black
parent a19b945ec6
commit 41c5df3336
6 changed files with 24 additions and 6 deletions

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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;
}

View File

@ -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);
}