move last_pile into rstate

This commit is contained in:
nick black 2021-11-10 21:08:24 -05:00
parent 832baac689
commit b3a58cdc8b
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
3 changed files with 24 additions and 23 deletions

View File

@ -57,6 +57,19 @@ struct ncvisual_details;
// we can't define multipart ncvisual here, because OIIO requires C++ syntax,
// and we can't go throwing C++ syntax into this header. so it goes.
typedef struct ncpile {
struct ncplane* top; // topmost plane, never NULL
struct ncplane* bottom; // bottommost plane, never NULL
struct ncplane* roots; // head of root plane list
struct crender* crender; // array (rows * cols crender objects)
struct notcurses* nc; // notcurses context
struct ncpile *prev, *next; // circular list
size_t crenderlen; // size of crender vector
unsigned dimy, dimx; // rows and cols at time of last render
int scrolls; // how many real lines need be scrolled at raster
sprixel* sprixelcache; // list of sprixels
} ncpile;
// A plane is memory for some rectilinear virtual window, plus current cursor
// state for that window, and part of a pile. Each pile has a total order along
// its z-axis. Functions update these virtual planes over a series of API
@ -137,6 +150,12 @@ typedef struct rasterstate {
unsigned lastbg;
unsigned lastbb;
// the last pile we rasterized. NULL until we've rasterized once. might
// be invalid due to the pile being destroyed; you are only allowed to
// evaluate it for equality to the pile being currently rasterized. when
// we switch piles, we need to clear all displayed sprixels, and
// invalidate the new pile's, pursuant to their display.
ncpile* last_pile;
// we track the sprixels that were visible as of the last rasterization,
// so that we can clear them if the pile changes.
sprixel_metadata* sprixels_last_drawn;
@ -290,19 +309,6 @@ struct crender {
} s;
};
typedef struct ncpile {
ncplane* top; // topmost plane, never NULL
ncplane* bottom; // bottommost plane, never NULL
ncplane* roots; // head of root plane list
struct crender* crender; // array (rows * cols crender objects)
struct notcurses* nc; // notcurses context
struct ncpile *prev, *next; // circular list
size_t crenderlen; // size of crender vector
unsigned dimy, dimx; // rows and cols at time of last render
int scrolls; // how many real lines need be scrolled at raster
sprixel* sprixelcache; // list of sprixels
} ncpile;
// the standard pile can be reached through ->stdplane.
typedef struct notcurses {
ncplane* stdplane; // standard plane, covers screen
@ -313,12 +319,6 @@ typedef struct notcurses {
// we keep a copy of the last rendered frame. this facilitates O(1)
// notcurses_at_yx() and O(1) damage detection (at the cost of some memory).
nccell* lastframe;// last rasterized framebuffer, NULL until first raster
// the last pile we rasterized. NULL until we've rasterized once. might
// be invalid due to the pile being destroyed; you are only allowed to
// evaluate it for equality to the pile being currently rasterized. when
// we switch piles, we need to clear all displayed sprixels, and
// invalidate the new pile's, pursuant to their display.
ncpile* last_pile;
egcpool pool; // egcpool for lastframe
unsigned lfdimx; // dimensions of lastframe, unchanged by screen resize

View File

@ -976,7 +976,8 @@ notcurses* notcurses_core_init(const notcurses_options* opts, FILE* outfp){
if(ret == NULL){
return ret;
}
ret->last_pile = NULL;
ret->rstate.sprixels_last_drawn = NULL;
ret->rstate.last_pile = NULL;
ret->rstate.f.buf = NULL;
ret->rstate.f.used = 0;
ret->rstate.f.size = 0;

View File

@ -917,7 +917,7 @@ clean_sprixels(notcurses* nc, ncpile* p, fbuf* f, int scrolls){
loginfo("Phase 1 sprixel %u state %d loc %d/%d\n", s->meta.id,
s->invalidated, s->n ? s->n->absy : -1, s->n ? s->n->absx : -1);
if(s->invalidated == SPRIXEL_QUIESCENT){
if(p != nc->last_pile){
if(p != nc->rstate.last_pile){
s->invalidated = SPRIXEL_UNSEEN;
}
}else if(s->invalidated == SPRIXEL_HIDE){
@ -941,7 +941,7 @@ clean_sprixels(notcurses* nc, ncpile* p, fbuf* f, int scrolls){
s->invalidated == SPRIXEL_INVALIDATED){
//fprintf(stderr, "1 MOVING BITMAP %d STATE %d AT %d/%d for %p\n", s->id, s->invalidated, y + nc->margin_t, x + nc->margin_l, s->n);
if(s->invalidated == SPRIXEL_MOVED){
if(p != nc->last_pile){
if(p != nc->rstate.last_pile){
s->invalidated = SPRIXEL_UNSEEN;
}else{
if(s->n->absx == s->meta.movedfromx){
@ -1378,7 +1378,7 @@ notcurses_rasterize(notcurses* nc, ncpile* p, fbuf* f){
ret = -1;
}
}
nc->last_pile = p;
nc->rstate.last_pile = p;
return ret;
}