mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-18 03:25:55 +00:00
dump sprixel_auxiliary_vector, save 50% of kitty/fbcon auxvec space
This commit is contained in:
parent
d857fedf16
commit
9483278ba1
@ -649,12 +649,6 @@ void sprixel_movefrom(sprixel* s, int y, int x);
|
||||
void sprixel_debug(const sprixel* s, FILE* out);
|
||||
void sixelmap_free(struct sixelmap *s);
|
||||
|
||||
// create an auxiliary vector suitable for a sprixcell, and zero it out. there
|
||||
// are two bytes per pixel in the cell. kitty uses only one (for an alpha
|
||||
// value). sixel uses both (for palette index, and transparency). FIXME fold
|
||||
// the transparency vector up into 1/8th as many bytes.
|
||||
uint8_t* sprixel_auxiliary_vector(const sprixel* s);
|
||||
|
||||
// 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
|
||||
|
@ -445,9 +445,21 @@ sprixel* kitty_recycle(ncplane* n){
|
||||
return sprixel_alloc(&ncplane_notcurses_const(n)->tcache, n, dimy, dimx);
|
||||
}
|
||||
|
||||
// for pre-animation kitty (NCPIXEL_KITTY_STATIC), we need a byte per pixel,
|
||||
// in which we stash the alpha.
|
||||
static inline uint8_t*
|
||||
kitty_auxiliary_vector(const sprixel* s){
|
||||
int pixels = s->cellpxy * s->cellpxx;
|
||||
uint8_t* ret = malloc(sizeof(*ret) * pixels);
|
||||
if(ret){
|
||||
memset(ret, 0, sizeof(*ret) * pixels);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int kitty_wipe(sprixel* s, int ycell, int xcell){
|
||||
//fprintf(stderr, "NEW WIPE %d %d/%d\n", s->id, ycell, xcell);
|
||||
uint8_t* auxvec = sprixel_auxiliary_vector(s);
|
||||
uint8_t* auxvec = kitty_auxiliary_vector(s);
|
||||
if(auxvec == NULL){
|
||||
return -1;
|
||||
}
|
||||
|
@ -3,8 +3,18 @@
|
||||
|
||||
// auxvecs for framebuffer are 1B each for s->cellpxx * s->cellpxy elements,
|
||||
// and store the original alpha value.
|
||||
static inline uint8_t*
|
||||
fbcon_auxiliary_vector(const sprixel* s){
|
||||
int pixels = s->cellpxy * s->cellpxx;
|
||||
uint8_t* ret = malloc(sizeof(*ret) * pixels);
|
||||
if(ret){
|
||||
memset(ret, 0, sizeof(*ret) * pixels);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int fbcon_wipe(sprixel* s, int ycell, int xcell){
|
||||
uint8_t* auxvec = sprixel_auxiliary_vector(s);
|
||||
uint8_t* auxvec = fbcon_auxiliary_vector(s);
|
||||
if(auxvec == NULL){
|
||||
return -1;
|
||||
}
|
||||
|
@ -20,6 +20,21 @@ sixelcount(int dimy, int dimx){
|
||||
return (dimy + 5) / 6 * dimx;
|
||||
}
|
||||
|
||||
// create an auxiliary vector suitable for a Sixel sprixcell, and zero it out.
|
||||
// there are two bytes per pixel in the cell: a contiguous set of palette
|
||||
// indices (yet another reason that we work with 256 colors), and a contiguous
|
||||
// set of two-value transparencies (these could be folded down to bits from
|
||||
// bytes, saving 7/8 of the space FIXME).
|
||||
static inline uint8_t*
|
||||
sixel_auxiliary_vector(const sprixel* s){
|
||||
int pixels = s->cellpxy * s->cellpxx;
|
||||
uint8_t* ret = malloc(sizeof(*ret) * pixels * 2);
|
||||
if(ret){
|
||||
memset(ret, 0, sizeof(*ret) * pixels);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// we keep a color-indexed set of sixels (a single-row column of six pixels,
|
||||
// encoded as a byte) across the life of the sprixel. This provides a good
|
||||
// combination of easy-to-edit (for wipes and restores) -- you can index by
|
||||
@ -210,7 +225,7 @@ wipe_color(sixelmap* smap, int color, int sband, int eband,
|
||||
// redrawn, it's redrawn using P2=1.
|
||||
int sixel_wipe(sprixel* s, int ycell, int xcell){
|
||||
//fprintf(stderr, "WIPING %d/%d\n", ycell, xcell);
|
||||
uint8_t* auxvec = sprixel_auxiliary_vector(s);
|
||||
uint8_t* auxvec = sixel_auxiliary_vector(s);
|
||||
if(auxvec == NULL){
|
||||
return -1;
|
||||
}
|
||||
|
@ -224,14 +224,3 @@ int sprite_init(const tinfo* t, int fd){
|
||||
}
|
||||
return t->pixel_init(fd);
|
||||
}
|
||||
|
||||
uint8_t* sprixel_auxiliary_vector(const sprixel* s){
|
||||
int pixels = s->cellpxy * s->cellpxx;
|
||||
// for now we just do two bytes per pixel. we ought squeeze the transparency
|
||||
// vector down to a bit per pixel, rather than a byte FIXME.
|
||||
uint8_t* ret = malloc(sizeof(*ret) * pixels * 2);
|
||||
if(ret){
|
||||
memset(ret, 0, sizeof(*ret) * pixels);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user