Merge commit 'origin/gallium-0.2' into gallium-xlib-rework
[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
58 extern GLvoid *
59 _mesa_image_address( GLuint dimensions,
60 const struct gl_pixelstore_attrib *packing,
61 const GLvoid *image,
62 GLsizei width, GLsizei height,
63 GLenum format, GLenum type,
64 GLint img, GLint row, GLint column );
65
66 extern GLvoid *
67 _mesa_image_address1d( const struct gl_pixelstore_attrib *packing,
68 const GLvoid *image,
69 GLsizei width,
70 GLenum format, GLenum type,
71 GLint column );
72
73 extern GLvoid *
74 _mesa_image_address2d( const struct gl_pixelstore_attrib *packing,
75 const GLvoid *image,
76 GLsizei width, GLsizei height,
77 GLenum format, GLenum type,
78 GLint row, GLint column );
79
80 extern GLvoid *
81 _mesa_image_address3d( 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
87
88 extern GLint
89 _mesa_image_row_stride( const struct gl_pixelstore_attrib *packing,
90 GLint width, GLenum format, GLenum type );
91
92
93 extern GLint
94 _mesa_image_image_stride( const struct gl_pixelstore_attrib *packing,
95 GLint width, GLint height,
96 GLenum format, GLenum type );
97
98 extern void
99 _mesa_unpack_polygon_stipple( const GLubyte *pattern, GLuint dest[32],
100 const struct gl_pixelstore_attrib *unpacking );
101
102
103 extern void
104 _mesa_pack_polygon_stipple( const GLuint pattern[32], GLubyte *dest,
105 const struct gl_pixelstore_attrib *packing );
106
107
108 extern GLvoid *
109 _mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels,
110 const struct gl_pixelstore_attrib *packing );
111
112 extern void
113 _mesa_pack_bitmap( GLint width, GLint height, const GLubyte *source,
114 GLubyte *dest, const struct gl_pixelstore_attrib *packing );
115
116
117 /** \name Pixel processing functions */
118 /*@{*/
119
120 extern void
121 _mesa_scale_and_bias_rgba(GLuint n, GLfloat rgba[][4],
122 GLfloat rScale, GLfloat gScale,
123 GLfloat bScale, GLfloat aScale,
124 GLfloat rBias, GLfloat gBias,
125 GLfloat bBias, GLfloat aBias);
126
127 extern void
128 _mesa_map_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4]);
129
130
131 extern void
132 _mesa_transform_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4]);
133
134
135 extern void
136 _mesa_lookup_rgba_float(const struct gl_color_table *table,
137 GLuint n, GLfloat rgba[][4]);
138
139 extern void
140 _mesa_lookup_rgba_ubyte(const struct gl_color_table *table,
141 GLuint n, GLubyte rgba[][4]);
142
143
144 extern void
145 _mesa_map_ci_to_rgba(const GLcontext *ctx,
146 GLuint n, const GLuint index[], GLfloat rgba[][4]);
147
148
149 extern void
150 _mesa_map_ci8_to_rgba8(const GLcontext *ctx, GLuint n, const GLubyte index[],
151 GLubyte rgba[][4]);
152
153
154 extern void
155 _mesa_scale_and_bias_depth(const GLcontext *ctx, GLuint n,
156 GLfloat depthValues[]);
157
158 extern void
159 _mesa_scale_and_bias_depth_uint(const GLcontext *ctx, GLuint n,
160 GLuint depthValues[]);
161
162 extern void
163 _mesa_apply_rgba_transfer_ops(GLcontext *ctx, GLbitfield transferOps,
164 GLuint n, GLfloat rgba[][4]);
165
166
167 extern void
168 _mesa_apply_ci_transfer_ops(const GLcontext *ctx, GLbitfield transferOps,
169 GLuint n, GLuint indexes[]);
170
171
172 extern void
173 _mesa_apply_stencil_transfer_ops(const GLcontext *ctx, GLuint n,
174 GLstencil stencil[]);
175
176
177 extern void
178 _mesa_pack_rgba_span_float( GLcontext *ctx, GLuint n, GLfloat rgba[][4],
179 GLenum dstFormat, GLenum dstType, GLvoid *dstAddr,
180 const struct gl_pixelstore_attrib *dstPacking,
181 GLbitfield transferOps );
182
183
184 extern void
185 _mesa_unpack_color_span_chan( GLcontext *ctx,
186 GLuint n, GLenum dstFormat, GLchan dest[],
187 GLenum srcFormat, GLenum srcType,
188 const GLvoid *source,
189 const struct gl_pixelstore_attrib *srcPacking,
190 GLbitfield transferOps );
191
192
193 extern void
194 _mesa_unpack_color_span_float( GLcontext *ctx,
195 GLuint n, GLenum dstFormat, GLfloat dest[],
196 GLenum srcFormat, GLenum srcType,
197 const GLvoid *source,
198 const struct gl_pixelstore_attrib *srcPacking,
199 GLbitfield transferOps );
200
201
202 extern void
203 _mesa_unpack_index_span( const GLcontext *ctx, GLuint n,
204 GLenum dstType, GLvoid *dest,
205 GLenum srcType, const GLvoid *source,
206 const struct gl_pixelstore_attrib *srcPacking,
207 GLbitfield transferOps );
208
209
210 extern void
211 _mesa_pack_index_span( const GLcontext *ctx, GLuint n,
212 GLenum dstType, GLvoid *dest, const GLuint *source,
213 const struct gl_pixelstore_attrib *dstPacking,
214 GLbitfield transferOps );
215
216
217 extern void
218 _mesa_unpack_stencil_span( const GLcontext *ctx, GLuint n,
219 GLenum dstType, GLvoid *dest,
220 GLenum srcType, const GLvoid *source,
221 const struct gl_pixelstore_attrib *srcPacking,
222 GLbitfield transferOps );
223
224 extern void
225 _mesa_pack_stencil_span( const GLcontext *ctx, GLuint n,
226 GLenum dstType, GLvoid *dest, const GLstencil *source,
227 const struct gl_pixelstore_attrib *dstPacking );
228
229
230 extern void
231 _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n,
232 GLenum dstType, GLvoid *dest, GLuint depthMax,
233 GLenum srcType, const GLvoid *source,
234 const struct gl_pixelstore_attrib *srcPacking );
235
236 extern void
237 _mesa_pack_depth_span( const GLcontext *ctx, GLuint n, GLvoid *dest,
238 GLenum dstType, const GLfloat *depthSpan,
239 const struct gl_pixelstore_attrib *dstPacking );
240
241
242 extern void
243 _mesa_pack_depth_stencil_span(const GLcontext *ctx, GLuint n, GLuint *dest,
244 const GLfloat *depthVals,
245 const GLstencil *stencilVals,
246 const struct gl_pixelstore_attrib *dstPacking);
247
248
249 extern void *
250 _mesa_unpack_image( GLuint dimensions,
251 GLsizei width, GLsizei height, GLsizei depth,
252 GLenum format, GLenum type, const GLvoid *pixels,
253 const struct gl_pixelstore_attrib *unpack );
254
255
256 extern void
257 _mesa_convert_colors(GLenum srcType, const GLvoid *src,
258 GLenum dstType, GLvoid *dst,
259 GLuint count, const GLubyte mask[]);
260
261
262 extern GLboolean
263 _mesa_clip_drawpixels(const GLcontext *ctx,
264 GLint *destX, GLint *destY,
265 GLsizei *width, GLsizei *height,
266 struct gl_pixelstore_attrib *unpack);
267
268
269 extern GLboolean
270 _mesa_clip_readpixels(const GLcontext *ctx,
271 GLint *destX, GLint *destY,
272 GLsizei *width, GLsizei *height,
273 struct gl_pixelstore_attrib *pack);
274
275 extern GLboolean
276 _mesa_clip_copytexsubimage(const GLcontext *ctx,
277 GLint *destX, GLint *destY,
278 GLint *srcX, GLint *srcY,
279 GLsizei *width, GLsizei *height);
280
281 extern GLboolean
282 _mesa_clip_to_region(GLint xmin, GLint ymin,
283 GLint xmax, GLint ymax,
284 GLint *x, GLint *y,
285 GLsizei *width, GLsizei *height );
286
287 #endif