mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-02 09:40:15 +00:00
[render] non-transparent backgrounds override bitmaps #1388
This commit is contained in:
parent
7b61822a7e
commit
ad215daaeb
126
src/lib/blit.c
126
src/lib/blit.c
@ -33,22 +33,22 @@ trilerp(uint32_t c0, uint32_t c1, uint32_t c2){
|
||||
|
||||
// Retarded RGBA blitter (ASCII only).
|
||||
static inline int
|
||||
tria_blit_ascii(ncplane* nc, int linesize, const void* data, int begy, int begx,
|
||||
tria_blit_ascii(ncplane* nc, int linesize, const void* data,
|
||||
int leny, int lenx, const blitterargs* bargs){
|
||||
//fprintf(stderr, "ASCII %d X %d @ %d X %d (%p) place: %d X %d\n", leny, lenx, begy, begx, data, bargs->cell.placey, bargs->cell.placex);
|
||||
//fprintf(stderr, "ASCII %d X %d @ %d X %d (%p) place: %d X %d\n", leny, lenx, bargs->begy, begx, data, bargs->placey, bargs->placex);
|
||||
const int bpp = 32;
|
||||
int dimy, dimx, x, y;
|
||||
int total = 0; // number of cells written
|
||||
ncplane_dim_yx(nc, &dimy, &dimx);
|
||||
// FIXME not going to necessarily be safe on all architectures hrmmm
|
||||
const unsigned char* dat = data;
|
||||
int visy = begy;
|
||||
for(y = bargs->cell.placey ; visy < (begy + leny) && y < dimy ; ++y, ++visy){
|
||||
if(ncplane_cursor_move_yx(nc, y, bargs->cell.placex)){
|
||||
int visy = bargs->begy;
|
||||
for(y = bargs->placey ; visy < (bargs->begy + leny) && y < dimy ; ++y, ++visy){
|
||||
if(ncplane_cursor_move_yx(nc, y, bargs->placex)){
|
||||
return -1;
|
||||
}
|
||||
int visx = begx;
|
||||
for(x = bargs->cell.placex ; visx < (begx + lenx) && x < dimx ; ++x, ++visx){
|
||||
int visx = bargs->begx;
|
||||
for(x = bargs->placex ; visx < (bargs->begx + lenx) && x < dimx ; ++x, ++visx){
|
||||
const unsigned char* rgbbase_up = dat + (linesize * visy) + (visx * bpp / CHAR_BIT);
|
||||
//fprintf(stderr, "[%04d/%04d] bpp: %d lsize: %d %02x %02x %02x %02x\n", y, x, bpp, linesize, rgbbase_up[0], rgbbase_up[1], rgbbase_up[2], rgbbase_up[3]);
|
||||
nccell* c = ncplane_cell_ref_yx(nc, y, x);
|
||||
@ -56,7 +56,7 @@ tria_blit_ascii(ncplane* nc, int linesize, const void* data, int begy, int begx,
|
||||
// effective in that case anyway
|
||||
c->channels = 0;
|
||||
c->stylemask = 0;
|
||||
if(bargs->cell.blendcolors){
|
||||
if(bargs->u.cell.blendcolors){
|
||||
cell_set_bg_alpha(c, CELL_ALPHA_BLEND);
|
||||
cell_set_fg_alpha(c, CELL_ALPHA_BLEND);
|
||||
}
|
||||
@ -81,25 +81,25 @@ tria_blit_ascii(ncplane* nc, int linesize, const void* data, int begy, int begx,
|
||||
// RGBA half-block blitter. Best for most images/videos. Full fidelity
|
||||
// combined with 1:1 pixel aspect ratio.
|
||||
static inline int
|
||||
tria_blit(ncplane* nc, int linesize, const void* data, int begy, int begx,
|
||||
tria_blit(ncplane* nc, int linesize, const void* data,
|
||||
int leny, int lenx, const blitterargs* bargs){
|
||||
//fprintf(stderr, "HALF %d X %d @ %d X %d (%p) place: %d X %d\n", leny, lenx, begy, begx, data, bargs->cell.placey, bargs->cell.placex);
|
||||
//fprintf(stderr, "HALF %d X %d @ %d X %d (%p) place: %d X %d\n", leny, lenx, bargs->begy, bargs->begx, data, bargs->placey, bargs->placex);
|
||||
const int bpp = 32;
|
||||
int dimy, dimx, x, y;
|
||||
int total = 0; // number of cells written
|
||||
ncplane_dim_yx(nc, &dimy, &dimx);
|
||||
// FIXME not going to necessarily be safe on all architectures hrmmm
|
||||
const unsigned char* dat = data;
|
||||
int visy = begy;
|
||||
for(y = bargs->cell.placey ; visy < (begy + leny) && y < dimy ; ++y, visy += 2){
|
||||
if(ncplane_cursor_move_yx(nc, y, bargs->cell.placex)){
|
||||
int visy = bargs->begy;
|
||||
for(y = bargs->placey ; visy < (bargs->begy + leny) && y < dimy ; ++y, visy += 2){
|
||||
if(ncplane_cursor_move_yx(nc, y, bargs->placex)){
|
||||
return -1;
|
||||
}
|
||||
int visx = begx;
|
||||
for(x = bargs->cell.placex ; visx < (begx + lenx) && x < dimx ; ++x, ++visx){
|
||||
int visx = bargs->begx;
|
||||
for(x = bargs->placex ; visx < (bargs->begx + lenx) && x < dimx ; ++x, ++visx){
|
||||
const unsigned char* rgbbase_up = dat + (linesize * visy) + (visx * bpp / CHAR_BIT);
|
||||
const unsigned char* rgbbase_down = zeroes;
|
||||
if(visy < begy + leny - 1){
|
||||
if(visy < bargs->begy + leny - 1){
|
||||
rgbbase_down = dat + (linesize * (visy + 1)) + (visx * bpp / CHAR_BIT);
|
||||
}
|
||||
//fprintf(stderr, "[%04d/%04d] bpp: %d lsize: %d %02x %02x %02x %02x\n", y, x, bpp, linesize, rgbbase_up[0], rgbbase_up[1], rgbbase_up[2], rgbbase_up[3]);
|
||||
@ -108,7 +108,7 @@ tria_blit(ncplane* nc, int linesize, const void* data, int begy, int begx,
|
||||
// effective in that case anyway
|
||||
c->channels = 0;
|
||||
c->stylemask = 0;
|
||||
if(bargs->cell.blendcolors){
|
||||
if(bargs->u.cell.blendcolors){
|
||||
cell_set_bg_alpha(c, CELL_ALPHA_BLEND);
|
||||
cell_set_fg_alpha(c, CELL_ALPHA_BLEND);
|
||||
}
|
||||
@ -403,40 +403,40 @@ qtrans_check(nccell* c, unsigned blendcolors,
|
||||
// quadrant blitter. maps 2x2 to each cell. since we only have two colors at
|
||||
// our disposal (foreground and background), we lose some fidelity.
|
||||
static inline int
|
||||
quadrant_blit(ncplane* nc, int linesize, const void* data, int begy, int begx,
|
||||
quadrant_blit(ncplane* nc, int linesize, const void* data,
|
||||
int leny, int lenx, const blitterargs* bargs){
|
||||
const int bpp = 32;
|
||||
int dimy, dimx, x, y;
|
||||
int total = 0; // number of cells written
|
||||
ncplane_dim_yx(nc, &dimy, &dimx);
|
||||
//fprintf(stderr, "quadblitter %dx%d -> %d/%d+%d/%d\n", leny, lenx, dimy, dimx, bargs->cell.placey, bargs->cell.placex);
|
||||
//fprintf(stderr, "quadblitter %dx%d -> %d/%d+%d/%d\n", leny, lenx, dimy, dimx, bargs->placey, bargs->placex);
|
||||
// FIXME not going to necessarily be safe on all architectures hrmmm
|
||||
const unsigned char* dat = data;
|
||||
int visy = begy;
|
||||
for(y = bargs->cell.placey ; visy < (begy + leny) && y < dimy ; ++y, visy += 2){
|
||||
if(ncplane_cursor_move_yx(nc, y, bargs->cell.placex)){
|
||||
int visy = bargs->begy;
|
||||
for(y = bargs->placey ; visy < (bargs->begy + leny) && y < dimy ; ++y, visy += 2){
|
||||
if(ncplane_cursor_move_yx(nc, y, bargs->placex)){
|
||||
return -1;
|
||||
}
|
||||
int visx = begx;
|
||||
for(x = bargs->cell.placex ; visx < (begx + lenx) && x < dimx ; ++x, visx += 2){
|
||||
int visx = bargs->begx;
|
||||
for(x = bargs->placex ; visx < (bargs->begx + lenx) && x < dimx ; ++x, visx += 2){
|
||||
const unsigned char* rgbbase_tl = dat + (linesize * visy) + (visx * bpp / CHAR_BIT);
|
||||
const unsigned char* rgbbase_tr = zeroes;
|
||||
const unsigned char* rgbbase_bl = zeroes;
|
||||
const unsigned char* rgbbase_br = zeroes;
|
||||
if(visx < begx + lenx - 1){
|
||||
if(visx < bargs->begx + lenx - 1){
|
||||
rgbbase_tr = dat + (linesize * visy) + ((visx + 1) * bpp / CHAR_BIT);
|
||||
if(visy < begy + leny - 1){
|
||||
if(visy < bargs->begy + leny - 1){
|
||||
rgbbase_br = dat + (linesize * (visy + 1)) + ((visx + 1) * bpp / CHAR_BIT);
|
||||
}
|
||||
}
|
||||
if(visy < begy + leny - 1){
|
||||
if(visy < bargs->begy + leny - 1){
|
||||
rgbbase_bl = dat + (linesize * (visy + 1)) + (visx * bpp / CHAR_BIT);
|
||||
}
|
||||
//fprintf(stderr, "[%04d/%04d] bpp: %d lsize: %d %02x %02x %02x %02x\n", y, x, bpp, linesize, rgbbase_tl[0], rgbbase_tr[1], rgbbase_bl[2], rgbbase_br[3]);
|
||||
nccell* c = ncplane_cell_ref_yx(nc, y, x);
|
||||
c->channels = 0;
|
||||
c->stylemask = 0;
|
||||
const char* egc = qtrans_check(c, bargs->cell.blendcolors, rgbbase_tl, rgbbase_tr, rgbbase_bl, rgbbase_br);
|
||||
const char* egc = qtrans_check(c, bargs->u.cell.blendcolors, rgbbase_tl, rgbbase_tr, rgbbase_bl, rgbbase_br);
|
||||
if(egc == NULL){
|
||||
uint32_t tl = 0, tr = 0, bl = 0, br = 0;
|
||||
channel_set_rgb8(&tl, rgbbase_tl[0], rgbbase_tl[1], rgbbase_tl[2]);
|
||||
@ -450,7 +450,7 @@ quadrant_blit(ncplane* nc, int linesize, const void* data, int begy, int begx,
|
||||
//fprintf(stderr, "%d/%d %08x/%08x\n", y, x, fg, bg);
|
||||
cell_set_fchannel(c, fg);
|
||||
cell_set_bchannel(c, bg);
|
||||
if(bargs->cell.blendcolors){
|
||||
if(bargs->u.cell.blendcolors){
|
||||
cell_set_bg_alpha(c, CELL_ALPHA_BLEND);
|
||||
cell_set_fg_alpha(c, CELL_ALPHA_BLEND);
|
||||
}
|
||||
@ -625,44 +625,44 @@ sex_trans_check(cell* c, const uint32_t rgbas[6], unsigned blendcolors){
|
||||
// sextant blitter. maps 3x2 to each cell. since we only have two colors at
|
||||
// our disposal (foreground and background), we lose some fidelity.
|
||||
static inline int
|
||||
sextant_blit(ncplane* nc, int linesize, const void* data, int begy, int begx,
|
||||
sextant_blit(ncplane* nc, int linesize, const void* data,
|
||||
int leny, int lenx, const blitterargs* bargs){
|
||||
const int bpp = 32;
|
||||
int dimy, dimx, x, y;
|
||||
int total = 0; // number of cells written
|
||||
ncplane_dim_yx(nc, &dimy, &dimx);
|
||||
//fprintf(stderr, "sexblitter %dx%d -> %d/%d+%d/%d\n", leny, lenx, dimy, dimx, bargs->cell.placey, bargs->cell.placex);
|
||||
//fprintf(stderr, "sexblitter %dx%d -> %d/%d+%d/%d\n", leny, lenx, dimy, dimx, bargs->placey, bargs->placex);
|
||||
const unsigned char* dat = data;
|
||||
int visy = begy;
|
||||
for(y = bargs->cell.placey ; visy < (begy + leny) && y < dimy ; ++y, visy += 3){
|
||||
if(ncplane_cursor_move_yx(nc, y, bargs->cell.placex)){
|
||||
int visy = bargs->begy;
|
||||
for(y = bargs->placey ; visy < (bargs->begy + leny) && y < dimy ; ++y, visy += 3){
|
||||
if(ncplane_cursor_move_yx(nc, y, bargs->placex)){
|
||||
return -1;
|
||||
}
|
||||
int visx = begx;
|
||||
for(x = bargs->cell.placex ; visx < (begx + lenx) && x < dimx ; ++x, visx += 2){
|
||||
int visx = bargs->begx;
|
||||
for(x = bargs->placex ; visx < (bargs->begx + lenx) && x < dimx ; ++x, visx += 2){
|
||||
uint32_t rgbas[6] = { 0, 0, 0, 0, 0, 0 };
|
||||
memcpy(&rgbas[0], (dat + (linesize * visy) + (visx * bpp / CHAR_BIT)), sizeof(*rgbas));
|
||||
if(visx < begx + lenx - 1){
|
||||
if(visx < bargs->begx + lenx - 1){
|
||||
memcpy(&rgbas[1], (dat + (linesize * visy) + ((visx + 1) * bpp / CHAR_BIT)), sizeof(*rgbas));
|
||||
if(visy < begy + leny - 1){
|
||||
if(visy < bargs->begy + leny - 1){
|
||||
memcpy(&rgbas[3], (dat + (linesize * (visy + 1)) + ((visx + 1) * bpp / CHAR_BIT)), sizeof(*rgbas));
|
||||
if(visy < begy + leny - 2){
|
||||
if(visy < bargs->begy + leny - 2){
|
||||
memcpy(&rgbas[5], (dat + (linesize * (visy + 2)) + ((visx + 1) * bpp / CHAR_BIT)), sizeof(*rgbas));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(visy < begy + leny - 1){
|
||||
if(visy < bargs->begy + leny - 1){
|
||||
memcpy(&rgbas[2], (dat + (linesize * (visy + 1)) + (visx * bpp / CHAR_BIT)), sizeof(*rgbas));
|
||||
if(visy < begy + leny - 2){
|
||||
if(visy < bargs->begy + leny - 2){
|
||||
memcpy(&rgbas[4], (dat + (linesize * (visy + 2)) + (visx * bpp / CHAR_BIT)), sizeof(*rgbas));
|
||||
}
|
||||
}
|
||||
nccell* c = ncplane_cell_ref_yx(nc, y, x);
|
||||
c->channels = 0;
|
||||
c->stylemask = 0;
|
||||
const char* egc = sex_trans_check(c, rgbas, bargs->cell.blendcolors);
|
||||
const char* egc = sex_trans_check(c, rgbas, bargs->u.cell.blendcolors);
|
||||
if(egc == NULL){
|
||||
egc = sex_solver(rgbas, &c->channels, bargs->cell.blendcolors);
|
||||
egc = sex_solver(rgbas, &c->channels, bargs->u.cell.blendcolors);
|
||||
cell_set_blitquadrants(c, 1, 1, 1, 1);
|
||||
}
|
||||
//fprintf(stderr, "sex EGC: %s channels: %016lx\n", egc, c->channels);
|
||||
@ -693,7 +693,7 @@ fold_rgb8(unsigned* restrict r, unsigned* restrict g, unsigned* restrict b,
|
||||
// visuals with only two colors in a given area, as it packs lots of
|
||||
// resolution. always transparent background.
|
||||
static inline int
|
||||
braille_blit(ncplane* nc, int linesize, const void* data, int begy, int begx,
|
||||
braille_blit(ncplane* nc, int linesize, const void* data,
|
||||
int leny, int lenx, const blitterargs* bargs){
|
||||
const int bpp = 32;
|
||||
int dimy, dimx, x, y;
|
||||
@ -701,13 +701,13 @@ braille_blit(ncplane* nc, int linesize, const void* data, int begy, int begx,
|
||||
ncplane_dim_yx(nc, &dimy, &dimx);
|
||||
// FIXME not going to necessarily be safe on all architectures hrmmm
|
||||
const unsigned char* dat = data;
|
||||
int visy = begy;
|
||||
for(y = bargs->cell.placey ; visy < (begy + leny) && y < dimy ; ++y, visy += 4){
|
||||
if(ncplane_cursor_move_yx(nc, y, bargs->cell.placex)){
|
||||
int visy = bargs->begy;
|
||||
for(y = bargs->placey ; visy < (bargs->begy + leny) && y < dimy ; ++y, visy += 4){
|
||||
if(ncplane_cursor_move_yx(nc, y, bargs->placex)){
|
||||
return -1;
|
||||
}
|
||||
int visx = begx;
|
||||
for(x = bargs->cell.placex ; visx < (begx + lenx) && x < dimx ; ++x, visx += 2){
|
||||
int visx = bargs->begx;
|
||||
for(x = bargs->placex ; visx < (bargs->begx + lenx) && x < dimx ; ++x, visx += 2){
|
||||
const uint32_t* rgbbase_l0 = (const uint32_t*)(dat + (linesize * visy) + (visx * bpp / CHAR_BIT));
|
||||
const uint32_t* rgbbase_r0 = &zeroes32;
|
||||
const uint32_t* rgbbase_l1 = &zeroes32;
|
||||
@ -719,23 +719,23 @@ braille_blit(ncplane* nc, int linesize, const void* data, int begy, int begx,
|
||||
unsigned r = 0, g = 0, b = 0;
|
||||
unsigned blends = 0;
|
||||
unsigned egcidx = 0;
|
||||
if(visx < begx + lenx - 1){
|
||||
if(visx < bargs->begx + lenx - 1){
|
||||
rgbbase_r0 = (const uint32_t*)(dat + (linesize * visy) + ((visx + 1) * bpp / CHAR_BIT));
|
||||
if(visy < begy + leny - 1){
|
||||
if(visy < bargs->begy + leny - 1){
|
||||
rgbbase_r1 = (const uint32_t*)(dat + (linesize * (visy + 1)) + ((visx + 1) * bpp / CHAR_BIT));
|
||||
if(visy < begy + leny - 2){
|
||||
if(visy < bargs->begy + leny - 2){
|
||||
rgbbase_r2 = (const uint32_t*)(dat + (linesize * (visy + 2)) + ((visx + 1) * bpp / CHAR_BIT));
|
||||
if(visy < begy + leny - 3){
|
||||
if(visy < bargs->begy + leny - 3){
|
||||
rgbbase_r3 = (const uint32_t*)(dat + (linesize * (visy + 3)) + ((visx + 1) * bpp / CHAR_BIT));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(visy < begy + leny - 1){
|
||||
if(visy < bargs->begy + leny - 1){
|
||||
rgbbase_l1 = (const uint32_t*)(dat + (linesize * (visy + 1)) + (visx * bpp / CHAR_BIT));
|
||||
if(visy < begy + leny - 2){
|
||||
if(visy < bargs->begy + leny - 2){
|
||||
rgbbase_l2 = (const uint32_t*)(dat + (linesize * (visy + 2)) + (visx * bpp / CHAR_BIT));
|
||||
if(visy < begy + leny - 3){
|
||||
if(visy < bargs->begy + leny - 3){
|
||||
rgbbase_l3 = (const uint32_t*)(dat + (linesize * (visy + 3)) + (visx * bpp / CHAR_BIT));
|
||||
}
|
||||
}
|
||||
@ -779,7 +779,7 @@ braille_blit(ncplane* nc, int linesize, const void* data, int begy, int begx,
|
||||
// effective in that case anyway
|
||||
c->channels = 0;
|
||||
c->stylemask = 0;
|
||||
if(bargs->cell.blendcolors){
|
||||
if(bargs->u.cell.blendcolors){
|
||||
cell_set_fg_alpha(c, CELL_ALPHA_BLEND);
|
||||
}
|
||||
// FIXME for now, we just sample, color-wise, and always draw crap.
|
||||
@ -960,13 +960,15 @@ int ncblit_rgba(const void* data, int linesize, const struct ncvisual_options* v
|
||||
return -1;
|
||||
}
|
||||
blitterargs bargs = {
|
||||
.cell = {
|
||||
.placey = vopts->y,
|
||||
.placex = vopts->x,
|
||||
.blendcolors = (vopts->flags & NCVISUAL_OPTION_BLEND),
|
||||
.placey = vopts->y,
|
||||
.placex = vopts->x,
|
||||
.u = {
|
||||
.cell = {
|
||||
.blendcolors = (vopts->flags & NCVISUAL_OPTION_BLEND),
|
||||
},
|
||||
},
|
||||
};
|
||||
return bset->blit(nc, linesize, data, begy, begx, leny, lenx, &bargs);
|
||||
return bset->blit(nc, linesize, data, leny, lenx, &bargs);
|
||||
}
|
||||
|
||||
ncblitter_e ncvisual_media_defblitter(const notcurses* nc, ncscale_e scale){
|
||||
|
@ -524,13 +524,12 @@ ncdirectv* ncdirect_render_frame(ncdirect* n, const char* file,
|
||||
}
|
||||
blitterargs bargs = {};
|
||||
if(bset->geom == NCBLIT_PIXEL){
|
||||
bargs.pixel.celldimx = n->tcache.cellpixx;
|
||||
bargs.pixel.celldimy = n->tcache.cellpixy;
|
||||
bargs.pixel.colorregs = n->tcache.color_registers;
|
||||
bargs.pixel.sprixelid = n->tcache.sprixelnonce++;
|
||||
bargs.u.pixel.celldimx = n->tcache.cellpixx;
|
||||
bargs.u.pixel.celldimy = n->tcache.cellpixy;
|
||||
bargs.u.pixel.colorregs = n->tcache.color_registers;
|
||||
bargs.u.pixel.sprixelid = n->tcache.sprixelnonce++;
|
||||
}
|
||||
if(ncvisual_blit(ncv, disprows, dispcols, ncdv, bset,
|
||||
0, 0, leny, lenx, &bargs)){
|
||||
if(ncvisual_blit(ncv, disprows, dispcols, ncdv, bset, leny, lenx, &bargs)){
|
||||
ncvisual_destroy(ncv);
|
||||
free_plane(ncdv);
|
||||
return NULL;
|
||||
|
@ -413,26 +413,26 @@ typedef struct notcurses {
|
||||
unsigned stdio_blocking_save; // was stdio blocking at entry? restore on stop.
|
||||
} notcurses;
|
||||
|
||||
// cell vs pixel-specific arguments
|
||||
typedef union {
|
||||
struct {
|
||||
int blendcolors; // use CELL_ALPHA_BLEND
|
||||
int placey; // placement within ncplane
|
||||
int placex;
|
||||
} cell; // for cells
|
||||
struct {
|
||||
int celldimx; // horizontal pixels per cell
|
||||
int celldimy; // vertical pixels per cell
|
||||
int colorregs; // number of color registers
|
||||
int sprixelid; // unqie 24-bit id into sprixel cache
|
||||
int placey; // placement within ncplane
|
||||
int placex;
|
||||
} pixel; // for pixels
|
||||
typedef struct {
|
||||
int begy; // upper left start within visual
|
||||
int begx;
|
||||
int placey; // placement within ncplane
|
||||
int placex;
|
||||
union { // cell vs pixel-specific arguments
|
||||
struct {
|
||||
int blendcolors; // use CELL_ALPHA_BLEND
|
||||
} cell; // for cells
|
||||
struct {
|
||||
int celldimx; // horizontal pixels per cell
|
||||
int celldimy; // vertical pixels per cell
|
||||
int colorregs; // number of color registers
|
||||
int sprixelid; // unqie 24-bit id into sprixel cache
|
||||
} pixel; // for pixels
|
||||
} u;
|
||||
} blitterargs;
|
||||
|
||||
typedef int (*blitter)(struct ncplane* n, int linesize, const void* data,
|
||||
int begy, int begx, int leny, int lenx,
|
||||
const blitterargs* bargs);
|
||||
int leny, int lenx, const blitterargs* bargs);
|
||||
|
||||
// a system for rendering RGBA pixels as text glyphs
|
||||
struct blitset {
|
||||
@ -920,7 +920,7 @@ ALLOC char* ncplane_vprintf_prep(const char* format, va_list ap);
|
||||
// change the internals of the ncvisual. Uses oframe.
|
||||
int ncvisual_blit(struct ncvisual* ncv, int rows, int cols,
|
||||
ncplane* n, const struct blitset* bset,
|
||||
int begy, int begx, int leny, int lenx, const blitterargs* bargs);
|
||||
int leny, int lenx, const blitterargs* bargs);
|
||||
|
||||
void nclog(const char* fmt, ...);
|
||||
|
||||
@ -1299,10 +1299,10 @@ ncdirect_bg_default_p(const struct ncdirect* nc){
|
||||
int sprite_sixel_cell_wipe(const notcurses* nc, sprixel* s, int y, int x);
|
||||
int sprite_kitty_cell_wipe(const notcurses* nc, sprixel* s, int y, int x);
|
||||
|
||||
int sixel_blit(ncplane* nc, int linesize, const void* data, int begy, int begx,
|
||||
int sixel_blit(ncplane* nc, int linesize, const void* data,
|
||||
int leny, int lenx, const blitterargs* bargs);
|
||||
|
||||
int kitty_blit(ncplane* nc, int linesize, const void* data, int begy, int begx,
|
||||
int kitty_blit(ncplane* nc, int linesize, const void* data,
|
||||
int leny, int lenx, const blitterargs* bargs);
|
||||
|
||||
int term_fg_rgb8(bool RGBflag, const char* setaf, int colors, FILE* out,
|
||||
@ -1312,9 +1312,9 @@ API const struct blitset* lookup_blitset(const tinfo* tcache, ncblitter_e setid,
|
||||
|
||||
static inline int
|
||||
rgba_blit_dispatch(ncplane* nc, const struct blitset* bset,
|
||||
int linesize, const void* data, int begy,
|
||||
int begx, int leny, int lenx, const blitterargs* bargs){
|
||||
return bset->blit(nc, linesize, data, begy, begx, leny, lenx, bargs);
|
||||
int linesize, const void* data,
|
||||
int leny, int lenx, const blitterargs* bargs){
|
||||
return bset->blit(nc, linesize, data, leny, lenx, bargs);
|
||||
}
|
||||
|
||||
static inline const struct blitset*
|
||||
@ -1339,7 +1339,7 @@ typedef struct ncvisual_implementation {
|
||||
int (*visual_init)(int loglevel);
|
||||
void (*visual_printbanner)(const struct notcurses* nc);
|
||||
int (*visual_blit)(struct ncvisual* ncv, int rows, int cols, ncplane* n,
|
||||
const struct blitset* bset, int begy, int begx,
|
||||
const struct blitset* bset,
|
||||
int leny, int lenx, const blitterargs* barg);
|
||||
struct ncvisual* (*visual_create)(void);
|
||||
struct ncvisual* (*visual_from_file)(const char* fname);
|
||||
|
@ -251,8 +251,8 @@ write_kitty_data(FILE* fp, int linesize, int leny, int lenx,
|
||||
// deflate-compressed) 24bit RGB.
|
||||
int kitty_blit_inner(ncplane* nc, int linesize, int leny, int lenx,
|
||||
const void* data, const blitterargs* bargs){
|
||||
int rows = leny / bargs->pixel.celldimy + !!(leny % bargs->pixel.celldimy);
|
||||
int cols = lenx / bargs->pixel.celldimx + !!(lenx % bargs->pixel.celldimx);
|
||||
int rows = leny / bargs->u.pixel.celldimy + !!(leny % bargs->u.pixel.celldimy);
|
||||
int cols = lenx / bargs->u.pixel.celldimx + !!(lenx % bargs->u.pixel.celldimx);
|
||||
char* buf = NULL;
|
||||
size_t size = 0;
|
||||
FILE* fp = open_memstream(&buf, &size);
|
||||
@ -260,14 +260,14 @@ int kitty_blit_inner(ncplane* nc, int linesize, int leny, int lenx,
|
||||
return -1;
|
||||
}
|
||||
int parse_start = 0;
|
||||
if(write_kitty_data(fp, linesize, leny, lenx, data, bargs->pixel.sprixelid,
|
||||
if(write_kitty_data(fp, linesize, leny, lenx, data, bargs->u.pixel.sprixelid,
|
||||
&parse_start)){
|
||||
fclose(fp);
|
||||
free(buf);
|
||||
return -1;
|
||||
}
|
||||
if(plane_blit_sixel(nc, buf, size, bargs->pixel.placey, bargs->pixel.placex,
|
||||
rows, cols, bargs->pixel.sprixelid, leny, lenx,
|
||||
if(plane_blit_sixel(nc, buf, size, bargs->placey, bargs->placex,
|
||||
rows, cols, bargs->u.pixel.sprixelid, leny, lenx,
|
||||
parse_start) < 0){
|
||||
free(buf);
|
||||
return -1;
|
||||
@ -276,10 +276,8 @@ int kitty_blit_inner(ncplane* nc, int linesize, int leny, int lenx,
|
||||
return 1;
|
||||
}
|
||||
|
||||
int kitty_blit(ncplane* nc, int linesize, const void* data, int begy, int begx,
|
||||
int kitty_blit(ncplane* nc, int linesize, const void* data,
|
||||
int leny, int lenx, const blitterargs* bargs){
|
||||
(void)begy;
|
||||
(void)begx;
|
||||
int r = kitty_blit_inner(nc, linesize, leny, lenx, data, bargs);
|
||||
if(r < 0){
|
||||
return -1;
|
||||
|
@ -286,7 +286,7 @@ paint(const ncplane* p, struct crender* rvec, int dstleny, int dstlenx,
|
||||
if(cell_sprixel_p(vis)){
|
||||
// if we already have a glyph solved, and we run into a bitmap
|
||||
// cell, we need to null that cell out.
|
||||
if(crender->p){
|
||||
if(crender->p || crender->s.bgblends){
|
||||
sprite_wipe_cell(ncplane_notcurses_const(p), p->sprite, y, x);
|
||||
}
|
||||
continue;
|
||||
|
@ -498,10 +498,10 @@ int sixel_blit_inner(ncplane* nc, int leny, int lenx, sixeltable* stab,
|
||||
free(buf);
|
||||
return -1;
|
||||
}
|
||||
unsigned cols = lenx / bargs->pixel.celldimx + !!(lenx % bargs->pixel.celldimx);
|
||||
unsigned rows = leny / bargs->pixel.celldimy + !!(leny % bargs->pixel.celldimy);
|
||||
if(plane_blit_sixel(nc, buf, size, bargs->pixel.placey, bargs->pixel.placex,
|
||||
rows, cols, bargs->pixel.sprixelid, leny, lenx,
|
||||
unsigned cols = lenx / bargs->u.pixel.celldimx + !!(lenx % bargs->u.pixel.celldimx);
|
||||
unsigned rows = leny / bargs->u.pixel.celldimy + !!(leny % bargs->u.pixel.celldimy);
|
||||
if(plane_blit_sixel(nc, buf, size, bargs->placey, bargs->placex,
|
||||
rows, cols, bargs->u.pixel.sprixelid, leny, lenx,
|
||||
parse_start) < 0){
|
||||
free(buf);
|
||||
return -1;
|
||||
@ -510,10 +510,10 @@ int sixel_blit_inner(ncplane* nc, int leny, int lenx, sixeltable* stab,
|
||||
return 1;
|
||||
}
|
||||
|
||||
int sixel_blit(ncplane* nc, int linesize, const void* data, int begy, int begx,
|
||||
int sixel_blit(ncplane* nc, int linesize, const void* data,
|
||||
int leny, int lenx, const blitterargs* bargs){
|
||||
int sixelcount = (lenx - begx) * ((leny - begy + 5) / 6);
|
||||
int colorregs = bargs->pixel.colorregs;
|
||||
int sixelcount = (lenx - bargs->begx) * ((leny - bargs->begy + 5) / 6);
|
||||
int colorregs = bargs->u.pixel.colorregs;
|
||||
if(colorregs <= 0){
|
||||
return -1;
|
||||
}
|
||||
@ -537,13 +537,13 @@ int sixel_blit(ncplane* nc, int linesize, const void* data, int begy, int begx,
|
||||
// stable.table doesn't need initializing; we start from the bottom
|
||||
memset(stable.data, 0, sixelcount * colorregs);
|
||||
memset(stable.deets, 0, sizeof(*stable.deets) * colorregs);
|
||||
if(extract_color_table(data, linesize, begy, begx, leny, lenx, &stable)){
|
||||
if(extract_color_table(data, linesize, bargs->begy, bargs->begx, leny, lenx, &stable)){
|
||||
free(stable.table);
|
||||
free(stable.data);
|
||||
free(stable.deets);
|
||||
return -1;
|
||||
}
|
||||
refine_color_table(data, linesize, begy, begx, leny, lenx, &stable);
|
||||
refine_color_table(data, linesize, bargs->begy, bargs->begx, leny, lenx, &stable);
|
||||
int r = sixel_blit_inner(nc, leny, lenx, &stable, bargs);
|
||||
free(stable.data);
|
||||
free(stable.deets);
|
||||
|
@ -14,17 +14,17 @@ int ncvisual_decode(ncvisual* nc){
|
||||
}
|
||||
|
||||
int ncvisual_blit(ncvisual* ncv, int rows, int cols, ncplane* n,
|
||||
const struct blitset* bset, int begy, int begx,
|
||||
int leny, int lenx, const blitterargs* barg){
|
||||
const struct blitset* bset, int leny, int lenx,
|
||||
const blitterargs* barg){
|
||||
int ret = -1;
|
||||
if(visual_implementation){
|
||||
if(visual_implementation->visual_blit(ncv, rows, cols, n, bset,
|
||||
begy, begx, leny, lenx, barg) >= 0){
|
||||
leny, lenx, barg) >= 0){
|
||||
ret = 0;
|
||||
}
|
||||
}else{
|
||||
if(rgba_blit_dispatch(n, bset, ncv->rowstride, ncv->data,
|
||||
begy, begx, leny, lenx, barg) >= 0){
|
||||
leny, lenx, barg) >= 0){
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
@ -436,7 +436,7 @@ ncplane* ncvisual_render_cells(notcurses* nc, ncvisual* ncv, const struct blitse
|
||||
scale_visual(ncv, &disprows, &dispcols);
|
||||
} // else stretch
|
||||
}
|
||||
//fprintf(stderr, "PLACING NEW PLANE: %d/%d @ %d/%d\n", disprows, dispcols, placey, placex);
|
||||
//fprintf(stderr, "PLACING NEW PLANE: %d/%d @ %d/%d %d/%d\n", disprows, dispcols, placey, placex, begy, begx);
|
||||
struct ncplane_options nopts = {
|
||||
.y = placey,
|
||||
.x = placex,
|
||||
@ -471,10 +471,12 @@ ncplane* ncvisual_render_cells(notcurses* nc, ncvisual* ncv, const struct blitse
|
||||
lenx = (lenx / (double)ncv->cols) * ((double)dispcols);
|
||||
//fprintf(stderr, "blit: %dx%d:%d+%d of %d/%d stride %u %p\n", begy, begx, leny, lenx, ncv->rows, ncv->cols, ncv->rowstride, ncv->data);
|
||||
blitterargs bargs;
|
||||
bargs.cell.placey = placey;
|
||||
bargs.cell.placex = placex;
|
||||
bargs.cell.blendcolors = blendcolors;
|
||||
if(ncvisual_blit(ncv, disprows, dispcols, n, bset, begy, begx, leny, lenx, &bargs)){
|
||||
bargs.begy = begy;
|
||||
bargs.begx = begx;
|
||||
bargs.placey = placey;
|
||||
bargs.placex = placex;
|
||||
bargs.u.cell.blendcolors = blendcolors;
|
||||
if(ncvisual_blit(ncv, disprows, dispcols, n, bset, leny, lenx, &bargs)){
|
||||
ncplane_destroy(n);
|
||||
return NULL;
|
||||
}
|
||||
@ -531,14 +533,15 @@ ncplane* ncvisual_render_pixels(notcurses* nc, ncvisual* ncv, const struct blits
|
||||
}
|
||||
//fprintf(stderr, "pblit: %dx%d <- %dx%d of %d/%d stride %u @%dx%d %p %u\n", disprows, dispcols, begy, begx, ncv->rows, ncv->cols, ncv->rowstride, placey, placex, ncv->data, nc->tcache.cellpixx);
|
||||
blitterargs bargs;
|
||||
bargs.pixel.celldimx = nc->tcache.cellpixx;
|
||||
bargs.pixel.celldimy = nc->tcache.cellpixy;
|
||||
bargs.pixel.colorregs = nc->tcache.color_registers;
|
||||
bargs.pixel.sprixelid = nc->tcache.sprixelnonce++;
|
||||
bargs.pixel.placey = placey;
|
||||
bargs.pixel.placex = placex;
|
||||
if(ncvisual_blit(ncv, disprows, dispcols, n, bset,
|
||||
begy, begx, disprows, dispcols, &bargs)){
|
||||
bargs.begy = begy;
|
||||
bargs.begx = begx;
|
||||
bargs.placey = placey;
|
||||
bargs.placex = placex;
|
||||
bargs.u.pixel.celldimx = nc->tcache.cellpixx;
|
||||
bargs.u.pixel.celldimy = nc->tcache.cellpixy;
|
||||
bargs.u.pixel.colorregs = nc->tcache.color_registers;
|
||||
bargs.u.pixel.sprixelid = nc->tcache.sprixelnonce++;
|
||||
if(ncvisual_blit(ncv, disprows, dispcols, n, bset, disprows, dispcols, &bargs)){
|
||||
ncplane_destroy(n);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -468,7 +468,7 @@ int ffmpeg_decode_loop(ncvisual* ncv){
|
||||
}
|
||||
|
||||
int ffmpeg_blit(ncvisual* ncv, int rows, int cols, ncplane* n,
|
||||
const struct blitset* bset, int begy, int begx,
|
||||
const struct blitset* bset,
|
||||
int leny, int lenx, const blitterargs* bargs) {
|
||||
const AVFrame* inframe = ncv->details->oframe ? ncv->details->oframe : ncv->details->frame;
|
||||
//fprintf(stderr, "inframe: %p oframe: %p frame: %p\n", inframe, ncv->details->oframe, ncv->details->frame);
|
||||
@ -522,7 +522,7 @@ int ffmpeg_blit(ncvisual* ncv, int rows, int cols, ncplane* n,
|
||||
data = ncv->data;
|
||||
}
|
||||
//fprintf(stderr, "place: %d/%d rows/cols: %d/%d %d/%d+%d/%d\n", bargs->cell.placey, bargs->cell.placex, rows, cols, begy, begx, leny, lenx);
|
||||
if(rgba_blit_dispatch(n, bset, stride, data, begy, begx, leny, lenx, bargs) < 0){
|
||||
if(rgba_blit_dispatch(n, bset, stride, data, leny, lenx, bargs) < 0){
|
||||
//fprintf(stderr, "rgba dispatch failed!\n");
|
||||
if(sframe){
|
||||
av_freep(sframe->data);
|
||||
|
@ -39,12 +39,12 @@ int none_resize(ncvisual* nc, int rows, int cols){
|
||||
}
|
||||
|
||||
int none_blit(struct ncvisual* ncv, int rows, int cols,
|
||||
ncplane* n, const struct blitset* bset,
|
||||
int begy, int begx, int leny, int lenx, const blitterargs* bargs){
|
||||
ncplane* n, const struct blitset* bset,
|
||||
int leny, int lenx, const blitterargs* bargs){
|
||||
(void)rows;
|
||||
(void)cols;
|
||||
if(rgba_blit_dispatch(n, bset, ncv->rowstride, ncv->data,
|
||||
begy, begx, leny, lenx, bargs) >= 0){
|
||||
leny, lenx, bargs) >= 0){
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
|
@ -5,10 +5,9 @@
|
||||
#include "oiio.h"
|
||||
|
||||
int oiio_blit_dispatch(struct ncplane* nc, const struct blitset* bset,
|
||||
int linesize, const void* data, int begy, int begx,
|
||||
int linesize, const void* data,
|
||||
int leny, int lenx, const blitterargs* bargs){
|
||||
if(rgba_blit_dispatch(nc, bset, linesize, data, begy, begx,
|
||||
leny, lenx, bargs) < 0){
|
||||
if(rgba_blit_dispatch(nc, bset, linesize, data, leny, lenx, bargs) < 0){
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -142,7 +142,7 @@ int oiio_resize(ncvisual* nc, int rows, int cols) {
|
||||
|
||||
int oiio_blit(struct ncvisual* ncv, int rows, int cols,
|
||||
ncplane* n, const struct blitset* bset,
|
||||
int begy, int begx, int leny, int lenx, const blitterargs* bargs) {
|
||||
int leny, int lenx, const blitterargs* bargs) {
|
||||
//fprintf(stderr, "%d/%d -> %d/%d on the resize\n", ncv->rows, ncv->cols, rows, cols);
|
||||
void* data = nullptr;
|
||||
int stride = 0;
|
||||
@ -163,8 +163,7 @@ int oiio_blit(struct ncvisual* ncv, int rows, int cols,
|
||||
data = ncv->data;
|
||||
stride = ncv->rowstride;
|
||||
}
|
||||
return oiio_blit_dispatch(n, bset, stride, data, begy, begx, leny, lenx, bargs);
|
||||
return 0;
|
||||
return oiio_blit_dispatch(n, bset, stride, data, leny, lenx, bargs);
|
||||
}
|
||||
|
||||
// FIXME before we can enable this, we need build an OIIO::APPBUFFER-style
|
||||
|
@ -12,14 +12,14 @@ struct ncvisual_details* oiio_details_init(void);
|
||||
void oiio_printbanner(const struct notcurses* nc);
|
||||
int oiio_blit(ncvisual* ncv, int rows, int cols,
|
||||
struct ncplane* n, const struct blitset* bset,
|
||||
int begy, int begx, int leny, int lenx, const blitterargs* bargs);
|
||||
int leny, int lenx, const blitterargs* bargs);
|
||||
ncvisual* oiio_from_file(const char* filename);
|
||||
int oiio_decode_loop(ncvisual* ncv);
|
||||
int oiio_resize(ncvisual* nc, int rows, int cols);
|
||||
ncvisual* oiio_create(void);
|
||||
void oiio_destroy(ncvisual* ncv);
|
||||
int oiio_blit_dispatch(struct ncplane* nc, const struct blitset* bset,
|
||||
int linesize, const void* data, int begy, int begx,
|
||||
int linesize, const void* data,
|
||||
int leny, int lenx, const blitterargs* bargs);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
Loading…
Reference in New Issue
Block a user