mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-12 10:39:04 -04:00
eliminate type-2 gclusters, sprixels no longer interact with fb #1656
This commit is contained in:
parent
b87407eb36
commit
346512ccdf
1
USAGE.md
1
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
|
// 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!
|
// 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);
|
const char* nccell_extended_gcluster(const struct ncplane* n, const nccell* c);
|
||||||
|
|
||||||
// Returns true if the two nccells are distinct EGCs, attributes, or channels.
|
// Returns true if the two nccells are distinct EGCs, attributes, or channels.
|
||||||
|
@ -748,7 +748,6 @@ nccell_wide_left_p(const nccell* c){
|
|||||||
|
|
||||||
// return a pointer to the NUL-terminated EGC referenced by 'c'. this pointer
|
// 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!
|
// 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);
|
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
|
// return the number of columns occupied by 'c'. returns -1 if passed a
|
||||||
|
@ -256,16 +256,10 @@ cell_extended_p(const nccell* c){
|
|||||||
return (htole(c->gcluster) & htole(0xff000000ul)) == htole(0x01000000ul);
|
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)?
|
// Is the cell simple (a UTF8-encoded EGC of four bytes or fewer)?
|
||||||
static inline bool
|
static inline bool
|
||||||
cell_simple_p(const nccell* c){
|
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
|
// only applies to complex cells, do not use on simple cells
|
||||||
|
@ -21,7 +21,6 @@ void ncplane_greyscale(ncplane *n){
|
|||||||
// we did some work here, filling everything we could reach. out-of-plane is 0.
|
// we did some work here, filling everything we could reach. out-of-plane is 0.
|
||||||
static int
|
static int
|
||||||
ncplane_polyfill_recurse(ncplane* n, int y, int x, const nccell* c, const char* filltarg){
|
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){
|
if(y >= n->leny || x >= n->lenx){
|
||||||
return 0; // not fillable
|
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
|
return 0; // not fillable
|
||||||
}
|
}
|
||||||
nccell* cur = &n->fb[nfbcellidx(n, y, x)];
|
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);
|
const char* glust = nccell_extended_gcluster(n, cur);
|
||||||
//fprintf(stderr, "checking %d/%d (%s) for [%s]\n", y, x, glust, filltarg);
|
//fprintf(stderr, "checking %d/%d (%s) for [%s]\n", y, x, glust, filltarg);
|
||||||
if(strcmp(glust, filltarg)){
|
if(strcmp(glust, filltarg)){
|
||||||
|
@ -1485,27 +1485,17 @@ egc_rtl(const char* egc, int* bytes){
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
// a sprixel occupies the entirety of its associated plane. each cell contains
|
// a sprixel occupies the entirety of its associated plane, usually an entirely
|
||||||
// a reference to the context-wide sprixel cache. this ought be an entirely
|
|
||||||
// new, purpose-specific plane. |leny| and |lenx| are output geometry in pixels.
|
// new, purpose-specific plane. |leny| and |lenx| are output geometry in pixels.
|
||||||
// |cols| and |rows| are output coverage in cells.
|
|
||||||
static inline int
|
static inline int
|
||||||
plane_blit_sixel(sprixel* spx, char* s, int bytes, int rows, int cols,
|
plane_blit_sixel(sprixel* spx, char* s, int bytes, int leny, int lenx,
|
||||||
int leny, int lenx, int parse_start, tament* tam){
|
int parse_start, tament* tam){
|
||||||
if(sprixel_load(spx, s, bytes, leny, lenx, parse_start)){
|
if(sprixel_load(spx, s, bytes, leny, lenx, parse_start)){
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ncplane* n = spx->n;
|
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){
|
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){
|
if(n->tam != tam){
|
||||||
free(n->tam);
|
free(n->tam);
|
||||||
}
|
}
|
||||||
|
@ -545,7 +545,7 @@ int kitty_blit(ncplane* n, int linesize, const void* data,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// take ownership of |buf| and |tam| on success
|
// 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){
|
leny, lenx, parse_start, tam) < 0){
|
||||||
if(!reuse){
|
if(!reuse){
|
||||||
free(tam);
|
free(tam);
|
||||||
|
@ -560,15 +560,11 @@ ncplane* ncplane_dup(const ncplane* n, void* opaque){
|
|||||||
}
|
}
|
||||||
// we don't duplicate sprites...though i'm unsure why not
|
// we don't duplicate sprites...though i'm unsure why not
|
||||||
size_t fbsize = sizeof(*n->fb) * dimx * dimy;
|
size_t fbsize = sizeof(*n->fb) * dimx * dimy;
|
||||||
if(n->sprite == NULL){
|
if(egcpool_dup(&newn->pool, &n->pool)){
|
||||||
if(egcpool_dup(&newn->pool, &n->pool)){
|
ncplane_destroy(newn);
|
||||||
ncplane_destroy(newn);
|
return NULL;
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
memmove(newn->fb, n->fb, fbsize);
|
|
||||||
}else{
|
|
||||||
memset(newn->fb, 0, fbsize);
|
|
||||||
}
|
}
|
||||||
|
memmove(newn->fb, n->fb, fbsize);
|
||||||
if(ncplane_cursor_move_yx(newn, n->y, n->x) < 0){
|
if(ncplane_cursor_move_yx(newn, n->y, n->x) < 0){
|
||||||
ncplane_destroy(newn);
|
ncplane_destroy(newn);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1323,9 +1319,6 @@ const char* nccell_extended_gcluster(const ncplane* n, const nccell* c){
|
|||||||
if(cell_simple_p(c)){
|
if(cell_simple_p(c)){
|
||||||
return (const char*)&c->gcluster;
|
return (const char*)&c->gcluster;
|
||||||
}
|
}
|
||||||
if(cell_sprixel_p(c)){
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return egcpool_extended_gcluster(&n->pool, c);
|
return egcpool_extended_gcluster(&n->pool, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -583,7 +583,7 @@ sixel_reblit(sprixel* s){
|
|||||||
// scaled geometry in pixels. We calculate output geometry herein, and supply
|
// scaled geometry in pixels. We calculate output geometry herein, and supply
|
||||||
// transparent filler input for any missing rows.
|
// transparent filler input for any missing rows.
|
||||||
static inline int
|
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){
|
const blitterargs* bargs, tament* tam){
|
||||||
char* buf = NULL;
|
char* buf = NULL;
|
||||||
size_t size = 0;
|
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,
|
scrub_tam_boundaries(tam, outy, lenx, bargs->u.pixel.celldimy,
|
||||||
bargs->u.pixel.celldimx);
|
bargs->u.pixel.celldimx);
|
||||||
// take ownership of buf on success
|
// 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){
|
outy, lenx, parse_start, tam) < 0){
|
||||||
free(buf);
|
free(buf);
|
||||||
return -1;
|
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);
|
refine_color_table(data, linesize, bargs->begy, bargs->begx, leny, lenx, &stable);
|
||||||
// takes ownership of sixelmap on success
|
// 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){
|
if(r < 0){
|
||||||
sixelmap_free(stable.map);
|
sixelmap_free(stable.map);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user