Merge remote branch 'origin/master' into gallium_draw_llvm
[mesa.git] / src / gallium / drivers / identity / id_objects.h
1 /**************************************************************************
2 *
3 * Copyright 2009 VMware, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #ifndef ID_OBJECTS_H
29 #define ID_OBJECTS_H
30
31
32 #include "pipe/p_compiler.h"
33 #include "pipe/p_state.h"
34 #include "pipe/p_video_state.h"
35
36 #include "id_screen.h"
37
38 struct identity_context;
39
40 struct identity_buffer
41 {
42 struct pipe_buffer base;
43
44 struct pipe_buffer *buffer;
45 };
46
47
48 struct identity_texture
49 {
50 struct pipe_texture base;
51
52 struct pipe_texture *texture;
53 };
54
55
56 struct identity_surface
57 {
58 struct pipe_surface base;
59
60 struct pipe_surface *surface;
61 };
62
63
64 struct identity_transfer
65 {
66 struct pipe_transfer base;
67
68 struct pipe_context *pipe;
69 struct pipe_transfer *transfer;
70 };
71
72
73 struct identity_video_surface
74 {
75 struct pipe_video_surface base;
76
77 struct pipe_video_surface *video_surface;
78 };
79
80
81 static INLINE struct identity_buffer *
82 identity_buffer(struct pipe_buffer *_buffer)
83 {
84 if(!_buffer)
85 return NULL;
86 (void)identity_screen(_buffer->screen);
87 return (struct identity_buffer *)_buffer;
88 }
89
90 static INLINE struct identity_texture *
91 identity_texture(struct pipe_texture *_texture)
92 {
93 if(!_texture)
94 return NULL;
95 (void)identity_screen(_texture->screen);
96 return (struct identity_texture *)_texture;
97 }
98
99 static INLINE struct identity_surface *
100 identity_surface(struct pipe_surface *_surface)
101 {
102 if(!_surface)
103 return NULL;
104 (void)identity_texture(_surface->texture);
105 return (struct identity_surface *)_surface;
106 }
107
108 static INLINE struct identity_transfer *
109 identity_transfer(struct pipe_transfer *_transfer)
110 {
111 if(!_transfer)
112 return NULL;
113 (void)identity_texture(_transfer->texture);
114 return (struct identity_transfer *)_transfer;
115 }
116
117 static INLINE struct identity_video_surface *
118 identity_video_surface(struct pipe_video_surface *_video_surface)
119 {
120 if (!_video_surface) {
121 return NULL;
122 }
123 (void)identity_screen(_video_surface->screen);
124 return (struct identity_video_surface *)_video_surface;
125 }
126
127 static INLINE struct pipe_buffer *
128 identity_buffer_unwrap(struct pipe_buffer *_buffer)
129 {
130 if(!_buffer)
131 return NULL;
132 return identity_buffer(_buffer)->buffer;
133 }
134
135 static INLINE struct pipe_texture *
136 identity_texture_unwrap(struct pipe_texture *_texture)
137 {
138 if(!_texture)
139 return NULL;
140 return identity_texture(_texture)->texture;
141 }
142
143 static INLINE struct pipe_surface *
144 identity_surface_unwrap(struct pipe_surface *_surface)
145 {
146 if(!_surface)
147 return NULL;
148 return identity_surface(_surface)->surface;
149 }
150
151 static INLINE struct pipe_transfer *
152 identity_transfer_unwrap(struct pipe_transfer *_transfer)
153 {
154 if(!_transfer)
155 return NULL;
156 return identity_transfer(_transfer)->transfer;
157 }
158
159
160 struct pipe_buffer *
161 identity_buffer_create(struct identity_screen *id_screen,
162 struct pipe_buffer *buffer);
163
164 void
165 identity_buffer_destroy(struct identity_buffer *id_buffer);
166
167 struct pipe_texture *
168 identity_texture_create(struct identity_screen *id_screen,
169 struct pipe_texture *texture);
170
171 void
172 identity_texture_destroy(struct identity_texture *id_texture);
173
174 struct pipe_surface *
175 identity_surface_create(struct identity_texture *id_texture,
176 struct pipe_surface *surface);
177
178 void
179 identity_surface_destroy(struct identity_surface *id_surface);
180
181 struct pipe_transfer *
182 identity_transfer_create(struct identity_context *id_context,
183 struct identity_texture *id_texture,
184 struct pipe_transfer *transfer);
185
186 void
187 identity_transfer_destroy(struct identity_context *id_context,
188 struct identity_transfer *id_transfer);
189
190 struct pipe_video_surface *
191 identity_video_surface_create(struct identity_screen *id_screen,
192 struct pipe_video_surface *video_surface);
193
194 void
195 identity_video_surface_destroy(struct identity_video_surface *id_video_surface);
196
197
198 #endif /* ID_OBJECTS_H */