diff --git a/gfx/gl/GLContextProviderGLX.cpp b/gfx/gl/GLContextProviderGLX.cpp index 5204454e2b63..638e55aaedf8 100644 --- a/gfx/gl/GLContextProviderGLX.cpp +++ b/gfx/gl/GLContextProviderGLX.cpp @@ -822,69 +822,69 @@ GLContextGLX::CreateGLContext(CreateContextFlags flags, const SurfaceCaps& caps, ScopedXErrorHandler xErrorHandler; -TRY_AGAIN_NO_SHARING: + do { + error = false; - error = false; - - GLXContext glxContext = shareContext ? shareContext->mContext : nullptr; - if (glx.HasCreateContextAttribs()) { - AutoTArray 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, + GLXContext glxContext = shareContext ? shareContext->mContext : nullptr; + if (glx.HasCreateContextAttribs()) { + AutoTArray 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.AppendElements(robust_attribs, MOZ_ARRAY_LENGTH(robust_attribs)); + attrib_list.AppendElement(0); + + context = glx.xCreateContextAttribs( + display, + cfg, + glxContext, + True, + attrib_list.Elements()); + } else { + context = glx.xCreateNewContext( + display, + cfg, + LOCAL_GLX_RGBA_TYPE, + glxContext, + True); } - 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); - context = glx.xCreateContextAttribs( - display, - cfg, - glxContext, - True, - attrib_list.Elements()); - } else { - context = glx.xCreateNewContext( - display, - cfg, - LOCAL_GLX_RGBA_TYPE, - glxContext, - True); - } - - if (context) { - glContext = new GLContextGLX(flags, caps, shareContext, isOffscreen, display, - drawable, context, deleteDrawable, db, pixmap, - profile); - if (!glContext->Init()) + if (context) { + glContext = new GLContextGLX(flags, caps, shareContext, isOffscreen, display, + drawable, context, deleteDrawable, db, pixmap, + profile); + if (!glContext->Init()) + error = true; + } else { error = true; - } else { - error = true; - } - - error |= xErrorHandler.SyncAndGetError(display); - - if (error) { - if (shareContext) { - shareContext = nullptr; - goto TRY_AGAIN_NO_SHARING; } - 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 - } + 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() @@ -1296,17 +1296,17 @@ CreateOffscreenPixmapContext(CreateContextFlags flags, const IntSize& size, ScopedXErrorHandler xErrorHandler; bool error = false; - // Must be declared before goto: + Drawable drawable; - GLXPixmap pixmap; + GLXPixmap pixmap = 0; gfx::IntSize dummySize(16, 16); RefPtr 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 @@ -1323,8 +1323,6 @@ CreateOffscreenPixmapContext(CreateContextFlags flags, const IntSize& size, error = true; } -DONE_CREATING_PIXMAP: - bool serverError = xErrorHandler.SyncAndGetError(display); if (error || serverError) return nullptr; diff --git a/gfx/gl/GfxTexturesReporter.cpp b/gfx/gl/GfxTexturesReporter.cpp index bf63a05589a7..8007fe6b130a 100644 --- a/gfx/gl/GfxTexturesReporter.cpp +++ b/gfx/gl/GfxTexturesReporter.cpp @@ -47,6 +47,9 @@ FormatBytes(size_t amount) case 3: unit = "GB"; break; + default: + unit = ""; + break; } stream << val << " " << unit;