mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-10 01:29:05 -04:00
create empty auxvec when wiping transparent cells
If we're a transparent sprixcell, we don't need an auxiliary vector...until we do. If we reload the sprixel, we have to update the auxiliary vectors, and assume one is there. Since we're going to be getting rid of auxvecs for kitty once we're using animation extensions, just go ahead and always create one. Closes #1847.
This commit is contained in:
parent
d06eb772b4
commit
6523c01ab7
@ -787,6 +787,8 @@ int sprite_init(const tinfo* t, int fd);
|
||||
int sprite_clear_all(const tinfo* t, int fd);
|
||||
int kitty_shutdown(int fd);
|
||||
int sixel_shutdown(int fd);
|
||||
uint8_t* sixel_trans_auxvec(const struct tinfo* ti);
|
||||
uint8_t* kitty_trans_auxvec(const struct tinfo* ti);
|
||||
// these three all use absolute coordinates
|
||||
void sprixel_invalidate(sprixel* s, int y, int x);
|
||||
void sprixel_movefrom(sprixel* s, int y, int x);
|
||||
|
@ -425,6 +425,7 @@ static int
|
||||
write_kitty_data(FILE* fp, int linesize, int leny, int lenx, int cols,
|
||||
const uint32_t* data, const blitterargs* bargs,
|
||||
tament* tam, int* parse_start){
|
||||
//fprintf(stderr, "drawing kitty %p\n", tam);
|
||||
if(linesize % sizeof(*data)){
|
||||
fclose(fp);
|
||||
return -1;
|
||||
@ -475,7 +476,7 @@ write_kitty_data(FILE* fp, int linesize, int leny, int lenx, int cols,
|
||||
int xcell = x / cdimx;
|
||||
int ycell = y / cdimy;
|
||||
int tyx = xcell + ycell * cols;
|
||||
//fprintf(stderr, "Tyx: %d y: %d (%d) * %d x: %d (%d) state %d\n", tyx, y, y / cdimy, cols, x, x / cdimx, tam[tyx].state);
|
||||
//fprintf(stderr, "Tyx: %d y: %d (%d) * %d x: %d (%d) state %d %p\n", tyx, y, y / cdimy, cols, x, x / cdimx, tam[tyx].state, tam[tyx].auxvector);
|
||||
if(tam[tyx].state == SPRIXCELL_ANNIHILATED || tam[tyx].state == SPRIXCELL_ANNIHILATED_TRANS){
|
||||
// this pixel is part of a cell which is currently wiped (alpha-nulled
|
||||
// out, to present a glyph "atop" it). we will continue to mark it
|
||||
@ -645,3 +646,12 @@ int kitty_shutdown(int fd){
|
||||
(void)fd;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t* kitty_trans_auxvec(const tinfo* ti){
|
||||
const size_t slen = ti->cellpixy * ti->cellpixx;
|
||||
uint8_t* a = malloc(slen);
|
||||
if(a){
|
||||
memset(a, 0, slen);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
@ -921,3 +921,12 @@ int sixel_rebuild(sprixel* s, int ycell, int xcell, uint8_t* auxvec){
|
||||
int sixel_shutdown(int fd){
|
||||
return tty_emit("\e[?8452l", fd);
|
||||
}
|
||||
|
||||
uint8_t* sixel_trans_auxvec(const tinfo* ti){
|
||||
const size_t slen = 2 * ti->cellpixy * ti->cellpixx;
|
||||
uint8_t* a = malloc(slen);
|
||||
if(a){
|
||||
memset(a, 0, slen);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
@ -176,6 +176,12 @@ int sprixel_load(sprixel* spx, char* s, int bytes, int pixy, int pixx,
|
||||
int sprite_wipe(const notcurses* nc, sprixel* s, int ycell, int xcell){
|
||||
int idx = s->dimx * ycell + xcell;
|
||||
if(s->n->tam[idx].state == SPRIXCELL_TRANSPARENT){
|
||||
// need to make a transparent auxvec, because a reload will force us to
|
||||
// update said auxvec.
|
||||
s->n->tam[idx].auxvector = nc->tcache.pixel_trans_auxvec(&nc->tcache);
|
||||
if(s->n->tam[idx].auxvector == NULL){
|
||||
return -1;
|
||||
}
|
||||
s->n->tam[idx].state = SPRIXCELL_ANNIHILATED_TRANS;
|
||||
return 1;
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ setup_sixel_bitmaps(tinfo* ti, int fd, bool invert80){
|
||||
ti->pixel_wipe = sixel_wipe;
|
||||
ti->pixel_shutdown = sixel_shutdown;
|
||||
ti->pixel_rebuild = sixel_rebuild;
|
||||
ti->pixel_trans_auxvec = sixel_trans_auxvec;
|
||||
ti->sprixel_scale_height = 6;
|
||||
sprite_init(ti, fd);
|
||||
}
|
||||
@ -71,6 +72,7 @@ setup_kitty_bitmaps(tinfo* ti, int fd){
|
||||
ti->sprixel_scale_height = 1;
|
||||
ti->pixel_rebuild = kitty_rebuild;
|
||||
ti->pixel_clear_all = kitty_clear_all;
|
||||
ti->pixel_trans_auxvec = kitty_trans_auxvec;
|
||||
set_pixel_blitter(kitty_blit);
|
||||
sprite_init(ti, fd);
|
||||
}
|
||||
|
@ -136,6 +136,7 @@ typedef struct tinfo {
|
||||
int (*pixel_destroy)(const struct notcurses* nc, const struct ncpile* p, FILE* out, struct sprixel* s);
|
||||
int (*pixel_shutdown)(int fd); // called during context shutdown
|
||||
int (*pixel_clear_all)(int fd); // called during startup, kitty only
|
||||
uint8_t* (*pixel_trans_auxvec)(const struct tinfo* ti); // create tranparent auxvec
|
||||
// sprixel parameters. there are several different sprixel protocols, of
|
||||
// which we support sixel and kitty. the kitty protocol is used based
|
||||
// on TERM heuristics. otherwise, we attempt to detect sixel support, and
|
||||
|
Loading…
x
Reference in New Issue
Block a user