mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-18 03:25:55 +00:00
kitty: set MIXED when appropriate on rebuild #1440
This commit is contained in:
parent
1d9ae4082f
commit
d435d6e083
@ -201,8 +201,10 @@ kitty_null(char* triplet, int skip, int max, int pleft, uint8_t* auxvec){
|
||||
// and restore a maximum of |max| pixels after that. returns the number of
|
||||
// pixels restored. |max| must be positive. |skip| must be non-negative, and
|
||||
// less than 3. |pleft| is the number of pixels available in the chunk.
|
||||
// |state| is set to MIXED if we find transparent pixels.
|
||||
static inline int
|
||||
kitty_restore(char* triplet, int skip, int max, int pleft, const uint8_t* auxvec){
|
||||
kitty_restore(char* triplet, int skip, int max, int pleft,
|
||||
const uint8_t* auxvec, sprixcell_e* state){
|
||||
//fprintf(stderr, "SKIP/MAX/PLEFT %d/%d/%d\n", skip, max, pleft);
|
||||
if(pleft > 3){
|
||||
pleft = 3;
|
||||
@ -212,29 +214,47 @@ kitty_restore(char* triplet, int skip, int max, int pleft, const uint8_t* auxvec
|
||||
}
|
||||
if(skip == 0){
|
||||
int a = auxvec[0];
|
||||
if(a == 0){
|
||||
*state = SPRIXCELL_MIXED_KITTY;
|
||||
}
|
||||
triplet[0x4] = b64subs[(a & 0xfc) >> 2];
|
||||
triplet[0x5] = b64subs[((a & 0x3) << 4) | (b64idx(triplet[0x5]) & 0xf)];
|
||||
if(max > 1){
|
||||
a = auxvec[1];
|
||||
if(a == 0){
|
||||
*state = SPRIXCELL_MIXED_KITTY;
|
||||
}
|
||||
triplet[0x9] = b64subs[(b64idx(triplet[0x9]) & 0x30) | ((a & 0xf0) >> 4)];
|
||||
triplet[0xA] = b64subs[((a & 0xf) << 2) | (b64idx(triplet[0xA]) & 0x3)];
|
||||
}
|
||||
if(max == 3){
|
||||
a = auxvec[2];
|
||||
if(a == 0){
|
||||
*state = SPRIXCELL_MIXED_KITTY;
|
||||
}
|
||||
triplet[0xE] = b64subs[((a & 0xc0) >> 6) | (b64idx(triplet[0xE]) & 0x3c)];
|
||||
triplet[0xF] = b64subs[(a & 0x3f)];
|
||||
}
|
||||
}else if(skip == 1){
|
||||
int a = auxvec[0];
|
||||
if(a == 0){
|
||||
*state = SPRIXCELL_MIXED_KITTY;
|
||||
}
|
||||
triplet[0x9] = b64subs[(b64idx(triplet[0x9]) & 0x30) | ((a & 0xf0) >> 4)];
|
||||
triplet[0xA] = b64subs[((a & 0xf) << 2) | (b64idx(triplet[0xA]) & 0x3)];
|
||||
if(max == 2){
|
||||
a = auxvec[1];
|
||||
if(a == 0){
|
||||
*state = SPRIXCELL_MIXED_KITTY;
|
||||
}
|
||||
triplet[0xE] = b64subs[((a & 0xc0) >> 6) | (b64idx(triplet[0xE]) & 0x3c)];
|
||||
triplet[0xF] = b64subs[(a & 0x3f)];
|
||||
}
|
||||
}else{ // skip == 2
|
||||
int a = auxvec[0];
|
||||
if(a == 0){
|
||||
*state = SPRIXCELL_MIXED_KITTY;
|
||||
}
|
||||
triplet[0xE] = b64subs[((a & 0xc0) >> 6) | (b64idx(triplet[0xE]) & 0x3c)];
|
||||
triplet[0xF] = b64subs[(a & 0x3f)];
|
||||
}
|
||||
@ -289,7 +309,8 @@ int kitty_rebuild(sprixel* s, int ycell, int xcell){
|
||||
// pixels remaining in the target row, and the pixels left in the chunk.
|
||||
//fprintf(stderr, "inchunk: %d total: %d triples: %d\n", inchunk, totalpixels, triples);
|
||||
int chomped = kitty_restore(c + tripbytes, tripskip, thisrow,
|
||||
inchunk - triples * 3, auxvec + auxvecidx);
|
||||
inchunk - triples * 3, auxvec + auxvecidx,
|
||||
&state);
|
||||
assert(chomped >= 0);
|
||||
auxvecidx += chomped;
|
||||
thisrow -= chomped;
|
||||
@ -298,7 +319,6 @@ int kitty_rebuild(sprixel* s, int ycell, int xcell){
|
||||
//fprintf(stderr, "CLEARED ROW, TARGY: %d\n", targy - 1);
|
||||
if(--targy == 0){
|
||||
free(auxvec);
|
||||
// FIXME needs be MIXED_KITTY if we got transparent pixels
|
||||
s->n->tam[s->dimx * ycell + xcell].state = state;
|
||||
s->n->tam[s->dimx * ycell + xcell].auxvector = NULL;
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user