eliminate type-2 gclusters, sprixels no longer interact with fb #1656

This commit is contained in:
nick black 2021-05-14 01:39:04 -04:00
parent b87407eb36
commit 346512ccdf
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
8 changed files with 13 additions and 43 deletions

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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)){

View File

@ -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);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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);
}