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