--- a/gfx/gl/GLContextProviderGLX.cpp
+++ b/gfx/gl/GLContextProviderGLX.cpp
@@ -817,79 +817,79 @@ GLContextGLX::CreateGLContext(CreateCont
}
GLXContext context;
RefPtr<GLContextGLX> glContext;
bool error;
ScopedXErrorHandler xErrorHandler;
-TRY_AGAIN_NO_SHARING:
-
- error = false;
-
- GLXContext glxContext = shareContext ? shareContext->mContext : nullptr;
- if (glx.HasCreateContextAttribs()) {
- AutoTArray<int, 11> attrib_list;
- if (glx.HasRobustness()) {
- int robust_attribs[] = {
- LOCAL_GL_CONTEXT_FLAGS_ARB, LOCAL_GL_CONTEXT_ROBUST_ACCESS_BIT_ARB,
- LOCAL_GL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, LOCAL_GL_LOSE_CONTEXT_ON_RESET_ARB,
- };
- attrib_list.AppendElements(robust_attribs, MOZ_ARRAY_LENGTH(robust_attribs));
- }
- if (profile == ContextProfile::OpenGLCore) {
- int core_attribs[] = {
- LOCAL_GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
- LOCAL_GLX_CONTEXT_MINOR_VERSION_ARB, 2,
- LOCAL_GLX_CONTEXT_FLAGS_ARB, LOCAL_GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
- };
- attrib_list.AppendElements(core_attribs, MOZ_ARRAY_LENGTH(core_attribs));
- };
- attrib_list.AppendElement(0);
+ do {
+ error = false;
- context = glx.xCreateContextAttribs(
- display,
- cfg,
- glxContext,
- True,
- attrib_list.Elements());
- } else {
- context = glx.xCreateNewContext(
- display,
- cfg,
- LOCAL_GLX_RGBA_TYPE,
- glxContext,
- True);
- }
+ GLXContext glxContext = shareContext ? shareContext->mContext : nullptr;
+ if (glx.HasCreateContextAttribs()) {
+ AutoTArray<int, 11> attrib_list;
+ if (glx.HasRobustness()) {
+ int robust_attribs[] = {
+ LOCAL_GL_CONTEXT_FLAGS_ARB, LOCAL_GL_CONTEXT_ROBUST_ACCESS_BIT_ARB,
+ LOCAL_GL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, LOCAL_GL_LOSE_CONTEXT_ON_RESET_ARB,
+ };
+ attrib_list.AppendElements(robust_attribs, MOZ_ARRAY_LENGTH(robust_attribs));
+ }
+ if (profile == ContextProfile::OpenGLCore) {
+ int core_attribs[] = {
+ LOCAL_GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
+ LOCAL_GLX_CONTEXT_MINOR_VERSION_ARB, 2,
+ LOCAL_GLX_CONTEXT_FLAGS_ARB, LOCAL_GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
+ };
+ attrib_list.AppendElements(core_attribs, MOZ_ARRAY_LENGTH(core_attribs));
+ };
+ attrib_list.AppendElement(0);
- if (context) {
- glContext = new GLContextGLX(flags, caps, shareContext, isOffscreen, display,
- drawable, context, deleteDrawable, db, pixmap,
- profile);
- if (!glContext->Init())
- error = true;
- } else {
- error = true;
- }
-
- error |= xErrorHandler.SyncAndGetError(display);
-
- if (error) {
- if (shareContext) {
- shareContext = nullptr;
- goto TRY_AGAIN_NO_SHARING;
+ context = glx.xCreateContextAttribs(
+ display,
+ cfg,
+ glxContext,
+ True,
+ attrib_list.Elements());
+ } else {
+ context = glx.xCreateNewContext(
+ display,
+ cfg,
+ LOCAL_GLX_RGBA_TYPE,
+ glxContext,
+ True);
}
- NS_WARNING("Failed to create GLXContext!");
- glContext = nullptr; // note: this must be done while the graceful X error handler is set,
- // because glxMakeCurrent can give a GLXBadDrawable error
- }
+ if (context) {
+ glContext = new GLContextGLX(flags, caps, shareContext, isOffscreen, display,
+ drawable, context, deleteDrawable, db, pixmap,
+ profile);
+ if (!glContext->Init())
+ error = true;
+ } else {
+ error = true;
+ }
+
+ error |= xErrorHandler.SyncAndGetError(display);
- return glContext.forget();
+ if (error) {
+ if (shareContext) {
+ shareContext = nullptr;
+ continue;
+ }
+
+ NS_WARNING("Failed to create GLXContext!");
+ glContext = nullptr; // note: this must be done while the graceful X error handler is set,
+ // because glxMakeCurrent can give a GLXBadDrawable error
+ }
+
+ return glContext.forget();
+ } while (true);
}
GLContextGLX::~GLContextGLX()
{
MarkDestroyed();
// Wrapped context should not destroy glxContext/Surface
if (!mOwnsContext) {
@@ -1291,45 +1291,43 @@ CreateOffscreenPixmapContext(CreateConte
}
Visual* visual;
int depth;
FindVisualAndDepth(display, visid, &visual, &depth);
ScopedXErrorHandler xErrorHandler;
bool error = false;
- // Must be declared before goto:
+
Drawable drawable;
- GLXPixmap pixmap;
+ GLXPixmap pixmap = 0;
gfx::IntSize dummySize(16, 16);
RefPtr<gfxXlibSurface> surface = gfxXlibSurface::Create(DefaultScreenOfDisplay(display),
visual,
dummySize);
if (surface->CairoStatus() != 0) {
- error = true;
- goto DONE_CREATING_PIXMAP;
+ mozilla::Unused << xErrorHandler.SyncAndGetError(display);
+ return nullptr;
}
// Handle slightly different signature between glXCreatePixmap and
// its pre-GLX-1.3 extension equivalent (though given the ABI, we
// might not need to).
drawable = surface->XDrawable();
if (glx->GLXVersionCheck(1, 3)) {
pixmap = glx->xCreatePixmap(display, config, drawable, nullptr);
} else {
pixmap = glx->xCreateGLXPixmapWithConfig(display, config, drawable);
}
if (pixmap == 0) {
error = true;
}
-DONE_CREATING_PIXMAP:
-
bool serverError = xErrorHandler.SyncAndGetError(display);
if (error || serverError)
return nullptr;
GLContextGLX* shareContext = GetGlobalContextGLX();
return GLContextGLX::CreateGLContext(flags, minCaps, shareContext, true, display,
pixmap, config, true, surface, profile);
}