further wipebitmap PoC flushwork

This commit is contained in:
nick black 2021-05-06 11:39:47 -04:00 committed by Nick Black
parent 00962bb99f
commit 88936490bb
6 changed files with 70 additions and 23 deletions

View File

@ -993,7 +993,7 @@ sprite_destroy(const notcurses* nc, const ncpile* p, FILE* out, sprixel* s){
// precondition: s->invalidated is SPRIXEL_INVALIDATED or SPRIXEL_MOVED.
static inline int
sprite_draw(const notcurses* n, const ncpile* p, sprixel* s, FILE* out){
//sprixel_debug(stderr, s);
sprixel_debug(stderr, s);
return n->tcache.pixel_draw(p, s, out);
}

View File

@ -336,13 +336,13 @@ int kitty_rebuild(sprixel* s, int ycell, int xcell, uint8_t* auxvec){
}
int kitty_wipe(sprixel* s, int ycell, int xcell){
//fprintf(stderr, "WIPING %d/%d\n", ycell, xcell);
fprintf(stderr, "WIPING %d/%d\n", ycell, xcell);
if(s->n->tam[s->dimx * ycell + xcell].state == SPRIXCELL_ANNIHILATED){
//fprintf(stderr, "CACHED WIPE %d %d/%d\n", s->id, ycell, xcell);
fprintf(stderr, "CACHED WIPE %d %d/%d\n", s->id, ycell, xcell);
return 0; // already annihilated, needn't draw glyph in kitty
}
uint8_t* auxvec = sprixel_auxiliary_vector(s);
//fprintf(stderr, "NEW WIPE %d %d/%d\n", s->id, ycell, xcell);
fprintf(stderr, "NEW WIPE %d %d/%d\n", s->id, ycell, xcell);
const int totalpixels = s->pixy * s->pixx;
const int xpixels = s->cellpxx;
const int ypixels = s->cellpxy;
@ -586,15 +586,18 @@ int kitty_destroy(const notcurses* nc, const ncpile* p, FILE* out, sprixel* s){
sprixcell_e state = sprixel_state(s, yy - s->movedfromy + s->n->absy - stdn->absy,
xx - s->movedfromx + s->n->absx - stdn->absx);
if(state == SPRIXCELL_OPAQUE_KITTY){
fprintf(stderr, "DAMAGED 1\n");
r->s.damaged = 1;
}else if(s->invalidated == SPRIXEL_MOVED){
// ideally, we wouldn't damage our annihilated sprixcells, but if
// we're being annihilated only during this cycle, we need to go
// ahead and damage it.
fprintf(stderr, "DAMAGED 2\n");
r->s.damaged = 1;
}
}else{
r->s.damaged = 1;
fprintf(stderr, "DAMAGED 3\n");
//r->s.damaged = 1;
}
}
}

View File

