2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
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:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
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.
36 #include "state_tracker/st_context.h"
37 #include "state_tracker/st_public.h"
40 extern _glthread_Mutex _xmesa_lock
;
42 extern XMesaBuffer XMesaBufferList
;
46 * Visual inforation, derived from GLvisual.
47 * Basically corresponds to an XVisualInfo.
50 GLvisual mesa_visual
; /* Device independent visual parameters */
51 XMesaDisplay
*display
; /* The X11 display */
53 GLint ColormapEntries
;
56 XMesaVisualInfo visinfo
; /* X's visual info (pointer to private copy) */
57 XVisualInfo
*vishandle
; /* Only used in fakeglx.c */
59 GLint BitsPerPixel
; /* True bits per pixel for XImages */
61 GLboolean ximage_flag
; /* Use XImage for back buffer (not pixmap)? */
66 * Context info, derived from st_context.
67 * Basically corresponds to a GLXContext.
69 struct xmesa_context
{
70 struct st_context
*st
;
71 XMesaVisual xm_visual
; /** pixel format info */
72 XMesaBuffer xm_buffer
; /** current drawbuffer */
77 * Types of X/GLX drawables we might render into.
80 WINDOW
, /* An X window */
81 GLXWINDOW
, /* GLX window */
82 PIXMAP
, /* GLX pixmap */
83 PBUFFER
/* GLX Pbuffer */
88 * Framebuffer information, derived from.
89 * Basically corresponds to a GLXDrawable.
92 struct st_framebuffer
*stfb
;
94 GLboolean wasCurrent
; /* was ever the current buffer? */
95 XMesaVisual xm_visual
; /* the X/Mesa visual */
96 XMesaDrawable drawable
; /* Usually the X window ID */
97 XMesaColormap cmap
; /* the X colormap */
98 BufferType type
; /* window, pixmap, pbuffer or glxwindow */
100 XMesaImage
*tempImage
;
101 unsigned long selectedEvents
;/* for pbuffers only */
103 GLuint shm
; /* X Shared Memory extension status: */
104 /* 0 = not available */
105 /* 1 = XImage support available */
106 /* 2 = Pixmap support available too */
107 #if defined(USE_XSHM) && !defined(XFree86Server)
108 XShmSegmentInfo shminfo
;
111 XMesaGC gc
; /* scratch GC for span, line, tri drawing */
113 /* GLX_EXT_texture_from_pixmap */
114 GLint TextureTarget
; /** GLX_TEXTURE_1D_EXT, for example */
115 GLint TextureFormat
; /** GLX_TEXTURE_FORMAT_RGB_EXT, for example */
116 GLint TextureMipmap
; /** 0 or 1 */
118 struct xmesa_buffer
*Next
; /* Linked list pointer: */
124 static INLINE XMesaContext
125 xmesa_context(GLcontext
*ctx
)
127 return (XMesaContext
) ctx
->DriverCtx
;
132 static INLINE XMesaBuffer
133 xmesa_buffer(GLframebuffer
*fb
)
135 struct st_framebuffer
*stfb
= (struct st_framebuffer
*) fb
;
136 return (XMesaBuffer
) st_framebuffer_private(stfb
);
141 xmesa_delete_framebuffer(struct gl_framebuffer
*fb
);
144 xmesa_find_buffer(XMesaDisplay
*dpy
, XMesaColormap cmap
, XMesaBuffer notThis
);
147 xmesa_check_and_update_buffer_size(XMesaContext xmctx
, XMesaBuffer drawBuffer
);
150 xmesa_destroy_buffers_on_display(XMesaDisplay
*dpy
);
152 extern struct pipe_context
*
153 xmesa_create_pipe_context(XMesaContext xm
, uint pixelformat
);
156 xmesa_buffer_width(XMesaBuffer b
)
158 return b
->stfb
->Base
.Width
;
162 xmesa_buffer_height(XMesaBuffer b
)
164 return b
->stfb
->Base
.Height
;
168 xmesa_display_surface(XMesaBuffer b
, const struct pipe_surface
*surf
);