mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-10-31 15:20:13 +00: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;
|
||||
int (*blit)(struct ncplane* n, int placey, int placex, int linesize,
|
||||
const void* data, int begy, int begx, int leny, int lenx,
|
||||
bool blendcolors);
|
||||
unsigned blendcolors);
|
||||
const char* name;
|
||||
bool fill;
|
||||
};
|
||||
|
@ -35,7 +35,7 @@ trilerp(uint32_t c0, uint32_t c1, uint32_t c2){
|
||||
static inline int
|
||||
tria_blit_ascii(ncplane* nc, int placey, int placex, int linesize,
|
||||
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);
|
||||
const int bpp = 32;
|
||||
int dimy, dimx, x, y;
|
||||
@ -84,7 +84,7 @@ tria_blit_ascii(ncplane* nc, int placey, int placex, int linesize,
|
||||
static inline int
|
||||
tria_blit(ncplane* nc, int placey, int placex, int linesize,
|
||||
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);
|
||||
const int bpp = 32;
|
||||
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 pass in rgbas as array of uint32_t ala sexblitter
|
||||
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_bl, const unsigned char* rgbbase_br){
|
||||
uint32_t tl = 0, tr = 0, bl = 0, br = 0;
|
||||
@ -418,7 +418,7 @@ qtrans_check(nccell* c, bool blendcolors,
|
||||
static inline int
|
||||
quadrant_blit(ncplane* nc, int placey, int placex, int linesize,
|
||||
const void* data, int begy, int begx,
|
||||
int leny, int lenx, bool blendcolors){
|
||||
int leny, int lenx, unsigned blendcolors){
|
||||
const int bpp = 32;
|
||||
int dimy, dimx, x, y;
|
||||
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
|
||||
// of pixels that minimizes total source distance from the resulting lerps.
|
||||
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,
|
||||
// for which we would calculate the same total differences, so just handle
|
||||
// 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*
|
||||
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*
|
||||
// 32: bottom right 16: bottom 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
|
||||
sextant_blit(ncplane* nc, int placey, int placex, int linesize,
|
||||
const void* data, int begy, int begx,
|
||||
int leny, int lenx, bool blendcolors){
|
||||
int leny, int lenx, unsigned blendcolors){
|
||||
const int bpp = 32;
|
||||
int dimy, dimx, x, y;
|
||||
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
|
||||
braille_blit(ncplane* nc, int placey, int placex, int linesize,
|
||||
const void* data, int begy, int begx,
|
||||
int leny, int lenx, bool blendcolors){
|
||||
int leny, int lenx, unsigned blendcolors){
|
||||
const int bpp = 32;
|
||||
int dimy, dimx, x, y;
|
||||
int total = 0; // number of cells written
|
||||
|
@ -514,7 +514,7 @@ ncdirectv* ncdirect_render_frame(ncdirect* n, const char* file,
|
||||
return nullptr;
|
||||
}
|
||||
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);
|
||||
free_plane(ncdv);
|
||||
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,
|
||||
const void* data, int begy, int begx,
|
||||
int leny, int lenx, bool blendcolors);
|
||||
int leny, int lenx, unsigned cellpixx);
|
||||
|
||||
typedef struct ncvisual_implementation {
|
||||
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
|
||||
// stacks. There is also a RLE component, handled in rasterization.
|
||||
// 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;
|
||||
size_t size = 0;
|
||||
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;
|
||||
}
|
||||
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);
|
||||
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,
|
||||
const void* data, int begy, int begx,
|
||||
int leny, int lenx, bool blendcolors){
|
||||
(void)blendcolors; // FIXME
|
||||
int leny, int lenx, unsigned cellpixx){
|
||||
colortable* ctab = malloc(sizeof(*ctab));
|
||||
if(ctab == NULL){
|
||||
return -1;
|
||||
@ -258,7 +259,7 @@ int sixel_blit(ncplane* nc, int placey, int placex, int linesize,
|
||||
free(ctab);
|
||||
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(ctab);
|
||||
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){
|
||||
dispcols = ncv->cols;
|
||||
disprows = ncv->rows;
|
||||
/*dispcols = dispcols / tcache->cellpixx + dispcols % tcache->cellpixx;
|
||||
disprows = disprows / tcache->cellpixy + disprows % tcache->cellpixy;*/
|
||||
}else{
|
||||
ncplane_dim_yx(n, &disprows, &dispcols);
|
||||
dispcols *= tcache->cellpixx;
|
||||
@ -534,7 +532,8 @@ auto ncvisual_render_pixels(tinfo* tcache, ncvisual* ncv, const blitset* bset,
|
||||
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);
|
||||
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);
|
||||
return nullptr;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user