diff --git a/src/lib/direct.cpp b/src/lib/direct.cpp index a92e5f022..34493c1d9 100644 --- a/src/lib/direct.cpp +++ b/src/lib/direct.cpp @@ -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; diff --git a/src/lib/internal.h b/src/lib/internal.h index 08d79995b..207cacbc7 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -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 diff --git a/src/lib/visual.cpp b/src/lib/visual.cpp index 990944051..bea83179a 100644 --- a/src/lib/visual.cpp +++ b/src/lib/visual.cpp @@ -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; } diff --git a/src/media/ffmpeg.cpp b/src/media/ffmpeg.cpp index 67cd4db51..ad318ff02 100644 --- a/src/media/ffmpeg.cpp +++ b/src/media/ffmpeg.cpp @@ -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); diff --git a/src/media/oiio.cpp b/src/media/oiio.cpp index 8fdae1eb8..ac289a12a 100644 --- a/src/media/oiio.cpp +++ b/src/media/oiio.cpp @@ -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; }