Skip to content

Commit

Permalink
rgba_blitter_default: just take tcache #1334
Browse files Browse the repository at this point in the history
  • Loading branch information
dankamongmen committed Feb 7, 2021
1 parent 568e83e commit 833f1b1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/lib/blit.c
Original file line number Diff line number Diff line change
Expand Up @@ -913,5 +913,5 @@ int ncblit_rgba(const void* data, int linesize, const struct ncvisual_options* v
}

ncblitter_e ncvisual_media_defblitter(const notcurses* nc, ncscale_e scale){
return rgba_blitter_default(nc->tcache.utf8, scale, nc->tcache.sextants);
return rgba_blitter_default(&nc->tcache, scale);
}
13 changes: 6 additions & 7 deletions src/lib/blitset.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,24 @@ encoding_x_scale(const struct blitset* bset) {

// Expand NCBLIT_DEFAULT for media blitting, based on environment.
static inline ncblitter_e
rgba_blitter_default(bool utf8, ncscale_e scale, bool sextants){
if(!utf8){
rgba_blitter_default(const tinfo* tcache, ncscale_e scale){
if(!tcache->utf8){
return NCBLIT_1x1;
}
if(scale == NCSCALE_NONE || scale == NCSCALE_SCALE){
return NCBLIT_2x1;
}
if(!sextants){
if(!tcache->sextants){
return NCBLIT_2x2;
}
return NCBLIT_3x2;
}

static inline const struct blitset*
rgba_blitter_low(const tinfo* tcache, bool sextants, ncscale_e scale, bool maydegrade,
rgba_blitter_low(const tinfo* tcache, ncscale_e scale, bool maydegrade,
ncblitter_e blitrec) {
if(blitrec == NCBLIT_DEFAULT){
blitrec = rgba_blitter_default(tcache->utf8, scale, sextants);
blitrec = rgba_blitter_default(tcache, scale);
}
const struct blitset* bset = lookup_blitset(tcache, blitrec, maydegrade);
if(bset && !bset->blit){ // FIXME remove this once all blitters are enabled
Expand All @@ -72,8 +72,7 @@ static inline const struct blitset*
rgba_blitter(const struct notcurses* nc, const struct ncvisual_options* opts) {
const bool maydegrade = !(opts && (opts->flags & NCVISUAL_OPTION_NODEGRADE));
const ncscale_e scale = opts ? opts->scaling : NCSCALE_NONE;
return rgba_blitter_low(&nc->tcache, notcurses_cansextant(nc),
scale, maydegrade, opts ? opts->blitter : NCBLIT_DEFAULT);
return rgba_blitter_low(&nc->tcache, scale, maydegrade, opts ? opts->blitter : NCBLIT_DEFAULT);
}

#endif
2 changes: 1 addition & 1 deletion src/lib/direct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ ncdirectv* ncdirect_render_frame(ncdirect* n, const char* file,
return nullptr;
}
//fprintf(stderr, "render %d/%d to %d+%d scaling: %d\n", ncv->rows, ncv->cols, leny, lenx, scale);
auto bset = rgba_blitter_low(&n->tcache, n->tcache.sextants, scale, true, blitter);
auto bset = rgba_blitter_low(&n->tcache, scale, true, blitter);
if(!bset){
ncvisual_destroy(ncv);
return nullptr;
Expand Down

0 comments on commit 833f1b1

Please sign in to comment.