vx32

Local 9vx git repository for patches.
git clone git://r-36.net/vx32
Log | Files | Refs

unload.c (1006B)


      1 #include "u.h"
      2 #include "lib.h"
      3 #include "draw.h"
      4 #include "memdraw.h"
      5 #include "memlayer.h"
      6 
      7 int
      8 memunload(Memimage *src, Rectangle r, uchar *data, int n)
      9 {
     10 	Memimage *tmp;
     11 	Memlayer *dl;
     12 	Rectangle lr;
     13 	int dx;
     14 
     15     Top:
     16 	dl = src->layer;
     17 	if(dl == nil)
     18 		return unloadmemimage(src, r, data, n);
     19 
     20 	/*
     21  	 * Convert to screen coordinates.
     22 	 */
     23 	lr = r;
     24 	r.min.x += dl->delta.x;
     25 	r.min.y += dl->delta.y;
     26 	r.max.x += dl->delta.x;
     27 	r.max.y += dl->delta.y;
     28 	dx = dl->delta.x&(7/src->depth);
     29 	if(dl->clear && dx==0){
     30 		src = dl->screen->image;
     31 		goto Top;
     32 	}
     33 
     34 	/*
     35 	 * src is an obscured layer or data is unaligned
     36 	 */
     37 	if(dl->save && dx==0){
     38 		if(dl->refreshfn != nil)
     39 			return -1;	/* can't unload window if it's not Refbackup */
     40 		if(n > 0)
     41 			memlhide(src, r);
     42 		n = unloadmemimage(dl->save, lr, data, n);
     43 		return n;
     44 	}
     45 	tmp = allocmemimage(lr, src->chan);
     46 	if(tmp == nil)
     47 		return -1;
     48 	memdraw(tmp, lr, src, lr.min, nil, lr.min, S);
     49 	n = unloadmemimage(tmp, lr, data, n);
     50 	freememimage(tmp);
     51 	return n;
     52 }