patch to import Jon Smirl's work from Bitkeeper
[mesa.git] / src / glx / mini / miniglxP.h
1 /**
2 * \file miniglxP.h
3 * \brief Define replacements for some X data types and define the DRI-related
4 * data structures.
5 *
6 * \note Cut down version of glxclient.h.
7 *
8 */
9
10 #ifndef _mini_GLX_client_h_
11 #define _mini_GLX_client_h_
12
13 #include <signal.h>
14 #include <linux/fb.h>
15
16 #include <GL/miniglx.h>
17 #include "glheader.h"
18 #include "mtypes.h"
19
20 #include "driver.h"
21 #include "dri.h"
22
23 /**
24 * \brief Supported pixel formats.
25 */
26 enum PixelFormat {
27 PF_B8G8R8, /**< \brief 24-bit BGR */
28 PF_B8G8R8A8, /**< \brief 32-bit BGRA */
29 PF_B5G6R5, /**< \brief 16-bit BGR */
30 PF_B5G5R5, /**< \brief 15-bit BGR */
31 PF_CI8 /**< \brief 8-bit color index */
32 };
33
34 /**
35 * \brief X Visual type.
36 *
37 * \sa ::Visual, \ref datatypes.
38 */
39 struct MiniGLXVisualRec {
40 /** \brief GLX visual information */
41 const __GLcontextModes *mode;
42
43 /** \brief pointer back to corresponding ::XVisualInfo */
44 XVisualInfo *visInfo;
45
46 /** \brief display handle */
47 Display *dpy;
48
49 /** \brief pixel format */
50 enum PixelFormat pixelFormat;
51 };
52
53
54
55 /**
56 * \brief X Window type.
57 *
58 * \sa ::Window, \ref datatypes.
59 */
60 struct MiniGLXWindowRec {
61 Visual *visual;
62 /** \brief position (always 0,0) */
63 int x, y;
64 /** \brief size */
65 unsigned int w, h;
66 void *frontStart; /**< \brief start of front color buffer */
67 void *backStart; /**< \brief start of back color buffer */
68 size_t size; /**< \brief color buffer size, in bytes */
69 GLuint bytesPerPixel;
70 GLuint rowStride; /**< \brief in bytes */
71 GLubyte *frontBottom; /**< \brief pointer to last row */
72 GLubyte *backBottom; /**< \brief pointer to last row */
73 GLubyte *curBottom; /**< = frontBottom or backBottom */
74 __DRIdrawable *driDrawable;
75 GLuint ismapped;
76 };
77
78
79 /**
80 * \brief GLXContext type.
81 *
82 * \sa ::GLXContext, \ref datatypes.
83 */
84 struct MiniGLXContextRec {
85 Window drawBuffer; /**< \brief drawing buffer */
86 Window curBuffer; /**< \brief current buffer */
87 VisualID vid; /**< \brief visual ID */
88 __DRIcontext *driContext; /**< \brief context dependent methods */
89 };
90
91 #define MINIGLX_BUF_SIZE 512
92 #define MINIGLX_MAX_SERVER_FDS 10
93 #define MINIGLX_MAX_CLIENT_FDS 1
94 #define MINIGLX_EVENT_QUEUE_SZ 16
95 #define MINIGLX_EVENT_QUEUE_MASK (MINIGLX_EVENT_QUEUE_SZ-1)
96
97 /**
98 * A connection to/from the server
99 *
100 * All information is to/from the server is buffered and then dispatched by
101 * __miniglx_Select() to avoid blocking the server.
102 */
103 struct MiniGLXConnection {
104 int fd; /**< \brief file descriptor */
105 char readbuf[MINIGLX_BUF_SIZE]; /**< \brief read buffer */
106 char writebuf[MINIGLX_BUF_SIZE]; /**< \brief write buffer */
107 int readbuf_count; /**< \brief count of bytes waiting to be read */
108 int writebuf_count; /**< \brief count of bytes waiting to be written */
109 };
110
111
112 /**
113 * \brief X Display type
114 *
115 * \sa ::Display, \ref datatypes.
116 */
117 struct MiniGLXDisplayRec {
118 /** \brief fixed framebuffer screen info */
119 struct fb_fix_screeninfo FixedInfo;
120 /** \brief original and current variable framebuffer screen info */
121 struct fb_var_screeninfo OrigVarInfo, VarInfo;
122 struct sigaction OrigSigUsr1;
123 struct sigaction OrigSigUsr2;
124 int OriginalVT;
125 int ConsoleFD; /**< \brief console TTY device file descriptor */
126 int FrameBufferFD; /**< \brief framebuffer device file descriptor */
127 int NumWindows; /**< \brief number of open windows */
128 Window TheWindow; /**< \brief open window - only allow one window for now */
129 int rotateMode;
130
131
132 volatile int vtSignalFlag;
133 volatile int haveVT; /**< \brief whether the VT is hold */
134 int hwActive; /**< \brief whether the hardware is active -- mimics
135 the variations of MiniGLXDisplayRec::haveVT */
136
137
138 int IsClient; /**< \brief whether it's a client or the server */
139 int clientID;
140 int nrFds; /**< \brief number of connections (usually just one for the clients) */
141 struct MiniGLXConnection *fd; /**< \brief connections */
142
143 struct {
144 int nr, head, tail;
145 XEvent queue[MINIGLX_EVENT_QUEUE_SZ];
146 } eventqueue;
147
148 /**
149 * \name Visuals
150 *
151 * Visuals (configs) in this screen.
152 */
153 /*@{*/
154 int numModes; /**< \brief Number of modes. */
155 const __GLcontextModes *modes; /**< \brief Modes list pointer. */
156 /*@}*/
157
158 /**
159 * \name From __GLXdisplayPrivate
160 */
161 /*@{*/
162 driCreateScreenFunc *createScreen; /**< \brief \e __driCreateScreen hook */
163 __DRIscreen *driScreen; /**< \brief Screen dependent methods */
164 void *dlHandle; /**<
165 * \brief handle to the client dynamic
166 * library
167 */
168 /*@}*/
169
170 /**
171 * \brief Mini GLX specific driver hooks
172 */
173 struct DRIDriverRec *driver;
174 struct DRIDriverContextRec driverContext;
175
176 /**
177 * \name Configuration details
178 *
179 * They are read from a configuration file by __read_config_file().
180 */
181 /*@{*/
182 const char *fbdevDevice;
183 const char *clientDriverName;
184 /*@}*/
185 };
186
187 extern __DRIscreen *__glXFindDRIScreen(Display *dpy, int scrn);
188
189 extern Bool __glXWindowExists(Display *dpy, GLXDrawable draw);
190
191 extern int __miniglx_open_connections( Display *dpy );
192 extern void __miniglx_close_connections( Display *dpy );
193
194 #endif /* !_mini_GLX_client_h_ */