9a07ebe8d725c471667cafa72ded9ab5b2bd2824
[profile/ivi/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_sampler_view
57 {
58    struct pipe_sampler_view base;
59
60    struct pipe_sampler_view *sampler_view;
61 };
62
63
64 struct identity_surface
65 {
66    struct pipe_surface base;
67
68    struct pipe_surface *surface;
69 };
70
71
72 struct identity_transfer
73 {
74    struct pipe_transfer base;
75
76    struct pipe_context *pipe;
77    struct pipe_transfer *transfer;
78 };
79
80
81 struct identity_video_surface
82 {
83    struct pipe_video_surface base;
84
85    struct pipe_video_surface *video_surface;
86 };
87
88
89 static INLINE struct identity_buffer *
90 identity_buffer(struct pipe_buffer *_buffer)
91 {
92    if(!_buffer)
93       return NULL;
94    (void)identity_screen(_buffer->screen);
95    return (struct identity_buffer *)_buffer;
96 }
97
98 static INLINE struct identity_texture *
99 identity_texture(struct pipe_texture *_texture)
100 {
101    if(!_texture)
102       return NULL;
103    (void)identity_screen(_texture->screen);
104    return (struct identity_texture *)_texture;
105 }
106
107 static INLINE struct identity_sampler_view *
108 identity_sampler_view(struct pipe_sampler_view *_sampler_view)
109 {
110    if (!_sampler_view) {
111       return NULL;
112    }
113    return (struct identity_sampler_view *)_sampler_view;
114 }
115
116 static INLINE struct identity_surface *
117 identity_surface(struct pipe_surface *_surface)
118 {
119    if(!_surface)
120       return NULL;
121    (void)identity_texture(_surface->texture);
122    return (struct identity_surface *)_surface;
123 }
124
125 static INLINE struct identity_transfer *
126 identity_transfer(struct pipe_transfer *_transfer)
127 {
128    if(!_transfer)
129       return NULL;
130    (void)identity_texture(_transfer->texture);
131    return (struct identity_transfer *)_transfer;
132 }
133
134 static INLINE struct identity_video_surface *
135 identity_video_surface(struct pipe_video_surface *_video_surface)
136 {
137    if (!_video_surface) {
138       return NULL;
139    }
140    (void)identity_screen(_video_surface->screen);
141    return (struct identity_video_surface *)_video_surface;
142 }
143
144 static INLINE struct pipe_buffer *
145 identity_buffer_unwrap(struct pipe_buffer *_buffer)
146 {
147    if(!_buffer)
148       return NULL;
149    return identity_buffer(_buffer)->buffer;
150 }
151
152 static INLINE struct pipe_texture *
153 identity_texture_unwrap(struct pipe_texture *_texture)
154 {
155    if(!_texture)
156       return NULL;
157    return identity_texture(_texture)->texture;
158 }
159
160 static INLINE struct pipe_sampler_view *
161 identity_sampler_view_unwrap(struct pipe_sampler_view *_sampler_view)
162 {
163    if (!_sampler_view) {
164       return NULL;
165    }
166    return identity_sampler_view(_sampler_view)->sampler_view;
167 }
168
169 static INLINE struct pipe_surface *
170 identity_surface_unwrap(struct pipe_surface *_surface)
171 {
172    if(!_surface)
173       return NULL;
174    return identity_surface(_surface)->surface;
175 }
176
177 static INLINE struct pipe_transfer *
178 identity_transfer_unwrap(struct pipe_transfer *_transfer)
179 {
180    if(!_transfer)
181       return NULL;
182    return identity_transfer(_transfer)->transfer;
183 }
184
185
186 struct pipe_buffer *
187 identity_buffer_create(struct identity_screen *id_screen,
188                        struct pipe_buffer *buffer);
189
190 void
191 identity_buffer_destroy(struct identity_buffer *id_buffer);
192
193 struct pipe_texture *
194 identity_texture_create(struct identity_screen *id_screen,
195                         struct pipe_texture *texture);
196
197 void
198 identity_texture_destroy(struct identity_texture *id_texture);
199
200 struct pipe_surface *
201 identity_surface_create(struct identity_texture *id_texture,
202                         struct pipe_surface *surface);
203
204 void
205 identity_surface_destroy(struct identity_surface *id_surface);
206
207 struct pipe_transfer *
208 identity_transfer_create(struct identity_context *id_context,
209                          struct identity_texture *id_texture,
210                          struct pipe_transfer *transfer);
211
212 void
213 identity_transfer_destroy(struct identity_context *id_context,
214                           struct identity_transfer *id_transfer);
215
216 struct pipe_video_surface *
217 identity_video_surface_create(struct identity_screen *id_screen,
218                               struct pipe_video_surface *video_surface);
219
220 void
221 identity_video_surface_destroy(struct identity_video_surface *id_video_surface);
222
223
224 #endif /* ID_OBJECTS_H */