mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-10 01:29:05 -04:00
[render] only invalidate glyphs when wipe fails
This commit is contained in:
parent
11f79dfd31
commit
89678ed412
@ -149,6 +149,10 @@ kitty_null(char* triplet, int skip, int max, int pleft){
|
||||
|
||||
#define RGBA_MAXLEN 768 // 768 base64-encoded pixels in 4096 bytes
|
||||
int sprite_kitty_cell_wipe(const notcurses* nc, sprixel* s, int ycell, int xcell){
|
||||
if(s->n->tacache[s->dimx * ycell + xcell] == SPRIXCELL_ANNIHILATED){
|
||||
//fprintf(stderr, "CACHED WIPE %d %d/%d\n", s->id, ycell, xcell);
|
||||
return 0; // already annihilated, needn't draw glyph in kitty
|
||||
}
|
||||
const int totalpixels = s->pixy * s->pixx;
|
||||
const int xpixels = nc->tcache.cellpixx;
|
||||
const int ypixels = nc->tcache.cellpixy;
|
||||
@ -199,6 +203,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;
|
||||
return 0;
|
||||
}
|
||||
thisrow = targx;
|
||||
|
@ -213,8 +213,8 @@ paint_sprixel(const ncplane* p, const nccell* vis, struct crender* crender,
|
||||
if(sprite_wipe_cell(nc, p->sprite, y, x)){
|
||||
//fprintf(stderr, "damaging due to wipe %d/%d\n", y, x);
|
||||
crender->s.damaged = 1;
|
||||
crender->s.p_beats_sprixel = 1;
|
||||
}
|
||||
crender->s.p_beats_sprixel = 1;
|
||||
}else if(!crender->p){
|
||||
// if we are a bitmap, and above a cell that has changed (and
|
||||
// will thus be printed), we'll need redraw the sprixel.
|
||||
|
@ -546,8 +546,10 @@ int sprite_sixel_init(int fd){
|
||||
// redrawn, it's redrawn using P2=1.
|
||||
int sixel_wipe(const notcurses* nc, sprixel* s, int ycell, int xcell){
|
||||
(void)nc;
|
||||
(void)ycell;
|
||||
(void)xcell;
|
||||
if(s->n->tacache[s->dimx * ycell + xcell] == SPRIXCELL_ANNIHILATED){
|
||||
//fprintf(stderr, "CACHED WIPE %d %d/%d\n", s->id, ycell, xcell);
|
||||
return 1; // already annihilated, but still must draw glyph
|
||||
}
|
||||
change_p2(s->glyph, SIXEL_P2_TRANS);
|
||||
return -1;
|
||||
}
|
||||
|
@ -112,31 +112,18 @@ int sprixel_load(sprixel* spx, char* s, int bytes, int placey, int placex,
|
||||
return 0;
|
||||
}
|
||||
|
||||
// returns 1 if already annihilated, 0 if we successfully annihilated the cell,
|
||||
// or -1 if we could not annihilate the cell (i.e. we're sixel).
|
||||
int sprite_wipe_cell(const notcurses* nc, sprixel* s, int ycell, int xcell){
|
||||
if(s->invalidated == SPRIXEL_HIDE){ // no need to do work if we're killing it
|
||||
return 0;
|
||||
}
|
||||
if(ycell >= s->dimy || ycell < 0){
|
||||
logerror(nc, "Bad y coordinate %d (%d)\n", ycell, s->dimy);
|
||||
return -1;
|
||||
}
|
||||
if(xcell >= s->dimx || xcell < 0){
|
||||
logerror(nc, "Bad x coordinate %d (%d)\n", xcell, s->dimx);
|
||||
return -1;
|
||||
}
|
||||
if(s->n->tacache[s->dimx * ycell + xcell] == SPRIXCELL_ANNIHILATED){
|
||||
//fprintf(stderr, "CACHED WIPE %d %d/%d\n", s->id, ycell, xcell);
|
||||
return 0; // already annihilated
|
||||
}
|
||||
// mark the cell as annihilated whether we actually scrubbed it or not,
|
||||
// so that we use this fact should we move to another frame
|
||||
s->n->tacache[s->dimx * ycell + xcell] = SPRIXCELL_ANNIHILATED;
|
||||
//fprintf(stderr, "ANNIHILATED %p %d\n", s->n->tacache, s->dimx * ycell + xcell);
|
||||
int r = nc->tcache.pixel_cell_wipe(nc, s, ycell, xcell);
|
||||
//fprintf(stderr, "WIPED %d %d/%d ret=%d\n", s->id, ycell, xcell, r);
|
||||
if(r == 0){
|
||||
s->invalidated = SPRIXEL_INVALIDATED;
|
||||
}
|
||||
// mark the cell as annihilated whether we actually scrubbed it or not,
|
||||
// so that we use this fact should we move to another frame
|
||||
s->n->tacache[s->dimx * ycell + xcell] = SPRIXCELL_ANNIHILATED;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user