mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 09:09:03 -04:00
start in on unified hires blitter (sex/oct)
This commit is contained in:
parent
27b49941a4
commit
e4a777f940
@ -130,7 +130,7 @@ endif()
|
||||
if(MSVC)
|
||||
add_compile_options(/W4)
|
||||
else()
|
||||
add_compile_options(-Wall -Wextra -W -Wshadow -Wvla -Wstrict-aliasing=2)
|
||||
add_compile_options(-Wall -Wextra -W -Wshadow -Wstrict-aliasing=2)
|
||||
# -ffast-math dies on NaNs we draw from libav (by -ffinite-math-only)
|
||||
add_compile_options(-fno-signed-zeros -fno-trapping-math -fassociative-math)
|
||||
add_compile_options(-fno-math-errno -freciprocal-math -funsafe-math-optimizations)
|
||||
|
@ -653,11 +653,12 @@ sex_trans_check(nccell* c, const uint32_t rgbas[6], unsigned blendcolors,
|
||||
return egc;
|
||||
}
|
||||
|
||||
// sextant blitter. maps 3x2 to each cell. since we only have two colors at
|
||||
// our disposal (foreground and background), we lose some fidelity.
|
||||
// sextant/octant blitter. maps 3x2 or 4x2 to each cell. since we only have two
|
||||
// colors at our disposal (foreground and background), we generally lose some
|
||||
// color fidelity.
|
||||
static inline int
|
||||
sextant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx,
|
||||
const blitterargs* bargs){
|
||||
hires_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx,
|
||||
const blitterargs* bargs, int cellheight){
|
||||
const unsigned nointerpolate = bargs->flags & NCVISUAL_OPTION_NOINTERPOLATE;
|
||||
const bool blendcolors = bargs->flags & NCVISUAL_OPTION_BLEND;
|
||||
unsigned dimy, dimx, x, y;
|
||||
@ -666,13 +667,15 @@ sextant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx,
|
||||
//fprintf(stderr, "sexblitter %dx%d -> %d/%d+%d/%d\n", leny, lenx, dimy, dimx, bargs->u.cell.placey, bargs->u.cell.placex);
|
||||
const unsigned char* dat = data;
|
||||
int visy = bargs->begy;
|
||||
for(y = bargs->u.cell.placey ; visy < (bargs->begy + leny) && y < dimy ; ++y, visy += 3){
|
||||
for(y = bargs->u.cell.placey ; visy < (bargs->begy + leny) && y < dimy ; ++y, visy += cellheight){
|
||||
if(ncplane_cursor_move_yx(nc, y, bargs->u.cell.placex < 0 ? 0 : bargs->u.cell.placex)){
|
||||
return -1;
|
||||
}
|
||||
int visx = bargs->begx;
|
||||
for(x = bargs->u.cell.placex ; visx < (bargs->begx + lenx) && x < dimx ; ++x, visx += 2){
|
||||
uint32_t rgbas[6] = { 0, 0, 0, 0, 0, 0 };
|
||||
uint32_t rgbas[cellheight * 2];
|
||||
memset(rgbas, 0, sizeof(rgbas));
|
||||
// FIXME need to handle this generally based off cellheight
|
||||
memcpy(&rgbas[0], (dat + (linesize * visy) + (visx * 4)), sizeof(*rgbas));
|
||||
if(visx < bargs->begx + lenx - 1){
|
||||
memcpy(&rgbas[1], (dat + (linesize * visy) + ((visx + 1) * 4)), sizeof(*rgbas));
|
||||
@ -711,6 +714,18 @@ sextant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx,
|
||||
return total;
|
||||
}
|
||||
|
||||
static inline int
|
||||
sextant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx,
|
||||
const blitterargs* bargs){
|
||||
return hires_blit(nc, linesize, data, leny, lenx, bargs, 3);
|
||||
}
|
||||
|
||||
static inline int
|
||||
octant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx,
|
||||
const blitterargs* bargs){
|
||||
return hires_blit(nc, linesize, data, leny, lenx, bargs, 4);
|
||||
}
|
||||
|
||||
// Bit is set where octant is present:
|
||||
// 0 1
|
||||
// 2 3
|
||||
@ -932,12 +947,6 @@ braille_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx,
|
||||
return blit_4x2(nc, linesize, data, leny, lenx, bargs, braille_egcs);
|
||||
}
|
||||
|
||||
static inline int
|
||||
octant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx,
|
||||
const blitterargs* bargs){
|
||||
return blit_4x2(nc, linesize, data, leny, lenx, bargs, octant_egcs);
|
||||
}
|
||||
|
||||
// NCBLIT_DEFAULT is not included, as it has no defined properties. It ought
|
||||
// be replaced with some real blitter implementation by the calling widget.
|
||||
// The order of contents is critical for 'egcs': ncplane_as_rgba() uses these
|
||||
|
@ -735,6 +735,7 @@ static const char*
|
||||
apply_kitty_heuristics(tinfo* ti, size_t* tablelen, size_t* tableused){
|
||||
// see https://sw.kovidgoyal.net/kitty/protocol-extensions.html
|
||||
ti->bg_collides_default |= 0x1000000;
|
||||
ti->caps.octants = true;
|
||||
ti->caps.sextants = true; // work since bugfix in 0.19.3
|
||||
ti->caps.quadrants = true;
|
||||
ti->caps.rgb = true;
|
||||
@ -1048,7 +1049,7 @@ apply_term_heuristics(tinfo* ti, const char* tname, queried_terminals_e qterm,
|
||||
}
|
||||
// run a wcwidth() to guarantee libc Unicode 16 support, independent of term
|
||||
if(wcwidth(L'') < 0){
|
||||
ti->caps.octants = false;
|
||||
// ti->caps.octants = false;
|
||||
}
|
||||
ti->termname = tname;
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user