mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-10 09:39:03 -04:00
tighten up state machine, only move to INVALIDATED from QUIESCENT #1631
This commit is contained in:
parent
d574dee3fe
commit
96491e42df
@ -999,20 +999,28 @@ sprite_draw(const notcurses* n, const ncpile* p, sprixel* s, FILE* out){
|
|||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
sprite_rebuild(const notcurses* nc, sprixel* s, int ycell, int xcell){
|
sprite_rebuild(const notcurses* nc, sprixel* s, int ycell, int xcell){
|
||||||
|
const int idx = s->dimx * ycell + xcell;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
// special case the transition back to SPRIXCELL_TRANSPARENT; this can be
|
// special case the transition back to SPRIXCELL_TRANSPARENT; this can be
|
||||||
// done in O(1), since the actual glyph needn't change.
|
// done in O(1), since the actual glyph needn't change.
|
||||||
if(s->n->tam[s->dimx * ycell + xcell].state == SPRIXCELL_ANNIHILATED_TRANS){
|
if(s->n->tam[idx].state == SPRIXCELL_ANNIHILATED_TRANS){
|
||||||
s->n->tam[s->dimx * ycell + xcell].state = SPRIXCELL_TRANSPARENT;
|
s->n->tam[idx].state = SPRIXCELL_TRANSPARENT;
|
||||||
}else if(s->n->tam[s->dimx * ycell + xcell].state == SPRIXCELL_ANNIHILATED){
|
}else if(s->n->tam[idx].state == SPRIXCELL_ANNIHILATED){
|
||||||
// sets the new state itself
|
// sets the new state itself
|
||||||
uint8_t* auxvec = s->n->tam[s->dimx * ycell + xcell].auxvector;
|
uint8_t* auxvec = s->n->tam[idx].auxvector;
|
||||||
assert(auxvec);
|
assert(auxvec);
|
||||||
ret = nc->tcache.pixel_rebuild(s, ycell, xcell, auxvec);
|
ret = nc->tcache.pixel_rebuild(s, ycell, xcell, auxvec);
|
||||||
free(auxvec);
|
free(auxvec);
|
||||||
s->n->tam[s->dimx * ycell + xcell].auxvector = NULL;
|
s->n->tam[idx].auxvector = NULL;
|
||||||
}
|
}
|
||||||
|
// don't upset SPRIXEL_MOVED
|
||||||
|
if(s->invalidated == SPRIXEL_QUIESCENT){
|
||||||
|
if(s->n->tam[idx].state != SPRIXCELL_TRANSPARENT &&
|
||||||
|
s->n->tam[idx].state != SPRIXCELL_ANNIHILATED &&
|
||||||
|
s->n->tam[idx].state != SPRIXCELL_ANNIHILATED_TRANS){
|
||||||
s->invalidated = SPRIXEL_INVALIDATED;
|
s->invalidated = SPRIXEL_INVALIDATED;
|
||||||
|
}
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ void sprixel_hide(sprixel* s){
|
|||||||
// y and x are absolute coordinates.
|
// y and x are absolute coordinates.
|
||||||
void sprixel_invalidate(sprixel* s, int y, int x){
|
void sprixel_invalidate(sprixel* s, int y, int x){
|
||||||
//fprintf(stderr, "INVALIDATING AT %d/%d\n", y, x);
|
//fprintf(stderr, "INVALIDATING AT %d/%d\n", y, x);
|
||||||
if(s->invalidated != SPRIXEL_HIDE && s->n){
|
if(s->invalidated == SPRIXEL_QUIESCENT && s->n){
|
||||||
int localy = y - s->n->absy;
|
int localy = y - s->n->absy;
|
||||||
int localx = x - s->n->absx;
|
int localx = x - s->n->absx;
|
||||||
//fprintf(stderr, "INVALIDATING AT %d/%d (%d/%d) TAM: %d\n", y, x, localy, localx, s->n->tam[localy * s->dimx + localx].state);
|
//fprintf(stderr, "INVALIDATING AT %d/%d (%d/%d) TAM: %d\n", y, x, localy, localx, s->n->tam[localy * s->dimx + localx].state);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user