Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:dreveman:openSUSE:11.1:cr
cr
cr-render-ignore-errors.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File cr-render-ignore-errors.diff of Package cr
diff --git a/spu/render/renderspu_glx.c b/spu/render/renderspu_glx.c index d9a830f..b45e83a 100644 --- a/spu/render/renderspu_glx.c +++ b/spu/render/renderspu_glx.c @@ -46,6 +46,20 @@ typedef struct static Bool WindowExistsFlag; static int +IgnoreErrorHandler( Display *dpy, XErrorEvent *xerr ) +{ + char buffer[256]; + char mesg[256]; + + XGetErrorText(dpy, xerr->error_code, buffer, sizeof (buffer)); + XGetErrorDatabaseText(dpy, "XlibMessage", "XError", "X Error", mesg, + sizeof (mesg)); + crWarning ("Render SPU: %s: %s", mesg, buffer); + + return 0; +} + +static int WindowExistsErrorHandler( Display *dpy, XErrorEvent *xerr ) { if (xerr->error_code == BadWindow) @@ -224,8 +238,13 @@ static int GetWindowVisualID( Display *dpy, Window w ) { XWindowAttributes attr; - int k = XGetWindowAttributes(dpy, w, &attr); - if (!k) + int (*oldXErrorHandler)(Display *, XErrorEvent *); + + WindowExistsFlag = GL_TRUE; + oldXErrorHandler = XSetErrorHandler(WindowExistsErrorHandler); + XGetWindowAttributes(dpy, w, &attr); + XSetErrorHandler(oldXErrorHandler); + if (!WindowExistsFlag) return -1; return attr.visual->visualid; } @@ -447,6 +466,8 @@ renderspu_SystemInitVisual( VisualInfo *visual ) return GL_FALSE; } + XSetErrorHandler(IgnoreErrorHandler); + if ( !render_spu.ws.glXQueryExtension( visual->dpy, NULL, NULL ) ) { crWarning( "Render SPU: Display %s doesn't support GLX", visual->displayName ); @@ -1061,40 +1082,37 @@ set_state(const struct saved_state *s) * Recreate the GLX context for ContextInfo. The new context will use the * visual specified by newVisualID. */ -static void -renderspu_RecreateContext( ContextInfo *context, int newVisualID ) +static GLXContext +renderspu_RecreateContext( ContextInfo *context, int newVisualID, XVisualInfo **vi ) { XVisualInfo templateVis, *vis; long templateFlags; int screen = 0, count; - GLXContext oldContext = context->context; + GLXContext newContext; templateFlags = VisualScreenMask | VisualIDMask; templateVis.screen = screen; templateVis.visualid = newVisualID; vis = XGetVisualInfo(context->visual->dpy, templateFlags, &templateVis, &count); - CRASSERT(vis); if (!vis) - return; + return None; /* create new context */ crDebug("Render SPU: Creating new GLX context with visual 0x%x", newVisualID); - context->context = render_spu.ws.glXCreateContext(context->visual->dpy, + newContext = render_spu.ws.glXCreateContext(context->visual->dpy, vis, NULL, render_spu.try_direct); - CRASSERT(context->context); + CRASSERT(newContext); #if USE_GLX_COPYCONTEXT /* copy old context state to new context */ render_spu.ws.glXCopyContext(context->visual->dpy, - oldContext, context->context, ~0); + context->context, newContext, ~0); crDebug("Render SPU: Done copying context state"); #endif - /* destroy old context */ - render_spu.ws.glXDestroyContext(context->visual->dpy, oldContext); - - context->visual->visual = vis; + *vi = vis; + return newContext; } @@ -1233,11 +1251,14 @@ renderspu_SystemMakeCurrent( WindowInfo *window, GLint nativeWindow, * Make sure the window ID is valid and that the window's X visual is * the same as the rendering context's. */ - if (WindowExists(window->visual->dpy, nativeWindow)) - { - int vid = GetWindowVisualID(window->visual->dpy, nativeWindow); - GLboolean recreated = GL_FALSE; + int vid = GetWindowVisualID(window->visual->dpy, nativeWindow); + GLXContext newContext = None; + XVisualInfo *vis = NULL; + if (vid >= 0) + { + int (*oldXErrorHandler)(Display *, XErrorEvent *); + /* check that the window's visual and context's visual match */ if (vid != (int) context->visual->visual->visualid) { crWarning("Render SPU: Can't bind context %d to CRUT/native window " @@ -1253,21 +1274,39 @@ renderspu_SystemMakeCurrent( WindowInfo *window, GLint nativeWindow, get_state(&SavedState); } #endif - renderspu_RecreateContext(context, vid); - recreated = GL_TRUE; + newContext = renderspu_RecreateContext(context, vid, &vis); } - /* OK, this should work */ + /* OK, this might work */ + window->nativeWindow = (Window) nativeWindow; + + WindowExistsFlag = GL_TRUE; + oldXErrorHandler = XSetErrorHandler(WindowExistsErrorHandler); window->nativeWindow = (Window) nativeWindow; b = render_spu.ws.glXMakeCurrent( window->visual->dpy, window->nativeWindow, - context->context ); - CRASSERT(b); + newContext ? newContext : context->context); + XSync(window->visual->dpy, False); + XSetErrorHandler(oldXErrorHandler); + if (!b || !WindowExistsFlag) + vid = -1; + } + + if(vid >= 0) + { + if (newContext) + { + /* destroy old context */ + render_spu.ws.glXDestroyContext(context->visual->dpy, context->context); + context->context = newContext; + context->visual->visual = vis; + #if !USE_GLX_COPYCONTEXT - if (recreated) { - set_state(&SavedState); - } + if (context->everCurrent) + set_state(&SavedState); #endif + + } } else { @@ -1279,6 +1318,12 @@ renderspu_SystemMakeCurrent( WindowInfo *window, GLint nativeWindow, b = render_spu.ws.glXMakeCurrent( window->visual->dpy, window->window, context->context ); CRASSERT(b); + + if (newContext) + { + /* destroy new context */ + render_spu.ws.glXDestroyContext(context->visual->dpy, newContext); + } } } else
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor