mesa: make _mesa_get_proxy_target() non-static
[profile/ivi/mesa.git] / src / mesa / main / teximage.h
1 /**
2  * \file teximage.h
3  * Texture images manipulation functions.
4  */
5
6 /*
7  * Mesa 3-D graphics library
8  * Version:  6.5
9  *
10  * Copyright (C) 1999-2005  Brian Paul   All Rights Reserved.
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining a
13  * copy of this software and associated documentation files (the "Software"),
14  * to deal in the Software without restriction, including without limitation
15  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16  * and/or sell copies of the Software, and to permit persons to whom the
17  * Software is furnished to do so, subject to the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be included
20  * in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
25  * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
26  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28  */
29
30
31 #ifndef TEXIMAGE_H
32 #define TEXIMAGE_H
33
34
35 #include "mtypes.h"
36 #include "formats.h"
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41
42 /** Is the given value one of the 6 cube faces? */
43 static inline GLboolean
44 _mesa_is_cube_face(GLenum target)
45 {
46    return (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
47            target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB);
48 }
49
50 /** Is any of the dimensions of given texture equal to zero? */
51 static inline GLboolean
52 _mesa_is_zero_size_texture(const struct gl_texture_image *texImage)
53 {
54    return (texImage->Width == 0 ||
55            texImage->Height == 0 ||
56            texImage->Depth == 0);
57 }
58
59 /** \name Internal functions */
60 /*@{*/
61
62 extern GLint
63 _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat );
64
65
66 extern GLboolean
67 _mesa_is_proxy_texture(GLenum target);
68
69 extern GLenum
70 _mesa_get_proxy_target(GLenum target);
71
72 extern struct gl_texture_image *
73 _mesa_new_texture_image( struct gl_context *ctx );
74
75
76 extern void
77 _mesa_delete_texture_image( struct gl_context *ctx,
78                             struct gl_texture_image *teximage );
79
80
81 extern void
82 _mesa_init_teximage_fields(struct gl_context *ctx,
83                            struct gl_texture_image *img,
84                            GLsizei width, GLsizei height, GLsizei depth,
85                            GLint border, GLenum internalFormat,
86                            gl_format format);
87
88
89 extern gl_format
90 _mesa_choose_texture_format(struct gl_context *ctx,
91                             struct gl_texture_object *texObj,
92                             GLenum target, GLint level,
93                             GLenum internalFormat, GLenum format, GLenum type);
94
95 extern void
96 _mesa_update_fbo_texture(struct gl_context *ctx,
97                          struct gl_texture_object *texObj,
98                          GLuint face, GLuint level);
99
100 extern void
101 _mesa_clear_texture_image(struct gl_context *ctx,
102                           struct gl_texture_image *texImage);
103
104
105 extern struct gl_texture_object *
106 _mesa_select_tex_object(struct gl_context *ctx,
107                         const struct gl_texture_unit *texUnit,
108                         GLenum target);
109
110 extern struct gl_texture_object *
111 _mesa_get_current_tex_object(struct gl_context *ctx, GLenum target);
112
113
114 extern struct gl_texture_image *
115 _mesa_select_tex_image(struct gl_context *ctx,
116                        const struct gl_texture_object *texObj,
117                        GLenum target, GLint level);
118
119
120 extern struct gl_texture_image *
121 _mesa_get_tex_image(struct gl_context *ctx, struct gl_texture_object *texObj,
122                     GLenum target, GLint level);
123
124
125 extern GLint
126 _mesa_max_texture_levels(struct gl_context *ctx, GLenum target);
127
128
129 extern GLboolean
130 _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level,
131                          GLint internalFormat, GLenum format, GLenum type,
132                          GLint width, GLint height, GLint depth, GLint border);
133
134
135 extern GLuint
136 _mesa_tex_target_to_face(GLenum target);
137
138 extern GLint
139 _mesa_get_texture_dimensions(GLenum target);
140
141 extern GLenum
142 _mesa_es_error_check_format_and_type(GLenum format, GLenum type,
143                                      unsigned dimensions);
144
145 /**
146  * Lock a texture for updating.  See also _mesa_lock_context_textures().
147  */
148 static inline void
149 _mesa_lock_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
150 {
151    _glthread_LOCK_MUTEX(ctx->Shared->TexMutex);
152    ctx->Shared->TextureStateStamp++;
153    (void) texObj;
154 }
155
156 static inline void
157 _mesa_unlock_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
158 {
159    (void) texObj;
160    _glthread_UNLOCK_MUTEX(ctx->Shared->TexMutex);
161 }
162
163 /*@}*/
164
165
166 /** \name API entry point functions */
167 /*@{*/
168
169 extern void GLAPIENTRY
170 _mesa_TexImage1D( GLenum target, GLint level, GLint internalformat,
171                   GLsizei width, GLint border,
172                   GLenum format, GLenum type, const GLvoid *pixels );
173
174
175 extern void GLAPIENTRY
176 _mesa_TexImage2D( GLenum target, GLint level, GLint internalformat,
177                   GLsizei width, GLsizei height, GLint border,
178                   GLenum format, GLenum type, const GLvoid *pixels );
179
180
181 extern void GLAPIENTRY
182 _mesa_TexImage3D( GLenum target, GLint level, GLint internalformat,
183                   GLsizei width, GLsizei height, GLsizei depth, GLint border,
184                   GLenum format, GLenum type, const GLvoid *pixels );
185
186
187 extern void GLAPIENTRY
188 _mesa_TexImage3DEXT( GLenum target, GLint level, GLenum internalformat,
189                      GLsizei width, GLsizei height, GLsizei depth,
190                      GLint border, GLenum format, GLenum type,
191                      const GLvoid *pixels );
192
193 extern void GLAPIENTRY
194 _mesa_EGLImageTargetTexture2DOES( GLenum target, GLeglImageOES image );
195
196 extern void GLAPIENTRY
197 _mesa_TexSubImage1D( GLenum target, GLint level, GLint xoffset,
198                      GLsizei width,
199                      GLenum format, GLenum type,
200                      const GLvoid *pixels );
201
202
203 extern void GLAPIENTRY
204 _mesa_TexSubImage2D( GLenum target, GLint level,
205                      GLint xoffset, GLint yoffset,
206                      GLsizei width, GLsizei height,
207                      GLenum format, GLenum type,
208                      const GLvoid *pixels );
209
210
211 extern void GLAPIENTRY
212 _mesa_TexSubImage3D( GLenum target, GLint level,
213                      GLint xoffset, GLint yoffset, GLint zoffset,
214                      GLsizei width, GLsizei height, GLsizei depth,
215                      GLenum format, GLenum type,
216                      const GLvoid *pixels );
217
218
219 extern void GLAPIENTRY
220 _mesa_CopyTexImage1D( GLenum target, GLint level, GLenum internalformat,
221                       GLint x, GLint y, GLsizei width, GLint border );
222
223
224 extern void GLAPIENTRY
225 _mesa_CopyTexImage2D( GLenum target, GLint level,
226                       GLenum internalformat, GLint x, GLint y,
227                       GLsizei width, GLsizei height, GLint border );
228
229
230 extern void GLAPIENTRY
231 _mesa_CopyTexSubImage1D( GLenum target, GLint level, GLint xoffset,
232                          GLint x, GLint y, GLsizei width );
233
234
235 extern void GLAPIENTRY
236 _mesa_CopyTexSubImage2D( GLenum target, GLint level,
237                          GLint xoffset, GLint yoffset,
238                          GLint x, GLint y, GLsizei width, GLsizei height );
239
240
241 extern void GLAPIENTRY
242 _mesa_CopyTexSubImage3D( GLenum target, GLint level,
243                          GLint xoffset, GLint yoffset, GLint zoffset,
244                          GLint x, GLint y, GLsizei width, GLsizei height );
245
246
247
248 extern void GLAPIENTRY
249 _mesa_CompressedTexImage1DARB(GLenum target, GLint level,
250                               GLenum internalformat, GLsizei width,
251                               GLint border, GLsizei imageSize,
252                               const GLvoid *data);
253
254 extern void GLAPIENTRY
255 _mesa_CompressedTexImage2DARB(GLenum target, GLint level,
256                               GLenum internalformat, GLsizei width,
257                               GLsizei height, GLint border, GLsizei imageSize,
258                               const GLvoid *data);
259
260 extern void GLAPIENTRY
261 _mesa_CompressedTexImage3DARB(GLenum target, GLint level,
262                               GLenum internalformat, GLsizei width,
263                               GLsizei height, GLsizei depth, GLint border,
264                               GLsizei imageSize, const GLvoid *data);
265
266 #ifdef VMS
267 #define _mesa_CompressedTexSubImage1DARB _mesa_CompressedTexSubImage1DAR
268 #define _mesa_CompressedTexSubImage2DARB _mesa_CompressedTexSubImage2DAR
269 #define _mesa_CompressedTexSubImage3DARB _mesa_CompressedTexSubImage3DAR
270 #endif
271 extern void GLAPIENTRY
272 _mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
273                                  GLsizei width, GLenum format,
274                                  GLsizei imageSize, const GLvoid *data);
275
276 extern void GLAPIENTRY
277 _mesa_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
278                                  GLint yoffset, GLsizei width, GLsizei height,
279                                  GLenum format, GLsizei imageSize,
280                                  const GLvoid *data);
281
282 extern void GLAPIENTRY
283 _mesa_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
284                                  GLint yoffset, GLint zoffset, GLsizei width,
285                                  GLsizei height, GLsizei depth, GLenum format,
286                                  GLsizei imageSize, const GLvoid *data);
287
288
289 extern void GLAPIENTRY
290 _mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer);
291
292
293 /*@}*/
294
295 #ifdef __cplusplus
296 }
297 #endif
298
299 #endif