diff --git a/src/lib/direct.c b/src/lib/direct.c index b8bc342de..646200a46 100644 --- a/src/lib/direct.c +++ b/src/lib/direct.c @@ -689,10 +689,8 @@ ncdirect_render_visual(ncdirect* n, ncvisual* ncv, bargs.transcolor = vopts->transcolor | 0x1000000ull; } if(bset->geom == NCBLIT_PIXEL){ - bargs.u.pixel.celldimx = n->tcache.cellpixx; - bargs.u.pixel.celldimy = n->tcache.cellpixy; bargs.u.pixel.colorregs = n->tcache.color_registers; - if((bargs.u.pixel.spx = sprixel_alloc(ncdv, nopts.rows, nopts.cols)) == NULL){ + if((bargs.u.pixel.spx = sprixel_alloc(&n->tcache, ncdv, nopts.rows, nopts.cols)) == NULL){ free_plane(ncdv); return NULL; } diff --git a/src/lib/internal.h b/src/lib/internal.h index 29ff39119..32a8ebc81 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -393,8 +393,6 @@ typedef struct blitterargs { int placex; } cell; // for cells struct { - int celldimx; // horizontal pixels per cell - int celldimy; // vertical pixels per cell int colorregs; // number of color registers sprixel* spx; // sprixel object } pixel; // for pixels @@ -653,7 +651,7 @@ void sprixel_free(sprixel* s); void sprixel_hide(sprixel* s); // dimy and dimx are cell geometry, not pixel. -sprixel* sprixel_alloc(ncplane* n, int dimy, int dimx); +sprixel* sprixel_alloc(const tinfo* ti, ncplane* n, int dimy, int dimx); sprixel* sprixel_recycle(ncplane* n); // takes ownership of s on success. int sprixel_load(sprixel* spx, char* s, int bytes, int pixy, int pixx, int parse_start); diff --git a/src/lib/iterm.c b/src/lib/iterm.c index c636978ef..e697ac22f 100644 --- a/src/lib/iterm.c +++ b/src/lib/iterm.c @@ -95,6 +95,7 @@ int iterm_blit(ncplane* n, int linesize, const void* data, if(write_iterm_graphic(s, data, leny, linesize, lenx)){ goto error; } + scrub_tam_boundaries(tam, leny, lenx, s->cellpxy, s->cellpxx); if(plane_blit_sixel(s, s->glyph, s->glyphlen, leny, lenx, parse_start, tam) < 0){ goto error; } diff --git a/src/lib/kitty.c b/src/lib/kitty.c index c594289a4..f7dcede52 100644 --- a/src/lib/kitty.c +++ b/src/lib/kitty.c @@ -303,7 +303,7 @@ int kitty_rebuild(sprixel* s, int ycell, int xcell, uint8_t* auxvec){ // size in pixels. posy and posx are the origin of the cell to be copied, // again in pixels. data is the image source. around the edges, we might // get truncated regions. -static inline uint8_t* +static inline void* kitty_anim_auxvec(int dimy, int dimx, int posy, int posx, int cellpxy, int cellpxx, const uint32_t* data, int rowstride, uint8_t* existing, uint32_t transcolor){ @@ -380,7 +380,7 @@ sprixel* kitty_recycle(ncplane* n){ int dimy = hides->dimy; int dimx = hides->dimx; sprixel_hide(hides); - return sprixel_alloc(n, dimy, dimx); + return sprixel_alloc(&ncplane_notcurses_const(n)->tcache, n, dimy, dimx); } int kitty_wipe(sprixel* s, int ycell, int xcell){ @@ -501,9 +501,10 @@ write_kitty_data(FILE* fp, int linesize, int leny, int lenx, int cols, return -1; } bool translucent = bargs->flags & NCVISUAL_OPTION_BLEND; - int sprixelid = bargs->u.pixel.spx->id; - int cdimy = bargs->u.pixel.celldimy; - int cdimx = bargs->u.pixel.celldimx; + sprixel* s = bargs->u.pixel.spx; + int sprixelid = s->id; + int cdimy = s->cellpxy; + int cdimx = s->cellpxx; uint32_t transcolor = bargs->transcolor; int total = leny * lenx; // total number of pixels (4 * total == bytecount) // number of 4KiB chunks we'll need diff --git a/src/lib/linux.c b/src/lib/linux.c index 373316dfa..d50d5abc2 100644 --- a/src/lib/linux.c +++ b/src/lib/linux.c @@ -28,9 +28,9 @@ int fbcon_blit(struct ncplane* n, int linesize, const void* data, int leny, int lenx, const struct blitterargs* bargs){ int cols = bargs->u.pixel.spx->dimx; int rows = bargs->u.pixel.spx->dimy; - int cdimx = bargs->u.pixel.celldimx; - int cdimy = bargs->u.pixel.celldimy; sprixel* s = bargs->u.pixel.spx; + int cdimx = s->cellpxx; + int cdimy = s->cellpxy; s->glyphlen = leny * lenx * 4; s->glyph = malloc(s->glyphlen); if(s->glyph == NULL){ @@ -77,6 +77,7 @@ int fbcon_blit(struct ncplane* n, int linesize, const void* data, src += 4; } } + scrub_tam_boundaries(tam, leny, lenx, cdimy, cdimx); if(plane_blit_sixel(s, s->glyph, s->glyphlen, leny, lenx, 0, tam) < 0){ goto error; } diff --git a/src/lib/sixel.c b/src/lib/sixel.c index a88fab86f..1e7770357 100644 --- a/src/lib/sixel.c +++ b/src/lib/sixel.c @@ -359,8 +359,9 @@ extract_color_table(const uint32_t* data, int linesize, int cols, tament* tam, const blitterargs* bargs){ const int begx = bargs->begx; const int begy = bargs->begy; - const int cdimy = bargs->u.pixel.celldimy; - const int cdimx = bargs->u.pixel.celldimx; + sprixel* s = bargs->u.pixel.spx; + const int cdimy = s->cellpxy; + const int cdimx = s->cellpxx; unsigned char mask = 0xc0; int pos = 0; // pixel position for(int visy = begy ; visy < (begy + leny) ; visy += 6){ // pixel row @@ -692,8 +693,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, - const blitterargs* bargs, tament* tam){ +sixel_blit_inner(int leny, int lenx, sixeltable* stab, sprixel* s, tament* tam){ char* buf = NULL; size_t size = 0; FILE* fp = open_memstream(&buf, &size); @@ -712,16 +712,14 @@ sixel_blit_inner(int leny, int lenx, sixeltable* stab, free(buf); return -1; } - scrub_tam_boundaries(tam, outy, lenx, bargs->u.pixel.celldimy, - bargs->u.pixel.celldimx); + scrub_tam_boundaries(tam, outy, lenx, s->cellpxy, s->cellpxx); // take ownership of buf on success - if(plane_blit_sixel(bargs->u.pixel.spx, buf, size, - outy, lenx, parse_start, tam) < 0){ + if(plane_blit_sixel(s, buf, size, outy, lenx, parse_start, tam) < 0){ free(buf); return -1; } sixelmap_trim(stab->map); - bargs->u.pixel.spx->smap = stab->map; + s->smap = stab->map; return 1; } @@ -781,7 +779,7 @@ int sixel_blit(ncplane* n, int linesize, const void* data, int leny, int lenx, } 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, bargs, tam); + int r = sixel_blit_inner(leny, lenx, &stable, bargs->u.pixel.spx, tam); if(r < 0){ sixelmap_free(stable.map); } diff --git a/src/lib/sprite.c b/src/lib/sprite.c index 9080bc93c..cca200307 100644 --- a/src/lib/sprite.c +++ b/src/lib/sprite.c @@ -59,7 +59,7 @@ sprixel* sprixel_recycle(ncplane* n){ int dimy = hides->dimy; int dimx = hides->dimx; sprixel_hide(hides); - return sprixel_alloc(n, dimy, dimx); + return sprixel_alloc(&nc->tcache, n, dimy, dimx); } return n->sprite; } @@ -115,7 +115,7 @@ void sprixel_invalidate(sprixel* s, int y, int x){ } } -sprixel* sprixel_alloc(ncplane* n, int dimy, int dimx){ +sprixel* sprixel_alloc(const tinfo* ti, ncplane* n, int dimy, int dimx){ sprixel* ret = malloc(sizeof(sprixel)); if(ret){ memset(ret, 0, sizeof(*ret)); @@ -128,20 +128,18 @@ sprixel* sprixel_alloc(ncplane* n, int dimy, int dimx){ sprixelid_nonce = 1; } //fprintf(stderr, "LOOKING AT %p (p->n = %p)\n", ret, ret->n); - if(ncplane_pile(ret->n)){ + ret->cellpxy = ti->cellpixy; + ret->cellpxx = ti->cellpixx; + if(ncplane_pile(ret->n)){ // rendered mode ncpile* np = ncplane_pile(ret->n); if( (ret->next = np->sprixelcache) ){ ret->next->prev = ret; } np->sprixelcache = ret; ret->prev = NULL; - const notcurses* nc = ncplane_notcurses_const(ret->n); - ret->cellpxy = nc->tcache.cellpixy; - ret->cellpxx = nc->tcache.cellpixx; //fprintf(stderr, "%p %p %p\n", nc->sprixelcache, ret, nc->sprixelcache->next); }else{ // ncdirect case ret->next = ret->prev = NULL; - ret->cellpxy = ret->cellpxx = -1; } } return ret; diff --git a/src/lib/visual.c b/src/lib/visual.c index 76ee4cb85..a87412f1a 100644 --- a/src/lib/visual.c +++ b/src/lib/visual.c @@ -951,13 +951,11 @@ ncplane* ncvisual_render_pixels(notcurses* nc, ncvisual* ncv, const struct blits bargs.leny = leny; bargs.lenx = lenx; bargs.flags = flags; - bargs.u.pixel.celldimx = nc->tcache.cellpixx; - bargs.u.pixel.celldimy = nc->tcache.cellpixy; bargs.u.pixel.colorregs = nc->tcache.color_registers; if(n->sprite == NULL){ - int cols = disppixx / bargs.u.pixel.celldimx + !!(disppixx % bargs.u.pixel.celldimx); - int rows = outy / bargs.u.pixel.celldimy + !!(outy % bargs.u.pixel.celldimy); - if((n->sprite = sprixel_alloc(n, rows, cols)) == NULL){ + int cols = disppixx / nc->tcache.cellpixx + !!(disppixx % nc->tcache.cellpixx); + int rows = outy / nc->tcache.cellpixy + !!(outy % nc->tcache.cellpixy); + if((n->sprite = sprixel_alloc(&nc->tcache, n, rows, cols)) == NULL){ ncplane_destroy(createdn); return NULL; }