Bug 1297315 - Fix Wmaybe-uninitialized warning and get rid of goto statement in GLContextProviderGLX.cpp and GfxTexturesReporter.cpp. r=jgilbert

MozReview-Commit-ID: AUjK7HhatX6

--HG--
extra : rebase_source : 3df07981fdd0f7cff9576cff8fecf955522294bf
This commit is contained in:
James Cheng 2016-08-23 14:30:37 +08:00
Родитель 8f72f1ce87
Коммит 19a28705ea
2 изменённых файлов: 62 добавлений и 61 удалений

Просмотреть файл

@ -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<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,
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.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<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
@ -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;

Просмотреть файл

@ -47,6 +47,9 @@ FormatBytes(size_t amount)
case 3:
unit = "GB";
break;
default:
unit = "";
break;
}
stream << val << " " << unit;