7 #define RECUR(a,b,c,d) _layerop(fn, i, Rect(a.x, b.y, c.x, d.y), clipr, etc, front->layer->rear);
11 void (*fn)(Memimage*, Rectangle, Rectangle, void*, int),
22 /* no one is in front of this part of window; use the screen */
23 fn(i->layer->screen->image, r, clipr, etc, 0);
26 fr = front->layer->screenr;
27 if(rectXrect(r, fr) == 0){
28 /* r doesn't touch this window; continue on next rearmost */
29 // assert(front && front->layer && front->layer->screen && front->layer->rear);
30 front = front->layer->rear;
33 if(fr.max.y < r.max.y){
34 RECUR(r.min, fr.max, r.max, r.max);
37 if(r.min.y < fr.min.y){
38 RECUR(r.min, r.min, r.max, fr.min);
41 if(fr.max.x < r.max.x){
42 RECUR(fr.max, r.min, r.max, r.max);
45 if(r.min.x < fr.min.x){
46 RECUR(r.min, r.min, fr.min, r.max);
49 /* r is covered by front, so put in save area */
50 (*fn)(i->layer->save, r, clipr, etc, 1);
54 * Assumes incoming rectangle has already been clipped to i's logical r and clipr
58 void (*fn)(Memimage*, Rectangle, Rectangle, void*, int),
60 Rectangle screenr, /* clipped to window boundaries */
61 Rectangle clipr, /* clipped also to clipping rectangles of hierarchy */
68 if(!rectclip(&screenr, l->screenr))
71 fn(l->screen->image, screenr, clipr, etc, 0);
75 scr = l->screen->image->clipr;
78 * Do the piece on the screen
80 if(rectclip(&screenr, scr))
81 _layerop(fn, i, screenr, clipr, etc, l->screen->frontmost);
82 if(rectinrect(r, scr))
86 * Do the piece off the screen
88 if(!rectXrect(r, scr)){
89 /* completely offscreen; easy */
90 fn(l->save, r, clipr, etc, 1);
93 if(r.min.y < scr.min.y){
95 fn(l->save, Rect(r.min.x, r.min.y, r.max.x, scr.min.y), clipr, etc, 1);
98 if(r.max.y > scr.max.y){
100 fn(l->save, Rect(r.min.x, scr.max.y, r.max.x, r.max.y), clipr, etc, 1);
103 if(r.min.x < scr.min.x){
105 fn(l->save, Rect(r.min.x, r.min.y, scr.min.x, r.max.y), clipr, etc, 1);
108 if(r.max.x > scr.max.x){
109 /* right of screen */
110 fn(l->save, Rect(scr.max.x, r.min.y, r.max.x, r.max.y), clipr, etc, 1);