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