@ -174,7 +174,7 @@ paint_sprixel(ncplane* p, struct crender* rvec, int starty, int startx,
// if sprite_wipe_cell() fails, we presumably do not have the
// ability to wipe, and must reprint the character
if(sprite_wipe(nc, p->sprite, y, x)){
//fprintf(stderr, "damaging due to wipe [%s] %d/%d\n", nccell_extended_gcluster(crender->p, &crender->c), absy, absx);
fprintf(stderr, "damaging due to wipe [%s] %d/%d\n", nccell_extended_gcluster(crender->p, &crender->c), absy, absx);
crender->s.damaged = 1;
}
crender->s.p_beats_sprixel = 1;
@ -358,6 +358,7 @@ paint(ncplane* p, struct crender* rvec, int dstleny, int dstlenx,
// side of a wide glyph (nor the null codepoint).
if( (targc->gcluster = vis->gcluster) ){ // index copy only
if(crender->sprixel && crender->sprixel->invalidated == SPRIXEL_HIDE){
//fprintf(stderr, "damaged due to hide\n");
crender->s.damaged = 1;
}
crender->s.blittedquads = cell_blittedquadrants(vis);
@ -440,15 +441,17 @@ postpaint_cell(nccell* lastframe, int dimx, struct crender* crender,
nccell* targc = &crender->c;
lock_in_highcontrast(targc, crender);
nccell* prevcell = &lastframe[fbcellidx(y, dimx, *x)];
//fprintf(stderr, "taking a look at %d/%d %08x\n", y, *x, crender->c.gcluster);
if(y < 5 && *x < 5) fprintf(stderr, "taking a look at %d/%d %08x %08x [%u]\n", y, *x, prevcell->gcluster, crender->c.gcluster, crender->s.damaged);
if(cellcmp_and_dupfar(pool, prevcell, crender->p, targc) > 0){
//fprintf(stderr, "damaging due to cmp [%s] %d %d\n", nccell_extended_gcluster(crender->p, &crender->c), y, *x);
if(crender->sprixel){
sprixcell_e state = sprixel_state(crender->sprixel, y, *x);
if(!crender->s.p_beats_sprixel && state != SPRIXCELL_OPAQUE_KITTY && state != SPRIXCELL_OPAQUE_SIXEL){
fprintf(stderr, "damaged due to opaque\n");
crender->s.damaged = 1;
}
}else{
fprintf(stderr, "damaged due to opaque else %d %d\n", y, *x);
crender->s.damaged = 1;
}
assert(!nccell_wide_right_p(targc));
@ -1007,6 +1010,7 @@ rasterize_core(notcurses* nc, const ncpile* p, FILE* out, unsigned phase){
++x;
}
}else if(phase != 0 || !rvec[damageidx].s.p_beats_sprixel){
fprintf(stderr, "phase %u damaged at %d/%d\n", phase, innery, innerx);
// in the first text phase, we draw only those glyphs where the glyph
// was not above a sprixel (and the cell is damaged). in the second
// phase, we draw everything that remains damaged.
@ -1081,7 +1085,7 @@ rasterize_core(notcurses* nc, const ncpile* p, FILE* out, unsigned phase){
nc->rstate.bgdefelidable = false;
nc->rstate.bgpalelidable = false;
}
//fprintf(stderr, "RAST %08x [%s] to %d/%d cols: %u %016lx\n", srccell->gcluster, pool_extended_gcluster(&nc->pool, srccell), y, x, srccell->width, srccell->channels);
fprintf(stderr, "RAST %08x [%s] to %d/%d cols: %u %016lx\n", srccell->gcluster, pool_extended_gcluster(&nc->pool, srccell), y, x, srccell->width, srccell->channels);
// this is used to invalidate the sprixel in the first text round,
// which is only necessary for sixel, not kitty.
if(rvec[damageidx].sprixel){
@ -1102,6 +1106,8 @@ rasterize_core(notcurses* nc, const ncpile* p, FILE* out, unsigned phase){
x += srccell->width - 1;
nc->rstate.x += srccell->width - 1;
}
}else{
fprintf(stderr, "YEET phase %u damaged at %d/%d\n", phase, innery, innerx);
}
//fprintf(stderr, "damageidx: %ld\n", damageidx);
}

View File

@ -262,7 +262,7 @@ extract_color_table(const uint32_t* data, int linesize, int cols,
const uint32_t* rgb = (data + (linesize / 4 * sy) + visx);
int txyidx = (sy / cdimy) * cols + (visx / cdimx);
if(tam[txyidx].state == SPRIXCELL_ANNIHILATED || tam[txyidx].state == SPRIXCELL_ANNIHILATED_TRANS){
//fprintf(stderr, "TRANS SKIP %d %d %d %d (cell: %d %d)\n", visy, visx, sy, txyidx, sy / cdimy, visx / cdimx);
fprintf(stderr, "TRANS SKIP %d %d %d %d (cell: %d %d)\n", visy, visx, sy, txyidx, sy / cdimy, visx / cdimx);
continue;
}
if(rgba_trans_p(*rgb, bargs->transcolor)){
@ -696,7 +696,7 @@ int sixel_destroy(const notcurses* nc, const ncpile* p, FILE* out, sprixel* s){
for(int xx = startx ; xx < startx + s->dimx && xx < p->dimx ; ++xx){
struct crender *r = &p->crender[yy * p->dimx + xx];
if(!r->sprixel){
r->s.damaged = 1;
//r->s.damaged = 1;
}
}
}
@ -846,7 +846,7 @@ wipe_color(sixelmap* smap, int color, int sband, int eband,
int sixel_wipe(sprixel* s, int ycell, int xcell){
if(s->n->tam[s->dimx * ycell + xcell].state == SPRIXCELL_ANNIHILATED){
//fprintf(stderr, "CACHED WIPE %d %d/%d\n", s->id, ycell, xcell);
return 1; // already annihilated FIXME but 0 breaks things
return 0; // already annihilated FIXME but 0 breaks things
}
//fprintf(stderr, "WIPING %d/%d\n", ycell, xcell);
uint8_t* auxvec = sprixel_auxiliary_vector(s);

View File

@ -108,7 +108,9 @@ textplay(struct notcurses* nc, struct ncplane* tplane, struct ncvisual* ncv){
if(!ncv){
clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, NULL);
}else{
ncvisual_decode(ncv);
for(int i = 0 ; i < 3 ; ++i){
ncvisual_decode(ncv);
}
}
}
ncplane_destroy(vopts.n);

View File

@ -25,10 +25,10 @@ wipebitmap(struct notcurses* nc){
if(n == NULL){
return -1;
}
ncvisual_destroy(ncv);
ncplane_putstr_yx(notcurses_stdplane(nc), 6, 0, "Ought see full square");
notcurses_debug(nc, stderr);
notcurses_render(nc);
sleep(3);
sleep(2);
ncplane_erase(notcurses_stdplane(nc));
for(int y = 1 ; y < 5 ; ++y){
@ -43,12 +43,13 @@ wipebitmap(struct notcurses* nc){
ncplane_move_top(notcurses_stdplane(nc));
ncplane_putstr_yx(notcurses_stdplane(nc), 6, 0, "Ought see 16 *s");
notcurses_render(nc);
sleep(3);
sleep(2);
ncplane_erase(notcurses_stdplane(nc));
ncplane_putstr_yx(notcurses_stdplane(nc), 6, 0, "Ought see full square");
notcurses_debug(nc, stderr);
notcurses_render(nc);
sleep(3);
sleep(2);
ncplane_erase(notcurses_stdplane(nc));
for(int y = 1 ; y < 5 ; ++y){
@ -57,31 +58,66 @@ wipebitmap(struct notcurses* nc){
}
}
ncplane_putstr_yx(notcurses_stdplane(nc), 6, 0, "Ought see 16 spaces");
notcurses_debug(nc, stderr);
notcurses_render(nc);
sleep(3);
sleep(2);
ncplane_erase(notcurses_stdplane(nc));
ncplane_destroy(n);
ncplane_putstr_yx(notcurses_stdplane(nc), 6, 0, "Ought see nothing");
notcurses_debug(nc, stderr);
notcurses_render(nc);
sleep(3);
sleep(2);
ncplane_erase(notcurses_stdplane(nc));
for(int i = cellpxy ; i < 5 * cellpxy ; ++i){
memset(pixels + (i * 6 * cellpxx + cellpxx), 0, cellpxx * 4 * sizeof(*pixels));
}
ncv = ncvisual_from_rgba(pixels, 6 * cellpxy, 6 * cellpxx * 4, 6 * cellpxx);
if(ncv == NULL){
struct ncvisual* ncve = ncvisual_from_rgba(pixels, 6 * cellpxy, 6 * cellpxx * 4, 6 * cellpxx);
if(ncve == NULL){
return -1;
}
if((n = ncvisual_render(nc, ncv, &vopts)) == NULL){
if((n = ncvisual_render(nc, ncve, &vopts)) == NULL){
return -1;
}
ncplane_putstr_yx(notcurses_stdplane(nc), 6, 0, "Ought see empty square");
ncvisual_destroy(ncv);
notcurses_debug(nc, stderr);
notcurses_render(nc);
sleep(2);
vopts.n = n;
ncplane_move_top(notcurses_stdplane(nc));
// now, actually wipe the middle with *s, and then ensure that a new render
// gets wiped out before being displayed
if(ncvisual_render(nc, ncv, &vopts) == NULL){
return -1;
}
ncplane_putstr_yx(notcurses_stdplane(nc), 6, 0, "Ought see full square");
notcurses_debug(nc, stderr);
notcurses_render(nc);
sleep(2);
for(int y = 1 ; y < 5 ; ++y){
for(int x = 1 ; x < 5 ; ++x){
ncplane_putchar_yx(notcurses_stdplane(nc), y, x, '*');
}
}
ncplane_putstr_yx(notcurses_stdplane(nc), 6, 0, "Ought see 16 *s");
notcurses_debug(nc, stderr);
notcurses_render(nc);
sleep(2);
if((n = ncvisual_render(nc, ncv, &vopts)) == NULL){
return -1;
}
ncplane_putstr_yx(notcurses_stdplane(nc), 6, 0, "Ought *still* see 16 *s");
notcurses_debug(nc, stderr);
notcurses_render(nc);
sleep(2);
ncvisual_destroy(ncve);
ncvisual_destroy(ncv);
ncplane_destroy(n);
sleep(3);
return 0;
}