From d6cb986d722bf65035763df8b7cf10ddb7285d30 Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 20 Mar 2021 02:29:29 -0400 Subject: [PATCH] [pixel] multiplex sprixel_cell_wipe() --- src/demo/yield.c | 4 ++++ src/lib/internal.h | 7 +++++++ src/lib/render.c | 9 +++++++++ src/lib/terminfo.c | 2 ++ 4 files changed, 22 insertions(+) diff --git a/src/demo/yield.c b/src/demo/yield.c index cea7693b2..03b598730 100644 --- a/src/demo/yield.c +++ b/src/demo/yield.c @@ -6,6 +6,10 @@ int yield_demo(struct notcurses* nc){ } int dimy, dimx; struct ncplane* std = notcurses_stddim_yx(nc, &dimy, &dimx); + // in sixel-based implementation, if we redraw each cycle, the underlying + // material will be redrawn, taking time. erasing won't eliminate the + // flicker, but it does minimize it. + ncplane_erase(std); char* pic = find_data("worldmap.png"); struct ncvisual* wmv = ncvisual_from_file(pic); free(pic); diff --git a/src/lib/internal.h b/src/lib/internal.h index 2f146710a..2987578fc 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -315,6 +315,10 @@ typedef struct tinfo { bool sixel_supported; // do we support sixel (post pixel_query_done)? int sprixelnonce; // next sprixel id int (*pixel_destroy)(struct notcurses* nc, const struct ncpile* p, FILE* out, sprixel* s); + // wipe out a cell's worth of pixels from within a sprixel. for sixel, this + // means leaving out the pixels (and likely resizes the string). for kitty, + // this means dialing down their alpha to 0 (in equivalent space). + int (*pixel_cell_wipe)(sprixel* s, int y, int x); bool pixel_query_done; // have we yet performed pixel query? bool sextants; // do we have (good, vetted) Unicode 13 sextant support? bool braille; // do we have Braille support? (linux console does not) @@ -1257,6 +1261,9 @@ ncdirect_bg_default_p(const struct ncdirect* nc){ return channels_bg_default_p(ncdirect_channels(nc)); } +int sprite_sixel_cell_wipe(sprixel* s, int y, int x); +int sprite_kitty_cell_wipe(sprixel* s, int y, int x); + int sixel_blit(ncplane* nc, int linesize, const void* data, int begy, int begx, int leny, int lenx, const blitterargs* bargs); diff --git a/src/lib/render.c b/src/lib/render.c index ffbd4fa9f..9694d7556 100644 --- a/src/lib/render.c +++ b/src/lib/render.c @@ -922,6 +922,11 @@ emit_bg_palindex(notcurses* nc, FILE* out, const nccell* srccell){ return 0; } +int sprite_kitty_cell_wipe(sprixel* s, int y, int x){ + // FIXME + return 0; +} + int sprite_kitty_annihilate(notcurses* nc, const ncpile* p, FILE* out, sprixel* s){ (void)p; (void)nc; @@ -931,6 +936,10 @@ int sprite_kitty_annihilate(notcurses* nc, const ncpile* p, FILE* out, sprixel* return 0; } +int sprite_sixel_cell_wipe(sprixel* s, int y, int x){ + return 0; // FIXME +} + int sprite_sixel_annihilate(notcurses* nc, const ncpile* p, FILE* out, sprixel* s){ (void)out; struct crender* rvec = p->crender; diff --git a/src/lib/terminfo.c b/src/lib/terminfo.c index 73ffb5ec2..391984561 100644 --- a/src/lib/terminfo.c +++ b/src/lib/terminfo.c @@ -60,6 +60,7 @@ apply_term_heuristics(tinfo* ti, const char* termname){ ti->sextants = true; // work since bugfix in 0.19.3 ti->pixel_query_done = true; ti->sixel_supported = true; + ti->pixel_cell_wipe = sprite_kitty_cell_wipe; ti->pixel_destroy = sprite_kitty_annihilate; set_pixel_blitter(kitty_blit); /*}else if(strstr(termname, "alacritty")){ @@ -346,6 +347,7 @@ query_sixel(tinfo* ti, int fd){ ti->sixel_supported = true; ti->color_registers = 256; // assumed default [shrug] ti->pixel_destroy = sprite_sixel_annihilate; + ti->pixel_cell_wipe = sprite_sixel_cell_wipe; ti->sixel_maxx = ti->sixel_maxy = 0; } }