lsetrefresh.c (702B)
1 #include "u.h" 2 #include "lib.h" 3 #include "draw.h" 4 #include "memdraw.h" 5 #include "memlayer.h" 6 7 int 8 memlsetrefresh(Memimage *i, Refreshfn fn, void *ptr) 9 { 10 Memlayer *l; 11 12 l = i->layer; 13 if(l->refreshfn!=nil && fn!=nil){ /* just change functions */ 14 l->refreshfn = fn; 15 l->refreshptr = ptr; 16 return 1; 17 } 18 19 if(l->refreshfn == nil){ /* is using backup image; just free it */ 20 freememimage(l->save); 21 l->save = nil; 22 l->refreshfn = fn; 23 l->refreshptr = ptr; 24 return 1; 25 } 26 27 l->save = allocmemimage(i->r, i->chan); 28 if(l->save == nil) 29 return 0; 30 /* easiest way is just to update the entire save area */ 31 l->refreshfn(i, i->r, l->refreshptr); 32 l->refreshfn = nil; 33 l->refreshptr = nil; 34 return 1; 35 }