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