ncvisual: plumb blitterargs all the way through the stack #1389

pull/1414/head
nick black 3 years ago
parent dc118e54f6
commit 63b4e74800
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -513,8 +513,14 @@ ncdirectv* ncdirect_render_frame(ncdirect* n, const char* file,
ncvisual_destroy(ncv);
return nullptr;
}
blitterargs bargs = {
.pixel = {
.celldimx = n->tcache.cellpixx,
.colorregs = n->tcache.color_registers,
},
};
if(ncvisual_blit(ncv, disprows, dispcols, ncdv, bset,
0, 0, 0, 0, leny, lenx, n->tcache.cellpixx)){
0, 0, 0, 0, leny, lenx, &bargs)){
ncvisual_destroy(ncv);
free_plane(ncdv);
return nullptr;

@ -873,7 +873,7 @@ ALLOC char* ncplane_vprintf_prep(const char* format, va_list ap);
int ncvisual_blit(struct ncvisual* ncv, int rows, int cols,
ncplane* n, const struct blitset* bset,
int placey, int placex, int begy, int begx,
int leny, int lenx, unsigned blendcolors);
int leny, int lenx, const blitterargs* bargs);
void nclog(const char* fmt, ...);
@ -1228,12 +1228,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 placey,
int placex, int linesize, const void* data, int begy,
int begx, int leny, int lenx, unsigned blendcolors){
blitterargs bargs = {
.blendcolors = blendcolors,
};
int begx, int leny, int lenx, const blitterargs* bargs){
return bset->blit(nc, placey, placex, linesize, data, begy, begx,
leny, lenx, &bargs);
leny, lenx, bargs);
}
static inline const struct blitset*
@ -1260,7 +1257,7 @@ typedef struct ncvisual_implementation {
int (*visual_blit)(struct ncvisual* ncv, int rows, int cols, ncplane* n,
const struct blitset* bset, int placey, int placex,
int begy, int begx, int leny, int lenx,
unsigned blendcolors);
const blitterargs* barg);
struct ncvisual* (*visual_create)(void);
struct ncvisual* (*visual_from_file)(const char* fname);
// ncv constructors other than ncvisual_from_file() need to set up the

@ -16,16 +16,16 @@ auto ncvisual_decode(ncvisual* nc) -> int {
auto ncvisual_blit(ncvisual* ncv, int rows, int cols, ncplane* n,
const struct blitset* bset, int placey, int placex,
int begy, int begx, int leny, int lenx,
unsigned blendcolors) -> int {
const blitterargs* barg) -> int {
int ret = -1;
if(visual_implementation){
if(visual_implementation->visual_blit(ncv, rows, cols, n, bset, placey, placex,
begy, begx, leny, lenx, blendcolors) >= 0){
begy, begx, leny, lenx, barg) >= 0){
ret = 0;
}
}else{
if(rgba_blit_dispatch(n, bset, placey, placex, ncv->rowstride, ncv->data,
begy, begx, leny, lenx, blendcolors) >= 0){
begy, begx, leny, lenx, barg) >= 0){
ret = 0;
}
}
@ -471,8 +471,10 @@ auto ncvisual_render_cells(notcurses* nc, ncvisual* ncv, const blitset* bset,
leny = (leny / (double)ncv->rows) * ((double)disprows);
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.blendcolors = blendcolors;
if(ncvisual_blit(ncv, disprows, dispcols, n, bset,
placey, placex, begy, begx, leny, lenx, blendcolors)){
placey, placex, begy, begx, leny, lenx, &bargs)){
ncplane_destroy(n);
return nullptr;
}
@ -524,9 +526,11 @@ auto ncvisual_render_pixels(tinfo* tcache, ncvisual* ncv, const blitset* bset,
scale_visual(ncv, &disprows, &dispcols);
}
//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, ncplane_notcurses(stdn)->tcache.cellpixx);
blitterargs bargs;
bargs.pixel.celldimx = ncplane_notcurses(stdn)->tcache.cellpixx;
bargs.pixel.colorregs = ncplane_notcurses(stdn)->tcache.color_registers;
if(ncvisual_blit(ncv, disprows, dispcols, n, bset,
placey, placex, begy, begx, disprows, dispcols,
ncplane_notcurses(stdn)->tcache.cellpixx)){
placey, placex, begy, begx, disprows, dispcols, &bargs)){
ncplane_destroy(n);
return nullptr;
}

@ -469,7 +469,7 @@ int ffmpeg_decode_loop(ncvisual* ncv){
int ffmpeg_blit(ncvisual* ncv, int rows, int cols, ncplane* n,
const struct blitset* bset, int placey, int placex,
int begy, int begx, int leny, int lenx, unsigned blendcolors) {
int begy, int begx, 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);
void* data = nullptr;
@ -523,7 +523,7 @@ int ffmpeg_blit(ncvisual* ncv, int rows, int cols, ncplane* n,
}
//fprintf(stderr, "place: %d/%d rows/cols: %d/%d %d/%d+%d/%d\n", placey, placex, rows, cols, begy, begx, leny, lenx);
if(rgba_blit_dispatch(n, bset, placey, placex, stride, data, begy, begx,
leny, lenx, blendcolors) < 0){
leny, lenx, bargs) < 0){
//fprintf(stderr, "rgba dispatch failed!\n");
if(sframe){
av_freep(sframe->data);

@ -150,7 +150,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 placey, int placex, int begy, int begx,
int leny, int lenx, unsigned blendcolors) {
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;
@ -172,7 +172,7 @@ int oiio_blit(struct ncvisual* ncv, int rows, int cols,
stride = ncv->rowstride;
}
return oiio_blit_dispatch(n, bset, placey, placex, stride, data,
begy, begx, leny, lenx, blendcolors);
begy, begx, leny, lenx, bargs);
return 0;
}

Loading…
Cancel
Save