OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [services/] [gfx/] [mw/] [v2_0/] [src/] [nanox/] [srvclip2.c] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
/*
2
 * Copyright (c) 2000 Greg Haerr <greg@censoft.com>
3
 * Portions Copyright (c) 1991 David I. Bell
4
 * Permission is granted to use, distribute, or modify this source,
5
 * provided that this copyright notice remains intact.
6
 *
7
 * DYNAMICREGIONS GsSetClipWindow
8
 */
9
#include <stdio.h>
10
#include <stdlib.h>
11
#include "serv.h"
12
 
13
/*
14
 * Set the clip rectangles for a window taking into account other
15
 * windows that may be obscuring it.  The windows that may be obscuring
16
 * this one are the siblings of each direct ancestor which are higher
17
 * in priority than those ancestors.  Also, each parent limits the visible
18
 * area of the window.  The clipping is not done if it is already up to
19
 * date of if the window is not outputtable.
20
 */
21
void
22
GsSetClipWindow(GR_WINDOW *wp, MWCLIPREGION *userregion, int flags)
23
{
24
        GR_WINDOW       *orgwp;         /* original window pointer */
25
        GR_WINDOW       *pwp;           /* parent window */
26
        GR_WINDOW       *sibwp;         /* sibling windows */
27
        GR_COORD        minx;           /* minimum clip x coordinate */
28
        GR_COORD        miny;           /* minimum clip y coordinate */
29
        GR_COORD        maxx;           /* maximum clip x coordinate */
30
        GR_COORD        maxy;           /* maximum clip y coordinate */
31
        GR_COORD        diff;           /* difference in coordinates */
32
        GR_SIZE         bs;             /* border size */
33
        GR_COORD        x, y, width, height;
34
        MWCLIPREGION    *vis, *r;
35
 
36
        if (wp->unmapcount || !wp->output)
37
                return;
38
 
39
        clipwp = wp;
40
 
41
        /*
42
         * Start with the rectangle for the complete window.
43
         * We will then cut pieces out of it as needed.
44
         */
45
        x = wp->x;
46
        y = wp->y;
47
        width = wp->width;
48
        height = wp->height;
49
 
50
        /*
51
         * First walk upwards through all parent windows,
52
         * and restrict the visible part of this window to the part
53
         * that shows through all of those parent windows.
54
         */
55
        pwp = wp;
56
        while (pwp != rootwp) {
57
                pwp = pwp->parent;
58
 
59
                diff = pwp->x - x;
60
                if (diff > 0) {
61
                        width -= diff;
62
                        x = pwp->x;
63
                }
64
 
65
                diff = (pwp->x + pwp->width) - (x + width);
66
                if (diff < 0)
67
                        width += diff;
68
 
69
                diff = pwp->y - y;
70
                if (diff > 0) {
71
                        height -= diff;
72
                        y = pwp->y;
73
                }
74
 
75
                diff = (pwp->y + pwp->height) - (y + height);
76
                if (diff < 0)
77
                        height += diff;
78
        }
79
 
80
        /*
81
         * If the window is completely clipped out of view, then
82
         * set the clipping region to indicate that.
83
         */
84
        if (width <= 0 || height <= 0) {
85
                GdSetClipRegion(clipwp->psd, NULL);
86
                return;
87
        }
88
 
89
        /*
90
         * Allocate region to clipped size of window
91
         */
92
        vis = GdAllocRectRegion(x, y, x+width, y+height);
93
 
94
        /*
95
         * Allocate temp region
96
         */
97
        r = GdAllocRegion();
98
 
99
        /*
100
         * Now examine all windows that obscure this window, and
101
         * for each obscuration, break up the clip rectangles into
102
         * the smaller pieces that are still visible.  The windows
103
         * that can obscure us are the earlier siblings of all of
104
         * our parents.
105
         */
106
        orgwp = wp;
107
        pwp = wp;
108
        while (pwp != NULL) {
109
                wp = pwp;
110
                pwp = wp->parent;
111
 
112
                if(!pwp) {
113
                        /* We're clipping the root window*/
114
                        if (!(flags & GR_MODE_EXCLUDECHILDREN))
115
                                /* start with root's children*/
116
                                sibwp = rootwp->children;
117
                        else sibwp = NULL;       /* no search*/
118
                        wp = NULL;               /* search all root's children*/
119
                } else {
120
                        sibwp = pwp->children;   /* clip siblings*/
121
                }
122
 
123
                for (; sibwp != wp; sibwp = sibwp->siblings) {
124
                        if (sibwp->unmapcount || !sibwp->output)
125
                                continue;
126
 
127
                        bs = sibwp->bordersize;
128
                        minx = sibwp->x - bs;
129
                        miny = sibwp->y - bs;
130
                        maxx = sibwp->x + sibwp->width + bs;
131
                        maxy = sibwp->y + sibwp->height + bs;
132
 
133
                        GdSetRectRegion(r, minx, miny, maxx, maxy);
134
                        GdSubtractRegion(vis, vis, r);
135
                }
136
 
137
                /* if not clipping the root window, stop when you reach it*/
138
                if (pwp == rootwp)
139
                        break;
140
        }
141
 
142
        wp = orgwp;
143
        /*
144
         * If not the root window, clip all children.
145
         * (Root window's children are are clipped above)
146
         */
147
        if(wp != rootwp && !(flags & GR_MODE_EXCLUDECHILDREN)) {
148
                for (sibwp=wp->children; sibwp; sibwp = sibwp->siblings) {
149
                        if (sibwp->unmapcount || !sibwp->output)
150
                                continue;
151
 
152
                        bs = sibwp->bordersize;
153
                        minx = sibwp->x - bs;
154
                        miny = sibwp->y - bs;
155
                        maxx = sibwp->x + sibwp->width + bs;
156
                        maxy = sibwp->y + sibwp->height + bs;
157
 
158
                        GdSetRectRegion(r, minx, miny, maxx, maxy);
159
                        GdSubtractRegion(vis, vis, r);
160
                }
161
        }
162
 
163
        /*
164
         * Intersect with user region, if set.
165
         */
166
        if (userregion) {
167
                /* temporarily offset region by window coordinates*/
168
                GdOffsetRegion(userregion, wp->x, wp->y);
169
                GdIntersectRegion(vis, vis, userregion);
170
                GdOffsetRegion(userregion, -wp->x, -wp->y);
171
        }
172
 
173
        /*
174
         * Set the clip region (later destroy handled by GdSetClipRegion)
175
         */
176
        GdSetClipRegion(clipwp->psd, vis);
177
 
178
        /*
179
         * Destroy temp region
180
         */
181
        GdDestroyRegion(r);
182
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.