image.h revision cdc920a0
17117f1b4Smrg/* 27117f1b4Smrg * Mesa 3-D graphics library 3c1f859d4Smrg * Version: 7.1 47117f1b4Smrg * 5c1f859d4Smrg * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 67117f1b4Smrg * 77117f1b4Smrg * Permission is hereby granted, free of charge, to any person obtaining a 87117f1b4Smrg * copy of this software and associated documentation files (the "Software"), 97117f1b4Smrg * to deal in the Software without restriction, including without limitation 107117f1b4Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 117117f1b4Smrg * and/or sell copies of the Software, and to permit persons to whom the 127117f1b4Smrg * Software is furnished to do so, subject to the following conditions: 137117f1b4Smrg * 147117f1b4Smrg * The above copyright notice and this permission notice shall be included 157117f1b4Smrg * in all copies or substantial portions of the Software. 167117f1b4Smrg * 177117f1b4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 187117f1b4Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 197117f1b4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 207117f1b4Smrg * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 217117f1b4Smrg * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 227117f1b4Smrg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 237117f1b4Smrg */ 247117f1b4Smrg 257117f1b4Smrg 267117f1b4Smrg#ifndef IMAGE_H 277117f1b4Smrg#define IMAGE_H 287117f1b4Smrg 297117f1b4Smrg 307117f1b4Smrg#include "mtypes.h" 317117f1b4Smrg 327117f1b4Smrg 337117f1b4Smrgextern void 347117f1b4Smrg_mesa_swap2( GLushort *p, GLuint n ); 357117f1b4Smrg 367117f1b4Smrgextern void 377117f1b4Smrg_mesa_swap4( GLuint *p, GLuint n ); 387117f1b4Smrg 39c1f859d4Smrgextern GLboolean 40c1f859d4Smrg_mesa_type_is_packed(GLenum type); 41c1f859d4Smrg 427117f1b4Smrgextern GLint 437117f1b4Smrg_mesa_sizeof_type( GLenum type ); 447117f1b4Smrg 457117f1b4Smrgextern GLint 467117f1b4Smrg_mesa_sizeof_packed_type( GLenum type ); 477117f1b4Smrg 487117f1b4Smrgextern GLint 497117f1b4Smrg_mesa_components_in_format( GLenum format ); 507117f1b4Smrg 517117f1b4Smrgextern GLint 527117f1b4Smrg_mesa_bytes_per_pixel( GLenum format, GLenum type ); 537117f1b4Smrg 547117f1b4Smrgextern GLboolean 557117f1b4Smrg_mesa_is_legal_format_and_type( GLcontext *ctx, GLenum format, GLenum type ); 567117f1b4Smrg 574a49301eSmrgextern GLboolean 584a49301eSmrg_mesa_is_color_format(GLenum format); 594a49301eSmrg 604a49301eSmrgextern GLboolean 614a49301eSmrg_mesa_is_index_format(GLenum format); 624a49301eSmrg 634a49301eSmrgextern GLboolean 644a49301eSmrg_mesa_is_depth_format(GLenum format); 654a49301eSmrg 664a49301eSmrgextern GLboolean 674a49301eSmrg_mesa_is_stencil_format(GLenum format); 684a49301eSmrg 694a49301eSmrgextern GLboolean 704a49301eSmrg_mesa_is_ycbcr_format(GLenum format); 714a49301eSmrg 724a49301eSmrgextern GLboolean 734a49301eSmrg_mesa_is_depthstencil_format(GLenum format); 744a49301eSmrg 754a49301eSmrgextern GLboolean 764a49301eSmrg_mesa_is_dudv_format(GLenum format); 774a49301eSmrg 787117f1b4Smrg 797117f1b4Smrgextern GLvoid * 807117f1b4Smrg_mesa_image_address( GLuint dimensions, 817117f1b4Smrg const struct gl_pixelstore_attrib *packing, 827117f1b4Smrg const GLvoid *image, 837117f1b4Smrg GLsizei width, GLsizei height, 847117f1b4Smrg GLenum format, GLenum type, 857117f1b4Smrg GLint img, GLint row, GLint column ); 867117f1b4Smrg 877117f1b4Smrgextern GLvoid * 887117f1b4Smrg_mesa_image_address1d( const struct gl_pixelstore_attrib *packing, 897117f1b4Smrg const GLvoid *image, 907117f1b4Smrg GLsizei width, 917117f1b4Smrg GLenum format, GLenum type, 927117f1b4Smrg GLint column ); 937117f1b4Smrg 947117f1b4Smrgextern GLvoid * 957117f1b4Smrg_mesa_image_address2d( const struct gl_pixelstore_attrib *packing, 967117f1b4Smrg const GLvoid *image, 977117f1b4Smrg GLsizei width, GLsizei height, 987117f1b4Smrg GLenum format, GLenum type, 997117f1b4Smrg GLint row, GLint column ); 1007117f1b4Smrg 1017117f1b4Smrgextern GLvoid * 1027117f1b4Smrg_mesa_image_address3d( const struct gl_pixelstore_attrib *packing, 1037117f1b4Smrg const GLvoid *image, 1047117f1b4Smrg GLsizei width, GLsizei height, 1057117f1b4Smrg GLenum format, GLenum type, 1067117f1b4Smrg GLint img, GLint row, GLint column ); 1077117f1b4Smrg 1087117f1b4Smrg 1097117f1b4Smrgextern GLint 1107117f1b4Smrg_mesa_image_row_stride( const struct gl_pixelstore_attrib *packing, 1117117f1b4Smrg GLint width, GLenum format, GLenum type ); 1127117f1b4Smrg 1137117f1b4Smrg 1147117f1b4Smrgextern GLint 1157117f1b4Smrg_mesa_image_image_stride( const struct gl_pixelstore_attrib *packing, 1167117f1b4Smrg GLint width, GLint height, 1177117f1b4Smrg GLenum format, GLenum type ); 1187117f1b4Smrg 1197117f1b4Smrgextern void 1207117f1b4Smrg_mesa_unpack_polygon_stipple( const GLubyte *pattern, GLuint dest[32], 1217117f1b4Smrg const struct gl_pixelstore_attrib *unpacking ); 1227117f1b4Smrg 1237117f1b4Smrg 1247117f1b4Smrgextern void 1257117f1b4Smrg_mesa_pack_polygon_stipple( const GLuint pattern[32], GLubyte *dest, 1267117f1b4Smrg const struct gl_pixelstore_attrib *packing ); 1277117f1b4Smrg 1287117f1b4Smrg 1297117f1b4Smrgextern GLvoid * 1307117f1b4Smrg_mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels, 1317117f1b4Smrg const struct gl_pixelstore_attrib *packing ); 1327117f1b4Smrg 1337117f1b4Smrgextern void 1347117f1b4Smrg_mesa_pack_bitmap( GLint width, GLint height, const GLubyte *source, 1357117f1b4Smrg GLubyte *dest, const struct gl_pixelstore_attrib *packing ); 1367117f1b4Smrg 1374a49301eSmrgextern void 1384a49301eSmrg_mesa_expand_bitmap(GLsizei width, GLsizei height, 1394a49301eSmrg const struct gl_pixelstore_attrib *unpack, 1404a49301eSmrg const GLubyte *bitmap, 1414a49301eSmrg GLubyte *destBuffer, GLint destStride, 1424a49301eSmrg GLubyte onValue); 1434a49301eSmrg 1447117f1b4Smrg 145c1f859d4Smrg/** \name Pixel processing functions */ 146c1f859d4Smrg/*@{*/ 147c1f859d4Smrg 148c1f859d4Smrgextern void 149c1f859d4Smrg_mesa_scale_and_bias_rgba(GLuint n, GLfloat rgba[][4], 150c1f859d4Smrg GLfloat rScale, GLfloat gScale, 151c1f859d4Smrg GLfloat bScale, GLfloat aScale, 152c1f859d4Smrg GLfloat rBias, GLfloat gBias, 153c1f859d4Smrg GLfloat bBias, GLfloat aBias); 154c1f859d4Smrg 155c1f859d4Smrgextern void 156c1f859d4Smrg_mesa_map_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4]); 157c1f859d4Smrg 158c1f859d4Smrg 159c1f859d4Smrgextern void 160c1f859d4Smrg_mesa_transform_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4]); 161c1f859d4Smrg 162c1f859d4Smrg 163c1f859d4Smrgextern void 164c1f859d4Smrg_mesa_lookup_rgba_float(const struct gl_color_table *table, 165c1f859d4Smrg GLuint n, GLfloat rgba[][4]); 166c1f859d4Smrg 167c1f859d4Smrgextern void 168c1f859d4Smrg_mesa_lookup_rgba_ubyte(const struct gl_color_table *table, 169c1f859d4Smrg GLuint n, GLubyte rgba[][4]); 170c1f859d4Smrg 171c1f859d4Smrg 172c1f859d4Smrgextern void 173c1f859d4Smrg_mesa_map_ci_to_rgba(const GLcontext *ctx, 174c1f859d4Smrg GLuint n, const GLuint index[], GLfloat rgba[][4]); 175c1f859d4Smrg 176c1f859d4Smrg 177c1f859d4Smrgextern void 178c1f859d4Smrg_mesa_map_ci8_to_rgba8(const GLcontext *ctx, GLuint n, const GLubyte index[], 179c1f859d4Smrg GLubyte rgba[][4]); 180c1f859d4Smrg 181c1f859d4Smrg 182c1f859d4Smrgextern void 183c1f859d4Smrg_mesa_scale_and_bias_depth(const GLcontext *ctx, GLuint n, 184c1f859d4Smrg GLfloat depthValues[]); 185c1f859d4Smrg 186c1f859d4Smrgextern void 187c1f859d4Smrg_mesa_scale_and_bias_depth_uint(const GLcontext *ctx, GLuint n, 188c1f859d4Smrg GLuint depthValues[]); 189c1f859d4Smrg 1907117f1b4Smrgextern void 1917117f1b4Smrg_mesa_apply_rgba_transfer_ops(GLcontext *ctx, GLbitfield transferOps, 1927117f1b4Smrg GLuint n, GLfloat rgba[][4]); 1937117f1b4Smrg 1947117f1b4Smrg 1957117f1b4Smrgextern void 1967117f1b4Smrg_mesa_apply_ci_transfer_ops(const GLcontext *ctx, GLbitfield transferOps, 1977117f1b4Smrg GLuint n, GLuint indexes[]); 1987117f1b4Smrg 1997117f1b4Smrg 2007117f1b4Smrgextern void 2017117f1b4Smrg_mesa_apply_stencil_transfer_ops(const GLcontext *ctx, GLuint n, 2027117f1b4Smrg GLstencil stencil[]); 2037117f1b4Smrg 2047117f1b4Smrg 2057117f1b4Smrgextern void 2067117f1b4Smrg_mesa_pack_rgba_span_float( GLcontext *ctx, GLuint n, GLfloat rgba[][4], 2077117f1b4Smrg GLenum dstFormat, GLenum dstType, GLvoid *dstAddr, 2087117f1b4Smrg const struct gl_pixelstore_attrib *dstPacking, 2097117f1b4Smrg GLbitfield transferOps ); 2107117f1b4Smrg 2117117f1b4Smrg 2127117f1b4Smrgextern void 2137117f1b4Smrg_mesa_unpack_color_span_chan( GLcontext *ctx, 2147117f1b4Smrg GLuint n, GLenum dstFormat, GLchan dest[], 2157117f1b4Smrg GLenum srcFormat, GLenum srcType, 2167117f1b4Smrg const GLvoid *source, 2177117f1b4Smrg const struct gl_pixelstore_attrib *srcPacking, 2187117f1b4Smrg GLbitfield transferOps ); 2197117f1b4Smrg 2207117f1b4Smrg 2217117f1b4Smrgextern void 2227117f1b4Smrg_mesa_unpack_color_span_float( GLcontext *ctx, 2237117f1b4Smrg GLuint n, GLenum dstFormat, GLfloat dest[], 2247117f1b4Smrg GLenum srcFormat, GLenum srcType, 2257117f1b4Smrg const GLvoid *source, 2267117f1b4Smrg const struct gl_pixelstore_attrib *srcPacking, 2277117f1b4Smrg GLbitfield transferOps ); 2287117f1b4Smrg 2294a49301eSmrgextern void 2304a49301eSmrg_mesa_unpack_dudv_span_byte( GLcontext *ctx, 2314a49301eSmrg GLuint n, GLenum dstFormat, GLbyte dest[], 2324a49301eSmrg GLenum srcFormat, GLenum srcType, 2334a49301eSmrg const GLvoid *source, 2344a49301eSmrg const struct gl_pixelstore_attrib *srcPacking, 2354a49301eSmrg GLbitfield transferOps ); 2367117f1b4Smrg 2377117f1b4Smrgextern void 2387117f1b4Smrg_mesa_unpack_index_span( const GLcontext *ctx, GLuint n, 2397117f1b4Smrg GLenum dstType, GLvoid *dest, 2407117f1b4Smrg GLenum srcType, const GLvoid *source, 2417117f1b4Smrg const struct gl_pixelstore_attrib *srcPacking, 2427117f1b4Smrg GLbitfield transferOps ); 2437117f1b4Smrg 2447117f1b4Smrg 2457117f1b4Smrgextern void 2467117f1b4Smrg_mesa_pack_index_span( const GLcontext *ctx, GLuint n, 2477117f1b4Smrg GLenum dstType, GLvoid *dest, const GLuint *source, 2487117f1b4Smrg const struct gl_pixelstore_attrib *dstPacking, 2497117f1b4Smrg GLbitfield transferOps ); 2507117f1b4Smrg 2517117f1b4Smrg 2527117f1b4Smrgextern void 2537117f1b4Smrg_mesa_unpack_stencil_span( const GLcontext *ctx, GLuint n, 2547117f1b4Smrg GLenum dstType, GLvoid *dest, 2557117f1b4Smrg GLenum srcType, const GLvoid *source, 2567117f1b4Smrg const struct gl_pixelstore_attrib *srcPacking, 2577117f1b4Smrg GLbitfield transferOps ); 2587117f1b4Smrg 2597117f1b4Smrgextern void 2607117f1b4Smrg_mesa_pack_stencil_span( const GLcontext *ctx, GLuint n, 2617117f1b4Smrg GLenum dstType, GLvoid *dest, const GLstencil *source, 2627117f1b4Smrg const struct gl_pixelstore_attrib *dstPacking ); 2637117f1b4Smrg 2647117f1b4Smrg 2657117f1b4Smrgextern void 2667117f1b4Smrg_mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, 267c1f859d4Smrg GLenum dstType, GLvoid *dest, GLuint depthMax, 2687117f1b4Smrg GLenum srcType, const GLvoid *source, 2697117f1b4Smrg const struct gl_pixelstore_attrib *srcPacking ); 2707117f1b4Smrg 2717117f1b4Smrgextern void 2727117f1b4Smrg_mesa_pack_depth_span( const GLcontext *ctx, GLuint n, GLvoid *dest, 2737117f1b4Smrg GLenum dstType, const GLfloat *depthSpan, 2747117f1b4Smrg const struct gl_pixelstore_attrib *dstPacking ); 2757117f1b4Smrg 2767117f1b4Smrg 2777117f1b4Smrgextern void 2787117f1b4Smrg_mesa_pack_depth_stencil_span(const GLcontext *ctx, GLuint n, GLuint *dest, 2797117f1b4Smrg const GLfloat *depthVals, 2807117f1b4Smrg const GLstencil *stencilVals, 2817117f1b4Smrg const struct gl_pixelstore_attrib *dstPacking); 2827117f1b4Smrg 2837117f1b4Smrg 2847117f1b4Smrgextern void * 2857117f1b4Smrg_mesa_unpack_image( GLuint dimensions, 2867117f1b4Smrg GLsizei width, GLsizei height, GLsizei depth, 2877117f1b4Smrg GLenum format, GLenum type, const GLvoid *pixels, 2887117f1b4Smrg const struct gl_pixelstore_attrib *unpack ); 2897117f1b4Smrg 2907117f1b4Smrg 2917117f1b4Smrgextern void 2927117f1b4Smrg_mesa_convert_colors(GLenum srcType, const GLvoid *src, 2937117f1b4Smrg GLenum dstType, GLvoid *dst, 2947117f1b4Smrg GLuint count, const GLubyte mask[]); 2957117f1b4Smrg 2967117f1b4Smrg 2977117f1b4Smrgextern GLboolean 2987117f1b4Smrg_mesa_clip_drawpixels(const GLcontext *ctx, 2997117f1b4Smrg GLint *destX, GLint *destY, 3007117f1b4Smrg GLsizei *width, GLsizei *height, 3017117f1b4Smrg struct gl_pixelstore_attrib *unpack); 3027117f1b4Smrg 3037117f1b4Smrg 3047117f1b4Smrgextern GLboolean 3057117f1b4Smrg_mesa_clip_readpixels(const GLcontext *ctx, 306cdc920a0Smrg GLint *srcX, GLint *srcY, 3077117f1b4Smrg GLsizei *width, GLsizei *height, 3087117f1b4Smrg struct gl_pixelstore_attrib *pack); 3097117f1b4Smrg 310c1f859d4Smrgextern GLboolean 311c1f859d4Smrg_mesa_clip_copytexsubimage(const GLcontext *ctx, 312c1f859d4Smrg GLint *destX, GLint *destY, 313c1f859d4Smrg GLint *srcX, GLint *srcY, 314c1f859d4Smrg GLsizei *width, GLsizei *height); 315c1f859d4Smrg 3167117f1b4Smrgextern GLboolean 3177117f1b4Smrg_mesa_clip_to_region(GLint xmin, GLint ymin, 3187117f1b4Smrg GLint xmax, GLint ymax, 3197117f1b4Smrg GLint *x, GLint *y, 3207117f1b4Smrg GLsizei *width, GLsizei *height ); 3217117f1b4Smrg 3224a49301eSmrgextern GLboolean 3234a49301eSmrg_mesa_clip_blit(GLcontext *ctx, 3244a49301eSmrg GLint *srcX0, GLint *srcY0, GLint *srcX1, GLint *srcY1, 3254a49301eSmrg GLint *dstX0, GLint *dstY0, GLint *dstX1, GLint *dstY1); 3264a49301eSmrg 3274a49301eSmrg 3287117f1b4Smrg#endif 329