diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index bf5472bda..f49dd61d3 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -1433,9 +1433,19 @@ typedef enum { NCPIXEL_SIXEL, // sixel NCPIXEL_LINUXFB, // linux framebuffer NCPIXEL_ITERM2, // iTerm2 - NCPIXEL_KITTY_STATIC, // kitty prior to C=1 and animation - NCPIXEL_KITTY_ANIMATED, // kitty with animation but not selfref - NCPIXEL_KITTY_SELFREF, // kitty with reflexive composition + // C=1 (disabling scrolling) was only introduced in 0.20.0, at the same + // time as animation. prior to this, graphics had to be entirely redrawn + // on any change, and it wasn't possible to use the bottom line. + NCPIXEL_KITTY_STATIC, + // until 0.22.0's introduction of 'a=c' for self-referential composition, we + // had to keep a complete copy of the RGBA data, in case a wiped cell needed + // to be rebuilt. we'd otherwise have to unpack the glyph and store it into + // the auxvec on the fly. + NCPIXEL_KITTY_ANIMATED, + // with 0.22.0, we only ever write transparent cells after writing the + // original image (which we now deflate, since we needn't unpack it later). + // the only data we need keep is the auxvecs. + NCPIXEL_KITTY_SELFREF, } ncpixelimpl_e; // Can we blit pixel-accurate bitmaps? diff --git a/src/lib/kitty.c b/src/lib/kitty.c index 9707ab3b6..36bc21508 100644 --- a/src/lib/kitty.c +++ b/src/lib/kitty.c @@ -662,10 +662,10 @@ add_to_deflator(z_stream* zctx, const uint32_t* src, int encodeable, bool wipe[s // writes to |*animated| based on normalized |level| static int -prep_deflator(kitty_graphics_e level, z_stream* zctx, int pixy, int pixx, +prep_deflator(ncpixelimpl_e level, z_stream* zctx, int pixy, int pixx, unsigned* animated){ memset(zctx, 0, sizeof(*zctx)); - if(level >= KITTY_ANIMATION){ + if(level >= NCPIXEL_KITTY_ANIMATED){ int zret; // 2 seems to work well for things that are going to compress up // meaningfully at all, while not taking too much time. @@ -697,12 +697,12 @@ destroy_deflator(unsigned animated, z_stream* zctx, int pixy, int pixx){ } } -// if we're KITTY_SELFREF, and we're blitting a secondary frame, we need +// if we're NCPIXEL_KITTY_SELFREF, and we're blitting a secondary frame, we need // carry through the TAM's annihilation entires...but we also need load the // frame *without* annihilations, lest we be unable to build it. we thus go // back through the TAM following a selfref blit, and any sprixcells which // are annihilated will have their annhilation appended to the main blit. -// ought only be called for KITTY_SELFREF. +// ought only be called for NCPIXEL_KITTY_SELFREF. static int finalize_multiframe_selfref(sprixel* s, fbuf* f){ int prewiped = 0; @@ -729,7 +729,7 @@ finalize_multiframe_selfref(sprixel* s, fbuf* f){ static int write_kitty_data(fbuf* f, int linesize, int leny, int lenx, int cols, const uint32_t* data, const blitterargs* bargs, - tament* tam, int* parse_start, kitty_graphics_e level){ + tament* tam, int* parse_start, ncpixelimpl_e level){ //fprintf(stderr, "drawing kitty %p\n", tam); if(linesize % sizeof(*data)){ logerror("Stride (%d) badly aligned\n", linesize); @@ -758,7 +758,7 @@ write_kitty_data(fbuf* f, int linesize, int leny, int lenx, int cols, //fprintf(stderr, "total: %d chunks = %d, s=%d,v=%d\n", total, chunks, lenx, leny); char out[17]; // three pixels base64 to no more than 17 bytes // set high if we are (1) reloading a frame with (2) annihilated cells copied over - // from the TAM and (3) we are KITTY_SELFREF. calls finalize_multiframe_selfref(). + // from the TAM and (3) we are NCPIXEL_KITTY_SELFREF. calls finalize_multiframe_selfref(). bool selfref_annihilated = false; while(chunks--){ // q=2 has been able to go on chunks other than the last chunk since @@ -814,7 +814,7 @@ write_kitty_data(fbuf* f, int linesize, int leny, int lenx, int cols, // data in them. on the first pixel of the cell, ditch the previous // auxvec in its entirety, and copy over the entire cell. if(x % cdimx == 0 && y % cdimy == 0){ - if(level == KITTY_ANIMATION){ + if(level == NCPIXEL_KITTY_ANIMATED){ uint8_t* tmp; tmp = kitty_anim_auxvec(leny, lenx, y, x, cdimy, cdimx, data, linesize, tam[tyx].auxvector, @@ -823,7 +823,7 @@ write_kitty_data(fbuf* f, int linesize, int leny, int lenx, int cols, goto err; } tam[tyx].auxvector = tmp; - }else if(level == KITTY_SELFREF){ + }else if(level == NCPIXEL_KITTY_SELFREF){ if(tam[tyx].auxvector == NULL){ tam[tyx].auxvector = malloc(sizeof(tam[tyx].state)); if(tam[tyx].auxvector == NULL){ @@ -841,7 +841,7 @@ write_kitty_data(fbuf* f, int linesize, int leny, int lenx, int cols, const int vyx = (y % cdimy) * cdimx + (x % cdimx); tam[tyx].auxvector[vyx] = ncpixel_a(source[e]); wipe[e] = 1; - }else if(level == KITTY_SELFREF){ + }else if(level == NCPIXEL_KITTY_SELFREF){ selfref_annihilated = true; }else{ tam[tyx].auxvector[s->cellpxx * s->cellpxy * 4] = 1; @@ -851,16 +851,16 @@ write_kitty_data(fbuf* f, int linesize, int leny, int lenx, int cols, ncpixel_set_a(&source[e], 0); // in case it was transcolor if(x % cdimx == 0 && y % cdimy == 0){ tam[tyx].state = SPRIXCELL_ANNIHILATED_TRANS; - if(level == KITTY_SELFREF){ + if(level == NCPIXEL_KITTY_SELFREF){ *tam[tyx].auxvector = SPRIXCELL_TRANSPARENT; } - }else if(level == KITTY_SELFREF && tam[tyx].state == SPRIXCELL_ANNIHILATED_TRANS){ + }else if(level == NCPIXEL_KITTY_SELFREF && tam[tyx].state == SPRIXCELL_ANNIHILATED_TRANS){ *tam[tyx].auxvector = SPRIXCELL_MIXED_KITTY; } }else{ - if(x % cdimx == 0 && y % cdimy == 0 && level == KITTY_SELFREF){ + if(x % cdimx == 0 && y % cdimy == 0 && level == NCPIXEL_KITTY_SELFREF){ *tam[tyx].auxvector = SPRIXCELL_OPAQUE_KITTY; - }else if(level == KITTY_SELFREF && *tam[tyx].auxvector == SPRIXCELL_TRANSPARENT){ + }else if(level == NCPIXEL_KITTY_SELFREF && *tam[tyx].auxvector == SPRIXCELL_TRANSPARENT){ *tam[tyx].auxvector = SPRIXCELL_MIXED_KITTY; } tam[tyx].state = SPRIXCELL_ANNIHILATED; @@ -1051,7 +1051,7 @@ int kitty_rebuild_animation(sprixel* s, int ycell, int xcell, uint8_t* auxvec){ // deflate-compressed) 24bit RGB. Returns -1 on error, 1 on success. static inline int kitty_blit_core(ncplane* n, int linesize, const void* data, int leny, int lenx, - const blitterargs* bargs, kitty_graphics_e level){ + const blitterargs* bargs, ncpixelimpl_e level){ //fprintf(stderr, "IMAGE: start %p end %p\n", data, (const char*)data + leny * linesize); int cols = bargs->u.pixel.spx->dimx; int rows = bargs->u.pixel.spx->dimy; @@ -1082,7 +1082,7 @@ kitty_blit_core(ncplane* n, int linesize, const void* data, int leny, int lenx, bargs, tam, &parse_start, level)){ goto error; } - if(level == KITTY_ALWAYS_SCROLLS){ + if(level == NCPIXEL_KITTY_STATIC){ s->animating = false; } // take ownership of |buf| and |tam| on success. @@ -1102,19 +1102,19 @@ error: int kitty_blit(ncplane* n, int linesize, const void* data, int leny, int lenx, const blitterargs* bargs){ return kitty_blit_core(n, linesize, data, leny, lenx, bargs, - KITTY_ALWAYS_SCROLLS); + NCPIXEL_KITTY_STATIC); } int kitty_blit_animated(ncplane* n, int linesize, const void* data, int leny, int lenx, const blitterargs* bargs){ return kitty_blit_core(n, linesize, data, leny, lenx, bargs, - KITTY_ANIMATION); + NCPIXEL_KITTY_ANIMATED); } int kitty_blit_selfref(ncplane* n, int linesize, const void* data, int leny, int lenx, const blitterargs* bargs){ return kitty_blit_core(n, linesize, data, leny, lenx, bargs, - KITTY_SELFREF); + NCPIXEL_KITTY_SELFREF); } int kitty_remove(int id, fbuf* f){ diff --git a/src/lib/sprite.h b/src/lib/sprite.h index 93c7abce5..883ccfefe 100644 --- a/src/lib/sprite.h +++ b/src/lib/sprite.h @@ -208,22 +208,6 @@ void sixel_refresh(const struct ncpile* p, sprixel* s); int sprixel_load(sprixel* spx, fbuf* f, int pixy, int pixx, int parse_start, sprixel_e state); -typedef enum { - // C=1 (disabling scrolling) was only introduced in 0.20.0, at the same - // time as animation. prior to this, graphics had to be entirely redrawn - // on any change, and it wasn't possible to use the bottom line. - KITTY_ALWAYS_SCROLLS, - // until 0.22.0's introduction of 'a=c' for self-referential composition, we - // had to keep a complete copy of the RGBA data, in case a wiped cell needed - // to be rebuilt. we'd otherwise have to unpack the glyph and store it into - // the auxvec on the fly. - KITTY_ANIMATION, - // with 0.22.0, we only ever write transparent cells after writing the - // original image (which we now deflate, since we needn't unpack it later). - // the only data we need keep is the auxvecs. - KITTY_SELFREF, -} kitty_graphics_e; - #ifdef __cplusplus } #endif diff --git a/src/lib/termdesc.c b/src/lib/termdesc.c index 424b45176..d70164e5e 100644 --- a/src/lib/termdesc.c +++ b/src/lib/termdesc.c @@ -75,7 +75,7 @@ setup_sixel_bitmaps(tinfo* ti, int fd, bool invert80){ // lacked animation, and must thus redraw the complete image every time it // changes. requires the older interface. static inline void -setup_kitty_bitmaps(tinfo* ti, int fd, kitty_graphics_e level){ +setup_kitty_bitmaps(tinfo* ti, int fd, ncpixelimpl_e level){ ti->pixel_scrub = kitty_scrub; ti->pixel_remove = kitty_remove; ti->pixel_draw = kitty_draw; @@ -86,7 +86,7 @@ setup_kitty_bitmaps(tinfo* ti, int fd, kitty_graphics_e level){ ti->pixel_scroll = NULL; ti->pixel_shutdown = kitty_shutdown; ti->pixel_clear_all = kitty_clear_all; - if(level == KITTY_ALWAYS_SCROLLS){ + if(level == NCPIXEL_KITTY_STATIC){ ti->pixel_wipe = kitty_wipe; ti->pixel_trans_auxvec = kitty_trans_auxvec; ti->pixel_rebuild = kitty_rebuild; @@ -94,7 +94,7 @@ setup_kitty_bitmaps(tinfo* ti, int fd, kitty_graphics_e level){ set_pixel_blitter(kitty_blit); ti->pixel_implementation = NCPIXEL_KITTY_STATIC; }else{ - if(level == KITTY_ANIMATION){ + if(level == NCPIXEL_KITTY_ANIMATED){ ti->pixel_wipe = kitty_wipe_animation; ti->pixel_rebuild = kitty_rebuild_animation; ti->sixel_maxy_pristine = 0; @@ -527,11 +527,11 @@ apply_term_heuristics(tinfo* ti, const char* termname, queried_terminals_e qterm return -1; } /*if(compare_versions(ti->termversion, "0.22.1") >= 0){ - setup_kitty_bitmaps(ti, ti->ttyfd, KITTY_SELFREF); + setup_kitty_bitmaps(ti, ti->ttyfd, NCPIXEL_KITTY_SELFREF); }else*/ if(compare_versions(ti->termversion, "0.20.0") >= 0){ - setup_kitty_bitmaps(ti, ti->ttyfd, KITTY_ANIMATION); + setup_kitty_bitmaps(ti, ti->ttyfd, NCPIXEL_KITTY_ANIMATED); }else{ - setup_kitty_bitmaps(ti, ti->ttyfd, KITTY_ALWAYS_SCROLLS); + setup_kitty_bitmaps(ti, ti->ttyfd, NCPIXEL_KITTY_STATIC); } if(add_pushcolors_escapes(ti, tablelen, tableused)){ return -1; @@ -949,7 +949,7 @@ int interrogate_terminfo(tinfo* ti, const char* termtype, FILE* out, unsigned ut build_supported_styles(ti); if(ti->pixel_draw == NULL && ti->pixel_draw_late == NULL){ if(kittygraphs){ - setup_kitty_bitmaps(ti, ti->ttyfd, KITTY_SELFREF); + setup_kitty_bitmaps(ti, ti->ttyfd, NCPIXEL_KITTY_ANIMATED); } // our current sixel quantization algorithm requires at least 64 color // registers. we make use of no more than 256. this needs to happen