Revision: 228 http://trac.macosforge.org/projects/xquartz/changeset/228 Author: gstaplin@apple.com Date: 2009-02-21 22:55:32 -0800 (Sat, 21 Feb 2009) Log Message: ----------- Improve error messages for the GLXPixmap code. It seems we will need to redo some of the _XError calls to call __glXSendError (a new thing I wrote) which properly works with XGetErrorDatabaseText. There is a difference in XError handling when using _XError, because most of the _XError calls I added didn't account for the extension error base. Some will be ok that are common X11 error codes like BadDrawable. Others will need some modifications. Modified Paths: -------------- AppleSGLX/trunk/Makefile AppleSGLX/trunk/apple_glx_pixmap.c AppleSGLX/trunk/apple_glx_pixmap.h AppleSGLX/trunk/glx_pbuffer.c AppleSGLX/trunk/glxext.c Modified: AppleSGLX/trunk/Makefile =================================================================== --- AppleSGLX/trunk/Makefile 2009-02-22 05:19:26 UTC (rev 227) +++ AppleSGLX/trunk/Makefile 2009-02-22 06:55:32 UTC (rev 228) @@ -30,7 +30,7 @@ appledri.o apple_glx_context.o apple_glx.o pixel.o \ compsize.o apple_visual.o apple_cgl.o glxreply.o glcontextmodes.o \ apple_xgl_api.o apple_glx_drawable.o xfont.o apple_glx_pbuffer.o \ - apple_glx_pixmap.o apple_xgl_api_read.o glx_empty.o + apple_glx_pixmap.o apple_xgl_api_read.o glx_empty.o glx_error.o #This is used for building the tests. #The tests don't require installation. @@ -53,6 +53,7 @@ glxreply.o: glxreply.c glxcmds.o: glxcmds.c apple_glx_context.h glx_pbuffer.o: glx_pbuffer.c +glx_error.o: glx_error.c glx_query.o: glx_query.c glxcurrent.o: glxcurrent.c glxextensions.o: glxextensions.h glxextensions.c Modified: AppleSGLX/trunk/apple_glx_pixmap.c =================================================================== --- AppleSGLX/trunk/apple_glx_pixmap.c 2009-02-22 05:19:26 UTC (rev 227) +++ AppleSGLX/trunk/apple_glx_pixmap.c 2009-02-22 06:55:32 UTC (rev 228) @@ -171,9 +171,10 @@ return false; } -void apple_glx_pixmap_destroy(Display *dpy, GLXPixmap pixmap) { +bool apple_glx_pixmap_destroy(Display *dpy, GLXPixmap pixmap) { struct apple_glx_pixmap *p; - + bool result = false; + lock_pixmap_list(); if(find_pixmap(pixmap, &p)) { @@ -206,9 +207,13 @@ p->next->previous = p->previous; free(p); + + result = true; } unlock_pixmap_list(); + + return result; } bool apple_glx_is_pixmap(Display *dpy, GLXDrawable drawable) { Modified: AppleSGLX/trunk/apple_glx_pixmap.h =================================================================== --- AppleSGLX/trunk/apple_glx_pixmap.h 2009-02-22 05:19:26 UTC (rev 227) +++ AppleSGLX/trunk/apple_glx_pixmap.h 2009-02-22 06:55:32 UTC (rev 228) @@ -38,7 +38,8 @@ bool apple_glx_pixmap_create(Display *dpy, int screen, Pixmap pixmap, const void *mode); -void apple_glx_pixmap_destroy(Display *dpy, Pixmap pixmap); +/* Returns true if the pixmap was successfully destroyed. */ +bool apple_glx_pixmap_destroy(Display *dpy, Pixmap pixmap); bool apple_glx_is_pixmap(Display *dpy, GLXDrawable drawable); Modified: AppleSGLX/trunk/glx_pbuffer.c =================================================================== --- AppleSGLX/trunk/glx_pbuffer.c 2009-02-22 05:19:26 UTC (rev 227) +++ AppleSGLX/trunk/glx_pbuffer.c 2009-02-22 06:55:32 UTC (rev 228) @@ -43,6 +43,7 @@ #include "apple_glx_pbuffer.h" #include "apple_glx_pixmap.h" +#include "glx_error.h" /** * Create a new pbuffer. @@ -309,7 +310,14 @@ PUBLIC void glXDestroyPixmap(Display *dpy, GLXPixmap pixmap) { - apple_glx_pixmap_destroy(dpy, pixmap); + + xError error; + GLXContext gc = __glXGetCurrentContext(); + + if(apple_glx_pixmap_destroy(dpy, pixmap)) + return; /* The pixmap existed and we successfully destroyed it. */ + + __glXSendError(dpy, GLXBadPixmap, pixmap, X_GLXDestroyPixmap); } Modified: AppleSGLX/trunk/glxext.c =================================================================== --- AppleSGLX/trunk/glxext.c 2009-02-22 05:19:26 UTC (rev 227) +++ AppleSGLX/trunk/glxext.c 2009-02-22 06:55:32 UTC (rev 228) @@ -83,8 +83,10 @@ /* Extension required boiler plate */ static char *__glXExtensionName = GLX_EXTENSION_NAME; -XExtensionInfo *__glXExtensionInfo = NULL; +static XExtensionInfo glxext_info_data; +static XExtensionInfo *glXExtensionInfo = &glxext_info_data; + static /* const */ char *error_list[] = { "GLXBadContext", "GLXBadContextState", @@ -111,13 +113,12 @@ __glXFreeContext(gc); } - return XextRemoveDisplay(__glXExtensionInfo, dpy); + return XextRemoveDisplay(glXExtensionInfo, dpy); } +static char *__glXErrorString(Display *dpy, int code, XExtCodes *codes, + char *buf, int n); -static XEXT_GENERATE_ERROR_STRING(__glXErrorString, __glXExtensionName, - __GLX_NUMBER_ERRORS, error_list) - static /* const */ XExtensionHooks __glXExtensionHooks = { NULL, /* create_gc */ NULL, /* copy_gc */ @@ -132,11 +133,17 @@ __glXErrorString, /* error_string */ }; -static -XEXT_GENERATE_FIND_DISPLAY(__glXFindDisplay, __glXExtensionInfo, + +XEXT_GENERATE_FIND_DISPLAY(__glXFindDisplay, glXExtensionInfo, __glXExtensionName, &__glXExtensionHooks, __GLX_NUMBER_EVENTS, NULL) +static XEXT_GENERATE_ERROR_STRING(__glXErrorString, __glXExtensionName, + __GLX_NUMBER_ERRORS, error_list) + + + + /************************************************************************/ /* @@ -634,7 +641,8 @@ #ifdef GLX_DIRECT_RENDERING Bool glx_direct, glx_accel; #endif - + + #if defined(USE_XTHREADS) { static int firstCall = 1;
participants (1)
-
source_changes@macosforge.org