image.h revision cdc920a0
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
78
79extern GLvoid *
80_mesa_image_address( GLuint dimensions,
81                     const struct gl_pixelstore_attrib *packing,
82                     const GLvoid *image,
83                     GLsizei width, GLsizei height,
84                     GLenum format, GLenum type,
85                     GLint img, GLint row, GLint column );
86
87extern GLvoid *
88_mesa_image_address1d( const struct gl_pixelstore_attrib *packing,
89                       const GLvoid *image,
90                       GLsizei width,
91                       GLenum format, GLenum type,
92                       GLint column );
93
94extern GLvoid *
95_mesa_image_address2d( const struct gl_pixelstore_attrib *packing,
96                       const GLvoid *image,
97                       GLsizei width, GLsizei height,
98                       GLenum format, GLenum type,
99                       GLint row, GLint column );
100
101extern GLvoid *
102_mesa_image_address3d( const struct gl_pixelstore_attrib *packing,
103                       const GLvoid *image,
104                       GLsizei width, GLsizei height,
105                       GLenum format, GLenum type,
106                       GLint img, GLint row, GLint column );
107
108
109extern GLint
110_mesa_image_row_stride( const struct gl_pixelstore_attrib *packing,
111                        GLint width, GLenum format, GLenum type );
112
113
114extern GLint
115_mesa_image_image_stride( const struct gl_pixelstore_attrib *packing,
116                          GLint width, GLint height,
117                          GLenum format, GLenum type );
118
119extern void
120_mesa_unpack_polygon_stipple( const GLubyte *pattern, GLuint dest[32],
121                              const struct gl_pixelstore_attrib *unpacking );
122
123
124extern void
125_mesa_pack_polygon_stipple( const GLuint pattern[32], GLubyte *dest,
126                            const struct gl_pixelstore_attrib *packing );
127
128
129extern GLvoid *
130_mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels,
131                     const struct gl_pixelstore_attrib *packing );
132
133extern void
134_mesa_pack_bitmap( GLint width, GLint height, const GLubyte *source,
135                   GLubyte *dest, const struct gl_pixelstore_attrib *packing );
136
137extern void
138_mesa_expand_bitmap(GLsizei width, GLsizei height,
139                    const struct gl_pixelstore_attrib *unpack,
140                    const GLubyte *bitmap,
141                    GLubyte *destBuffer, GLint destStride,
142                    GLubyte onValue);
143
144
145/** \name Pixel processing functions */
146/*@{*/
147
148extern void
149_mesa_scale_and_bias_rgba(GLuint n, GLfloat rgba[][4],
150                          GLfloat rScale, GLfloat gScale,
151                          GLfloat bScale, GLfloat aScale,
152                          GLfloat rBias, GLfloat gBias,
153                          GLfloat bBias, GLfloat aBias);
154
155extern void
156_mesa_map_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4]);
157
158
159extern void
160_mesa_transform_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4]);
161
162
163extern void
164_mesa_lookup_rgba_float(const struct gl_color_table *table,
165                        GLuint n, GLfloat rgba[][4]);
166
167extern void
168_mesa_lookup_rgba_ubyte(const struct gl_color_table *table,
169                        GLuint n, GLubyte rgba[][4]);
170
171
172extern void
173_mesa_map_ci_to_rgba(const GLcontext *ctx,
174                     GLuint n, const GLuint index[], GLfloat rgba[][4]);
175
176
177extern void
178_mesa_map_ci8_to_rgba8(const GLcontext *ctx, GLuint n, const GLubyte index[],
179                       GLubyte rgba[][4]);
180
181
182extern void
183_mesa_scale_and_bias_depth(const GLcontext *ctx, GLuint n,
184                           GLfloat depthValues[]);
185
186extern void
187_mesa_scale_and_bias_depth_uint(const GLcontext *ctx, GLuint n,
188                                GLuint depthValues[]);
189
190extern void
191_mesa_apply_rgba_transfer_ops(GLcontext *ctx, GLbitfield transferOps,
192                              GLuint n, GLfloat rgba[][4]);
193
194
195extern void
196_mesa_apply_ci_transfer_ops(const GLcontext *ctx, GLbitfield transferOps,
197                            GLuint n, GLuint indexes[]);
198
199
200extern void
201_mesa_apply_stencil_transfer_ops(const GLcontext *ctx, GLuint n,
202                                 GLstencil stencil[]);
203
204
205extern void
206_mesa_pack_rgba_span_float( GLcontext *ctx, GLuint n, GLfloat rgba[][4],
207                            GLenum dstFormat, GLenum dstType, GLvoid *dstAddr,
208                            const struct gl_pixelstore_attrib *dstPacking,
209                            GLbitfield transferOps );
210
211
212extern void
213_mesa_unpack_color_span_chan( GLcontext *ctx,
214                              GLuint n, GLenum dstFormat, GLchan dest[],
215                              GLenum srcFormat, GLenum srcType,
216                              const GLvoid *source,
217                              const struct gl_pixelstore_attrib *srcPacking,
218                              GLbitfield transferOps );
219
220
221extern void
222_mesa_unpack_color_span_float( GLcontext *ctx,
223                               GLuint n, GLenum dstFormat, GLfloat dest[],
224                               GLenum srcFormat, GLenum srcType,
225                               const GLvoid *source,
226                               const struct gl_pixelstore_attrib *srcPacking,
227                               GLbitfield transferOps );
228
229extern void
230_mesa_unpack_dudv_span_byte( GLcontext *ctx,
231                             GLuint n, GLenum dstFormat, GLbyte dest[],
232                             GLenum srcFormat, GLenum srcType,
233                             const GLvoid *source,
234                             const struct gl_pixelstore_attrib *srcPacking,
235                             GLbitfield transferOps );
236
237extern void
238_mesa_unpack_index_span( const GLcontext *ctx, GLuint n,
239                         GLenum dstType, GLvoid *dest,
240                         GLenum srcType, const GLvoid *source,
241                         const struct gl_pixelstore_attrib *srcPacking,
242                         GLbitfield transferOps );
243
244
245extern void
246_mesa_pack_index_span( const GLcontext *ctx, GLuint n,
247                       GLenum dstType, GLvoid *dest, const GLuint *source,
248                       const struct gl_pixelstore_attrib *dstPacking,
249                       GLbitfield transferOps );
250
251
252extern void
253_mesa_unpack_stencil_span( const GLcontext *ctx, GLuint n,
254                           GLenum dstType, GLvoid *dest,
255                           GLenum srcType, const GLvoid *source,
256                           const struct gl_pixelstore_attrib *srcPacking,
257                           GLbitfield transferOps );
258
259extern void
260_mesa_pack_stencil_span( const GLcontext *ctx, GLuint n,
261                         GLenum dstType, GLvoid *dest, const GLstencil *source,
262                         const struct gl_pixelstore_attrib *dstPacking );
263
264
265extern void
266_mesa_unpack_depth_span( const GLcontext *ctx, GLuint n,
267                         GLenum dstType, GLvoid *dest, GLuint depthMax,
268                         GLenum srcType, const GLvoid *source,
269                         const struct gl_pixelstore_attrib *srcPacking );
270
271extern void
272_mesa_pack_depth_span( const GLcontext *ctx, GLuint n, GLvoid *dest,
273                       GLenum dstType, const GLfloat *depthSpan,
274                       const struct gl_pixelstore_attrib *dstPacking );
275
276
277extern void
278_mesa_pack_depth_stencil_span(const GLcontext *ctx, GLuint n, GLuint *dest,
279                              const GLfloat *depthVals,
280                              const GLstencil *stencilVals,
281                              const struct gl_pixelstore_attrib *dstPacking);
282
283
284extern void *
285_mesa_unpack_image( GLuint dimensions,
286                    GLsizei width, GLsizei height, GLsizei depth,
287                    GLenum format, GLenum type, const GLvoid *pixels,
288                    const struct gl_pixelstore_attrib *unpack );
289
290
291extern void
292_mesa_convert_colors(GLenum srcType, const GLvoid *src,
293                     GLenum dstType, GLvoid *dst,
294                     GLuint count, const GLubyte mask[]);
295
296
297extern GLboolean
298_mesa_clip_drawpixels(const GLcontext *ctx,
299                      GLint *destX, GLint *destY,
300                      GLsizei *width, GLsizei *height,
301                      struct gl_pixelstore_attrib *unpack);
302
303
304extern GLboolean
305_mesa_clip_readpixels(const GLcontext *ctx,
306                      GLint *srcX, GLint *srcY,
307                      GLsizei *width, GLsizei *height,
308                      struct gl_pixelstore_attrib *pack);
309
310extern GLboolean
311_mesa_clip_copytexsubimage(const GLcontext *ctx,
312                           GLint *destX, GLint *destY,
313                           GLint *srcX, GLint *srcY,
314                           GLsizei *width, GLsizei *height);
315
316extern GLboolean
317_mesa_clip_to_region(GLint xmin, GLint ymin,
318                     GLint xmax, GLint ymax,
319                     GLint *x, GLint *y,
320                     GLsizei *width, GLsizei *height );
321
322extern GLboolean
323_mesa_clip_blit(GLcontext *ctx,
324                GLint *srcX0, GLint *srcY0, GLint *srcX1, GLint *srcY1,
325                GLint *dstX0, GLint *dstY0, GLint *dstX1, GLint *dstY1);
326
327
328#endif
329