-
-
Notifications
You must be signed in to change notification settings - Fork 140
Open
Labels
userquestionnot quite bugs--inquiries from usersnot quite bugs--inquiries from users
Description
Hello!
I noticed that ncplane_destroy_family is defined in internal.h and I wonder if it would make sense to export it as public?
In general i try to keep track of my own planes or merge & destroy the ones i don't wish to track.
Then i wished to support pixel graphics where available but since pixel-planes cannot be merged i was hoping to rely on ncplane_reparent to keep track of any conditionally created planes.. but that idea kinda blew up.
void blit_and_merge (struct notcurses *nc, struct ncplane *target, int rows, int cols) {
if (rows == -1) rows = ncplane_dim_y(target);
if (cols == -1) cols = ncplane_dim_x(target);
struct ncvisual *ncv = ncvisual_from_rgba(...)
bool use_pixels = notcurses_check_pixel_support(nc) <= 0;
if (use_pixels) {
struct ncvisual_options vopts = {
.scaling = NCSCALE_SCALE_HIRES,
.blitter = NCBLIT_PIXEL,
.leny = cols,
.lenx = rows
};
struct ncplane *cplane = ncvisual_blit(nc, ncv, &vopts);
ncplane_reparent(cplane, target);
// OUCH! cplane will leak on ncplane_destroy(target);
} else {
struct ncplane_options opts = {
.rows = rows,
.cols = cols,
};
struct ncplane *canvas = ncplane_create(target, &opts);
struct ncvisual_options vopts = {
.n = canvas,
.scaling = NCSCALE_STRETCH,
};
struct ncplane *cplane = ncvisual_blit(nc, ncv, &vopts);
assert(cplane == canvas);
int err = ncplane_mergedown_simple(canvas, target);
assert(err >= 0);
err = ncplane_destroy(canvas);
assert(err >= 0);
}
ncvisual_destroy(ncv);
}Metadata
Metadata
Assignees
Labels
userquestionnot quite bugs--inquiries from usersnot quite bugs--inquiries from users