From d435d6e0833e3edc46896e738b65fc674fa2b11a Mon Sep 17 00:00:00 2001 From: nick black Date: Mon, 26 Apr 2021 02:19:42 -0400 Subject: [PATCH] kitty: set MIXED when appropriate on rebuild #1440 --- src/lib/kitty.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/lib/kitty.c b/src/lib/kitty.c index dc03c8673..76f4dd848 100644 --- a/src/lib/kitty.c +++ b/src/lib/kitty.c @@ -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;