image.h revision c34feadd1c2fa5c62022c1f48ee675b25a985ac6
1/*
2 * Mesa 3-D graphics library
3 * Version:  7.1
4 *
5 * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25
26#ifndef IMAGE_H
27#define IMAGE_H
28
29
30#include "mtypes.h"
31
32
33extern void
34_mesa_swap2( GLushort *p, GLuint n );
35
36extern void
37_mesa_swap4( GLuint *p, GLuint n );
38
39extern GLboolean
40_mesa_type_is_packed(GLenum type);
41
42extern GLint
43_mesa_sizeof_type( GLenum type );
44
45extern GLint
46_mesa_sizeof_packed_type( GLenum type );
47
48extern GLint
49_mesa_components_in_format( GLenum format );
50
51extern GLint
52_mesa_bytes_per_pixel( GLenum format, GLenum type );
53
54extern GLboolean
55_mesa_is_legal_format_and_type( GLcontext *ctx, GLenum format, GLenum type );
56
57extern GLboolean
58_mesa_is_color_format(GLenum format);
59
60extern GLboolean
61_mesa_is_index_format(GLenum format);
62
63extern GLboolean
64_mesa_is_depth_format(GLenum format);
65
66extern GLboolean
67_mesa_is_stencil_format(GLenum format);
68
69extern GLboolean
70_mesa_is_ycbcr_format(GLenum format);
71
72extern GLboolean
73_mesa_is_depthstencil_format(GLenum format);
74
75extern GLboolean
76_mesa_is_dudv_format(GLenum format);
77
78extern GLboolean
79_mesa_is_compressed_format(GLcontext *ctx, GLenum format);
80
81extern GLvoid *
82_mesa_image_address( GLuint dimensions,
83                     const struct gl_pixelstore_attrib *packing,
84                     const GLvoid *image,
85                     GLsizei width, GLsizei height,
86                     GLenum format, GLenum type,
87                     GLint img, GLint row, GLint column );
88
89extern GLvoid *
90_mesa_image_address1d( const struct gl_pixelstore_attrib *packing,
91                       const GLvoid *image,
92                       GLsizei width,
93                       GLenum format, GLenum type,
94                       GLint column );
95
96extern GLvoid *
97_mesa_image_address2d( const struct gl_pixelstore_attrib *packing,
98                       const GLvoid *image,
99                       GLsizei width, GLsizei height,
100                       GLenum format, GLenum type,
101                       GLint row, GLint column );
102
103extern GLvoid *
104_mesa_image_address3d( const struct gl_pixelstore_attrib *packing,
105                       const GLvoid *image,
106                       GLsizei width, GLsizei height,
107                       GLenum format, GLenum type,
108                       GLint img, GLint row, GLint column );
109
110
111extern GLint
112_mesa_image_row_stride( const struct gl_pixelstore_attrib *packing,
113                        GLint width, GLenum format, GLenum type );
114
115
116extern GLint
117_mesa_image_image_stride( const struct gl_pixelstore_attrib *packing,
118                          GLint width, GLint height,
119                          GLenum format, GLenum type );
120
121extern void
122_mesa_unpack_polygon_stipple( const GLubyte *pattern, GLuint dest[32],
123                              const struct gl_pixelstore_attrib *unpacking );
124
125
126extern void
127_mesa_pack_polygon_stipple( const GLuint pattern[32], GLubyte *dest,
128                            const struct gl_pixelstore_attrib *packing );
129
130
131extern GLvoid *
132_mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels,
133                     const struct gl_pixelstore_attrib *packing );
134
135extern void
136_mesa_pack_bitmap( GLint width, GLint height, const GLubyte *source,
137                   GLubyte *dest, const struct gl_pixelstore_attrib *packing );
138
139extern void
140_mesa_expand_bitmap(GLsizei width, GLsizei height,
141                    const struct gl_pixelstore_attrib *unpack,
142                    const GLubyte *bitmap,
143                    GLubyte *destBuffer, GLint destStride,
144                    GLubyte onValue);
145
146
147/** \name Pixel processing functions */
148/*@{*/
149
150extern void
151_mesa_scale_and_bias_rgba(GLuint n, GLfloat rgba[][4],
152                          GLfloat rScale, GLfloat gScale,
153                          GLfloat bScale, GLfloat aScale,
154                          GLfloat rBias, GLfloat gBias,
155                          GLfloat bBias, GLfloat aBias);
156
157extern void
158_mesa_map_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4]);
159
160
161extern void
162_mesa_transform_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4]);
163
164
165extern void
166_mesa_lookup_rgba_float(const struct gl_color_table *table,
167                        GLuint n, GLfloat rgba[][4]);
168
169extern void
170_mesa_lookup_rgba_ubyte(const struct gl_color_table *table,
171                        GLuint n, GLubyte rgba[][4]);
172
173
174extern void
175_mesa_map_ci_to_rgba(const GLcontext *ctx,
176                     GLuint n, const GLuint index[], GLfloat rgba[][4]);
177
178
179extern void
180_mesa_map_ci8_to_rgba8(const GLcontext *ctx, GLuint n, const GLubyte index[],
181                       GLubyte rgba[][4]);
182
183
184extern void
185_mesa_scale_and_bias_depth(const GLcontext *ctx, GLuint n,
186                           GLfloat depthValues[]);
187
188extern void
189_mesa_scale_and_bias_depth_uint(const GLcontext *ctx, GLuint n,
190                                GLuint depthValues[]);
191
192extern void
193_mesa_apply_rgba_transfer_ops(GLcontext *ctx, GLbitfield transferOps,
194                              GLuint n, GLfloat rgba[][4]);
195
196
197extern void
198_mesa_apply_ci_transfer_ops(const GLcontext *ctx, GLbitfield transferOps,
199                            GLuint n, GLuint indexes[]);
200
201
202extern void
203_mesa_apply_stencil_transfer_ops(const GLcontext *ctx, GLuint n,
204                                 GLstencil stencil[]);
205
206
207extern void
208_mesa_pack_rgba_span_float( GLcontext *ctx, GLuint n, GLfloat rgba[][4],
209                            GLenum dstFormat, GLenum dstType, GLvoid *dstAddr,
210                            const struct gl_pixelstore_attrib *dstPacking,
211                            GLbitfield transferOps );
212
213
214extern void
215_mesa_unpack_color_span_chan( GLcontext *ctx,
216                              GLuint n, GLenum dstFormat, GLchan dest[],
217                              GLenum srcFormat, GLenum srcType,
218                              const GLvoid *source,
219                              const struct gl_pixelstore_attrib *srcPacking,
220                              GLbitfield transferOps );
221
222
223extern void
224_mesa_unpack_color_span_float( GLcontext *ctx,
225                               GLuint n, GLenum dstFormat, GLfloat dest[],
226                               GLenum srcFormat, GLenum srcType,
227                               const GLvoid *source,
228                               const struct gl_pixelstore_attrib *srcPacking,
229                               GLbitfield transferOps );
230
231extern void
232_mesa_unpack_dudv_span_byte( GLcontext *ctx,
233                             GLuint n, GLenum dstFormat, GLbyte dest[],
234                             GLenum srcFormat, GLenum srcType,
235                             const GLvoid *source,
236                             const struct gl_pixelstore_attrib *srcPacking,
237                             GLbitfield transferOps );
238
239extern void
240_mesa_unpack_index_span( const GLcontext *ctx, GLuint n,
241                         GLenum dstType, GLvoid *dest,
242                         GLenum srcType, const GLvoid *source,
243                         const struct gl_pixelstore_attrib *srcPacking,
244                         GLbitfield transferOps );
245
246
247extern void
248_mesa_pack_index_span( const GLcontext *ctx, GLuint n,
249                       GLenum dstType, GLvoid *dest, const GLuint *source,
250                       const struct gl_pixelstore_attrib *dstPacking,
251                       GLbitfield transferOps );
252
253
254extern void
255_mesa_unpack_stencil_span( const GLcontext *ctx, GLuint n,
256                           GLenum dstType, GLvoid *dest,
257                           GLenum srcType, const GLvoid *source,
258                           const struct gl_pixelstore_attrib *srcPacking,
259                           GLbitfield transferOps );
260
261extern void
262_mesa_pack_stencil_span( const GLcontext *ctx, GLuint n,
263                         GLenum dstType, GLvoid *dest, const GLstencil *source,
264                         const struct gl_pixelstore_attrib *dstPacking );
265
266
267extern void
268_mesa_unpack_depth_span( const GLcontext *ctx, GLuint n,
269                         GLenum dstType, GLvoid *dest, GLuint depthMax,
270                         GLenum srcType, const GLvoid *source,
271                         const struct gl_pixelstore_attrib *srcPacking );
272
273extern void
274_mesa_pack_depth_span( const GLcontext *ctx, GLuint n, GLvoid *dest,
275                       GLenum dstType, const GLfloat *depthSpan,
276                       const struct gl_pixelstore_attrib *dstPacking );
277
278
279extern void
280_mesa_pack_depth_stencil_span(const GLcontext *ctx, GLuint n, GLuint *dest,
281                              const GLfloat *depthVals,
282                              const GLstencil *stencilVals,
283                              const struct gl_pixelstore_attrib *dstPacking);
284
285
286extern void *
287_mesa_unpack_image( GLuint dimensions,
288                    GLsizei width, GLsizei height, GLsizei depth,
289                    GLenum format, GLenum type, const GLvoid *pixels,
290                    const struct gl_pixelstore_attrib *unpack );
291
292
293extern void
294_mesa_convert_colors(GLenum srcType, const GLvoid *src,
295                     GLenum dstType, GLvoid *dst,
296                     GLuint count, const GLubyte mask[]);
297
298
299extern GLboolean
300_mesa_clip_drawpixels(const GLcontext *ctx,
301                      GLint *destX, GLint *destY,
302                      GLsizei *width, GLsizei *height,
303                      struct gl_pixelstore_attrib *unpack);
304
305
306extern GLboolean
307_mesa_clip_readpixels(const GLcontext *ctx,
308                      GLint *srcX, GLint *srcY,
309                      GLsizei *width, GLsizei *height,
310                      struct gl_pixelstore_attrib *pack);
311
312extern GLboolean
313_mesa_clip_copytexsubimage(const GLcontext *ctx,
314                           GLint *destX, GLint *destY,
315                           GLint *srcX, GLint *srcY,
316                           GLsizei *width, GLsizei *height);
317
318extern GLboolean
319_mesa_clip_to_region(GLint xmin, GLint ymin,
320                     GLint xmax, GLint ymax,
321                     GLint *x, GLint *y,
322                     GLsizei *width, GLsizei *height );
323
324extern GLboolean
325_mesa_clip_blit(GLcontext *ctx,
326                GLint *srcX0, GLint *srcY0, GLint *srcX1, GLint *srcY1,
327                GLint *dstX0, GLint *dstY0, GLint *dstX1, GLint *dstY1);
328
329
330#endif
331