plots: use pool_blit_direct() #1182

Use pool_blit_direct() instead of ncplane_putwc_yx() in
redraw_plot(). This eliminates use of rtl_egc() and wcwidth()
on the EGCs used in plots, sidestepping Debian's -1 wcwidth
for sextants (in the same fashion blitting does) and slightly
speeding up plot drawing. At a plot rate of 10Hz, notcurses-demo
is now faster than it used to be at 1Hz, so that's nice.
dankamongmen/ltr
nick black 4 years ago
parent 93f7f681a4
commit a7f59e4fab
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -26,6 +26,7 @@ The following have been established on a Debian Unstable workstation.
| Sakura | ✔ |`TERM=vte-256color` `COLORTERM=24bit` | No terminfo entry? |
| mlterm | 🗴 |`TERM=mlterm-256color` | Do not set `COLORTERM`. `mlterm-direct` gives strange results. |
| st | ✔ |`TERM=st-256color` `COLORTERM=24bit` | |
| wterm | | | |
| GNU Screen | 🗴 |`TERM=screen.OLDTERM` | Must be compiled with `--enable-256color`. `TERM` should typically be `screen.` suffixed by the appropriate `TERM` value for the true connected terminal, e.g. `screen.vte-256color`. See below. |
| tmux | | | |

@ -502,7 +502,7 @@ int hud_schedule(const char* demoname){
return hud_print_finished(elems);
}
// wake up every 100ms and render a frame so the HUD doesn't appear locked up.
// wake up every 10ms and render a frame so the HUD doesn't appear locked up.
// provide an absolute deadline calculated via CLOCK_MONOTONIC.
static int
demo_nanosleep_abstime_ns(struct notcurses* nc, uint64_t deadline){

@ -788,7 +788,7 @@ const struct blitset notcurses_blitters[] = {
{ .geom = NCBLIT_2x2, .width = 2, .height = 2, .egcs = L" ▗▐▖▄▟▌▙█",
.blit = quadrant_blit, .name = "quadblitter", .fill = false, },
{ .geom = NCBLIT_3x2, .width = 2, .height = 3, .egcs = L" 🬞🬦▐🬏🬭🬵🬷🬓🬱🬹🬻▌🬲🬺█",
.blit = sextant_blit, .name = "sexblitter", .fill = false, },
.blit = sextant_blit, .name = "sexblitter", .fill = false, },
{ .geom = NCBLIT_4x1, .width = 1, .height = 4, .egcs = L" ▂▄▆█",
.blit = tria_blit, .name = "fourstep", .fill = false, },
{ .geom = NCBLIT_BRAILLE, .width = 2, .height = 4, .egcs = L"⠀⢀⢠⢰⢸⡀⣀⣠⣰⣸⡄⣄⣤⣴⣼⡆⣆⣦⣶⣾⡇⣇⣧⣷⣿",

@ -227,11 +227,9 @@ class ncppplot {
double scaled = log(gvals[i] - miny) / log(interval);
double sival = intervalbase ? log(intervalbase) / log(interval) : 0;
egcidx = scaled - sival;
//fprintf(stderr, "egcidx: %zu gvals: %u interval: %f scaled: %f sival: %f\n", egcidx, gvals[i], interval, scaled, sival);
}else{
egcidx = (gvals[i] - intervalbase) / interval;
}
//fprintf(stderr, "%d/%d ibase: %f ival: %f egcidx: %zu\n", dimy - y - 1, x, intervalbase, interval, egcidx);
if(egcidx >= states){
egcidx = states - 1;
done = false;
@ -246,8 +244,19 @@ class ncppplot {
// we need handle ASCII differently, since it can't print full block.
// in ASCII mode, egcidx != means swap colors and use space.
if(sumidx){
//fprintf(stderr, "dimy: %d y: %d x: %d sumidx: %zu egc[%zu]: %lc\n", dimy, y, x, sumidx, sumidx, egc[sumidx]);
if(notcurses_canutf8(ncplane_notcurses(ncp))){
if(ncplane_putwc_yx(ncp, dimy - y - 1, x, egc[sumidx]) <= 0){
char utf8[MB_CUR_MAX + 1];
int bytes = wctomb(utf8, egc[sumidx]);
if(bytes < 0){
return -1;
}
utf8[bytes] = '\0';
cell* c = ncplane_cell_ref_yx(ncp, dimy - y - 1, x);
cell_set_bchannel(c, channels_bchannel(channels));
cell_set_fchannel(c, channels_fchannel(channels));
cell_set_styles(c, NCSTYLE_NONE);
if(pool_blit_direct(&ncp->pool, c, utf8, bytes, 1) <= 0){
return -1;
}
}else{

Loading…
Cancel
Save