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