1 | /* $XFree86: xc/programs/Xserver/GL/mesa/src/X/xf86glx_util.h,v 1.5 2000/08/10 17:40:29 dawes Exp $ */
|
---|
2 | /**************************************************************************
|
---|
3 |
|
---|
4 | Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
|
---|
5 | 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
|
---|
9 | "Software"), to deal in the Software without restriction, including
|
---|
10 | without limitation the rights to use, copy, modify, merge, publish,
|
---|
11 | distribute, sub license, and/or sell copies of the Software, and to
|
---|
12 | permit persons to whom the Software is furnished to do so, subject to
|
---|
13 | the following conditions:
|
---|
14 |
|
---|
15 | The above copyright notice and this permission notice (including the
|
---|
16 | next paragraph) shall be included in all copies or substantial portions
|
---|
17 | of the Software.
|
---|
18 |
|
---|
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
---|
20 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
---|
21 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
---|
22 | IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
|
---|
23 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
---|
24 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
---|
25 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
---|
26 |
|
---|
27 | **************************************************************************/
|
---|
28 |
|
---|
29 | /*
|
---|
30 | * Authors:
|
---|
31 | * Kevin E. Martin <kevin@precisioninsight.com>
|
---|
32 | * Brian Paul <brian@precisioninsight.com>
|
---|
33 | */
|
---|
34 |
|
---|
35 | #ifdef HAVE_DIX_CONFIG_H
|
---|
36 | #include <dix-config.h>
|
---|
37 | #endif
|
---|
38 |
|
---|
39 | #ifndef _XF86GLX_UTIL_H_
|
---|
40 | #define _XF86GLX_UTIL_H_
|
---|
41 |
|
---|
42 | #ifdef __CYGWIN__
|
---|
43 | #undef WIN32
|
---|
44 | #undef _WIN32
|
---|
45 | #endif
|
---|
46 |
|
---|
47 | #include <screenint.h>
|
---|
48 | #include <pixmap.h>
|
---|
49 | #include <gc.h>
|
---|
50 | #include "GL/xmesa.h"
|
---|
51 |
|
---|
52 | #define XMESA_USE_PUTPIXEL_MACRO
|
---|
53 |
|
---|
54 | struct _XMesaImageRec {
|
---|
55 | int width, height;
|
---|
56 | char *data;
|
---|
57 | int bytes_per_line; /* Padded to 32 bits */
|
---|
58 | int bits_per_pixel;
|
---|
59 | };
|
---|
60 |
|
---|
61 | extern XMesaImage *XMesaCreateImage(int bitsPerPixel, int width, int height,
|
---|
62 | char *data);
|
---|
63 | extern void XMesaDestroyImage(XMesaImage *image);
|
---|
64 | extern unsigned long XMesaGetPixel(XMesaImage *image, int x, int y);
|
---|
65 | #ifdef XMESA_USE_PUTPIXEL_MACRO
|
---|
66 | #define XMesaPutPixel(__i,__x,__y,__p) \
|
---|
67 | { \
|
---|
68 | CARD8 *__row = (CARD8 *)(__i->data + __y*__i->bytes_per_line); \
|
---|
69 | CARD8 *__i8; \
|
---|
70 | CARD16 *__i16; \
|
---|
71 | CARD32 *__i32; \
|
---|
72 | switch (__i->bits_per_pixel) { \
|
---|
73 | case 8: \
|
---|
74 | __i8 = (CARD8 *)__row; \
|
---|
75 | __i8[__x] = (CARD8)__p; \
|
---|
76 | break; \
|
---|
77 | case 15: \
|
---|
78 | case 16: \
|
---|
79 | __i16 = (CARD16 *)__row; \
|
---|
80 | __i16[__x] = (CARD16)__p; \
|
---|
81 | break; \
|
---|
82 | case 24: /* WARNING: architecture specific code */ \
|
---|
83 | __i8 = (CARD8 *)__row; \
|
---|
84 | __i8[__x*3] = (CARD8)(__p); \
|
---|
85 | __i8[__x*3+1] = (CARD8)(__p>>8); \
|
---|
86 | __i8[__x*3+2] = (CARD8)(__p>>16); \
|
---|
87 | break; \
|
---|
88 | case 32: \
|
---|
89 | __i32 = (CARD32 *)__row; \
|
---|
90 | __i32[__x] = (CARD32)__p; \
|
---|
91 | break; \
|
---|
92 | } \
|
---|
93 | }
|
---|
94 | #else
|
---|
95 | extern void XMesaPutPixel(XMesaImage *image, int x, int y,
|
---|
96 | unsigned long pixel);
|
---|
97 | #endif
|
---|
98 |
|
---|
99 | extern void XMesaPutImageHelper(ScreenPtr display,
|
---|
100 | DrawablePtr d, GCPtr gc,
|
---|
101 | XMesaImage *image,
|
---|
102 | int src_x, int src_y,
|
---|
103 | int dest_x, int dest_y,
|
---|
104 | unsigned int width, unsigned int height);
|
---|
105 |
|
---|
106 | #endif /* _XF86GLX_UTIL_H_ */
|
---|