Revert "[bitmap] on move, clear old OPAQUE cells #1527"

This reverts commit 416806c42c.
pull/1549/head
nick black 3 years ago
parent 416806c42c
commit b1317ddf7e
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -547,7 +547,7 @@ ncdirect_render_visual(ncdirect* n, ncvisual* ncv, ncblitter_e blitfxn,
bargs.u.pixel.colorregs = n->tcache.color_registers;
int cols = lenx / bargs.u.pixel.celldimx + !!(lenx % bargs.u.pixel.celldimx);
int rows = leny / bargs.u.pixel.celldimy + !!(leny % bargs.u.pixel.celldimy);
if((bargs.u.pixel.spx = sprixel_alloc(ncdv, ncv, rows, cols, 0, 0)) == NULL){
if((bargs.u.pixel.spx = sprixel_alloc(ncdv, ncv, rows, cols)) == NULL){
free_plane(ncdv);
return NULL;
}

@ -111,8 +111,7 @@ typedef enum {
//
// when a sprixel is removed from the rendering pile, in Sixel all cells it
// covered must be marked damaged, so that they are rendered, obliterating
// the bitmap. in Kitty the bitmap can simply be deleted, except for those
// cells which were SPRIXCELL_OPAQUE (they must be damaged).
// the bitmap. in Kitty the bitmap can simply be deleted.
//
// when a sprixel is moved, its TAM must be updated. OPAQUE, MIXED, and
// TRANSPARENT cells retain their entries. ANNIHILATED cells remain
@ -923,8 +922,7 @@ int sprite_draw(const notcurses* n, const ncpile *p, sprixel* s, FILE* out);
int kitty_draw(const notcurses* n, const ncpile *p, sprixel* s, FILE* out);
int sixel_draw(const notcurses* n, const ncpile *p, sprixel* s, FILE* out);
// dimy and dimx are cell geometry, not pixel. takes ownership of s on success.
sprixel* sprixel_alloc(ncplane* n, struct ncvisual* ncv, int dimy, int dimx,
int placey, int placex);
sprixel* sprixel_alloc(ncplane* n, struct ncvisual* ncv, int dimy, int dimx);
sprixel* sprixel_recycle(ncplane* n, struct ncvisual* ncv);
int sprixel_load(sprixel* spx, char* s, int bytes, int placey, int placex,
int pixy, int pixx, int parse_start);

@ -209,7 +209,7 @@ int sprite_kitty_cell_wipe(const notcurses* nc, sprixel* s, int ycell, int xcell
if(thisrow == 0){
//fprintf(stderr, "CLEARED ROW, TARGY: %d\n", targy - 1);
if(--targy == 0){
//s->invalidated = SPRIXEL_INVALIDATED;
s->invalidated = SPRIXEL_INVALIDATED;
return 0;
}
thisrow = targx;
@ -367,27 +367,13 @@ int kitty_blit(ncplane* n, int linesize, const void* data,
return 1;
}
// removes the kitty bitmap graphic identified by s->id, and damages those
// cells which were SPRIXCEL_OPAQUE
// removes the kitty bitmap graphic identified by s->id
int sprite_kitty_annihilate(const notcurses* nc, const ncpile* p, FILE* out, sprixel* s){
(void)p;
(void)nc;
if(fprintf(out, "\e_Ga=d,d=i,i=%d\e\\", s->id) < 0){
return 0;
}
//fprintf(stderr, "MOVED FROM: %d/%d\n", s->movedfromy, s->movedfromx);
for(int yy = s->movedfromy ; yy < s->movedfromy + s->dimy && yy < p->dimy ; ++yy){
for(int xx = s->movedfromx ; xx < s->movedfromx + s->dimx && xx < p->dimx ; ++xx){
struct crender *r = &p->crender[yy * p->dimx + xx];
if(s->n){
//fprintf(stderr, "CHECKING %d/%d\n", yy - s->movedfromy, xx - s->movedfromx);
if(s->n->tacache[(yy - s->movedfromy) * s->dimx + (xx - s->movedfromx)] == SPRIXCELL_OPAQUE){
//fprintf(stderr, "DAMAGING %d/%d!\n", yy, xx);
r->s.damaged = 1;
}
}
}
}
return 0;
}

@ -866,10 +866,7 @@ clean_sprixels(notcurses* nc, const ncpile* p, FILE* out){
ret = -1;
}
}else if(s->invalidated == SPRIXEL_MOVED || s->invalidated == SPRIXEL_INVALIDATED){
// FIXME clean this up, don't use sprite_draw, etc.
if(s->invalidated == SPRIXEL_MOVED){
sprite_destroy(nc, p, out, s);
}
// FIXME clean this up, don't use sprite_draw, don't always move, etc.
int y, x;
ncplane_yx(s->n, &y, &x);
y += s->y;

@ -24,10 +24,8 @@ sprixel* sprixel_recycle(ncplane* n, ncvisual* ncv){
assert(hides);
int dimy = hides->dimy;
int dimx = hides->dimx;
int y = hides->y;
int x = hides->x;
sprixel_hide(hides);
return sprixel_alloc(n, ncv, dimy, dimx, y, x);
return sprixel_alloc(n, ncv, dimy, dimx);
}
return n->sprite;
}
@ -37,7 +35,6 @@ sprixel* sprixel_recycle(ncplane* n, ncvisual* ncv){
void sprixel_movefrom(sprixel* s, int y, int x){
if(s->invalidated != SPRIXEL_HIDE){
if(s->invalidated != SPRIXEL_MOVED){
//fprintf(stderr, "SETTING TO MOVE: %d/%d was: %d\n", y, x, s->invalidated);
s->invalidated = SPRIXEL_MOVED;
s->movedfromy = y;
s->movedfromx = x;
@ -86,8 +83,7 @@ sprixel* sprixel_by_id(const notcurses* nc, uint32_t id){
return NULL;
}
sprixel* sprixel_alloc(ncplane* n, ncvisual* ncv, int dimy, int dimx,
int placey, int placex){
sprixel* sprixel_alloc(ncplane* n, ncvisual* ncv, int dimy, int dimx){
sprixel* ret = malloc(sizeof(sprixel));
if(ret){
memset(ret, 0, sizeof(*ret));
@ -95,8 +91,6 @@ sprixel* sprixel_alloc(ncplane* n, ncvisual* ncv, int dimy, int dimx,
ret->ncv = ncv;
ret->dimy = dimy;
ret->dimx = dimx;
ret->y = placey;
ret->x = placex;
ret->id = ++sprixelid_nonce;
//fprintf(stderr, "LOOKING AT %p (p->n = %p)\n", ret, ret->n);
if(ncplane_pile(ret->n)){

@ -694,7 +694,7 @@ ncplane* ncvisual_render_pixels(notcurses* nc, ncvisual* ncv, const struct blits
if(n->sprite){
sprixel_hide(n->sprite);
}
if((ncv->spx = sprixel_alloc(n, ncv, rows, cols, placey, placex)) == NULL){
if((ncv->spx = sprixel_alloc(n, ncv, rows, cols)) == NULL){
goto err;
}
}else{

Loading…
Cancel
Save