Consolidate, move, fix code related to color index and stencil image transfer
[mesa.git] / src / mesa / main / image.h
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.5.2
4 *
5 * Copyright (C) 1999-2006 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 GLint
40 _mesa_sizeof_type( GLenum type );
41
42 extern GLint
43 _mesa_sizeof_packed_type( GLenum type );
44
45 extern GLint
46 _mesa_components_in_format( GLenum format );
47
48 extern GLint
49 _mesa_bytes_per_pixel( GLenum format, GLenum type );
50
51 extern GLboolean
52 _mesa_is_legal_format_and_type( GLcontext *ctx, GLenum format, GLenum type );
53
54
55 extern GLvoid *
56 _mesa_image_address( GLuint dimensions,
57 const struct gl_pixelstore_attrib *packing,
58 const GLvoid *image,
59 GLsizei width, GLsizei height,
60 GLenum format, GLenum type,
61 GLint img, GLint row, GLint column );
62
63 extern GLvoid *
64 _mesa_image_address1d( const struct gl_pixelstore_attrib *packing,
65 const GLvoid *image,
66 GLsizei width,
67 GLenum format, GLenum type,
68 GLint column );
69
70 extern GLvoid *
71 _mesa_image_address2d( const struct gl_pixelstore_attrib *packing,
72 const GLvoid *image,
73 GLsizei width, GLsizei height,
74 GLenum format, GLenum type,
75 GLint row, GLint column );
76
77 extern GLvoid *
78 _mesa_image_address3d( const struct gl_pixelstore_attrib *packing,
79 const GLvoid *image,
80 GLsizei width, GLsizei height,
81 GLenum format, GLenum type,
82 GLint img, GLint row, GLint column );
83
84
85 extern GLint
86 _mesa_image_row_stride( const struct gl_pixelstore_attrib *packing,
87 GLint width, GLenum format, GLenum type );
88
89
90 extern GLint
91 _mesa_image_image_stride( const struct gl_pixelstore_attrib *packing,
92 GLint width, GLint height,
93 GLenum format, GLenum type );
94
95 extern void
96 _mesa_unpack_polygon_stipple( const GLubyte *pattern, GLuint dest[32],
97 const struct gl_pixelstore_attrib *unpacking );
98
99
100 extern void
101 _mesa_pack_polygon_stipple( const GLuint pattern[32], GLubyte *dest,
102 const struct gl_pixelstore_attrib *packing );
103
104
105 extern GLvoid *
106 _mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels,
107 const struct gl_pixelstore_attrib *packing );
108
109 extern void
110 _mesa_pack_bitmap( GLint width, GLint height, const GLubyte *source,
111 GLubyte *dest, const struct gl_pixelstore_attrib *packing );
112
113
114 extern void
115 _mesa_apply_rgba_transfer_ops(GLcontext *ctx, GLbitfield transferOps,
116 GLuint n, GLfloat rgba[][4]);
117
118
119 extern void
120 _mesa_apply_ci_transfer_ops(const GLcontext *ctx, GLbitfield transferOps,
121 GLuint n, GLuint indexes[]);
122
123
124 extern void
125 _mesa_apply_stencil_transfer_ops(const GLcontext *ctx, GLuint n,
126 GLstencil stencil[]);
127
128
129 extern void
130 _mesa_pack_rgba_span_float( GLcontext *ctx, GLuint n, GLfloat rgba[][4],
131 GLenum dstFormat, GLenum dstType, GLvoid *dstAddr,
132 const struct gl_pixelstore_attrib *dstPacking,
133 GLbitfield transferOps );
134
135
136 extern void
137 _mesa_unpack_color_span_chan( GLcontext *ctx,
138 GLuint n, GLenum dstFormat, GLchan dest[],
139 GLenum srcFormat, GLenum srcType,
140 const GLvoid *source,
141 const struct gl_pixelstore_attrib *srcPacking,
142 GLbitfield transferOps );
143
144
145 extern void
146 _mesa_unpack_color_span_float( GLcontext *ctx,
147 GLuint n, GLenum dstFormat, GLfloat dest[],
148 GLenum srcFormat, GLenum srcType,
149 const GLvoid *source,
150 const struct gl_pixelstore_attrib *srcPacking,
151 GLbitfield transferOps );
152
153
154 extern void
155 _mesa_unpack_index_span( const GLcontext *ctx, GLuint n,
156 GLenum dstType, GLvoid *dest,
157 GLenum srcType, const GLvoid *source,
158 const struct gl_pixelstore_attrib *srcPacking,
159 GLbitfield transferOps );
160
161
162 extern void
163 _mesa_pack_index_span( const GLcontext *ctx, GLuint n,
164 GLenum dstType, GLvoid *dest, const GLuint *source,
165 const struct gl_pixelstore_attrib *dstPacking,
166 GLbitfield transferOps );
167
168
169 extern void
170 _mesa_unpack_stencil_span( const GLcontext *ctx, GLuint n,
171 GLenum dstType, GLvoid *dest,
172 GLenum srcType, const GLvoid *source,
173 const struct gl_pixelstore_attrib *srcPacking,
174 GLbitfield transferOps );
175
176 extern void
177 _mesa_pack_stencil_span( const GLcontext *ctx, GLuint n,
178 GLenum dstType, GLvoid *dest, const GLstencil *source,
179 const struct gl_pixelstore_attrib *dstPacking );
180
181
182 extern void
183 _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n,
184 GLenum dstType, GLvoid *dest, GLfloat depthScale,
185 GLenum srcType, const GLvoid *source,
186 const struct gl_pixelstore_attrib *srcPacking );
187
188 extern void
189 _mesa_pack_depth_span( const GLcontext *ctx, GLuint n, GLvoid *dest,
190 GLenum dstType, const GLfloat *depthSpan,
191 const struct gl_pixelstore_attrib *dstPacking );
192
193
194 extern void
195 _mesa_pack_depth_stencil_span(const GLcontext *ctx, GLuint n, GLuint *dest,
196 const GLfloat *depthVals,
197 const GLstencil *stencilVals,
198 const struct gl_pixelstore_attrib *dstPacking);
199
200
201 extern void *
202 _mesa_unpack_image( GLuint dimensions,
203 GLsizei width, GLsizei height, GLsizei depth,
204 GLenum format, GLenum type, const GLvoid *pixels,
205 const struct gl_pixelstore_attrib *unpack );
206
207
208 extern void
209 _mesa_convert_colors(GLenum srcType, const GLvoid *src,
210 GLenum dstType, GLvoid *dst,
211 GLuint count, const GLubyte mask[]);
212
213
214 extern GLboolean
215 _mesa_clip_drawpixels(const GLcontext *ctx,
216 GLint *destX, GLint *destY,
217 GLsizei *width, GLsizei *height,
218 struct gl_pixelstore_attrib *unpack);
219
220
221 extern GLboolean
222 _mesa_clip_readpixels(const GLcontext *ctx,
223 GLint *destX, GLint *destY,
224 GLsizei *width, GLsizei *height,
225 struct gl_pixelstore_attrib *pack);
226
227 extern GLboolean
228 _mesa_clip_to_region(GLint xmin, GLint ymin,
229 GLint xmax, GLint ymax,
230 GLint *x, GLint *y,
231 GLsizei *width, GLsizei *height );
232
233 #endif