Bug 1427088 - Don't rely on glGetStringi just because it exists. - r=daoshengmu
MozReview-Commit-ID: Gmf6phqDOTK
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -1651,38 +1651,41 @@ GLContext::DebugCallback(GLenum source,
void
GLContext::InitExtensions()
{
MOZ_ASSERT(IsCurrent());
std::vector<nsCString> driverExtensionList;
- if (mSymbols.fGetStringi) {
- GLuint count = 0;
- GetUIntegerv(LOCAL_GL_NUM_EXTENSIONS, &count);
- for (GLuint i = 0; i < count; i++) {
- // This is UTF-8.
- const char* rawExt = (const char*)fGetStringi(LOCAL_GL_EXTENSIONS, i);
-
- // We CANNOT use nsDependentCString here, because the spec doesn't guarantee
- // that the pointers returned are different, only that their contents are.
- // On Flame, each of these index string queries returns the same address.
- driverExtensionList.push_back(nsCString(rawExt));
+ [&]() {
+ if (mSymbols.fGetStringi) {
+ GLuint count = 0;
+ if (GetPotentialInteger(LOCAL_GL_NUM_EXTENSIONS, (GLint*)&count)) {
+ for (GLuint i = 0; i < count; i++) {
+ // This is UTF-8.
+ const char* rawExt = (const char*)fGetStringi(LOCAL_GL_EXTENSIONS, i);
+
+ // We CANNOT use nsDependentCString here, because the spec doesn't guarantee
+ // that the pointers returned are different, only that their contents are.
+ // On Flame, each of these index string queries returns the same address.
+ driverExtensionList.push_back(nsCString(rawExt));
+ }
+ return;
+ }
}
- } else {
- MOZ_ALWAYS_TRUE(!fGetError());
+
const char* rawExts = (const char*)fGetString(LOCAL_GL_EXTENSIONS);
- MOZ_ALWAYS_TRUE(!fGetError());
-
if (rawExts) {
nsDependentCString exts(rawExts);
SplitByChar(exts, ' ', &driverExtensionList);
}
- }
+ }();
+ const auto err = fGetError();
+ MOZ_ASSERT(!err);
const bool shouldDumpExts = ShouldDumpExts();
if (shouldDumpExts) {
printf_stderr("%i GL driver extensions: (*: recognized)\n",
(uint32_t)driverExtensionList.size());
}
MarkBitfieldByStrings(driverExtensionList, shouldDumpExts, sExtensionNames,