739c5dda13248ec8fa721225d951095a6e694c34
[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
70 extern struct gl_texture_image *
71 _mesa_new_texture_image( struct gl_context *ctx );
72
73
74 extern void
75 _mesa_delete_texture_image( struct gl_context *ctx,
76                             struct gl_texture_image *teximage );
77
78
79 extern void
80 _mesa_init_teximage_fields(struct gl_context *ctx,
81                            struct gl_texture_image *img,
82                            GLsizei width, GLsizei height, GLsizei depth,
83                            GLint border, GLenum internalFormat,
84                            gl_format format);
85
86
87 extern gl_format
88 _mesa_choose_texture_format(struct gl_context *ctx,
89                             struct gl_texture_object *texObj,
90                             GLenum target, GLint level,
91                             GLenum internalFormat, GLenum format, GLenum type);
92
93 extern void
94 _mesa_update_fbo_texture(struct gl_context *ctx,
95                          struct gl_texture_object *texObj,
96                          GLuint face, GLuint level);
97
98 extern void
99 _mesa_clear_texture_image(struct gl_context *ctx,
100                           struct gl_texture_image *texImage);
101
102
103 extern struct gl_texture_object *
104 _mesa_select_tex_object(struct gl_context *ctx,
105                         const struct gl_texture_unit *texUnit,
106                         GLenum target);
107
108 extern struct gl_texture_object *
109 _mesa_get_current_tex_object(struct gl_context *ctx, GLenum target);
110
111
112 extern struct gl_texture_image *
113 _mesa_select_tex_image(struct gl_context *ctx,
114                        const struct gl_texture_object *texObj,
115                        GLenum target, GLint level);
116
117
118 extern struct gl_texture_image *
119 _mesa_get_tex_image(struct gl_context *ctx, struct gl_texture_object *texObj,
120                     GLenum target, GLint level);
121
122
123 extern struct gl_texture_image *
124 _mesa_get_proxy_tex_image(struct gl_context *ctx, GLenum target, GLint level);
125
126
127 extern GLint
128 _mesa_max_texture_levels(struct gl_context *ctx, GLenum target);
129
130
131 extern GLboolean
132 _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level,
133                          GLint internalFormat, GLenum format, GLenum type,
134                          GLint width, GLint height, GLint depth, GLint border);
135
136
137 extern GLuint
138 _mesa_tex_target_to_face(GLenum target);
139
140 extern GLint
141 _mesa_get_texture_dimensions(GLenum target);
142
143 extern GLenum
144 _mesa_es_error_check_format_and_type(GLenum format, GLenum type,
145                                      unsigned dimensions);
146
147 /**
148  * Lock a texture for updating.  See also _mesa_lock_context_textures().
149  */
150 static inline void
151 _mesa_lock_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
152 {
153    _glthread_LOCK_MUTEX(ctx->Shared->TexMutex);
154    ctx->Shared->TextureStateStamp++;
155    (void) texObj;
156 }
157
158 static inline void
159 _mesa_unlock_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
160 {
161    (void) texObj;
162    _glthread_UNLOCK_MUTEX(ctx->Shared->TexMutex);
163 }
164
165 /*@}*/
166
167
168 /** \name API entry point functions */
169 /*@{*/
170
171 extern void GLAPIENTRY
172 _mesa_TexImage1D( GLenum target, GLint level, GLint internalformat,
173                   GLsizei width, GLint border,
174                   GLenum format, GLenum type, const GLvoid *pixels );
175
176
177 extern void GLAPIENTRY
178 _mesa_TexImage2D( GLenum target, GLint level, GLint internalformat,
179                   GLsizei width, GLsizei height, GLint border,
180                   GLenum format, GLenum type, const GLvoid *pixels );
181
182
183 extern void GLAPIENTRY
184 _mesa_TexImage3D( GLenum target, GLint level, GLint internalformat,
185                   GLsizei width, GLsizei height, GLsizei depth, GLint border,
186                   GLenum format, GLenum type, const GLvoid *pixels );
187
188
189 extern void GLAPIENTRY
190 _mesa_TexImage3DEXT( GLenum target, GLint level, GLenum internalformat,
191                      GLsizei width, GLsizei height, GLsizei depth,
192                      GLint border, GLenum format, GLenum type,
193                      const GLvoid *pixels );
194
195 extern void GLAPIENTRY
196 _mesa_EGLImageTargetTexture2DOES( GLenum target, GLeglImageOES image );
197
198 extern void GLAPIENTRY
199 _mesa_TexSubImage1D( GLenum target, GLint level, GLint xoffset,
200                      GLsizei width,
201                      GLenum format, GLenum type,
202                      const GLvoid *pixels );
203
204
205 extern void GLAPIENTRY
206 _mesa_TexSubImage2D( GLenum target, GLint level,
207                      GLint xoffset, GLint yoffset,
208                      GLsizei width, GLsizei height,
209                      GLenum format, GLenum type,
210                      const GLvoid *pixels );
211
212
213 extern void GLAPIENTRY
214 _mesa_TexSubImage3D( GLenum target, GLint level,
215                      GLint xoffset, GLint yoffset, GLint zoffset,
216                      GLsizei width, GLsizei height, GLsizei depth,
217                      GLenum format, GLenum type,
218                      const GLvoid *pixels );
219
220
221 extern void GLAPIENTRY
222 _mesa_CopyTexImage1D( GLenum target, GLint level, GLenum internalformat,
223                       GLint x, GLint y, GLsizei width, GLint border );
224
225
226 extern void GLAPIENTRY
227 _mesa_CopyTexImage2D( GLenum target, GLint level,
228                       GLenum internalformat, GLint x, GLint y,
229                       GLsizei width, GLsizei height, GLint border );
230
231
232 extern void GLAPIENTRY
233 _mesa_CopyTexSubImage1D( GLenum target, GLint level, GLint xoffset,
234                          GLint x, GLint y, GLsizei width );
235
236
237 extern void GLAPIENTRY
238 _mesa_CopyTexSubImage2D( GLenum target, GLint level,
239                          GLint xoffset, GLint yoffset,
240                          GLint x, GLint y, GLsizei width, GLsizei height );
241
242
243 extern void GLAPIENTRY
244 _mesa_CopyTexSubImage3D( GLenum target, GLint level,
245                          GLint xoffset, GLint yoffset, GLint zoffset,
246                          GLint x, GLint y, GLsizei width, GLsizei height );
247
248
249
250 extern void GLAPIENTRY
251 _mesa_CompressedTexImage1DARB(GLenum target, GLint level,
252                               GLenum internalformat, GLsizei width,
253                               GLint border, GLsizei imageSize,
254                               const GLvoid *data);
255
256 extern void GLAPIENTRY
257 _mesa_CompressedTexImage2DARB(GLenum target, GLint level,
258                               GLenum internalformat, GLsizei width,
259                               GLsizei height, GLint border, GLsizei imageSize,
260                               const GLvoid *data);
261
262 extern void GLAPIENTRY
263 _mesa_CompressedTexImage3DARB(GLenum target, GLint level,
264                               GLenum internalformat, GLsizei width,
265                               GLsizei height, GLsizei depth, GLint border,
266                               GLsizei imageSize, const GLvoid *data);
267
268 #ifdef VMS
269 #define _mesa_CompressedTexSubImage1DARB _mesa_CompressedTexSubImage1DAR
270 #define _mesa_CompressedTexSubImage2DARB _mesa_CompressedTexSubImage2DAR
271 #define _mesa_CompressedTexSubImage3DARB _mesa_CompressedTexSubImage3DAR
272 #endif
273 extern void GLAPIENTRY
274 _mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
275                                  GLsizei width, GLenum format,
276                                  GLsizei imageSize, const GLvoid *data);
277
278 extern void GLAPIENTRY
279 _mesa_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
280                                  GLint yoffset, GLsizei width, GLsizei height,
281                                  GLenum format, GLsizei imageSize,
282                                  const GLvoid *data);
283
284 extern void GLAPIENTRY
285 _mesa_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
286                                  GLint yoffset, GLint zoffset, GLsizei width,
287                                  GLsizei height, GLsizei depth, GLenum format,
288                                  GLsizei imageSize, const GLvoid *data);
289
290
291 extern void GLAPIENTRY
292 _mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer);
293
294
295 /*@}*/
296
297 #ifdef __cplusplus
298 }
299 #endif
300
301 #endif