From 346512ccdf13330960ad83337940d58676d273ae Mon Sep 17 00:00:00 2001 From: nick black Date: Fri, 14 May 2021 01:39:04 -0400 Subject: [PATCH] eliminate type-2 gclusters, sprixels no longer interact with fb #1656 --- USAGE.md | 1 - include/notcurses/notcurses.h | 1 - src/lib/egcpool.h | 8 +------- src/lib/fill.c | 5 ----- src/lib/internal.h | 18 ++++-------------- src/lib/kitty.c | 2 +- src/lib/notcurses.c | 15 ++++----------- src/lib/sixel.c | 6 +++--- 8 files changed, 13 insertions(+), 43 deletions(-) diff --git a/USAGE.md b/USAGE.md index e148a5110..550ee5880 100644 --- a/USAGE.md +++ b/USAGE.md @@ -1949,7 +1949,6 @@ nccell_load_egc32(struct ncplane* n, nccell* c, uint32_t egc){ // return a pointer to the NUL-terminated EGC referenced by 'c'. this pointer // is invalidated by any further operation on the plane 'n', so...watch out! -// returns NULL if called on a sprixel. const char* nccell_extended_gcluster(const struct ncplane* n, const nccell* c); // Returns true if the two nccells are distinct EGCs, attributes, or channels. diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index 30e292ba4..d9ab4d79b 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -748,7 +748,6 @@ nccell_wide_left_p(const nccell* c){ // return a pointer to the NUL-terminated EGC referenced by 'c'. this pointer // can be invalidated by any further operation on the plane 'n', so...watch out! -// returns NULL if called on a pixel graphic. API const char* nccell_extended_gcluster(const struct ncplane* n, const nccell* c); // return the number of columns occupied by 'c'. returns -1 if passed a diff --git a/src/lib/egcpool.h b/src/lib/egcpool.h index b127d8062..aa7b36727 100644 --- a/src/lib/egcpool.h +++ b/src/lib/egcpool.h @@ -256,16 +256,10 @@ cell_extended_p(const nccell* c){ return (htole(c->gcluster) & htole(0xff000000ul)) == htole(0x01000000ul); } -// Is the cell part of a sprixel? -static inline bool -cell_sprixel_p(const nccell* c){ - return (htole(c->gcluster) & htole(0xff000000ul)) == htole(0x02000000ul); -} - // Is the cell simple (a UTF8-encoded EGC of four bytes or fewer)? static inline bool cell_simple_p(const nccell* c){ - return !cell_extended_p(c) && !cell_sprixel_p(c); + return !cell_extended_p(c); } // only applies to complex cells, do not use on simple cells diff --git a/src/lib/fill.c b/src/lib/fill.c index c345386c3..b6f8e0ac1 100644 --- a/src/lib/fill.c +++ b/src/lib/fill.c @@ -21,7 +21,6 @@ void ncplane_greyscale(ncplane *n){ // we did some work here, filling everything we could reach. out-of-plane is 0. static int ncplane_polyfill_recurse(ncplane* n, int y, int x, const nccell* c, const char* filltarg){ - const notcurses* nc = ncplane_notcurses_const(n); if(y >= n->leny || x >= n->lenx){ return 0; // not fillable } @@ -29,10 +28,6 @@ ncplane_polyfill_recurse(ncplane* n, int y, int x, const nccell* c, const char* return 0; // not fillable } nccell* cur = &n->fb[nfbcellidx(n, y, x)]; - if(cell_sprixel_p(cur)){ - logerror(nc, "Won't polyfill a sprixel at %d/%d\n", y, x); - return -1; - } const char* glust = nccell_extended_gcluster(n, cur); //fprintf(stderr, "checking %d/%d (%s) for [%s]\n", y, x, glust, filltarg); if(strcmp(glust, filltarg)){ diff --git a/src/lib/internal.h b/src/lib/internal.h index d464c7687..e6745ce0a 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -1485,27 +1485,17 @@ egc_rtl(const char* egc, int* bytes){ return s; } -// a sprixel occupies the entirety of its associated plane. each cell contains -// a reference to the context-wide sprixel cache. this ought be an entirely +// a sprixel occupies the entirety of its associated plane, usually an entirely // new, purpose-specific plane. |leny| and |lenx| are output geometry in pixels. -// |cols| and |rows| are output coverage in cells. static inline int -plane_blit_sixel(sprixel* spx, char* s, int bytes, int rows, int cols, - int leny, int lenx, int parse_start, tament* tam){ +plane_blit_sixel(sprixel* spx, char* s, int bytes, int leny, int lenx, + int parse_start, tament* tam){ if(sprixel_load(spx, s, bytes, leny, lenx, parse_start)){ return -1; } ncplane* n = spx->n; - uint32_t gcluster = htole(0x02000000ul) + htole(spx->id); - for(int y = 0 ; y < rows ; ++y){ - for(int x = 0 ; x < cols ; ++x){ - nccell* c = ncplane_cell_ref_yx(n, y, x); - memcpy(&c->gcluster, &gcluster, sizeof(gcluster)); - c->width = cols; - } - } if(n){ -//fprintf(stderr, "TAM WAS: %p NOW: %p size: %d/%d\n", n->tam, tam, rows, cols); +//fprintf(stderr, "TAM WAS: %p NOW: %p\n", n->tam, tam); if(n->tam != tam){ free(n->tam); } diff --git a/src/lib/kitty.c b/src/lib/kitty.c index cd41d32cc..753538be8 100644 --- a/src/lib/kitty.c +++ b/src/lib/kitty.c @@ -545,7 +545,7 @@ int kitty_blit(ncplane* n, int linesize, const void* data, return -1; } // take ownership of |buf| and |tam| on success - if(plane_blit_sixel(bargs->u.pixel.spx, buf, size, rows, cols, + if(plane_blit_sixel(bargs->u.pixel.spx, buf, size, leny, lenx, parse_start, tam) < 0){ if(!reuse){ free(tam); diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index 0c5c632a9..5b7280f8d 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -560,15 +560,11 @@ ncplane* ncplane_dup(const ncplane* n, void* opaque){ } // we don't duplicate sprites...though i'm unsure why not size_t fbsize = sizeof(*n->fb) * dimx * dimy; - if(n->sprite == NULL){ - if(egcpool_dup(&newn->pool, &n->pool)){ - ncplane_destroy(newn); - return NULL; - } - memmove(newn->fb, n->fb, fbsize); - }else{ - memset(newn->fb, 0, fbsize); + if(egcpool_dup(&newn->pool, &n->pool)){ + ncplane_destroy(newn); + return NULL; } + memmove(newn->fb, n->fb, fbsize); if(ncplane_cursor_move_yx(newn, n->y, n->x) < 0){ ncplane_destroy(newn); return NULL; @@ -1323,9 +1319,6 @@ const char* nccell_extended_gcluster(const ncplane* n, const nccell* c){ if(cell_simple_p(c)){ return (const char*)&c->gcluster; } - if(cell_sprixel_p(c)){ - return NULL; - } return egcpool_extended_gcluster(&n->pool, c); } diff --git a/src/lib/sixel.c b/src/lib/sixel.c index 07c46aa53..b25cb69a2 100644 --- a/src/lib/sixel.c +++ b/src/lib/sixel.c @@ -583,7 +583,7 @@ sixel_reblit(sprixel* s){ // scaled geometry in pixels. We calculate output geometry herein, and supply // transparent filler input for any missing rows. static inline int -sixel_blit_inner(int leny, int lenx, sixeltable* stab, int rows, int cols, +sixel_blit_inner(int leny, int lenx, sixeltable* stab, const blitterargs* bargs, tament* tam){ char* buf = NULL; size_t size = 0; @@ -607,7 +607,7 @@ sixel_blit_inner(int leny, int lenx, sixeltable* stab, int rows, int cols, scrub_tam_boundaries(tam, outy, lenx, bargs->u.pixel.celldimy, bargs->u.pixel.celldimx); // take ownership of buf on success - if(plane_blit_sixel(bargs->u.pixel.spx, buf, size, rows, cols, + if(plane_blit_sixel(bargs->u.pixel.spx, buf, size, outy, lenx, parse_start, tam) < 0){ free(buf); return -1; @@ -679,7 +679,7 @@ int sixel_blit(ncplane* n, int linesize, const void* data, } refine_color_table(data, linesize, bargs->begy, bargs->begx, leny, lenx, &stable); // takes ownership of sixelmap on success - int r = sixel_blit_inner(leny, lenx, &stable, rows, cols, bargs, tam); + int r = sixel_blit_inner(leny, lenx, &stable, bargs, tam); if(r < 0){ sixelmap_free(stable.map); }