mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 09:09:03 -04:00
stacking tests: ncvisual_render() -> ncvisual_blit() #1462
This commit is contained in:
parent
f096064648
commit
2c8286c099
27
USAGE.md
27
USAGE.md
@ -3301,8 +3301,8 @@ int ncvisual_set_yx(const struct ncvisual* n, int y, int x, uint32_t pixel);
|
||||
// If a subtitle ought be displayed at this time, return a new plane (bound
|
||||
// to 'parent' containing the subtitle, which might be text or graphics
|
||||
// (depending on the input format).
|
||||
struct ncplane* ncvisual_subtitle(struct ncplane* parent,
|
||||
const struct ncvisual* ncv);
|
||||
struct ncplane* ncvisual_subtitle_plane(struct ncplane* parent,
|
||||
const struct ncvisual* ncv);
|
||||
```
|
||||
|
||||
And finally, the `ncvisual` can be blitted to one or more `ncplane`s:
|
||||
@ -3424,27 +3424,8 @@ typedef int (*streamcb)(struct ncplane*, struct ncvisual*,
|
||||
// Shut up and display my frames! Provide as an argument to ncvisual_stream().
|
||||
// If you'd like subtitles to be decoded, provide an ncplane as the curry. If the
|
||||
// curry is NULL, subtitles will not be displayed.
|
||||
static inline int
|
||||
ncvisual_simple_streamer(struct ncplane* n, struct ncvisual* ncv,
|
||||
const struct timespec* tspec, void* curry){
|
||||
if(notcurses_render(ncplane_notcurses(n))){
|
||||
return -1;
|
||||
}
|
||||
int ret = 0;
|
||||
if(curry){
|
||||
// need a cast for C++ callers
|
||||
struct ncplane* subncp = (struct ncplane*)curry;
|
||||
char* subtitle = ncvisual_subtitle(ncv);
|
||||
if(subtitle){
|
||||
if(ncplane_putstr_yx(subncp, 0, 0, subtitle) < 0){
|
||||
ret = -1;
|
||||
}
|
||||
free(subtitle);
|
||||
}
|
||||
}
|
||||
clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, tspec, NULL);
|
||||
return ret;
|
||||
}
|
||||
int ncvisual_simple_streamer(struct ncvisual* ncv, struct ncvisual_options* vopts,
|
||||
const struct timespec* tspec, void* curry);
|
||||
|
||||
// Stream the entirety of the media, according to its own timing. Blocking,
|
||||
// obviously. streamer may be NULL; it is otherwise called for each frame, and
|
||||
|
@ -198,7 +198,8 @@ int outro(struct notcurses* nc){
|
||||
return -1;
|
||||
}
|
||||
vopts.scaling = NCSCALE_STRETCH;
|
||||
vopts.flags = NCVISUAL_OPTION_BLEND;
|
||||
vopts.flags = NCVISUAL_OPTION_BLEND | NCVISUAL_OPTION_CHILDPLANE;
|
||||
vopts.n = notcurses_stdplane(nc);
|
||||
if((vopts.n = ncvisual_blit(nc, chncv, &vopts)) == NULL){
|
||||
ncvisual_destroy(chncv);
|
||||
return -1;
|
||||
|
@ -14,6 +14,7 @@ draw_background(struct notcurses* nc){
|
||||
struct ncvisual_options vopts = {
|
||||
.scaling = NCSCALE_STRETCH,
|
||||
.n = n,
|
||||
.flags = NCVISUAL_OPTION_CHILDPLANE,
|
||||
};
|
||||
if(ncvisual_blit(nc, ncv, &vopts) == NULL){
|
||||
ncvisual_destroy(ncv);
|
||||
|
@ -70,6 +70,11 @@ ncplane* ncvisual_subtitle_plane(ncplane* parent, const ncvisual* ncv){
|
||||
return visual_implementation.visual_subtitle(parent, ncv);
|
||||
}
|
||||
|
||||
char* ncvisual_subtitle(const ncvisual* ncv){
|
||||
(void)ncv; // FIXME remove for abi3
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int ncvisual_blit_internal(ncvisual* ncv, int rows, int cols, ncplane* n,
|
||||
const struct blitset* bset, const blitterargs* barg){
|
||||
if(!(barg->flags & NCVISUAL_OPTION_NOINTERPOLATE)){
|
||||
|
@ -45,7 +45,7 @@ TEST_CASE("Stacking") {
|
||||
.leny = 2, .lenx = 1, .blitter = NCBLIT_2x1, .flags = 0,
|
||||
.transcolor = 0, .pxoffy = 0, .pxoffx = 0,
|
||||
};
|
||||
CHECK(top == ncvisual_render(nc_, ncv, &vopts));
|
||||
CHECK(top == ncvisual_blit(nc_, ncv, &vopts));
|
||||
ncvisual_destroy(ncv);
|
||||
|
||||
// create an ncvisual of 2 rows, 1 column, with the top 0xffffff
|
||||
@ -53,19 +53,24 @@ TEST_CASE("Stacking") {
|
||||
ncv = ncvisual_from_rgba(botv, 2, 4, 1);
|
||||
REQUIRE(nullptr != ncv);
|
||||
vopts.n = n_;
|
||||
CHECK(n_ == ncvisual_render(nc_, ncv, &vopts));
|
||||
vopts.flags |= NCVISUAL_OPTION_CHILDPLANE;
|
||||
auto newn = ncvisual_blit(nc_, ncv, &vopts);
|
||||
REQUIRE(nullptr != newn);
|
||||
ncvisual_destroy(ncv);
|
||||
ncplane_move_below(newn, top);
|
||||
|
||||
CHECK(0 == notcurses_render(nc_));
|
||||
uint64_t channels;
|
||||
auto egc = notcurses_at_yx(nc_, 0, 0, nullptr, &channels);
|
||||
REQUIRE(nullptr != egc);
|
||||
notcurses_debug(nc_, stderr);
|
||||
// ought yield space with white background FIXME currently just yields
|
||||
// a lower half block
|
||||
CHECK(0 == strcmp("\u2584", egc));
|
||||
CHECK(0xffffff == ncchannels_fg_rgb(channels));
|
||||
CHECK(0xffffff == ncchannels_bg_rgb(channels));
|
||||
ncplane_destroy(top);
|
||||
CHECK(0 == ncplane_destroy(top));
|
||||
CHECK(0 == ncplane_destroy(newn));
|
||||
}
|
||||
|
||||
SUBCASE("UpperAtopLowerWhite") {
|
||||
@ -83,7 +88,7 @@ TEST_CASE("Stacking") {
|
||||
.leny = 2, .lenx = 1, .blitter = NCBLIT_2x1, .flags = 0,
|
||||
.transcolor = 0, .pxoffy = 0, .pxoffx = 0,
|
||||
};
|
||||
CHECK(top == ncvisual_render(nc_, ncv, &vopts));
|
||||
CHECK(top == ncvisual_blit(nc_, ncv, &vopts));
|
||||
ncvisual_destroy(ncv);
|
||||
|
||||
// create an ncvisual of 2 rows, 1 column, with the bottom 0xffffff
|
||||
@ -91,8 +96,11 @@ TEST_CASE("Stacking") {
|
||||
ncv = ncvisual_from_rgba(botv, 2, 4, 1);
|
||||
REQUIRE(nullptr != ncv);
|
||||
vopts.n = n_;
|
||||
CHECK(n_ == ncvisual_render(nc_, ncv, &vopts));
|
||||
vopts.flags |= NCVISUAL_OPTION_CHILDPLANE;
|
||||
auto newn = ncvisual_blit(nc_, ncv, &vopts);
|
||||
REQUIRE(nullptr != newn);
|
||||
ncvisual_destroy(ncv);
|
||||
ncplane_move_below(newn, top);
|
||||
|
||||
CHECK(0 == notcurses_render(nc_));
|
||||
uint64_t channels;
|
||||
@ -103,7 +111,8 @@ TEST_CASE("Stacking") {
|
||||
CHECK(0 == strcmp("\u2580", egc));
|
||||
CHECK(0xffffff == ncchannels_fg_rgb(channels));
|
||||
CHECK(0xffffff == ncchannels_bg_rgb(channels));
|
||||
ncplane_destroy(top);
|
||||
CHECK(0 == ncplane_destroy(top));
|
||||
CHECK(0 == ncplane_destroy(newn));
|
||||
}
|
||||
|
||||
SUBCASE("StackedQuadHalves") {
|
||||
@ -122,7 +131,7 @@ TEST_CASE("Stacking") {
|
||||
.leny = 2, .lenx = 2, .blitter = NCBLIT_2x2, .flags = 0,
|
||||
.transcolor = 0, .pxoffy = 0, .pxoffx = 0,
|
||||
};
|
||||
CHECK(top == ncvisual_render(nc_, ncv, &vopts));
|
||||
CHECK(top == ncvisual_blit(nc_, ncv, &vopts));
|
||||
ncvisual_destroy(ncv);
|
||||
|
||||
// create an ncvisual of 2 rows, 2 columns, with the bottom 0xffffff
|
||||
@ -130,8 +139,11 @@ TEST_CASE("Stacking") {
|
||||
ncv = ncvisual_from_rgba(botv, 2, 8, 2);
|
||||
REQUIRE(nullptr != ncv);
|
||||
vopts.n = n_;
|
||||
CHECK(n_ == ncvisual_render(nc_, ncv, &vopts));
|
||||
vopts.flags = NCVISUAL_OPTION_CHILDPLANE;
|
||||
auto newn = ncvisual_blit(nc_, ncv, &vopts);
|
||||
REQUIRE(nullptr != newn);
|
||||
ncvisual_destroy(ncv);
|
||||
ncplane_move_below(newn, top);
|
||||
|
||||
CHECK(0 == notcurses_render(nc_));
|
||||
uint64_t channels;
|
||||
@ -142,7 +154,8 @@ TEST_CASE("Stacking") {
|
||||
CHECK(0 == strcmp("\u2580", egc));
|
||||
CHECK(0x00ff00 == ncchannels_fg_rgb(channels));
|
||||
CHECK(0x00ff00 == ncchannels_bg_rgb(channels));
|
||||
ncplane_destroy(top);
|
||||
CHECK(0 == ncplane_destroy(top));
|
||||
CHECK(0 == ncplane_destroy(newn));
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,7 +177,7 @@ TEST_CASE("Stacking") {
|
||||
.leny = 2, .lenx = 2, .blitter = NCBLIT_2x2, .flags = 0,
|
||||
.transcolor = 0, .pxoffy = 0, .pxoffx = 0,
|
||||
};
|
||||
CHECK(top == ncvisual_render(nc_, ncv, &vopts));
|
||||
CHECK(top == ncvisual_blit(nc_, ncv, &vopts));
|
||||
ncvisual_destroy(ncv);
|
||||
|
||||
// create an ncvisual of 2 rows, 2 columns, with the tr, bl 0xffffff
|
||||
@ -172,8 +185,11 @@ TEST_CASE("Stacking") {
|
||||
ncv = ncvisual_from_rgba(botv, 2, 8, 2);
|
||||
REQUIRE(nullptr != ncv);
|
||||
vopts.n = n_;
|
||||
CHECK(n_ == ncvisual_render(nc_, ncv, &vopts));
|
||||
vopts.flags = NCVISUAL_OPTION_CHILDPLANE;
|
||||
auto newn = ncvisual_blit(nc_, ncv, &vopts);
|
||||
REQUIRE(nullptr != newn);
|
||||
ncvisual_destroy(ncv);
|
||||
ncplane_move_below(newn, top);
|
||||
|
||||
CHECK(0 == notcurses_render(nc_));
|
||||
uint64_t channels;
|
||||
@ -184,7 +200,8 @@ TEST_CASE("Stacking") {
|
||||
CHECK(0 == strcmp("\u259a", egc)); // quadrant upper left and lower right
|
||||
CHECK(0xffffff == ncchannels_fg_rgb(channels));
|
||||
CHECK(0xffffff == ncchannels_bg_rgb(channels));
|
||||
ncplane_destroy(top);
|
||||
CHECK(0 == ncplane_destroy(top));
|
||||
CHECK(0 == ncplane_destroy(newn));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user