2005-08-08 16:50:13 +04:00
|
|
|
#include <u.h>
|
|
|
|
#include <libc.h>
|
|
|
|
#include <draw.h>
|
|
|
|
#include <memdraw.h>
|
|
|
|
#include <memlayer.h>
|
|
|
|
|
|
|
|
int
|
|
|
|
memlsetrefresh(Memimage *i, Refreshfn fn, void *ptr)
|
|
|
|
{
|
|
|
|
Memlayer *l;
|
|
|
|
|
|
|
|
l = i->layer;
|
2006-05-21 21:02:05 +04:00
|
|
|
if(l->refreshfn!=0 && fn!=0){ /* just change functions */
|
2005-08-08 16:50:13 +04:00
|
|
|
l->refreshfn = fn;
|
|
|
|
l->refreshptr = ptr;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2006-05-21 21:02:05 +04:00
|
|
|
if(l->refreshfn == 0){ /* is using backup image; just free it */
|
2005-08-08 16:50:13 +04:00
|
|
|
freememimage(l->save);
|
|
|
|
l->save = nil;
|
|
|
|
l->refreshfn = fn;
|
|
|
|
l->refreshptr = ptr;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
l->save = allocmemimage(i->r, i->chan);
|
|
|
|
if(l->save == nil)
|
|
|
|
return 0;
|
|
|
|
/* easiest way is just to update the entire save area */
|
|
|
|
l->refreshfn(i, i->r, l->refreshptr);
|
2006-05-21 21:02:05 +04:00
|
|
|
l->refreshfn = 0;
|
2005-08-08 16:50:13 +04:00
|
|
|
l->refreshptr = nil;
|
|
|
|
return 1;
|
|
|
|
}
|