mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-18 03:25:55 +00:00
kitty: tripartite blit implementation #1900
This commit is contained in:
parent
57f962399d
commit
e399687d7d
@ -172,6 +172,7 @@ int kitty_rebuild(sprixel* s, int ycell, int xcell, uint8_t* auxvec);
|
||||
int iterm_rebuild(sprixel* s, int ycell, int xcell, uint8_t* auxvec);
|
||||
int fbcon_rebuild(sprixel* s, int ycell, int xcell, uint8_t* auxvec);
|
||||
int kitty_rebuild_animation(sprixel* s, int ycell, int xcell, uint8_t* auxvec);
|
||||
int kitty_rebuild_selfref(sprixel* s, int ycell, int xcell, uint8_t* auxvec);
|
||||
int sixel_draw(const tinfo* ti, const struct ncpile *p, sprixel* s,
|
||||
FILE* out, int y, int x);
|
||||
int kitty_draw(const tinfo* ti, const struct ncpile *p, sprixel* s,
|
||||
@ -199,11 +200,29 @@ int iterm_blit(struct ncplane* nc, int linesize, const void* data,
|
||||
int leny, int lenx, const struct blitterargs* bargs);
|
||||
int kitty_blit_animated(struct ncplane* n, int linesize, const void* data,
|
||||
int leny, int lenx, const struct blitterargs* bargs);
|
||||
int kitty_blit_selfref(struct ncplane* nc, int linesize, const void* data,
|
||||
int leny, int lenx, const struct blitterargs* bargs);
|
||||
int fbcon_blit(struct ncplane* nc, int linesize, const void* data,
|
||||
int leny, int lenx, const struct blitterargs* bargs);
|
||||
int fbcon_draw(const tinfo* ti, const struct ncpile *p, sprixel* s,
|
||||
FILE* out, int y, int x);
|
||||
|
||||
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.21.3's introduction of 't=z' for self-reference, 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.21.3, 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
|
||||
|
@ -85,9 +85,10 @@ setup_iterm_bitmaps(tinfo* ti, int fd){
|
||||
}
|
||||
|
||||
// kitty 0.19.3 didn't have C=1, and thus needs sixel_maxy_pristine. it also
|
||||
// lacked animation, and thus requires the older interface.
|
||||
// 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, int sixel_maxy_pristine){
|
||||
setup_kitty_bitmaps(tinfo* ti, int fd, kitty_graphics_e level){
|
||||
ti->pixel_scrub = kitty_scrub;
|
||||
ti->pixel_remove = kitty_remove;
|
||||
ti->pixel_draw = kitty_draw;
|
||||
@ -95,16 +96,21 @@ setup_kitty_bitmaps(tinfo* ti, int fd, int sixel_maxy_pristine){
|
||||
ti->pixel_move = kitty_move;
|
||||
ti->pixel_shutdown = kitty_shutdown;
|
||||
ti->pixel_clear_all = kitty_clear_all;
|
||||
ti->sixel_maxy_pristine = sixel_maxy_pristine;
|
||||
if(sixel_maxy_pristine){
|
||||
if(level == KITTY_ALWAYS_SCROLLS){
|
||||
ti->pixel_wipe = kitty_wipe;
|
||||
ti->pixel_trans_auxvec = kitty_trans_auxvec;
|
||||
ti->pixel_rebuild = kitty_rebuild;
|
||||
ti->sixel_maxy_pristine = INT_MAX;
|
||||
set_pixel_blitter(kitty_blit);
|
||||
}else{
|
||||
ti->pixel_wipe = kitty_wipe_animation;
|
||||
if(level == KITTY_ANIMATION){
|
||||
ti->pixel_rebuild = kitty_rebuild_animation;
|
||||
set_pixel_blitter(kitty_blit_animated);
|
||||
}else{
|
||||
ti->pixel_rebuild = kitty_rebuild_selfref;
|
||||
set_pixel_blitter(kitty_blit_selfref);
|
||||
}
|
||||
}
|
||||
sprite_init(ti, fd);
|
||||
}
|
||||
@ -501,11 +507,12 @@ apply_term_heuristics(tinfo* ti, const char* termname, int fd,
|
||||
if(add_smulx_escapes(ti, tablelen, tableused)){
|
||||
return -1;
|
||||
}
|
||||
// kitty only introduced C=1 in 0.20.0
|
||||
if(compare_versions(ti->termversion, "0.20.0") < 0){
|
||||
setup_kitty_bitmaps(ti, fd, INT_MAX);
|
||||
if(compare_versions(ti->termversion, "0.21.3") >= 0){
|
||||
setup_kitty_bitmaps(ti, fd, KITTY_SELFREF);
|
||||
}else if(compare_versions(ti->termversion, "0.20.0") >= 0){
|
||||
setup_kitty_bitmaps(ti, fd, KITTY_ANIMATION);
|
||||
}else{
|
||||
setup_kitty_bitmaps(ti, fd, 0);
|
||||
setup_kitty_bitmaps(ti, fd, KITTY_ALWAYS_SCROLLS);
|
||||
}
|
||||
if(add_pushcolors_escapes(ti, tablelen, tableused)){
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user