VirtualBox

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

Last change on this file since 78293 was 58634, checked in by vboxsync, 9 years ago

Additions/x11: added header files for building X.Org video driver against X.Org Server 1.18.

  • Property svn:eol-style set to native
File size: 10.5 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
88extern _X_EXPORT unsigned int ResourceClientBits(void);
89/* bits and fields within a resource id */
90#define RESOURCE_AND_CLIENT_COUNT 29 /* 29 bits for XIDs */
91#define RESOURCE_CLIENT_BITS ResourceClientBits() /* client field offset */
92#define CLIENTOFFSET (RESOURCE_AND_CLIENT_COUNT - RESOURCE_CLIENT_BITS)
93/* resource field */
94#define RESOURCE_ID_MASK ((1 << CLIENTOFFSET) - 1)
95/* client field */
96#define RESOURCE_CLIENT_MASK (((1 << RESOURCE_CLIENT_BITS) - 1) << CLIENTOFFSET)
97/* extract the client mask from an XID */
98#define CLIENT_BITS(id) ((id) & RESOURCE_CLIENT_MASK)
99/* extract the client id from an XID */
100#define CLIENT_ID(id) ((int)(CLIENT_BITS(id) >> CLIENTOFFSET))
101#define SERVER_BIT (Mask)0x40000000 /* use illegal bit */
102
103#ifdef INVALID
104#undef INVALID /* needed on HP/UX */
105#endif
106
107/* Invalid resource id */
108#define INVALID (0)
109
110#define BAD_RESOURCE 0xe0000000
111
112#define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
113
114/* Resource state callback */
115extern _X_EXPORT CallbackListPtr ResourceStateCallback;
116
117typedef enum { ResourceStateAdding,
118 ResourceStateFreeing
119} ResourceState;
120
121typedef struct {
122 ResourceState state;
123 XID id;
124 RESTYPE type;
125 void *value;
126} ResourceStateInfoRec;
127
128typedef int (*DeleteType) (void *value,
129 XID id);
130
131typedef void (*FindResType) (void *value,
132 XID id,
133 void *cdata);
134
135typedef void (*FindAllRes) (void *value,
136 XID id,
137 RESTYPE type,
138 void *cdata);
139
140typedef Bool (*FindComplexResType) (void *value,
141 XID id,
142 void *cdata);
143
144/* Structure for estimating resource memory usage. Memory usage
145 * consists of space allocated for the resource itself and of
146 * references to other resources. Currently the most important use for
147 * this structure is to estimate pixmap usage of different resources
148 * more accurately. */
149typedef struct {
150 /* Size of resource itself. Zero if not implemented. */
151 unsigned long resourceSize;
152 /* Size attributed to pixmap references from the resource. */
153 unsigned long pixmapRefSize;
154 /* Number of references to this resource; typically 1 */
155 unsigned long refCnt;
156} ResourceSizeRec, *ResourceSizePtr;
157
158typedef void (*SizeType)(void *value,
159 XID id,
160 ResourceSizePtr size);
161
162extern _X_EXPORT RESTYPE CreateNewResourceType(DeleteType deleteFunc,
163 const char *name);
164
165typedef void (*FindTypeSubResources)(void *value,
166 FindAllRes func,
167 void *cdata);
168
169extern _X_EXPORT SizeType GetResourceTypeSizeFunc(
170 RESTYPE /*type*/);
171
172extern _X_EXPORT void SetResourceTypeFindSubResFunc(
173 RESTYPE /*type*/, FindTypeSubResources /*findFunc*/);
174
175extern _X_EXPORT void SetResourceTypeSizeFunc(
176 RESTYPE /*type*/, SizeType /*sizeFunc*/);
177
178extern _X_EXPORT void SetResourceTypeErrorValue(
179 RESTYPE /*type*/, int /*errorValue*/);
180
181extern _X_EXPORT RESTYPE CreateNewResourceClass(void);
182
183extern _X_EXPORT Bool InitClientResources(ClientPtr /*client */ );
184
185extern _X_EXPORT XID FakeClientID(int /*client */ );
186
187/* Quartz support on Mac OS X uses the CarbonCore
188 framework whose AddResource function conflicts here. */
189#ifdef __APPLE__
190#define AddResource Darwin_X_AddResource
191#endif
192extern _X_EXPORT Bool AddResource(XID id,
193 RESTYPE type,
194 void *value);
195
196extern _X_EXPORT void FreeResource(XID /*id */ ,
197 RESTYPE /*skipDeleteFuncType */ );
198
199extern _X_EXPORT void FreeResourceByType(XID /*id */ ,
200 RESTYPE /*type */ ,
201 Bool /*skipFree */ );
202
203extern _X_EXPORT Bool ChangeResourceValue(XID id,
204 RESTYPE rtype,
205 void *value);
206
207extern _X_EXPORT void FindClientResourcesByType(ClientPtr client,
208 RESTYPE type,
209 FindResType func,
210 void *cdata);
211
212extern _X_EXPORT void FindAllClientResources(ClientPtr client,
213 FindAllRes func,
214 void *cdata);
215
216/** @brief Iterate through all subresources of a resource.
217
218 @note The XID argument provided to the FindAllRes function
219 may be 0 for subresources that don't have an XID */
220extern _X_EXPORT void FindSubResources(void *resource,
221 RESTYPE type,
222 FindAllRes func,
223 void *cdata);
224
225extern _X_EXPORT void FreeClientNeverRetainResources(ClientPtr /*client */ );
226
227extern _X_EXPORT void FreeClientResources(ClientPtr /*client */ );
228
229extern _X_EXPORT void FreeAllResources(void);
230
231extern _X_EXPORT Bool LegalNewID(XID /*id */ ,
232 ClientPtr /*client */ );
233
234extern _X_EXPORT void *LookupClientResourceComplex(ClientPtr client,
235 RESTYPE type,
236 FindComplexResType func,
237 void *cdata);
238
239extern _X_EXPORT int dixLookupResourceByType(void **result,
240 XID id,
241 RESTYPE rtype,
242 ClientPtr client,
243 Mask access_mode);
244
245extern _X_EXPORT int dixLookupResourceByClass(void **result,
246 XID id,
247 RESTYPE rclass,
248 ClientPtr client,
249 Mask access_mode);
250
251extern _X_EXPORT void GetXIDRange(int /*client */ ,
252 Bool /*server */ ,
253 XID * /*minp */ ,
254 XID * /*maxp */ );
255
256extern _X_EXPORT unsigned int GetXIDList(ClientPtr /*client */ ,
257 unsigned int /*count */ ,
258 XID * /*pids */ );
259
260extern _X_EXPORT RESTYPE lastResourceType;
261extern _X_EXPORT RESTYPE TypeMask;
262
263/** @brief A hashing function to be used for hashing resource IDs
264
265 @param id The resource ID to hash
266 @param numBits The number of bits in the resulting hash. Must be >=0.
267
268 @note This function is really only for handling
269 INITHASHSIZE..MAXHASHSIZE bit hashes, but will handle any number
270 of bits by either masking numBits lower bits of the ID or by
271 providing at most MAXHASHSIZE hashes.
272*/
273extern _X_EXPORT int HashResourceID(XID id,
274 int numBits);
275
276#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