summaryrefslogtreecommitdiff
path: root/libmemlayer/unload.c
diff options
context:
space:
mode:
authorCharles.Forsyth <devnull@localhost>2006-12-22 17:07:39 +0000
committerCharles.Forsyth <devnull@localhost>2006-12-22 17:07:39 +0000
commit37da2899f40661e3e9631e497da8dc59b971cbd0 (patch)
treecbc6d4680e347d906f5fa7fca73214418741df72 /libmemlayer/unload.c
parent54bc8ff236ac10b3eaa928fd6bcfc0cdb2ba46ae (diff)
20060303a
Diffstat (limited to 'libmemlayer/unload.c')
-rw-r--r--libmemlayer/unload.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/libmemlayer/unload.c b/libmemlayer/unload.c
new file mode 100644
index 00000000..741fe423
--- /dev/null
+++ b/libmemlayer/unload.c
@@ -0,0 +1,51 @@
+#include "lib9.h"
+#include "draw.h"
+#include "memdraw.h"
+#include "memlayer.h"
+
+int
+memunload(Memimage *src, Rectangle r, uchar *data, int n)
+{
+ Memimage *tmp;
+ Memlayer *dl;
+ Rectangle lr;
+ int dx;
+
+ Top:
+ dl = src->layer;
+ if(dl == nil)
+ return unloadmemimage(src, r, data, n);
+
+ /*
+ * Convert to screen coordinates.
+ */
+ lr = r;
+ r.min.x += dl->delta.x;
+ r.min.y += dl->delta.y;
+ r.max.x += dl->delta.x;
+ r.max.y += dl->delta.y;
+ dx = dl->delta.x&(7/src->depth);
+ if(dl->clear && dx==0){
+ src = dl->screen->image;
+ goto Top;
+ }
+
+ /*
+ * src is an obscured layer or data is unaligned
+ */
+ if(dl->save && dx==0){
+ if(dl->refreshfn != nil)
+ return -1; /* can't unload window if it's not Refbackup */
+ if(n > 0)
+ memlhide(src, r);
+ n = unloadmemimage(dl->save, lr, data, n);
+ return n;
+ }
+ tmp = allocmemimage(lr, src->chan);
+ if(tmp == nil)
+ return -1;
+ memdraw(tmp, lr, src, lr.min, nil, lr.min, S);
+ n = unloadmemimage(tmp, lr, data, n);
+ freememimage(tmp);
+ return n;
+}