handle.h revision d41e694cf78ada8c9258f96995115c9da8437894
1/**************************************************************************
2 *
3 * Copyright 2010 VMware, Inc.  All Rights Reserved.
4 *
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:
12 *
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.
16 *
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.
24 *
25 **************************************************************************/
26
27
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.
31 */
32
33
34#ifndef HANDLE_H
35#define HANDLE_H
36
37#include "VG/openvg.h"
38#include "pipe/p_compiler.h"
39
40
41struct vg_mask_layer;
42struct vg_font;
43struct vg_image;
44struct vg_paint;
45struct path;
46
47
48static INLINE VGHandle
49image_to_handle(struct vg_image *img)
50{
51   return (VGHandle) img;
52}
53
54
55static INLINE VGHandle
56masklayer_to_handle(struct vg_mask_layer *mask)
57{
58   return (VGHandle) mask;
59}
60
61
62static INLINE VGHandle
63font_to_handle(struct vg_font *font)
64{
65   return (VGHandle) font;
66}
67
68static INLINE VGHandle
69paint_to_handle(struct vg_paint *paint)
70{
71   return (VGHandle) paint;
72}
73
74static INLINE VGHandle
75path_to_handle(struct path *path)
76{
77   return (VGHandle) path;
78}
79
80
81static INLINE void *
82handle_to_pointer(VGHandle h)
83{
84   return (void *) h;
85}
86
87
88static INLINE struct vg_font *
89handle_to_font(VGHandle h)
90{
91   return (struct vg_font *) handle_to_pointer(h);
92}
93
94
95static INLINE struct vg_image *
96handle_to_image(VGHandle h)
97{
98   return (struct vg_image *) handle_to_pointer(h);
99}
100
101
102static INLINE struct vg_mask_layer *
103handle_to_masklayer(VGHandle h)
104{
105   return (struct vg_mask_layer *) handle_to_pointer(h);
106}
107
108
109static INLINE struct vg_object *
110handle_to_object(VGHandle h)
111{
112   return (struct vg_object *) handle_to_pointer(h);
113}
114
115
116static INLINE struct vg_paint *
117handle_to_paint(VGHandle h)
118{
119   return (struct vg_paint *) handle_to_pointer(h);
120}
121
122
123static INLINE struct path *
124handle_to_path(VGHandle h)
125{
126   return (struct path *) handle_to_pointer(h);
127}
128
129
130#endif /* HANDLE_H */
131