cell: checkpoint: remove more of the old per-fragment code
[mesa.git] / src / gallium / winsys / xlib / xmesaP.h
1 /*
2 * Mesa 3-D graphics library
3 * Version: 7.1
4 *
5 * Copyright (C) 1999-2007 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 XMESAP_H
27 #define XMESAP_H
28
29
30 #include "GL/xmesa.h"
31 #include "mtypes.h"
32 #ifdef XFree86Server
33 #include "xm_image.h"
34 #endif
35
36 #include "state_tracker/st_context.h"
37 #include "state_tracker/st_public.h"
38 #include "pipe/p_thread.h"
39
40
41 extern pipe_mutex _xmesa_lock;
42
43 extern XMesaBuffer XMesaBufferList;
44
45 /*
46 */
47 #define XMESA_SOFTPIPE 1
48 #define XMESA_AUB 2
49 extern int xmesa_mode;
50
51
52 /**
53 * Visual inforation, derived from GLvisual.
54 * Basically corresponds to an XVisualInfo.
55 */
56 struct xmesa_visual {
57 GLvisual mesa_visual; /* Device independent visual parameters */
58 XMesaDisplay *display; /* The X11 display */
59 #ifdef XFree86Server
60 GLint ColormapEntries;
61 GLint nplanes;
62 #else
63 XMesaVisualInfo visinfo; /* X's visual info (pointer to private copy) */
64 XVisualInfo *vishandle; /* Only used in fakeglx.c */
65 #endif
66 GLint BitsPerPixel; /* True bits per pixel for XImages */
67
68 GLboolean ximage_flag; /* Use XImage for back buffer (not pixmap)? */
69 };
70
71
72 /**
73 * Context info, derived from st_context.
74 * Basically corresponds to a GLXContext.
75 */
76 struct xmesa_context {
77 struct st_context *st;
78 XMesaVisual xm_visual; /** pixel format info */
79 XMesaBuffer xm_buffer; /** current drawbuffer */
80 };
81
82
83 /**
84 * Types of X/GLX drawables we might render into.
85 */
86 typedef enum {
87 WINDOW, /* An X window */
88 GLXWINDOW, /* GLX window */
89 PIXMAP, /* GLX pixmap */
90 PBUFFER /* GLX Pbuffer */
91 } BufferType;
92
93
94 /**
95 * Framebuffer information, derived from.
96 * Basically corresponds to a GLXDrawable.
97 */
98 struct xmesa_buffer {
99 struct st_framebuffer *stfb;
100
101 GLboolean wasCurrent; /* was ever the current buffer? */
102 XMesaVisual xm_visual; /* the X/Mesa visual */
103 XMesaDrawable drawable; /* Usually the X window ID */
104 XMesaColormap cmap; /* the X colormap */
105 BufferType type; /* window, pixmap, pbuffer or glxwindow */
106
107 XMesaImage *tempImage;
108 unsigned long selectedEvents;/* for pbuffers only */
109
110 GLuint shm; /* X Shared Memory extension status: */
111 /* 0 = not available */
112 /* 1 = XImage support available */
113 /* 2 = Pixmap support available too */
114 #if defined(USE_XSHM) && !defined(XFree86Server)
115 XShmSegmentInfo shminfo;
116 #endif
117
118 XMesaGC gc; /* scratch GC for span, line, tri drawing */
119
120 /* GLX_EXT_texture_from_pixmap */
121 GLint TextureTarget; /** GLX_TEXTURE_1D_EXT, for example */
122 GLint TextureFormat; /** GLX_TEXTURE_FORMAT_RGB_EXT, for example */
123 GLint TextureMipmap; /** 0 or 1 */
124
125 struct xmesa_buffer *Next; /* Linked list pointer: */
126 };
127
128
129
130 /** cast wrapper */
131 static INLINE XMesaContext
132 xmesa_context(GLcontext *ctx)
133 {
134 return (XMesaContext) ctx->DriverCtx;
135 }
136
137
138 /** cast wrapper */
139 static INLINE XMesaBuffer
140 xmesa_buffer(GLframebuffer *fb)
141 {
142 struct st_framebuffer *stfb = (struct st_framebuffer *) fb;
143 return (XMesaBuffer) st_framebuffer_private(stfb);
144 }
145
146
147 extern void
148 xmesa_delete_framebuffer(struct gl_framebuffer *fb);
149
150 extern XMesaBuffer
151 xmesa_find_buffer(XMesaDisplay *dpy, XMesaColormap cmap, XMesaBuffer notThis);
152
153 extern void
154 xmesa_check_and_update_buffer_size(XMesaContext xmctx, XMesaBuffer drawBuffer);
155
156 extern void
157 xmesa_destroy_buffers_on_display(XMesaDisplay *dpy);
158
159 extern struct pipe_context *
160 xmesa_create_pipe_context(XMesaContext xm, uint pixelformat);
161
162 static INLINE GLuint
163 xmesa_buffer_width(XMesaBuffer b)
164 {
165 return b->stfb->Base.Width;
166 }
167
168 static INLINE GLuint
169 xmesa_buffer_height(XMesaBuffer b)
170 {
171 return b->stfb->Base.Height;
172 }
173
174 extern void
175 xmesa_display_surface(XMesaBuffer b, const struct pipe_surface *surf);
176
177 extern int
178 xmesa_check_for_xshm(XMesaDisplay *display);
179
180 #endif