hw/xwin/glx: Better handling of SetPixelFormat() failure

Propagate and report the failure if SetPixelFormat() fails

Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
This commit is contained in:
Jon TURNEY 2010-10-30 17:23:52 +01:00
parent eecc8e06eb
commit 8216316867

View File

@ -987,7 +987,7 @@ int glxWinReleaseTexImage(__GLXcontext *baseContext,
* lists with the old one... * lists with the old one...
*/ */
static void static Bool
glxWinSetPixelFormat(__GLXWinContext *gc, HDC hdc, int bppOverride, int drawableTypeOverride) glxWinSetPixelFormat(__GLXWinContext *gc, HDC hdc, int bppOverride, int drawableTypeOverride)
{ {
__GLXscreen *screen = gc->base.pGlxScreen; __GLXscreen *screen = gc->base.pGlxScreen;
@ -1009,10 +1009,10 @@ glxWinSetPixelFormat(__GLXWinContext *gc, HDC hdc, int bppOverride, int drawable
if (!SetPixelFormat(hdc, winConfig->pixelFormatIndex, NULL)) if (!SetPixelFormat(hdc, winConfig->pixelFormatIndex, NULL))
{ {
ErrorF("SetPixelFormat error: %s\n", glxWinErrorMessage()); ErrorF("SetPixelFormat error: %s\n", glxWinErrorMessage());
return; return FALSE;
} }
return; return TRUE;
} }
/* /*
@ -1044,7 +1044,7 @@ glxWinSetPixelFormat(__GLXWinContext *gc, HDC hdc, int bppOverride, int drawable
if (fbConfigToPixelFormat(gc->base.config, &pfd, drawableTypeOverride)) if (fbConfigToPixelFormat(gc->base.config, &pfd, drawableTypeOverride))
{ {
ErrorF("glxWinSetPixelFormat: fbConfigToPixelFormat failed\n"); ErrorF("glxWinSetPixelFormat: fbConfigToPixelFormat failed\n");
return; return FALSE;
} }
if (glxWinDebugSettings.dumpPFD) if (glxWinDebugSettings.dumpPFD)
@ -1060,7 +1060,7 @@ glxWinSetPixelFormat(__GLXWinContext *gc, HDC hdc, int bppOverride, int drawable
if (pixelFormat == 0) if (pixelFormat == 0)
{ {
ErrorF("ChoosePixelFormat error: %s\n", glxWinErrorMessage()); ErrorF("ChoosePixelFormat error: %s\n", glxWinErrorMessage());
return; return FALSE;
} }
GLWIN_DEBUG_MSG("ChoosePixelFormat: chose pixelFormatIndex %d", pixelFormat); GLWIN_DEBUG_MSG("ChoosePixelFormat: chose pixelFormatIndex %d", pixelFormat);
@ -1069,7 +1069,7 @@ glxWinSetPixelFormat(__GLXWinContext *gc, HDC hdc, int bppOverride, int drawable
if (!SetPixelFormat(hdc, pixelFormat, &pfd)) if (!SetPixelFormat(hdc, pixelFormat, &pfd))
{ {
ErrorF("SetPixelFormat error: %s\n", glxWinErrorMessage()); ErrorF("SetPixelFormat error: %s\n", glxWinErrorMessage());
return; return FALSE;
} }
} }
else else
@ -1078,7 +1078,7 @@ glxWinSetPixelFormat(__GLXWinContext *gc, HDC hdc, int bppOverride, int drawable
if (pixelFormat == 0) if (pixelFormat == 0)
{ {
ErrorF("wglChoosePixelFormat error: %s\n", glxWinErrorMessage()); ErrorF("wglChoosePixelFormat error: %s\n", glxWinErrorMessage());
return; return FALSE;
} }
GLWIN_DEBUG_MSG("wglChoosePixelFormat: chose pixelFormatIndex %d", pixelFormat); GLWIN_DEBUG_MSG("wglChoosePixelFormat: chose pixelFormatIndex %d", pixelFormat);
@ -1087,9 +1087,11 @@ glxWinSetPixelFormat(__GLXWinContext *gc, HDC hdc, int bppOverride, int drawable
if (!SetPixelFormat(hdc, pixelFormat, NULL)) if (!SetPixelFormat(hdc, pixelFormat, NULL))
{ {
ErrorF("SetPixelFormat error: %s\n", glxWinErrorMessage()); ErrorF("SetPixelFormat error: %s\n", glxWinErrorMessage());
return; return FALSE;
} }
} }
return TRUE;
} }
static HDC static HDC
@ -1140,7 +1142,13 @@ glxWinMakeDC(__GLXWinContext *gc, __GLXWinDrawable *draw, HDC *hdc, HWND *hwnd)
gc->hwnd = *hwnd; gc->hwnd = *hwnd;
/* We must select a pixelformat, but SetPixelFormat can only be called once for a window... */ /* We must select a pixelformat, but SetPixelFormat can only be called once for a window... */
glxWinSetPixelFormat(gc, *hdc, 0, GLX_WINDOW_BIT); if (!glxWinSetPixelFormat(gc, *hdc, 0, GLX_WINDOW_BIT))
{
ErrorF("glxWinSetPixelFormat error: %s\n", glxWinErrorMessage());
ReleaseDC(*hwnd, *hdc);
*hdc = NULL;
return NULL;
}
} }
} }
break; break;