summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/x11/xm_api.c
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-03-09 11:43:53 -0700
committerBrian <[email protected]>2007-03-09 11:43:53 -0700
commit2cf5fd48d1586f961910a14324a457854cb66221 (patch)
tree6b8690b1e3ac2b59369356d692214cc7d6a889c6 /src/mesa/drivers/x11/xm_api.c
parent9f44247acf62b91669f77974a4bbad687d58859e (diff)
parentf9f79c8d770e696249bd98c68b563f887562c974 (diff)
Merge branch 'origin' into glsl-compiler-1
Conflicts: src/mesa/main/context.c
Diffstat (limited to 'src/mesa/drivers/x11/xm_api.c')
-rw-r--r--src/mesa/drivers/x11/xm_api.c106
1 files changed, 28 insertions, 78 deletions
diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c
index b0ef422de2e..776928dec4d 100644
--- a/src/mesa/drivers/x11/xm_api.c
+++ b/src/mesa/drivers/x11/xm_api.c
@@ -345,7 +345,7 @@ xmesa_get_window_size(XMesaDisplay *dpy, XMesaBuffer b,
/***** Linked list of XMesaBuffers *****/
/**********************************************************************/
-static XMesaBuffer XMesaBufferList = NULL;
+XMesaBuffer XMesaBufferList = NULL;
/**
@@ -378,12 +378,12 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type,
b->cmap = cmap;
_mesa_initialize_framebuffer(&b->mesa_buffer, &vis->mesa_visual);
+ b->mesa_buffer.Delete = xmesa_delete_framebuffer;
/*
* Front renderbuffer
*/
- b->frontxrb = xmesa_new_renderbuffer(NULL, 0, &vis->mesa_visual,
- GL_FALSE);
+ b->frontxrb = xmesa_new_renderbuffer(NULL, 0, &vis->mesa_visual, GL_FALSE);
if (!b->frontxrb) {
_mesa_free(b);
return NULL;
@@ -398,8 +398,7 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type,
* Back renderbuffer
*/
if (vis->mesa_visual.doubleBufferMode) {
- b->backxrb = xmesa_new_renderbuffer(NULL, 0, &vis->mesa_visual,
- GL_TRUE);
+ b->backxrb = xmesa_new_renderbuffer(NULL, 0, &vis->mesa_visual, GL_TRUE);
if (!b->backxrb) {
/* XXX free front xrb too */
_mesa_free(b);
@@ -451,8 +450,8 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type,
* Find an XMesaBuffer by matching X display and colormap but NOT matching
* the notThis buffer.
*/
-static XMesaBuffer
-find_xmesa_buffer(XMesaDisplay *dpy, XMesaColormap cmap, XMesaBuffer notThis)
+XMesaBuffer
+xmesa_find_buffer(XMesaDisplay *dpy, XMesaColormap cmap, XMesaBuffer notThis)
{
XMesaBuffer b;
for (b=XMesaBufferList; b; b=b->Next) {
@@ -465,38 +464,27 @@ find_xmesa_buffer(XMesaDisplay *dpy, XMesaColormap cmap, XMesaBuffer notThis)
/**
- * Free an XMesaBuffer, remove from linked list, perhaps free X colormap
- * entries.
+ * Remove buffer from linked list, delete if no longer referenced.
*/
static void
-free_xmesa_buffer(int client, XMesaBuffer buffer)
+xmesa_free_buffer(XMesaBuffer buffer)
{
XMesaBuffer prev = NULL, b;
- (void) client;
- for (b=XMesaBufferList; b; b=b->Next) {
- if (b==buffer) {
- /* unlink bufer from list */
+
+ for (b = XMesaBufferList; b; b = b->Next) {
+ if (b == buffer) {
+ struct gl_framebuffer *fb = &buffer->mesa_buffer;
+
+ /* unlink buffer from list */
if (prev)
prev->Next = buffer->Next;
else
XMesaBufferList = buffer->Next;
- /* Check to free X colors */
- if (buffer->num_alloced>0) {
- /* If no other buffer uses this X colormap then free the colors. */
- if (!find_xmesa_buffer(buffer->display, buffer->cmap, buffer)) {
-#ifdef XFree86Server
- (void)FreeColors(buffer->cmap, client,
- buffer->num_alloced, buffer->alloced_colors,
- 0);
-#else
- XFreeColors(buffer->display, buffer->cmap,
- buffer->alloced_colors, buffer->num_alloced, 0);
-#endif
- }
- }
- _mesa_free_framebuffer_data(&buffer->mesa_buffer);
- _mesa_free(buffer);
+ /* mark as delete pending */
+ fb->DeletePending = GL_TRUE;
+ /* Unreference. If count = zero we'll really delete the buffer */
+ _mesa_unreference_framebuffer(&fb);
return;
}
@@ -504,7 +492,7 @@ free_xmesa_buffer(int client, XMesaBuffer buffer)
prev = b;
}
/* buffer not found in XMesaBufferList */
- _mesa_problem(NULL,"free_xmesa_buffer() - buffer not found\n");
+ _mesa_problem(NULL,"xmesa_free_buffer() - buffer not found\n");
}
@@ -686,7 +674,7 @@ setup_grayscale(int client, XMesaVisual v,
return GL_FALSE;
}
- prevBuffer = find_xmesa_buffer(v->display, cmap, buffer);
+ prevBuffer = xmesa_find_buffer(v->display, cmap, buffer);
if (prevBuffer &&
(buffer->xm_visual->mesa_visual.rgbMode ==
prevBuffer->xm_visual->mesa_visual.rgbMode)) {
@@ -775,7 +763,7 @@ setup_dithered_color(int client, XMesaVisual v,
return GL_FALSE;
}
- prevBuffer = find_xmesa_buffer(v->display, cmap, buffer);
+ prevBuffer = xmesa_find_buffer(v->display, cmap, buffer);
if (prevBuffer &&
(buffer->xm_visual->mesa_visual.rgbMode ==
prevBuffer->xm_visual->mesa_visual.rgbMode)) {
@@ -1666,7 +1654,7 @@ XMesaCreateWindowBuffer2(XMesaVisual v, XMesaWindow w, XMesaContext c)
if (!initialize_visual_and_buffer( client, v, b, v->mesa_visual.rgbMode,
(XMesaDrawable) w, cmap )) {
- free_xmesa_buffer(client, b);
+ xmesa_free_buffer(b);
return NULL;
}
@@ -1787,7 +1775,7 @@ XMesaCreatePixmapBuffer(XMesaVisual v, XMesaPixmap p, XMesaColormap cmap)
if (!initialize_visual_and_buffer(client, v, b, v->mesa_visual.rgbMode,
(XMesaDrawable) p, cmap)) {
- free_xmesa_buffer(client, b);
+ xmesa_free_buffer(b);
return NULL;
}
@@ -1821,7 +1809,7 @@ XMesaCreatePBuffer(XMesaVisual v, XMesaColormap cmap,
if (!initialize_visual_and_buffer(client, v, b, v->mesa_visual.rgbMode,
drawable, cmap)) {
- free_xmesa_buffer(client, b);
+ xmesa_free_buffer(b);
return NULL;
}
@@ -1834,48 +1822,10 @@ XMesaCreatePBuffer(XMesaVisual v, XMesaColormap cmap,
/*
* Deallocate an XMesaBuffer structure and all related info.
*/
-void XMesaDestroyBuffer( XMesaBuffer b )
+void
+XMesaDestroyBuffer(XMesaBuffer b)
{
- int client = 0;
-
-#ifdef XFree86Server
- if (b->frontxrb->drawable)
- client = CLIENT_ID(b->frontxrb->drawable->id);
-#endif
-
- if (b->gc) XMesaFreeGC( b->xm_visual->display, b->gc );
- if (b->cleargc) XMesaFreeGC( b->xm_visual->display, b->cleargc );
- if (b->swapgc) XMesaFreeGC( b->xm_visual->display, b->swapgc );
-
- if (b->xm_visual->mesa_visual.doubleBufferMode)
- {
- if (b->backxrb->ximage) {
-#if defined(USE_XSHM) && !defined(XFree86Server)
- if (b->shm) {
- XShmDetach( b->xm_visual->display, &b->shminfo );
- XDestroyImage( b->backxrb->ximage );
- shmdt( b->shminfo.shmaddr );
- }
- else
-#endif
- XMesaDestroyImage( b->backxrb->ximage );
- }
- if (b->backxrb->pixmap) {
- XMesaFreePixmap( b->xm_visual->display, b->backxrb->pixmap );
- if (b->xm_visual->hpcr_clear_flag) {
- XMesaFreePixmap( b->xm_visual->display,
- b->xm_visual->hpcr_clear_pixmap );
- XMesaDestroyImage( b->xm_visual->hpcr_clear_ximage );
- }
- }
- }
- if (b->rowimage) {
- _mesa_free( b->rowimage->data );
- b->rowimage->data = NULL;
- XMesaDestroyImage( b->rowimage );
- }
-
- free_xmesa_buffer(client, b);
+ xmesa_free_buffer(b);
}
@@ -2436,7 +2386,7 @@ void xmesa_destroy_buffers_on_display(XMesaDisplay *dpy)
for (b = XMesaBufferList; b; b = next) {
next = b->Next;
if (b->display == dpy) {
- free_xmesa_buffer(0, b);
+ xmesa_free_buffer(b);
}
}
}