[ncvisual] refuse to blit bitmaps to standard plane

This commit is contained in:
nick black 2021-03-21 17:07:47 -04:00 committed by Nick Black
parent 1599e026cd
commit a6548fbcc8
3 changed files with 15 additions and 8 deletions

View File

@ -4,6 +4,8 @@ rearrangements of Notcurses.
* 2.2.4 (not yet released)
* Implemented **EXPERIMENTAL** `NCBLIT_PIXEL` for terminals reporting the
Kitty pixel graphics protocol.
* Added `notcurses_debug_caps()` to dump terminal properties, both those
reported and those inferred, to a `FILE*`.
* 2.2.3 (2021-03-08)
* Implemented **EXPERIMENTAL** `NCBLIT_PIXEL` for terminals reporting Sixel

View File

@ -218,9 +218,11 @@ check for support with **notcurses_check_pixel_support**. If this function has
not successfully returned, attempts to use **NCBLIT_PIXEL** will fall back to
**NCBLIT_3x2** (or fail, if **NCVISUAL_OPTION_NODEGRADE** is used).
Pixel blitting creates a new, immutable, purpose-specific plane. Attempting
to pass a non-**NULL** ***n*** in **ncvisual_options** will result in an error
if **NCBLIT_PIXEL** is used.
Bitmaps cannot be blitted to the standard plane; an attempt to do so will be
rejected as an error. Only one bitmap can be blitted onto a plane at a time
(but multiple planes with bitmaps may be visible); blitting a second to the
same plane will delete the original. Destroying the plane with which a bitmap
is associated will delete the bitmap.
# RETURN VALUES

View File

@ -483,7 +483,12 @@ ncplane* ncvisual_render_cells(notcurses* nc, ncvisual* ncv, const struct blitse
ncplane* ncvisual_render_pixels(notcurses* nc, ncvisual* ncv, const struct blitset* bset,
int placey, int placex, int begy, int begx,
ncplane* n, ncscale_e scaling, ncplane* stdn){
ncplane* n, ncscale_e scaling){
ncplane* stdn = notcurses_stdplane(nc);
if(stdn == n){
logerror(nc, "Won't render bitmaps to the standard plane\n");
return NULL;
}
int disprows = 0, dispcols = 0;
if(scaling == NCSCALE_NONE || scaling == NCSCALE_NONE_HIRES){
dispcols = ncv->cols;
@ -584,11 +589,9 @@ ncplane* ncvisual_render(notcurses* nc, ncvisual* ncv, const struct ncvisual_opt
ncscale_e scaling = vopts ? vopts->scaling : NCSCALE_NONE;
if(bset->geom != NCBLIT_PIXEL){
n = ncvisual_render_cells(nc, ncv, bset, placey, placex, begy, begx, leny, lenx,
n, scaling,
vopts && (vopts->flags & NCVISUAL_OPTION_BLEND));
n, scaling, vopts && (vopts->flags & NCVISUAL_OPTION_BLEND));
}else{
n = ncvisual_render_pixels(nc, ncv, bset, placey, placex, begy, begx,
n, scaling, notcurses_stdplane(nc));
n = ncvisual_render_pixels(nc, ncv, bset, placey, placex, begy, begx, n, scaling);
}
return n;
}