painter: skip unnecessary work

pull/282/head
nick black 5 years ago
parent b2dcc7cdf2
commit fc1341ea5a
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -208,15 +208,28 @@ paint(notcurses* nc, ncplane* p, struct crender* rvec, cell* fb){
offy = p->absy; offy = p->absy;
offx = p->absx; offx = p->absx;
//fprintf(stderr, "PLANE %p %d %d %d %d %d %d\n", p, dimy, dimx, offy, offx, nc->stdscr->leny, nc->stdscr->lenx); //fprintf(stderr, "PLANE %p %d %d %d %d %d %d\n", p, dimy, dimx, offy, offx, nc->stdscr->leny, nc->stdscr->lenx);
for(y = 0 ; y < dimy ; ++y){ // skip content above or to the left of the physical screen
for(x = 0 ; x < dimx ; ++x){ int starty, startx;
int absy = y + offy; if(offy < 0){
int absx = x + offx; starty = -offy;
if(absy < 0 || absy >= nc->stdscr->leny){ }else{
continue; starty = 0;
} }
if(absx < 0 || absx >= nc->stdscr->lenx){ if(offx < 0){
continue; startx = -offx;
}else{
startx = 0;
}
for(y = starty ; y < dimy ; ++y){
const int absy = y + offy;
// once we've passed the physical screen's bottom, we're done
if(absy >= nc->stdscr->leny){
break;
}
for(x = startx ; x < dimx ; ++x){
const int absx = x + offx;
if(absx >= nc->stdscr->lenx){
break;
} }
cell* targc = &fb[fbcellidx(absy, nc->stdscr->lenx, absx)]; cell* targc = &fb[fbcellidx(absy, nc->stdscr->lenx, absx)];
if(cell_locked_p(targc)){ if(cell_locked_p(targc)){

Loading…
Cancel
Save