revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / mesa / src / gallium / state_trackers / vega / handle.h
blob9ed326d5098c85db1002ce9d7ab16f3bf8ac033a
1 /**************************************************************************
3 * Copyright 2010 VMware, Inc. All Rights Reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sub license, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial portions
15 * of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
21 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 **************************************************************************/
28 /**
29 * Convert opaque VG object handles into pointers and vice versa.
30 * XXX This is not yet 64-bit safe! All VG handles are 32 bits in size.
34 #ifndef HANDLE_H
35 #define HANDLE_H
37 #include "pipe/p_compiler.h"
38 #include "util/u_hash_table.h"
39 #include "util/u_pointer.h"
41 #include "VG/openvg.h"
42 #include "vg_context.h"
45 extern struct util_hash_table *handle_hash;
48 struct vg_mask_layer;
49 struct vg_font;
50 struct vg_image;
51 struct vg_paint;
52 struct path;
55 extern void
56 init_handles(void);
59 extern void
60 free_handles(void);
63 extern VGHandle
64 create_handle(void *object);
67 extern void
68 destroy_handle(VGHandle h);
71 static INLINE VGHandle
72 object_to_handle(struct vg_object *obj)
74 return obj ? obj->handle : VG_INVALID_HANDLE;
78 static INLINE VGHandle
79 image_to_handle(struct vg_image *img)
81 /* vg_image is derived from vg_object */
82 return object_to_handle((struct vg_object *) img);
86 static INLINE VGHandle
87 masklayer_to_handle(struct vg_mask_layer *mask)
89 /* vg_object is derived from vg_object */
90 return object_to_handle((struct vg_object *) mask);
94 static INLINE VGHandle
95 font_to_handle(struct vg_font *font)
97 return object_to_handle((struct vg_object *) font);
101 static INLINE VGHandle
102 paint_to_handle(struct vg_paint *paint)
104 return object_to_handle((struct vg_object *) paint);
108 static INLINE VGHandle
109 path_to_handle(struct path *path)
111 return object_to_handle((struct vg_object *) path);
115 static INLINE void *
116 handle_to_pointer(VGHandle h)
118 void *v = util_hash_table_get(handle_hash, intptr_to_pointer(h));
119 #ifdef DEBUG
120 if (v) {
121 struct vg_object *obj = (struct vg_object *) v;
122 assert(obj->handle == h);
124 #endif
125 return v;
129 static INLINE struct vg_font *
130 handle_to_font(VGHandle h)
132 return (struct vg_font *) handle_to_pointer(h);
136 static INLINE struct vg_image *
137 handle_to_image(VGHandle h)
139 return (struct vg_image *) handle_to_pointer(h);
143 static INLINE struct vg_mask_layer *
144 handle_to_masklayer(VGHandle h)
146 return (struct vg_mask_layer *) handle_to_pointer(h);
150 static INLINE struct vg_object *
151 handle_to_object(VGHandle h)
153 return (struct vg_object *) handle_to_pointer(h);
157 static INLINE struct vg_paint *
158 handle_to_paint(VGHandle h)
160 return (struct vg_paint *) handle_to_pointer(h);
164 static INLINE struct path *
165 handle_to_path(VGHandle h)
167 return (struct path *) handle_to_pointer(h);
171 #endif /* HANDLE_H */