Merge branch 'mesa_7_5_branch'
[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
35 #include "id_screen.h"
36
37
38 struct identity_buffer
39 {
40 struct pipe_buffer base;
41
42 struct pipe_buffer *buffer;
43 };
44
45
46 struct identity_texture
47 {
48 struct pipe_texture base;
49
50 struct pipe_texture *texture;
51 };
52
53
54 struct identity_surface
55 {
56 struct pipe_surface base;
57
58 struct pipe_surface *surface;
59 };
60
61
62 struct identity_transfer
63 {
64 struct pipe_transfer base;
65
66 struct pipe_transfer *transfer;
67 };
68
69
70 static INLINE struct identity_buffer *
71 identity_buffer(struct pipe_buffer *_buffer)
72 {
73 if(!_buffer)
74 return NULL;
75 (void)identity_screen(_buffer->screen);
76 return (struct identity_buffer *)_buffer;
77 }
78
79 static INLINE struct identity_texture *
80 identity_texture(struct pipe_texture *_texture)
81 {
82 if(!_texture)
83 return NULL;
84 (void)identity_screen(_texture->screen);
85 return (struct identity_texture *)_texture;
86 }
87
88 static INLINE struct identity_surface *
89 identity_surface(struct pipe_surface *_surface)
90 {
91 if(!_surface)
92 return NULL;
93 (void)identity_texture(_surface->texture);
94 return (struct identity_surface *)_surface;
95 }
96
97 static INLINE struct identity_transfer *
98 identity_transfer(struct pipe_transfer *_transfer)
99 {
100 if(!_transfer)
101 return NULL;
102 (void)identity_texture(_transfer->texture);
103 return (struct identity_transfer *)_transfer;
104 }
105
106
107 static INLINE struct pipe_buffer *
108 identity_buffer_unwrap(struct pipe_buffer *_buffer)
109 {
110 if(!_buffer)
111 return NULL;
112 return identity_buffer(_buffer)->buffer;
113 }
114
115 static INLINE struct pipe_texture *
116 identity_texture_unwrap(struct pipe_texture *_texture)
117 {
118 if(!_texture)
119 return NULL;
120 return identity_texture(_texture)->texture;
121 }
122
123 static INLINE struct pipe_surface *
124 identity_surface_unwrap(struct pipe_surface *_surface)
125 {
126 if(!_surface)
127 return NULL;
128 return identity_surface(_surface)->surface;
129 }
130
131 static INLINE struct pipe_transfer *
132 identity_transfer_unwrap(struct pipe_transfer *_transfer)
133 {
134 if(!_transfer)
135 return NULL;
136 return identity_transfer(_transfer)->transfer;
137 }
138
139
140 struct pipe_buffer *
141 identity_buffer_create(struct identity_screen *id_screen,
142 struct pipe_buffer *buffer);
143
144 void
145 identity_buffer_destroy(struct identity_buffer *id_buffer);
146
147 struct pipe_texture *
148 identity_texture_create(struct identity_screen *id_screen,
149 struct pipe_texture *texture);
150
151 void
152 identity_texture_destroy(struct identity_texture *id_texture);
153
154 struct pipe_surface *
155 identity_surface_create(struct identity_texture *id_texture,
156 struct pipe_surface *surface);
157
158 void
159 identity_surface_destroy(struct identity_surface *id_surface);
160
161 struct pipe_transfer *
162 identity_transfer_create(struct identity_texture *id_texture,
163 struct pipe_transfer *transfer);
164
165 void
166 identity_transfer_destroy(struct identity_transfer *id_transfer);
167
168
169 #endif /* ID_OBJECTS_H */