mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-10 01:29:05 -04:00
sixel: set egc width properly based off tcache #1380
This commit is contained in:
parent
3ad8057965
commit
7b61395ec4
@ -3411,7 +3411,7 @@ struct blitset {
|
|||||||
const wchar_t* egcs;
|
const wchar_t* egcs;
|
||||||
int (*blit)(struct ncplane* n, int placey, int placex, int linesize,
|
int (*blit)(struct ncplane* n, int placey, int placex, int linesize,
|
||||||
const void* data, int begy, int begx, int leny, int lenx,
|
const void* data, int begy, int begx, int leny, int lenx,
|
||||||
bool blendcolors);
|
unsigned blendcolors);
|
||||||
const char* name;
|
const char* name;
|
||||||
bool fill;
|
bool fill;
|
||||||
};
|
};
|
||||||
|
@ -35,7 +35,7 @@ trilerp(uint32_t c0, uint32_t c1, uint32_t c2){
|
|||||||
static inline int
|
static inline int
|
||||||
tria_blit_ascii(ncplane* nc, int placey, int placex, int linesize,
|
tria_blit_ascii(ncplane* nc, int placey, int placex, int linesize,
|
||||||
const void* data, int begy, int begx,
|
const void* data, int begy, int begx,
|
||||||
int leny, int lenx, bool blendcolors){
|
int leny, int lenx, unsigned blendcolors){
|
||||||
//fprintf(stderr, "ASCII %d X %d @ %d X %d (%p) place: %d X %d\n", leny, lenx, begy, begx, data, placey, placex);
|
//fprintf(stderr, "ASCII %d X %d @ %d X %d (%p) place: %d X %d\n", leny, lenx, begy, begx, data, placey, placex);
|
||||||
const int bpp = 32;
|
const int bpp = 32;
|
||||||
int dimy, dimx, x, y;
|
int dimy, dimx, x, y;
|
||||||
@ -84,7 +84,7 @@ tria_blit_ascii(ncplane* nc, int placey, int placex, int linesize,
|
|||||||
static inline int
|
static inline int
|
||||||
tria_blit(ncplane* nc, int placey, int placex, int linesize,
|
tria_blit(ncplane* nc, int placey, int placex, int linesize,
|
||||||
const void* data, int begy, int begx,
|
const void* data, int begy, int begx,
|
||||||
int leny, int lenx, bool blendcolors){
|
int leny, int lenx, unsigned blendcolors){
|
||||||
//fprintf(stderr, "HALF %d X %d @ %d X %d (%p) place: %d X %d\n", leny, lenx, begy, begx, data, placey, placex);
|
//fprintf(stderr, "HALF %d X %d @ %d X %d (%p) place: %d X %d\n", leny, lenx, begy, begx, data, placey, placex);
|
||||||
const int bpp = 32;
|
const int bpp = 32;
|
||||||
int dimy, dimx, x, y;
|
int dimy, dimx, x, y;
|
||||||
@ -306,7 +306,7 @@ quadrant_solver(uint32_t tl, uint32_t tr, uint32_t bl, uint32_t br,
|
|||||||
// FIXME we ought be able to just build up a bitstring and use it as an index!
|
// FIXME we ought be able to just build up a bitstring and use it as an index!
|
||||||
// FIXME pass in rgbas as array of uint32_t ala sexblitter
|
// FIXME pass in rgbas as array of uint32_t ala sexblitter
|
||||||
static inline const char*
|
static inline const char*
|
||||||
qtrans_check(nccell* c, bool blendcolors,
|
qtrans_check(nccell* c, unsigned blendcolors,
|
||||||
const unsigned char* rgbbase_tl, const unsigned char* rgbbase_tr,
|
const unsigned char* rgbbase_tl, const unsigned char* rgbbase_tr,
|
||||||
const unsigned char* rgbbase_bl, const unsigned char* rgbbase_br){
|
const unsigned char* rgbbase_bl, const unsigned char* rgbbase_br){
|
||||||
uint32_t tl = 0, tr = 0, bl = 0, br = 0;
|
uint32_t tl = 0, tr = 0, bl = 0, br = 0;
|
||||||
@ -418,7 +418,7 @@ qtrans_check(nccell* c, bool blendcolors,
|
|||||||
static inline int
|
static inline int
|
||||||
quadrant_blit(ncplane* nc, int placey, int placex, int linesize,
|
quadrant_blit(ncplane* nc, int placey, int placex, int linesize,
|
||||||
const void* data, int begy, int begx,
|
const void* data, int begy, int begx,
|
||||||
int leny, int lenx, bool blendcolors){
|
int leny, int lenx, unsigned blendcolors){
|
||||||
const int bpp = 32;
|
const int bpp = 32;
|
||||||
int dimy, dimx, x, y;
|
int dimy, dimx, x, y;
|
||||||
int total = 0; // number of cells written
|
int total = 0; // number of cells written
|
||||||
@ -501,7 +501,7 @@ generalerp(unsigned rsum, unsigned gsum, unsigned bsum, int count){
|
|||||||
// (all six pixels are different colors). We want to solve for the 2-partition
|
// (all six pixels are different colors). We want to solve for the 2-partition
|
||||||
// of pixels that minimizes total source distance from the resulting lerps.
|
// of pixels that minimizes total source distance from the resulting lerps.
|
||||||
static const char*
|
static const char*
|
||||||
sex_solver(const uint32_t rgbas[6], uint64_t* channels, bool blendcolors){
|
sex_solver(const uint32_t rgbas[6], uint64_t* channels, unsigned blendcolors){
|
||||||
// each element within the set of 64 has an inverse element within the set,
|
// each element within the set of 64 has an inverse element within the set,
|
||||||
// for which we would calculate the same total differences, so just handle
|
// for which we would calculate the same total differences, so just handle
|
||||||
// the first 32. the partition[] bit masks represent combinations of
|
// the first 32. the partition[] bit masks represent combinations of
|
||||||
@ -583,7 +583,7 @@ sex_solver(const uint32_t rgbas[6], uint64_t* channels, bool blendcolors){
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const char*
|
static const char*
|
||||||
sex_trans_check(cell* c, const uint32_t rgbas[6], bool blendcolors){
|
sex_trans_check(cell* c, const uint32_t rgbas[6], unsigned blendcolors){
|
||||||
// bit is *set* where sextant *is not*
|
// bit is *set* where sextant *is not*
|
||||||
// 32: bottom right 16: bottom left
|
// 32: bottom right 16: bottom left
|
||||||
// 8: middle right 4: middle left
|
// 8: middle right 4: middle left
|
||||||
@ -641,7 +641,7 @@ sex_trans_check(cell* c, const uint32_t rgbas[6], bool blendcolors){
|
|||||||
static inline int
|
static inline int
|
||||||
sextant_blit(ncplane* nc, int placey, int placex, int linesize,
|
sextant_blit(ncplane* nc, int placey, int placex, int linesize,
|
||||||
const void* data, int begy, int begx,
|
const void* data, int begy, int begx,
|
||||||
int leny, int lenx, bool blendcolors){
|
int leny, int lenx, unsigned blendcolors){
|
||||||
const int bpp = 32;
|
const int bpp = 32;
|
||||||
int dimy, dimx, x, y;
|
int dimy, dimx, x, y;
|
||||||
int total = 0; // number of cells written
|
int total = 0; // number of cells written
|
||||||
@ -710,7 +710,7 @@ fold_rgb8(unsigned* restrict r, unsigned* restrict g, unsigned* restrict b,
|
|||||||
static inline int
|
static inline int
|
||||||
braille_blit(ncplane* nc, int placey, int placex, int linesize,
|
braille_blit(ncplane* nc, int placey, int placex, int linesize,
|
||||||
const void* data, int begy, int begx,
|
const void* data, int begy, int begx,
|
||||||
int leny, int lenx, bool blendcolors){
|
int leny, int lenx, unsigned blendcolors){
|
||||||
const int bpp = 32;
|
const int bpp = 32;
|
||||||
int dimy, dimx, x, y;
|
int dimy, dimx, x, y;
|
||||||
int total = 0; // number of cells written
|
int total = 0; // number of cells written
|
||||||
|
@ -514,7 +514,7 @@ ncdirectv* ncdirect_render_frame(ncdirect* n, const char* file,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if(ncvisual_blit(ncv, disprows, dispcols, ncdv, bset,
|
if(ncvisual_blit(ncv, disprows, dispcols, ncdv, bset,
|
||||||
0, 0, 0, 0, leny, lenx, false)){
|
0, 0, 0, 0, leny, lenx, n->tcache.cellpixx)){
|
||||||
ncvisual_destroy(ncv);
|
ncvisual_destroy(ncv);
|
||||||
free_plane(ncdv);
|
free_plane(ncdv);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -1204,7 +1204,7 @@ ncdirect_bg_default_p(const struct ncdirect* nc){
|
|||||||
|
|
||||||
int sixel_blit(ncplane* nc, int placey, int placex, int linesize,
|
int sixel_blit(ncplane* nc, int placey, int placex, int linesize,
|
||||||
const void* data, int begy, int begx,
|
const void* data, int begy, int begx,
|
||||||
int leny, int lenx, bool blendcolors);
|
int leny, int lenx, unsigned cellpixx);
|
||||||
|
|
||||||
typedef struct ncvisual_implementation {
|
typedef struct ncvisual_implementation {
|
||||||
int (*visual_init)(int loglevel);
|
int (*visual_init)(int loglevel);
|
||||||
|
@ -210,7 +210,8 @@ write_sixel_data(FILE* fp, int lenx, sixeltable* stab){
|
|||||||
// are programmed as a set of registers, which are then referenced by the
|
// are programmed as a set of registers, which are then referenced by the
|
||||||
// stacks. There is also a RLE component, handled in rasterization.
|
// stacks. There is also a RLE component, handled in rasterization.
|
||||||
// A pixel block is indicated by setting cell_pixels_p().
|
// A pixel block is indicated by setting cell_pixels_p().
|
||||||
int sixel_blit_inner(ncplane* nc, int placey, int placex, int lenx, sixeltable* stab){
|
int sixel_blit_inner(ncplane* nc, int placey, int placex, int lenx,
|
||||||
|
sixeltable* stab, unsigned cellpixx){
|
||||||
char* buf = NULL;
|
char* buf = NULL;
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
FILE* fp = open_memstream(&buf, &size);
|
FILE* fp = open_memstream(&buf, &size);
|
||||||
@ -223,7 +224,8 @@ int sixel_blit_inner(ncplane* nc, int placey, int placex, int lenx, sixeltable*
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
nccell* c = ncplane_cell_ref_yx(nc, placey, placex);
|
nccell* c = ncplane_cell_ref_yx(nc, placey, placex);
|
||||||
if(pool_blit_direct(&nc->pool, c, buf, size, 1) < 0){ // FIXME true width?
|
unsigned width = lenx / cellpixx + !!(lenx % cellpixx);
|
||||||
|
if(pool_blit_direct(&nc->pool, c, buf, size, width) < 0){
|
||||||
free(buf);
|
free(buf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -233,8 +235,7 @@ int sixel_blit_inner(ncplane* nc, int placey, int placex, int lenx, sixeltable*
|
|||||||
|
|
||||||
int sixel_blit(ncplane* nc, int placey, int placex, int linesize,
|
int sixel_blit(ncplane* nc, int placey, int placex, int linesize,
|
||||||
const void* data, int begy, int begx,
|
const void* data, int begy, int begx,
|
||||||
int leny, int lenx, bool blendcolors){
|
int leny, int lenx, unsigned cellpixx){
|
||||||
(void)blendcolors; // FIXME
|
|
||||||
colortable* ctab = malloc(sizeof(*ctab));
|
colortable* ctab = malloc(sizeof(*ctab));
|
||||||
if(ctab == NULL){
|
if(ctab == NULL){
|
||||||
return -1;
|
return -1;
|
||||||
@ -258,7 +259,7 @@ int sixel_blit(ncplane* nc, int placey, int placex, int linesize,
|
|||||||
free(ctab);
|
free(ctab);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int r = sixel_blit_inner(nc, placey, placex, lenx, &stable);
|
int r = sixel_blit_inner(nc, placey, placex, lenx, &stable, cellpixx);
|
||||||
free(stable.data);
|
free(stable.data);
|
||||||
free(ctab);
|
free(ctab);
|
||||||
return r;
|
return r;
|
||||||
|
@ -517,8 +517,6 @@ auto ncvisual_render_pixels(tinfo* tcache, ncvisual* ncv, const blitset* bset,
|
|||||||
if(scaling == NCSCALE_NONE || scaling == NCSCALE_NONE_HIRES){
|
if(scaling == NCSCALE_NONE || scaling == NCSCALE_NONE_HIRES){
|
||||||
dispcols = ncv->cols;
|
dispcols = ncv->cols;
|
||||||
disprows = ncv->rows;
|
disprows = ncv->rows;
|
||||||
/*dispcols = dispcols / tcache->cellpixx + dispcols % tcache->cellpixx;
|
|
||||||
disprows = disprows / tcache->cellpixy + disprows % tcache->cellpixy;*/
|
|
||||||
}else{
|
}else{
|
||||||
ncplane_dim_yx(n, &disprows, &dispcols);
|
ncplane_dim_yx(n, &disprows, &dispcols);
|
||||||
dispcols *= tcache->cellpixx;
|
dispcols *= tcache->cellpixx;
|
||||||
@ -534,7 +532,8 @@ auto ncvisual_render_pixels(tinfo* tcache, ncvisual* ncv, const blitset* bset,
|
|||||||
lenx = dispcols;
|
lenx = dispcols;
|
||||||
//fprintf(stderr, "blit: %dx%d <- %dx%d:%d+%d of %d/%d stride %u @%dx%d %p\n", disprows, dispcols, begy, begx, leny, lenx, ncv->rows, ncv->cols, ncv->rowstride, placey, placex, ncv->data);
|
//fprintf(stderr, "blit: %dx%d <- %dx%d:%d+%d of %d/%d stride %u @%dx%d %p\n", disprows, dispcols, begy, begx, leny, lenx, ncv->rows, ncv->cols, ncv->rowstride, placey, placex, ncv->data);
|
||||||
if(ncvisual_blit(ncv, disprows, dispcols, n, bset,
|
if(ncvisual_blit(ncv, disprows, dispcols, n, bset,
|
||||||
placey, placex, begy, begx, leny, lenx, false)){
|
placey, placex, begy, begx, leny, lenx,
|
||||||
|
ncplane_notcurses(stdn)->tcache.cellpixx)){
|
||||||
ncplane_destroy(n);
|
ncplane_destroy(n);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user