From a9fd1542e4b09e51ee63e504dad70e78b5b079a6 Mon Sep 17 00:00:00 2001 From: nick black Date: Mon, 1 Nov 2021 20:30:03 -0400 Subject: [PATCH] [geom] properly copy alignments through #1684 --- src/lib/notcurses.c | 12 ++++++------ src/lib/visual.c | 15 +++++++++++---- src/tests/bitmap.cpp | 1 + 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index 745a2d786..f6ac1de12 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -421,22 +421,22 @@ make_ncpile(notcurses* nc, ncplane* n){ ncplane* ncplane_new_internal(notcurses* nc, ncplane* n, const ncplane_options* nopts){ if(nopts->flags >= (NCPLANE_OPTION_FIXED << 1u)){ - logwarn("Provided unsupported flags %016" PRIx64 "\n", nopts->flags); + logwarn("provided unsupported flags %016" PRIx64 "\n", nopts->flags); } if(nopts->flags & NCPLANE_OPTION_HORALIGNED || nopts->flags & NCPLANE_OPTION_VERALIGNED){ if(n == NULL){ - logerror("Alignment requires a parent plane\n"); + logerror("alignment requires a parent plane\n"); return NULL; } } if(nopts->flags & NCPLANE_OPTION_MARGINALIZED){ if(nopts->rows != 0 || nopts->cols != 0){ - logerror("Geometry specified with margins (r=%d, c=%d)\n", + logerror("geometry specified with margins (r=%d, c=%d)\n", nopts->rows, nopts->cols); return NULL; } }else if(nopts->rows <= 0 || nopts->cols <= 0){ - logerror("Won't create denormalized plane (r=%d, c=%d)\n", + logerror("won't create denormalized plane (r=%d, c=%d)\n", nopts->rows, nopts->cols); return NULL; } @@ -467,7 +467,7 @@ ncplane* ncplane_new_internal(notcurses* nc, ncplane* n, } size_t fbsize = sizeof(*p->fb) * (p->leny * p->lenx); if((p->fb = malloc(fbsize)) == NULL){ - logerror("Error allocating cellmatrix (r=%d, c=%d)\n", + logerror("error allocating cellmatrix (r=%d, c=%d)\n", p->leny, p->lenx); free(p); return NULL; @@ -540,7 +540,7 @@ ncplane* ncplane_new_internal(notcurses* nc, ncplane* n, pthread_mutex_unlock(&nc->stats.lock); pthread_mutex_unlock(&nc->pilelock); } - loginfo("Created new %dx%d plane \"%s\" @ %dx%d\n", + loginfo("created new %dx%d plane \"%s\" @ %dx%d\n", p->leny, p->lenx, p->name ? p->name : "", p->absy, p->absx); return p; } diff --git a/src/lib/visual.c b/src/lib/visual.c index cf0186eb6..8c50e1fdd 100644 --- a/src/lib/visual.c +++ b/src/lib/visual.c @@ -1024,6 +1024,7 @@ ncplane* ncvisual_render_pixels(notcurses* nc, ncvisual* ncv, const struct blits int placey, int placex, const ncvgeom* geom, ncplane* n, uint64_t flags, uint32_t transcolor, int pxoffy, int pxoffx){ + logdebug("pblit: rows/cols: %dx%d plane: %d/%d\n", geom->rcelly, geom->rcellx, ncplane_dim_y(n), ncplane_dim_x(n)); const tinfo* ti = &nc->tcache; blitterargs bargs; bargs.transcolor = transcolor; @@ -1035,7 +1036,6 @@ ncplane* ncvisual_render_pixels(notcurses* nc, ncvisual* ncv, const struct blits bargs.u.pixel.colorregs = ti->color_registers; bargs.u.pixel.pxoffy = pxoffy; bargs.u.pixel.pxoffx = pxoffx; - logdebug("pblit: rows/cols: %dx%d plane: %d/%d\n", geom->rcelly, geom->rcellx, ncplane_dim_y(n), ncplane_dim_x(n)); if(n->sprite == NULL){ if((n->sprite = sprixel_alloc(&nc->tcache, n, geom->rcelly, geom->rcellx)) == NULL){ return NULL; @@ -1135,9 +1135,16 @@ ncplane* ncvisual_blit(notcurses* nc, ncvisual* ncv, const struct ncvisual_optio .userptr = NULL, .name = geom.blitter == NCBLIT_PIXEL ? "bmap" : "cvis", .resizecb = NULL, - .flags = ((vopts->flags & NCVISUAL_OPTION_HORALIGNED) ? NCPLANE_OPTION_HORALIGNED : 0) - | ((vopts->flags & NCVISUAL_OPTION_VERALIGNED) ? NCPLANE_OPTION_VERALIGNED : 0), + .flags = 0, }; + if(vopts->flags & NCVISUAL_OPTION_HORALIGNED){ + nopts.flags |= NCPLANE_OPTION_HORALIGNED; + nopts.x = vopts->x; + } + if(vopts->flags & NCVISUAL_OPTION_VERALIGNED){ + nopts.flags |= NCPLANE_OPTION_VERALIGNED; + nopts.y = vopts->y; + } loginfo("placing new plane: %d/%d @ %d/%d 0x%016lx\n", nopts.rows, nopts.cols, nopts.y, nopts.x, nopts.flags); if(n == NULL){ n = ncpile_create(nc, &nopts); @@ -1150,7 +1157,7 @@ ncplane* ncvisual_blit(notcurses* nc, ncvisual* ncv, const struct ncvisual_optio placey = 0; placex = 0; } -//fprintf(stderr, "PLACING NEW PLANE: %d/%d @ %d/%d %d/%d\n", disprows, dispcols, placey, placex, begy, begx); + logdebug("blit to plane %p at %d/%d geom %dx%d\n", n, ncplane_y(n), ncplane_x(n), ncplane_dim_y(n), ncplane_dim_x(n)); if(geom.blitter != NCBLIT_PIXEL){ n = ncvisual_render_cells(ncv, bset, placey, placex, &geom, n, vopts->flags, transcolor); diff --git a/src/tests/bitmap.cpp b/src/tests/bitmap.cpp index e938b7503..497ac3d0d 100644 --- a/src/tests/bitmap.cpp +++ b/src/tests/bitmap.cpp @@ -362,6 +362,7 @@ TEST_CASE("Bitmaps") { REQUIRE(nullptr != ncv); auto child = ncvisual_blit(nc_, ncv, &vopts); REQUIRE(child); + CHECK(0 == notcurses_render(nc_)); CHECK(18 == ncplane_dim_y(child)); CHECK(5 == ncplane_dim_x(child)); CHECK(0 == ncplane_y(child));