mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 09:09:03 -04:00
expose ncvisual_default_blitter(), name blitter in notcurses-view #995
This commit is contained in:
parent
9c5d6eca27
commit
f88c8ae79c
4
NEWS.md
4
NEWS.md
@ -1,6 +1,10 @@
|
||||
This document attempts to list user-visible changes and any major internal
|
||||
rearrangements of Notcurses.
|
||||
|
||||
* 1.7.2 (not yet released)
|
||||
* Exported `ncvisual_default_blitter()`, so that the effective value of
|
||||
`NCBLIT_DEFAULT` can be determined.
|
||||
|
||||
* 1.7.1 (2020-08-31)
|
||||
* Renamed `CELL_SIMPLE_INITIALIZER` to `CELL_CHAR_INITIALIZER`, and
|
||||
`cell_load_simple()` to `cell_load_char()`.
|
||||
|
@ -90,6 +90,8 @@ typedef int (*streamcb)(struct notcurses*, struct ncvisual*, void*);
|
||||
|
||||
**const char* notcurses_str_blitter(ncblitter_e blitter);**
|
||||
|
||||
**ncblitter_e ncvisual_default_blitter(bool utf8, ncscale_e scaling);**
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
An **ncvisual** is a virtual pixel framebuffer. They can be created from
|
||||
|
@ -3089,6 +3089,20 @@ struct blitset {
|
||||
|
||||
API extern const struct blitset notcurses_blitters[];
|
||||
|
||||
static inline ncblitter_e
|
||||
ncvisual_default_blitter(bool utf8, ncscale_e scale){
|
||||
if(utf8){
|
||||
// NCBLIT_2x2 is better image quality, especially for large images, but
|
||||
// it's not the general default because it doesn't preserve aspect ratio.
|
||||
// NCSCALE_STRETCH throws away aspect ratio, and can safely use NCBLIT_2x2.
|
||||
if(scale == NCSCALE_STRETCH){
|
||||
return NCBLIT_2x2;
|
||||
}
|
||||
return NCBLIT_2x1;
|
||||
}
|
||||
return NCBLIT_1x1;
|
||||
}
|
||||
|
||||
#undef API
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -39,20 +39,6 @@ encoding_x_scale(const struct blitset* bset) {
|
||||
return bset->width;
|
||||
}
|
||||
|
||||
static inline ncblitter_e
|
||||
ncvisual_default_blitter(bool utf8, ncscale_e scale) {
|
||||
if(utf8){
|
||||
// NCBLIT_2x2 is better image quality, especially for large images, but
|
||||
// it's not the general default because it doesn't preserve aspect ratio.
|
||||
// NCSCALE_STRETCH throws away aspect ratio, and can safely use NCBLIT_2x2.
|
||||
if(scale == NCSCALE_STRETCH){
|
||||
return NCBLIT_2x2;
|
||||
}
|
||||
return NCBLIT_2x1;
|
||||
}
|
||||
return NCBLIT_1x1;
|
||||
}
|
||||
|
||||
static inline const struct blitset*
|
||||
rgba_blitter_low(bool utf8, ncscale_e scale, bool maydegrade, ncblitter_e blitrec) {
|
||||
const struct blitset* bset;
|
||||
|
@ -60,9 +60,14 @@ auto perframe(struct ncvisual* ncv, struct ncvisual_options* vopts,
|
||||
struct timespec now;
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
intmax_t ns = timespec_to_ns(&now) - timespec_to_ns(start);
|
||||
auto blitter = vopts->blitter;
|
||||
if(blitter == NCBLIT_DEFAULT){
|
||||
blitter = ncvisual_default_blitter(notcurses_canutf8(nc), vopts->scaling);
|
||||
vopts->blitter = blitter;
|
||||
}
|
||||
// clear top line only
|
||||
stdn->printf(0, NCAlign::Left, "frame %06d\u2026 (%s)", *framecount,
|
||||
notcurses_str_blitter(vopts->blitter));
|
||||
notcurses_str_blitter(blitter));
|
||||
char* subtitle = ncvisual_subtitle(ncv);
|
||||
if(subtitle){
|
||||
if(!subtitle_plane){
|
||||
|
Loading…
x
Reference in New Issue
Block a user