VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/xorg-server-1.17.1/resource.h@ 78293

Last change on this file since 78293 was 54163, checked in by vboxsync, 10 years ago

Additions/x11/vboxvideo: support X.Org Server 1.17 (still untested).

  • Property svn:eol-style set to native
File size: 10.6 KB
Line 
1/***********************************************************
2
3Copyright 1987, 1989, 1998 The Open Group
4
5Permission to use, copy, modify, distribute, and sell this software and its
6documentation for any purpose is hereby granted without fee, provided that
7the above copyright notice appear in all copies and that both that
8copyright notice and this permission notice appear in supporting
9documentation.
10
11The above copyright notice and this permission notice shall be included in
12all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
21Except as contained in this notice, the name of The Open Group shall not be
22used in advertising or otherwise to promote the sale, use or other dealings
23in this Software without prior written authorization from The Open Group.
24
25Copyright 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
26
27 All Rights Reserved
28
29Permission to use, copy, modify, and distribute this software and its
30documentation for any purpose and without fee is hereby granted,
31provided that the above copyright notice appear in all copies and that
32both that copyright notice and this permission notice appear in
33supporting documentation, and that the name of Digital not be
34used in advertising or publicity pertaining to distribution of the
35software without specific, written prior permission.
36
37DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
38ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
39DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
40ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
41WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
42ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
43SOFTWARE.
44
45******************************************************************/
46
47#ifndef RESOURCE_H
48#define RESOURCE_H 1
49#include "misc.h"
50#include "dixaccess.h"
51
52/*****************************************************************
53 * STUFF FOR RESOURCES
54 *****************************************************************/
55
56/* classes for Resource routines */
57
58typedef uint32_t RESTYPE;
59
60#define RC_VANILLA ((RESTYPE)0)
61#define RC_CACHED ((RESTYPE)1<<31)
62#define RC_DRAWABLE ((RESTYPE)1<<30)
63/* Use class RC_NEVERRETAIN for resources that should not be retained
64 * regardless of the close down mode when the client dies. (A client's
65 * event selections on objects that it doesn't own are good candidates.)
66 * Extensions can use this too!
67 */
68#define RC_NEVERRETAIN ((RESTYPE)1<<29)
69#define RC_LASTPREDEF RC_NEVERRETAIN
70#define RC_ANY (~(RESTYPE)0)
71
72/* types for Resource routines */
73
74#define RT_WINDOW ((RESTYPE)1|RC_DRAWABLE)
75#define RT_PIXMAP ((RESTYPE)2|RC_DRAWABLE)
76#define RT_GC ((RESTYPE)3)
77#undef RT_FONT
78#undef RT_CURSOR
79#define RT_FONT ((RESTYPE)4)
80#define RT_CURSOR ((RESTYPE)5)
81#define RT_COLORMAP ((RESTYPE)6)
82#define RT_CMAPENTRY ((RESTYPE)7)
83#define RT_OTHERCLIENT ((RESTYPE)8|RC_NEVERRETAIN)
84#define RT_PASSIVEGRAB ((RESTYPE)9|RC_NEVERRETAIN)
85#define RT_LASTPREDEF ((RESTYPE)9)
86#define RT_NONE ((RESTYPE)0)
87
88/* bits and fields within a resource id */
89#define RESOURCE_AND_CLIENT_COUNT 29 /* 29 bits for XIDs */
90#if MAXCLIENTS == 64
91#define RESOURCE_CLIENT_BITS 6
92#endif
93#if MAXCLIENTS == 128
94#define RESOURCE_CLIENT_BITS 7
95#endif
96#if MAXCLIENTS == 256
97#define RESOURCE_CLIENT_BITS 8
98#endif
99#if MAXCLIENTS == 512
100#define RESOURCE_CLIENT_BITS 9
101#endif
102/* client field offset */
103#define CLIENTOFFSET (RESOURCE_AND_CLIENT_COUNT - RESOURCE_CLIENT_BITS)
104/* resource field */
105#define RESOURCE_ID_MASK ((1 << CLIENTOFFSET) - 1)
106/* client field */
107#define RESOURCE_CLIENT_MASK (((1 << RESOURCE_CLIENT_BITS) - 1) << CLIENTOFFSET)
108/* extract the client mask from an XID */
109#define CLIENT_BITS(id) ((id) & RESOURCE_CLIENT_MASK)
110/* extract the client id from an XID */
111#define CLIENT_ID(id) ((int)(CLIENT_BITS(id) >> CLIENTOFFSET))
112#define SERVER_BIT (Mask)0x40000000 /* use illegal bit */
113
114#ifdef INVALID
115#undef INVALID /* needed on HP/UX */
116#endif
117
118/* Invalid resource id */
119#define INVALID (0)
120
121#define BAD_RESOURCE 0xe0000000
122
123#define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
124
125/* Resource state callback */
126extern _X_EXPORT CallbackListPtr ResourceStateCallback;
127
128typedef enum { ResourceStateAdding,
129 ResourceStateFreeing
130} ResourceState;
131
132typedef struct {
133 ResourceState state;
134 XID id;
135 RESTYPE type;
136 void *value;
137} ResourceStateInfoRec;
138
139typedef int (*DeleteType) (void *value,
140 XID id);
141
142typedef void (*FindResType) (void *value,
143 XID id,
144 void *cdata);
145
146typedef void (*FindAllRes) (void *value,
147 XID id,
148 RESTYPE type,
149 void *cdata);
150
151typedef Bool (*FindComplexResType) (void *value,
152 XID id,
153 void *cdata);
154
155/* Structure for estimating resource memory usage. Memory usage
156 * consists of space allocated for the resource itself and of
157 * references to other resources. Currently the most important use for
158 * this structure is to estimate pixmap usage of different resources
159 * more accurately. */
160typedef struct {
161 /* Size of resource itself. Zero if not implemented. */
162 unsigned long resourceSize;
163 /* Size attributed to pixmap references from the resource. */
164 unsigned long pixmapRefSize;
165 /* Number of references to this resource; typically 1 */
166 unsigned long refCnt;
167} ResourceSizeRec, *ResourceSizePtr;
168
169typedef void (*SizeType)(void *value,
170 XID id,
171 ResourceSizePtr size);
172
173extern _X_EXPORT RESTYPE CreateNewResourceType(DeleteType deleteFunc,
174 const char *name);
175
176typedef void (*FindTypeSubResources)(void *value,
177 FindAllRes func,
178 void *cdata);
179
180extern _X_EXPORT SizeType GetResourceTypeSizeFunc(
181 RESTYPE /*type*/);
182
183extern _X_EXPORT void SetResourceTypeFindSubResFunc(
184 RESTYPE /*type*/, FindTypeSubResources /*findFunc*/);
185
186extern _X_EXPORT void SetResourceTypeSizeFunc(
187 RESTYPE /*type*/, SizeType /*sizeFunc*/);
188
189extern _X_EXPORT void SetResourceTypeErrorValue(
190 RESTYPE /*type*/, int /*errorValue*/);
191
192extern _X_EXPORT RESTYPE CreateNewResourceClass(void);
193
194extern _X_EXPORT Bool InitClientResources(ClientPtr /*client */ );
195
196extern _X_EXPORT XID FakeClientID(int /*client */ );
197
198/* Quartz support on Mac OS X uses the CarbonCore
199 framework whose AddResource function conflicts here. */
200#ifdef __APPLE__
201#define AddResource Darwin_X_AddResource
202#endif
203extern _X_EXPORT Bool AddResource(XID id,
204 RESTYPE type,
205 void *value);
206
207extern _X_EXPORT void FreeResource(XID /*id */ ,
208 RESTYPE /*skipDeleteFuncType */ );
209
210extern _X_EXPORT void FreeResourceByType(XID /*id */ ,
211 RESTYPE /*type */ ,
212 Bool /*skipFree */ );
213
214extern _X_EXPORT Bool ChangeResourceValue(XID id,
215 RESTYPE rtype,
216 void *value);
217
218extern _X_EXPORT void FindClientResourcesByType(ClientPtr client,
219 RESTYPE type,
220 FindResType func,
221 void *cdata);
222
223extern _X_EXPORT void FindAllClientResources(ClientPtr client,
224 FindAllRes func,
225 void *cdata);
226
227/** @brief Iterate through all subresources of a resource.
228
229 @note The XID argument provided to the FindAllRes function
230 may be 0 for subresources that don't have an XID */
231extern _X_EXPORT void FindSubResources(void *resource,
232 RESTYPE type,
233 FindAllRes func,
234 void *cdata);
235
236extern _X_EXPORT void FreeClientNeverRetainResources(ClientPtr /*client */ );
237
238extern _X_EXPORT void FreeClientResources(ClientPtr /*client */ );
239
240extern _X_EXPORT void FreeAllResources(void);
241
242extern _X_EXPORT Bool LegalNewID(XID /*id */ ,
243 ClientPtr /*client */ );
244
245extern _X_EXPORT void *LookupClientResourceComplex(ClientPtr client,
246 RESTYPE type,
247 FindComplexResType func,
248 void *cdata);
249
250extern _X_EXPORT int dixLookupResourceByType(void **result,
251 XID id,
252 RESTYPE rtype,
253 ClientPtr client,
254 Mask access_mode);
255
256extern _X_EXPORT int dixLookupResourceByClass(void **result,
257 XID id,
258 RESTYPE rclass,
259 ClientPtr client,
260 Mask access_mode);
261
262extern _X_EXPORT void GetXIDRange(int /*client */ ,
263 Bool /*server */ ,
264 XID * /*minp */ ,
265 XID * /*maxp */ );
266
267extern _X_EXPORT unsigned int GetXIDList(ClientPtr /*client */ ,
268 unsigned int /*count */ ,
269 XID * /*pids */ );
270
271extern _X_EXPORT RESTYPE lastResourceType;
272extern _X_EXPORT RESTYPE TypeMask;
273
274/** @brief A hashing function to be used for hashing resource IDs
275
276 @param id The resource ID to hash
277 @param numBits The number of bits in the resulting hash. Must be >=0.
278
279 @note This function is really only for handling
280 INITHASHSIZE..MAXHASHSIZE bit hashes, but will handle any number
281 of bits by either masking numBits lower bits of the ID or by
282 providing at most MAXHASHSIZE hashes.
283*/
284extern _X_EXPORT int HashResourceID(XID id,
285 int numBits);
286
287#endif /* RESOURCE_H */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette