start in on unified hires blitter (sex/oct)

This commit is contained in:
nick black 2024-12-26 23:04:02 -05:00 committed by nick black
parent 27b49941a4
commit e4a777f940
3 changed files with 24 additions and 14 deletions

View File

@ -130,7 +130,7 @@ endif()
if(MSVC) if(MSVC)
add_compile_options(/W4) add_compile_options(/W4)
else() 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) # -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-signed-zeros -fno-trapping-math -fassociative-math)
add_compile_options(-fno-math-errno -freciprocal-math -funsafe-math-optimizations) add_compile_options(-fno-math-errno -freciprocal-math -funsafe-math-optimizations)

View File

@ -653,11 +653,12 @@ sex_trans_check(nccell* c, const uint32_t rgbas[6], unsigned blendcolors,
return egc; return egc;
} }
// sextant blitter. maps 3x2 to each cell. since we only have two colors at // sextant/octant blitter. maps 3x2 or 4x2 to each cell. since we only have two
// our disposal (foreground and background), we lose some fidelity. // colors at our disposal (foreground and background), we generally lose some
// color fidelity.
static inline int static inline int
sextant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, hires_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx,
const blitterargs* bargs){ const blitterargs* bargs, int cellheight){
const unsigned nointerpolate = bargs->flags & NCVISUAL_OPTION_NOINTERPOLATE; const unsigned nointerpolate = bargs->flags & NCVISUAL_OPTION_NOINTERPOLATE;
const bool blendcolors = bargs->flags & NCVISUAL_OPTION_BLEND; const bool blendcolors = bargs->flags & NCVISUAL_OPTION_BLEND;
unsigned dimy, dimx, x, y; 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); //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; const unsigned char* dat = data;
int visy = bargs->begy; 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)){ if(ncplane_cursor_move_yx(nc, y, bargs->u.cell.placex < 0 ? 0 : bargs->u.cell.placex)){
return -1; return -1;
} }
int visx = bargs->begx; int visx = bargs->begx;
for(x = bargs->u.cell.placex ; visx < (bargs->begx + lenx) && x < dimx ; ++x, visx += 2){ 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)); memcpy(&rgbas[0], (dat + (linesize * visy) + (visx * 4)), sizeof(*rgbas));
if(visx < bargs->begx + lenx - 1){ if(visx < bargs->begx + lenx - 1){
memcpy(&rgbas[1], (dat + (linesize * visy) + ((visx + 1) * 4)), sizeof(*rgbas)); 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; 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: // Bit is set where octant is present:
// 0 1 // 0 1
// 2 3 // 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); 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 // NCBLIT_DEFAULT is not included, as it has no defined properties. It ought
// be replaced with some real blitter implementation by the calling widget. // be replaced with some real blitter implementation by the calling widget.
// The order of contents is critical for 'egcs': ncplane_as_rgba() uses these // The order of contents is critical for 'egcs': ncplane_as_rgba() uses these

View File

@ -735,6 +735,7 @@ static const char*
apply_kitty_heuristics(tinfo* ti, size_t* tablelen, size_t* tableused){ apply_kitty_heuristics(tinfo* ti, size_t* tablelen, size_t* tableused){
// see https://sw.kovidgoyal.net/kitty/protocol-extensions.html // see https://sw.kovidgoyal.net/kitty/protocol-extensions.html
ti->bg_collides_default |= 0x1000000; ti->bg_collides_default |= 0x1000000;
ti->caps.octants = true;
ti->caps.sextants = true; // work since bugfix in 0.19.3 ti->caps.sextants = true; // work since bugfix in 0.19.3
ti->caps.quadrants = true; ti->caps.quadrants = true;
ti->caps.rgb = 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 // run a wcwidth(𜴀) to guarantee libc Unicode 16 support, independent of term
if(wcwidth(L'𜴀') < 0){ if(wcwidth(L'𜴀') < 0){
ti->caps.octants = false; // ti->caps.octants = false;
} }
ti->termname = tname; ti->termname = tname;
return 0; return 0;