[geom] properly copy alignments through #1684

pull/2320/head
nick black 3 years ago committed by nick black
parent 3476087dbf
commit a9fd1542e4

@ -421,22 +421,22 @@ make_ncpile(notcurses* nc, ncplane* n){
ncplane* ncplane_new_internal(notcurses* nc, ncplane* n, ncplane* ncplane_new_internal(notcurses* nc, ncplane* n,
const ncplane_options* nopts){ const ncplane_options* nopts){
if(nopts->flags >= (NCPLANE_OPTION_FIXED << 1u)){ 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(nopts->flags & NCPLANE_OPTION_HORALIGNED || nopts->flags & NCPLANE_OPTION_VERALIGNED){
if(n == NULL){ if(n == NULL){
logerror("Alignment requires a parent plane\n"); logerror("alignment requires a parent plane\n");
return NULL; return NULL;
} }
} }
if(nopts->flags & NCPLANE_OPTION_MARGINALIZED){ if(nopts->flags & NCPLANE_OPTION_MARGINALIZED){
if(nopts->rows != 0 || nopts->cols != 0){ 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); nopts->rows, nopts->cols);
return NULL; return NULL;
} }
}else if(nopts->rows <= 0 || nopts->cols <= 0){ }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); nopts->rows, nopts->cols);
return NULL; return NULL;
} }
@ -467,7 +467,7 @@ ncplane* ncplane_new_internal(notcurses* nc, ncplane* n,
} }
size_t fbsize = sizeof(*p->fb) * (p->leny * p->lenx); size_t fbsize = sizeof(*p->fb) * (p->leny * p->lenx);
if((p->fb = malloc(fbsize)) == NULL){ 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); p->leny, p->lenx);
free(p); free(p);
return NULL; return NULL;
@ -540,7 +540,7 @@ ncplane* ncplane_new_internal(notcurses* nc, ncplane* n,
pthread_mutex_unlock(&nc->stats.lock); pthread_mutex_unlock(&nc->stats.lock);
pthread_mutex_unlock(&nc->pilelock); 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); p->leny, p->lenx, p->name ? p->name : "", p->absy, p->absx);
return p; return p;
} }

@ -1024,6 +1024,7 @@ ncplane* ncvisual_render_pixels(notcurses* nc, ncvisual* ncv, const struct blits
int placey, int placex, const ncvgeom* geom, int placey, int placex, const ncvgeom* geom,
ncplane* n, uint64_t flags, uint32_t transcolor, ncplane* n, uint64_t flags, uint32_t transcolor,
int pxoffy, int pxoffx){ 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; const tinfo* ti = &nc->tcache;
blitterargs bargs; blitterargs bargs;
bargs.transcolor = transcolor; 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.colorregs = ti->color_registers;
bargs.u.pixel.pxoffy = pxoffy; bargs.u.pixel.pxoffy = pxoffy;
bargs.u.pixel.pxoffx = pxoffx; 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 == NULL){
if((n->sprite = sprixel_alloc(&nc->tcache, n, geom->rcelly, geom->rcellx)) == NULL){ if((n->sprite = sprixel_alloc(&nc->tcache, n, geom->rcelly, geom->rcellx)) == NULL){
return NULL; return NULL;
@ -1135,9 +1135,16 @@ ncplane* ncvisual_blit(notcurses* nc, ncvisual* ncv, const struct ncvisual_optio
.userptr = NULL, .userptr = NULL,
.name = geom.blitter == NCBLIT_PIXEL ? "bmap" : "cvis", .name = geom.blitter == NCBLIT_PIXEL ? "bmap" : "cvis",
.resizecb = NULL, .resizecb = NULL,
.flags = ((vopts->flags & NCVISUAL_OPTION_HORALIGNED) ? NCPLANE_OPTION_HORALIGNED : 0) .flags = 0,
| ((vopts->flags & NCVISUAL_OPTION_VERALIGNED) ? NCPLANE_OPTION_VERALIGNED : 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); loginfo("placing new plane: %d/%d @ %d/%d 0x%016lx\n", nopts.rows, nopts.cols, nopts.y, nopts.x, nopts.flags);
if(n == NULL){ if(n == NULL){
n = ncpile_create(nc, &nopts); n = ncpile_create(nc, &nopts);
@ -1150,7 +1157,7 @@ ncplane* ncvisual_blit(notcurses* nc, ncvisual* ncv, const struct ncvisual_optio
placey = 0; placey = 0;
placex = 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){ if(geom.blitter != NCBLIT_PIXEL){
n = ncvisual_render_cells(ncv, bset, placey, placex, n = ncvisual_render_cells(ncv, bset, placey, placex,
&geom, n, vopts->flags, transcolor); &geom, n, vopts->flags, transcolor);

@ -362,6 +362,7 @@ TEST_CASE("Bitmaps") {
REQUIRE(nullptr != ncv); REQUIRE(nullptr != ncv);
auto child = ncvisual_blit(nc_, ncv, &vopts); auto child = ncvisual_blit(nc_, ncv, &vopts);
REQUIRE(child); REQUIRE(child);
CHECK(0 == notcurses_render(nc_));
CHECK(18 == ncplane_dim_y(child)); CHECK(18 == ncplane_dim_y(child));
CHECK(5 == ncplane_dim_x(child)); CHECK(5 == ncplane_dim_x(child));
CHECK(0 == ncplane_y(child)); CHECK(0 == ncplane_y(child));

Loading…
Cancel
Save