From 63a954808a57f31490202efc3e08616a6ac6a6d0 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Tue, 22 Dec 2009 23:49:05 -0800 Subject: aleays redraw after scaling, allows more responsive resizing. --- src/main.c | 26 +++++++++++++++----------- src/meh.h | 2 ++ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/main.c b/src/main.c index e22c7fb..3bf667a 100644 --- a/src/main.c +++ b/src/main.c @@ -168,14 +168,14 @@ struct image *imageopen2(char *filename){ return NULL; } -int doredraw(struct image **i){ +void doredraw(struct image **i){ if(!*i){ if(mode == MODE_CTL){ if(images[0] == NULL) - return 0; + return; if(!(*i = imageopen2(images[0]))){ images[0] = NULL; - return 0; + return; } }else{ int firstimg = imageidx; @@ -219,17 +219,18 @@ int doredraw(struct image **i){ /* state should be set by format */ assert((*i)->state == LOADED || (*i)->state == FASTLOADED); }else if(width && height){ - if(dstate == SCALED || dstate == FASTSCALED){ - (*i)->ximg = getimage(*i, width, height, dstate == FASTSCALED); - (*i)->state = dstate; - }else if(dstate == DRAWN || dstate == FASTDRAWN){ - assert((*i)->ximg); - drawimage((*i)->ximg, width, height); + if(dstate == SCALED || dstate == FASTSCALED2 || dstate == FASTSCALED){ + (*i)->ximg = getimage(*i, width, height, dstate != SCALED); (*i)->state = dstate; + dstate++; /* Always draw after rendering */ } } + if(dstate == DRAWN || dstate == FASTDRAWN || dstate == FASTDRAWN2){ + assert((*i)->ximg); + drawimage((*i)->ximg, width, height); + (*i)->state = dstate; + } } - return (*i)->state != DRAWN; } void run(){ @@ -275,7 +276,10 @@ void run(){ }else if(ret == 0){ if(mode == MODE_CTL && images[0] == NULL){ tv = NULL; - }else if(!doredraw(&curimg)){ + }else if(!curimg || curimg->state != DRAWN){ + doredraw(&curimg); + //}else if(!nextimg || nextimg->state != DRAWN){ + }else{ /* If we get here everything has been drawn in full or we need more input to continue */ tv = NULL; } diff --git a/src/meh.h b/src/meh.h index 602ecee..b8522d9 100644 --- a/src/meh.h +++ b/src/meh.h @@ -18,6 +18,8 @@ typedef enum{ FASTSCALED, FASTDRAWN, LOADED, + FASTSCALED2, + FASTDRAWN2, SCALED, DRAWN, ERROR -- cgit v1.2.3