Bug 1344433 - Reformat. - r=daoshengmu draft
authorJeff Gilbert <jgilbert@mozilla.com>
Fri, 03 Mar 2017 16:49:49 -0800
changeset 493549 99dce8a6e34bddee7b330404649832cf7d735d09
parent 493548 9ea84c5270ce98b0905c40bb5511bc29e56e28d3
child 493550 f29fb486aefaf2e0832f37acfc7b935f57a6919b
push id47799
push userbmo:jgilbert@mozilla.com
push dateSat, 04 Mar 2017 22:02:43 +0000
reviewersdaoshengmu
bugs1344433
milestone54.0a1
Bug 1344433 - Reformat. - r=daoshengmu MozReview-Commit-ID: 8W0oGeHBYtR
gfx/gl/GLContextProviderCGL.mm
gfx/gl/GLContextProviderEGL.cpp
gfx/gl/GLContextProviderGLX.cpp
gfx/gl/GLContextProviderWGL.cpp
gfx/gl/GLLibraryEGL.cpp
gfx/gl/GLLibraryEGL.h
gfx/gl/GLLibraryLoader.cpp
gfx/gl/GLLibraryLoader.h
gfx/gl/GLXLibrary.h
gfx/gl/SharedSurfaceD3D11Interop.cpp
gfx/gl/WGLLibrary.h
--- a/gfx/gl/GLContextProviderCGL.mm
+++ b/gfx/gl/GLContextProviderCGL.mm
@@ -89,17 +89,16 @@ GLContextCGL::~GLContextCGL()
         if ([NSOpenGLContext currentContext] == mContext) {
             // Clear the current context before releasing. If we don't do
             // this, the next time we call [NSOpenGLContext currentContext],
             // "invalid context" will be printed to the console.
             [NSOpenGLContext clearCurrentContext];
         }
         [mContext release];
     }
-
 }
 
 bool
 GLContextCGL::Init()
 {
     if (!InitWithPrefix("gl", true))
         return false;
 
--- a/gfx/gl/GLContextProviderEGL.cpp
+++ b/gfx/gl/GLContextProviderEGL.cpp
@@ -417,17 +417,17 @@ GLContextEGL::ReleaseSurface() {
         mSurfaceOverride = EGL_NO_SURFACE;
     }
     mSurface = EGL_NO_SURFACE;
 }
 
 bool
 GLContextEGL::SetupLookupFunction()
 {
-    mLookupFunc = (PlatformLookupFunction)sEGLLibrary.mSymbols.fGetProcAddress;
+    mLookupFunc = sEGLLibrary.GetLookupFunction();
     return true;
 }
 
 bool
 GLContextEGL::SwapBuffers()
 {
     EGLSurface surface = mSurfaceOverride != EGL_NO_SURFACE
                           ? mSurfaceOverride
--- a/gfx/gl/GLContextProviderGLX.cpp
+++ b/gfx/gl/GLContextProviderGLX.cpp
@@ -94,66 +94,69 @@ GLXLibrary::EnsureInitialized()
         }
         reporter.SetSuccessful();
     }
 
     if (gfxEnv::GlxDebug()) {
         mDebug = true;
     }
 
-    GLLibraryLoader::SymLoadStruct symbols[] = {
+#define SYMBOL(X) { (PRFuncPtr*)&mSymbols.f##X, { "glX" #X, nullptr } }
+#define END_OF_SYMBOLS { nullptr, { nullptr } }
+
+    const GLLibraryLoader::SymLoadStruct symbols[] = {
         /* functions that were in GLX 1.0 */
-        { (PRFuncPtr*) &xDestroyContextInternal, { "glXDestroyContext", nullptr } },
-        { (PRFuncPtr*) &xMakeCurrentInternal, { "glXMakeCurrent", nullptr } },
-        { (PRFuncPtr*) &xSwapBuffersInternal, { "glXSwapBuffers", nullptr } },
-        { (PRFuncPtr*) &xQueryVersionInternal, { "glXQueryVersion", nullptr } },
-        { (PRFuncPtr*) &xGetCurrentContextInternal, { "glXGetCurrentContext", nullptr } },
-        { (PRFuncPtr*) &xWaitGLInternal, { "glXWaitGL", nullptr } },
-        { (PRFuncPtr*) &xWaitXInternal, { "glXWaitX", nullptr } },
+        SYMBOL(DestroyContext),
+        SYMBOL(MakeCurrent),
+        SYMBOL(SwapBuffers),
+        SYMBOL(QueryVersion),
+        SYMBOL(GetCurrentContext),
+        SYMBOL(WaitGL),
+        SYMBOL(WaitX),
         /* functions introduced in GLX 1.1 */
-        { (PRFuncPtr*) &xQueryExtensionsStringInternal, { "glXQueryExtensionsString", nullptr } },
-        { (PRFuncPtr*) &xGetClientStringInternal, { "glXGetClientString", nullptr } },
-        { (PRFuncPtr*) &xQueryServerStringInternal, { "glXQueryServerString", nullptr } },
+        SYMBOL(QueryExtensionsString),
+        SYMBOL(GetClientString),
+        SYMBOL(QueryServerString),
         /* functions introduced in GLX 1.3 */
-        { (PRFuncPtr*) &xChooseFBConfigInternal, { "glXChooseFBConfig", nullptr } },
-        { (PRFuncPtr*) &xGetFBConfigAttribInternal, { "glXGetFBConfigAttrib", nullptr } },
+        SYMBOL(ChooseFBConfig),
+        SYMBOL(GetFBConfigAttrib),
         // WARNING: xGetFBConfigs not set in symbols13_ext
-        { (PRFuncPtr*) &xGetFBConfigsInternal, { "glXGetFBConfigs", nullptr } },
+        SYMBOL(GetFBConfigs),
         // WARNING: symbols13_ext sets xCreateGLXPixmapWithConfig instead
-        { (PRFuncPtr*) &xCreatePixmapInternal, { "glXCreatePixmap", nullptr } },
-        { (PRFuncPtr*) &xDestroyPixmapInternal, { "glXDestroyPixmap", nullptr } },
-        { (PRFuncPtr*) &xCreateNewContextInternal, { "glXCreateNewContext", nullptr } },
+        SYMBOL(CreatePixmap),
+        SYMBOL(DestroyPixmap),
+        SYMBOL(CreateNewContext),
         /* functions introduced in GLX 1.4 */
-        { (PRFuncPtr*) &xGetProcAddressInternal, { "glXGetProcAddress", nullptr } },
-        { nullptr, { nullptr } }
+        SYMBOL(GetProcAddress),
+        END_OF_SYMBOLS
     };
 
-    GLLibraryLoader::SymLoadStruct symbols_texturefrompixmap[] = {
-        { (PRFuncPtr*) &xBindTexImageInternal, { "glXBindTexImageEXT", nullptr } },
-        { (PRFuncPtr*) &xReleaseTexImageInternal, { "glXReleaseTexImageEXT", nullptr } },
-        { nullptr, { nullptr } }
+    const GLLibraryLoader::SymLoadStruct symbols_texturefrompixmap[] = {
+        SYMBOL(BindTexImageEXT),
+        SYMBOL(ReleaseTexImageEXT),
+        END_OF_SYMBOLS
     };
 
-    GLLibraryLoader::SymLoadStruct symbols_createcontext[] = {
-        { (PRFuncPtr*) &xCreateContextAttribsInternal, { "glXCreateContextAttribsARB", nullptr } },
-        { nullptr, { nullptr } }
+    const GLLibraryLoader::SymLoadStruct symbols_createcontext[] = {
+        SYMBOL(CreateContextAttribsARB),
+        END_OF_SYMBOLS
     };
 
-    GLLibraryLoader::SymLoadStruct symbols_videosync[] = {
-      { (PRFuncPtr*) &xGetVideoSyncInternal, { "glXGetVideoSyncSGI", nullptr } },
-      { (PRFuncPtr*) &xWaitVideoSyncInternal, { "glXWaitVideoSyncSGI", nullptr } },
-      { nullptr, { nullptr } }
+    const GLLibraryLoader::SymLoadStruct symbols_videosync[] = {
+        SYMBOL(GetVideoSyncSGI),
+        SYMBOL(WaitVideoSyncSGI),
+        END_OF_SYMBOLS
     };
 
-    GLLibraryLoader::SymLoadStruct symbols_swapcontrol[] = {
-      { (PRFuncPtr*) &xSwapIntervalInternal, { "glXSwapIntervalEXT", nullptr } },
-      { nullptr, { nullptr } }
+    const GLLibraryLoader::SymLoadStruct symbols_swapcontrol[] = {
+        SYMBOL(SwapIntervalEXT),
+        END_OF_SYMBOLS
     };
 
-    if (!GLLibraryLoader::LoadSymbols(mOGLLibrary, &symbols[0])) {
+    if (!GLLibraryLoader::LoadSymbols(mOGLLibrary, symbols)) {
         NS_WARNING("Couldn't find required entry point in OpenGL shared library");
         return false;
     }
 
     Display* display = DefaultXDisplay();
     int screen = DefaultScreen(display);
 
     {
@@ -161,52 +164,59 @@ GLXLibrary::EnsureInitialized()
         if (!xQueryVersion(display, &major, &minor) ||
             major != 1 || minor < 4)
         {
             NS_ERROR("GLX version older than 1.4. (released in 2005)");
             return false;
         }
     }
 
+    const auto lookupFunction =
+        (GLLibraryLoader::PlatformLookupFunction)mSymbols.fGetProcAddress;
+
+    const auto fnLoadSymbols = [&](const GLLibraryLoader::SymLoadStruct* symbols) {
+        if (GLLibraryLoader::LoadSymbols(mOGLLibrary, symbols, lookupFunction))
+            return true;
+
+        GLLibraryLoader::ClearSymbols(symbols);
+        return false;
+    };
+
     const char* clientVendor = xGetClientString(display, LOCAL_GLX_VENDOR);
     const char* serverVendor = xQueryServerString(display, screen, LOCAL_GLX_VENDOR);
     const char* extensionsStr = xQueryExtensionsString(display, screen);
 
     if (HasExtension(extensionsStr, "GLX_EXT_texture_from_pixmap") &&
-        GLLibraryLoader::LoadSymbols(mOGLLibrary, symbols_texturefrompixmap,
-                                         (GLLibraryLoader::PlatformLookupFunction)&xGetProcAddress))
+        fnLoadSymbols(symbols_texturefrompixmap))
     {
         mUseTextureFromPixmap = gfxPrefs::UseGLXTextureFromPixmap();
     } else {
         mUseTextureFromPixmap = false;
         NS_WARNING("Texture from pixmap disabled");
     }
 
     if (HasExtension(extensionsStr, "GLX_ARB_create_context") &&
         HasExtension(extensionsStr, "GLX_ARB_create_context_profile") &&
-        GLLibraryLoader::LoadSymbols(mOGLLibrary, symbols_createcontext,
-                                     (GLLibraryLoader::PlatformLookupFunction)&xGetProcAddress))
+        fnLoadSymbols(symbols_createcontext))
     {
         mHasCreateContextAttribs = true;
     }
 
-    if (HasExtension(extensionsStr, "GLX_ARB_create_context_robustness"))
-    {
+    if (HasExtension(extensionsStr, "GLX_ARB_create_context_robustness")) {
         mHasRobustness = true;
     }
 
     if (HasExtension(extensionsStr, "GLX_SGI_video_sync") &&
-        GLLibraryLoader::LoadSymbols(mOGLLibrary, symbols_videosync,
-                                     (GLLibraryLoader::PlatformLookupFunction)&xGetProcAddress))
+        fnLoadSymbols(symbols_videosync))
     {
         mHasVideoSync = true;
     }
 
-    if (!(HasExtension(extensionsStr, "GLX_EXT_swap_control") &&
-          GLLibraryLoader::LoadSymbols(mOGLLibrary, symbols_swapcontrol)))
+    if (!HasExtension(extensionsStr, "GLX_EXT_swap_control") ||
+        !fnLoadSymbols(symbols_swapcontrol))
     {
         NS_WARNING("GLX_swap_control unsupported, ASAP mode may still block on buffer swaps.");
     }
 
     mIsATI = serverVendor && DoesStringMatch(serverVendor, "ATI");
     mIsNVIDIA = serverVendor && DoesStringMatch(serverVendor, "NVIDIA Corporation");
     mClientIsMesa = clientVendor && DoesStringMatch(clientVendor, "Mesa");
 
@@ -484,258 +494,244 @@ GLXLibrary::AfterGLXCall()
 #define AFTER_GLX_CALL do { } while(0)
 
 #endif
 
 void
 GLXLibrary::xDestroyContext(Display* display, GLXContext context)
 {
     BEFORE_GLX_CALL;
-    xDestroyContextInternal(display, context);
+    mSymbols.fDestroyContext(display, context);
     AFTER_GLX_CALL;
 }
 
 Bool
 GLXLibrary::xMakeCurrent(Display* display,
                          GLXDrawable drawable,
                          GLXContext context)
 {
     BEFORE_GLX_CALL;
-    Bool result = xMakeCurrentInternal(display, drawable, context);
+    const auto result = mSymbols.fMakeCurrent(display, drawable, context);
     AFTER_GLX_CALL;
     return result;
 }
 
 GLXContext
 GLXLibrary::xGetCurrentContext()
 {
     BEFORE_GLX_CALL;
-    GLXContext result = xGetCurrentContextInternal();
-    AFTER_GLX_CALL;
-    return result;
-}
-
-/* static */ void*
-GLXLibrary::xGetProcAddress(const char* procName)
-{
-    BEFORE_GLX_CALL;
-    void* result = sGLXLibrary.xGetProcAddressInternal(procName);
+    const auto result = mSymbols.fGetCurrentContext();
     AFTER_GLX_CALL;
     return result;
 }
 
 GLXFBConfig*
 GLXLibrary::xChooseFBConfig(Display* display,
                             int screen,
                             const int* attrib_list,
                             int* nelements)
 {
     BEFORE_GLX_CALL;
-    GLXFBConfig* result = xChooseFBConfigInternal(display, screen, attrib_list, nelements);
+    const auto result = mSymbols.fChooseFBConfig(display, screen, attrib_list, nelements);
     AFTER_GLX_CALL;
     return result;
 }
 
 GLXFBConfig*
 GLXLibrary::xGetFBConfigs(Display* display,
                           int screen,
                           int* nelements)
 {
     BEFORE_GLX_CALL;
-    GLXFBConfig* result = xGetFBConfigsInternal(display, screen, nelements);
+    const auto result = mSymbols.fGetFBConfigs(display, screen, nelements);
     AFTER_GLX_CALL;
     return result;
 }
 
 GLXContext
 GLXLibrary::xCreateNewContext(Display* display,
                               GLXFBConfig config,
                               int render_type,
                               GLXContext share_list,
                               Bool direct)
 {
     BEFORE_GLX_CALL;
-    GLXContext result = xCreateNewContextInternal(display, config,
-                                                  render_type,
-                                                  share_list, direct);
+    const auto result = mSymbols.fCreateNewContext(display, config, render_type,
+                                                   share_list, direct);
     AFTER_GLX_CALL;
     return result;
 }
 
 int
 GLXLibrary::xGetFBConfigAttrib(Display* display,
                                GLXFBConfig config,
                                int attribute,
                                int* value)
 {
     BEFORE_GLX_CALL;
-    int result = xGetFBConfigAttribInternal(display, config,
-                                            attribute, value);
+    const auto result = mSymbols.fGetFBConfigAttrib(display, config, attribute, value);
     AFTER_GLX_CALL;
     return result;
 }
 
 void
 GLXLibrary::xSwapBuffers(Display* display, GLXDrawable drawable)
 {
     BEFORE_GLX_CALL;
-    xSwapBuffersInternal(display, drawable);
+    mSymbols.fSwapBuffers(display, drawable);
     AFTER_GLX_CALL;
 }
 
 const char*
 GLXLibrary::xQueryExtensionsString(Display* display,
                                    int screen)
 {
     BEFORE_GLX_CALL;
-    const char* result = xQueryExtensionsStringInternal(display, screen);
+    const auto result = mSymbols.fQueryExtensionsString(display, screen);
     AFTER_GLX_CALL;
     return result;
 }
 
 const char*
 GLXLibrary::xGetClientString(Display* display,
                              int screen)
 {
     BEFORE_GLX_CALL;
-    const char* result = xGetClientStringInternal(display, screen);
+    const auto result = mSymbols.fGetClientString(display, screen);
     AFTER_GLX_CALL;
     return result;
 }
 
 const char*
 GLXLibrary::xQueryServerString(Display* display,
                                int screen, int name)
 {
     BEFORE_GLX_CALL;
-    const char* result = xQueryServerStringInternal(display, screen, name);
+    const auto result = mSymbols.fQueryServerString(display, screen, name);
     AFTER_GLX_CALL;
     return result;
 }
 
 GLXPixmap
 GLXLibrary::xCreatePixmap(Display* display,
                           GLXFBConfig config,
                           Pixmap pixmap,
                           const int* attrib_list)
 {
     BEFORE_GLX_CALL;
-    GLXPixmap result = xCreatePixmapInternal(display, config,
+    const auto result = mSymbols.fCreatePixmap(display, config,
                                              pixmap, attrib_list);
     AFTER_GLX_CALL;
     return result;
 }
 
 GLXPixmap
 GLXLibrary::xCreateGLXPixmapWithConfig(Display* display,
                                        GLXFBConfig config,
                                        Pixmap pixmap)
 {
     BEFORE_GLX_CALL;
-    GLXPixmap result = xCreateGLXPixmapWithConfigInternal(display, config, pixmap);
+    const auto result = mSymbols.fCreateGLXPixmapWithConfig(display, config, pixmap);
     AFTER_GLX_CALL;
     return result;
 }
 
 void
 GLXLibrary::xDestroyPixmap(Display* display, GLXPixmap pixmap)
 {
     BEFORE_GLX_CALL;
-    xDestroyPixmapInternal(display, pixmap);
+    mSymbols.fDestroyPixmap(display, pixmap);
     AFTER_GLX_CALL;
 }
 
 Bool
 GLXLibrary::xQueryVersion(Display* display,
                           int* major,
                           int* minor)
 {
     BEFORE_GLX_CALL;
-    Bool result = xQueryVersionInternal(display, major, minor);
+    const auto result = mSymbols.fQueryVersion(display, major, minor);
     AFTER_GLX_CALL;
     return result;
 }
 
 void
 GLXLibrary::xBindTexImage(Display* display,
                           GLXDrawable drawable,
                           int buffer,
                           const int* attrib_list)
 {
     BEFORE_GLX_CALL;
-    xBindTexImageInternal(display, drawable, buffer, attrib_list);
+    mSymbols.fBindTexImageEXT(display, drawable, buffer, attrib_list);
     AFTER_GLX_CALL;
 }
 
 void
 GLXLibrary::xReleaseTexImage(Display* display,
                              GLXDrawable drawable,
                              int buffer)
 {
     BEFORE_GLX_CALL;
-    xReleaseTexImageInternal(display, drawable, buffer);
+    mSymbols.fReleaseTexImageEXT(display, drawable, buffer);
     AFTER_GLX_CALL;
 }
 
 void
 GLXLibrary::xWaitGL()
 {
     BEFORE_GLX_CALL;
-    xWaitGLInternal();
+    mSymbols.fWaitGL();
     AFTER_GLX_CALL;
 }
 
 void
 GLXLibrary::xWaitX()
 {
     BEFORE_GLX_CALL;
-    xWaitXInternal();
+    mSymbols.fWaitX();
     AFTER_GLX_CALL;
 }
 
 GLXContext
 GLXLibrary::xCreateContextAttribs(Display* display,
                                   GLXFBConfig config,
                                   GLXContext share_list,
                                   Bool direct,
                                   const int* attrib_list)
 {
     BEFORE_GLX_CALL;
-    GLXContext result = xCreateContextAttribsInternal(display,
-                                                      config,
-                                                      share_list,
-                                                      direct,
-                                                      attrib_list);
+    const auto result = mSymbols.fCreateContextAttribsARB(display, config, share_list,
+                                                          direct, attrib_list);
     AFTER_GLX_CALL;
     return result;
 }
 
 int
 GLXLibrary::xGetVideoSync(unsigned int* count)
 {
     BEFORE_GLX_CALL;
-    int result = xGetVideoSyncInternal(count);
+    const auto result = mSymbols.fGetVideoSyncSGI(count);
     AFTER_GLX_CALL;
     return result;
 }
 
 int
 GLXLibrary::xWaitVideoSync(int divisor, int remainder, unsigned int* count)
 {
     BEFORE_GLX_CALL;
-    int result = xWaitVideoSyncInternal(divisor, remainder, count);
+    const auto result = mSymbols.fWaitVideoSyncSGI(divisor, remainder, count);
     AFTER_GLX_CALL;
     return result;
 }
 
 void
 GLXLibrary::xSwapInterval(Display* display, GLXDrawable drawable, int interval)
 {
     BEFORE_GLX_CALL;
-    xSwapIntervalInternal(display, drawable, interval);
+    mSymbols.fSwapIntervalEXT(display, drawable, interval);
     AFTER_GLX_CALL;
 }
 
 already_AddRefed<GLContextGLX>
 GLContextGLX::CreateGLContext(CreateContextFlags flags, const SurfaceCaps& caps,
                               GLContextGLX* shareContext, bool isOffscreen,
                               Display* display, GLXDrawable drawable, GLXFBConfig cfg,
                               bool deleteDrawable, gfxXlibSurface* pixmap,
@@ -901,17 +897,17 @@ GLContextGLX::MakeCurrentImpl(bool aForc
 bool
 GLContextGLX::IsCurrent() {
     return mGLX->xGetCurrentContext() == mContext;
 }
 
 bool
 GLContextGLX::SetupLookupFunction()
 {
-    mLookupFunc = (PlatformLookupFunction)&GLXLibrary::xGetProcAddress;
+    mLookupFunc = (PlatformLookupFunction)sGLXLibrary.GetGetProcAddress();
     return true;
 }
 
 bool
 GLContextGLX::IsDoubleBuffered() const
 {
     return mDoubleBuffered;
 }
--- a/gfx/gl/GLContextProviderWGL.cpp
+++ b/gfx/gl/GLContextProviderWGL.cpp
@@ -114,166 +114,165 @@ WGLLibrary::EnsureInitialized()
     if (!mOGLLibrary) {
         mOGLLibrary = PR_LoadLibrary(libGLFilename.c_str());
         if (!mOGLLibrary) {
             NS_WARNING("Couldn't load OpenGL library.");
             return false;
         }
     }
 
+#define SYMBOL(X) { (PRFuncPtr*)&mSymbols.f##X, { "wgl" #X, nullptr } }
+#define END_OF_SYMBOLS { nullptr, { nullptr } }
+
     const GLLibraryLoader::SymLoadStruct earlySymbols[] = {
-        { (PRFuncPtr*) &fCreateContext, { "wglCreateContext", nullptr } },
-        { (PRFuncPtr*) &fMakeCurrent, { "wglMakeCurrent", nullptr } },
-        { (PRFuncPtr*) &fGetProcAddress, { "wglGetProcAddress", nullptr } },
-        { (PRFuncPtr*) &fDeleteContext, { "wglDeleteContext", nullptr } },
-        { (PRFuncPtr*) &fGetCurrentContext, { "wglGetCurrentContext", nullptr } },
-        { (PRFuncPtr*) &fGetCurrentDC, { "wglGetCurrentDC", nullptr } },
-        { nullptr, { nullptr } }
+        SYMBOL(CreateContext),
+        SYMBOL(MakeCurrent),
+        SYMBOL(GetProcAddress),
+        SYMBOL(DeleteContext),
+        SYMBOL(GetCurrentContext),
+        SYMBOL(GetCurrentDC),
+        END_OF_SYMBOLS
     };
 
     if (!GLLibraryLoader::LoadSymbols(mOGLLibrary, &earlySymbols[0])) {
         NS_WARNING("Couldn't find required entry points in OpenGL DLL (early init)");
         return false;
     }
 
     // This is ridiculous -- we have to actually create a context to
     // get the OpenGL ICD to load.
     mWindow = CreateDummyWindow(&mWindowDC);
     NS_ENSURE_TRUE(mWindow, false);
 
     // create rendering context
-    mWindowGLContext = fCreateContext(mWindowDC);
+    mWindowGLContext = mSymbols.fCreateContext(mWindowDC);
     NS_ENSURE_TRUE(mWindowGLContext, false);
 
-    if (!fMakeCurrent(mWindowDC, mWindowGLContext)) {
+    if (!mSymbols.fMakeCurrent(mWindowDC, mWindowGLContext)) {
         NS_WARNING("wglMakeCurrent failed");
         return false;
     }
 
-    const auto curCtx = fGetCurrentContext();
-    const auto curDC = fGetCurrentDC();
+    const auto& curCtx = mSymbols.fGetCurrentContext();
+    const auto& curDC = mSymbols.fGetCurrentDC();
 
-    const auto lookupFunc = (GLLibraryLoader::PlatformLookupFunction)fGetProcAddress;
+    const auto& lookupFunc = (GLLibraryLoader::PlatformLookupFunction)mSymbols.fGetProcAddress;
 
     // Now we can grab all the other symbols that we couldn't without having
     // a context current.
     const GLLibraryLoader::SymLoadStruct pbufferSymbols[] = {
-        { (PRFuncPtr*) &fCreatePbuffer, { "wglCreatePbufferARB", "wglCreatePbufferEXT", nullptr } },
-        { (PRFuncPtr*) &fDestroyPbuffer, { "wglDestroyPbufferARB", "wglDestroyPbufferEXT", nullptr } },
-        { (PRFuncPtr*) &fGetPbufferDC, { "wglGetPbufferDCARB", "wglGetPbufferDCEXT", nullptr } },
-        { (PRFuncPtr*) &fBindTexImage, { "wglBindTexImageARB", "wglBindTexImageEXT", nullptr } },
-        { (PRFuncPtr*) &fReleaseTexImage, { "wglReleaseTexImageARB", "wglReleaseTexImageEXT", nullptr } },
-        { nullptr, { nullptr } }
+        { (PRFuncPtr*)&mSymbols.fCreatePbuffer, { "wglCreatePbufferARB", "wglCreatePbufferEXT", nullptr } },
+        { (PRFuncPtr*)&mSymbols.fDestroyPbuffer, { "wglDestroyPbufferARB", "wglDestroyPbufferEXT", nullptr } },
+        { (PRFuncPtr*)&mSymbols.fGetPbufferDC, { "wglGetPbufferDCARB", "wglGetPbufferDCEXT", nullptr } },
+        { (PRFuncPtr*)&mSymbols.fBindTexImage, { "wglBindTexImageARB", "wglBindTexImageEXT", nullptr } },
+        { (PRFuncPtr*)&mSymbols.fReleaseTexImage, { "wglReleaseTexImageARB", "wglReleaseTexImageEXT", nullptr } },
+        END_OF_SYMBOLS
     };
 
     const GLLibraryLoader::SymLoadStruct pixFmtSymbols[] = {
-        { (PRFuncPtr*) &fChoosePixelFormat, { "wglChoosePixelFormatARB", "wglChoosePixelFormatEXT", nullptr } },
-        { (PRFuncPtr*) &fGetPixelFormatAttribiv, { "wglGetPixelFormatAttribivARB", "wglGetPixelFormatAttribivEXT", nullptr } },
-        { nullptr, { nullptr } }
+        { (PRFuncPtr*)&mSymbols.fChoosePixelFormat, { "wglChoosePixelFormatARB", "wglChoosePixelFormatEXT", nullptr } },
+        { (PRFuncPtr*)&mSymbols.fGetPixelFormatAttribiv, { "wglGetPixelFormatAttribivARB", "wglGetPixelFormatAttribivEXT", nullptr } },
+        END_OF_SYMBOLS
     };
 
-    if (!GLLibraryLoader::LoadSymbols(mOGLLibrary, &pbufferSymbols[0], lookupFunc)) {
+    if (!GLLibraryLoader::LoadSymbols(mOGLLibrary, pbufferSymbols, lookupFunc)) {
         // this isn't an error, just means that pbuffers aren't supported
-        fCreatePbuffer = nullptr;
+        ClearSymbols(pbufferSymbols);
     }
 
-    if (!GLLibraryLoader::LoadSymbols(mOGLLibrary, &pixFmtSymbols[0], lookupFunc)) {
+    if (!GLLibraryLoader::LoadSymbols(mOGLLibrary, pixFmtSymbols, lookupFunc)) {
         // this isn't an error, just means that we don't have the pixel format extension
-        fChoosePixelFormat = nullptr;
+        ClearSymbols(pixFmtSymbols);
     }
 
     const GLLibraryLoader::SymLoadStruct extensionsSymbols[] = {
-        { (PRFuncPtr*) &fGetExtensionsString, { "wglGetExtensionsStringARB", nullptr} },
-        { nullptr, { nullptr } }
+        SYMBOL(GetExtensionsStringARB),
+        END_OF_SYMBOLS
     };
 
     const GLLibraryLoader::SymLoadStruct robustnessSymbols[] = {
-        { (PRFuncPtr*) &fCreateContextAttribs, { "wglCreateContextAttribsARB", nullptr} },
-        { nullptr, { nullptr } }
+        SYMBOL(CreateContextAttribsARB),
+        END_OF_SYMBOLS
     };
 
     const GLLibraryLoader::SymLoadStruct dxInteropSymbols[] = {
-        { (PRFuncPtr*)&fDXSetResourceShareHandle,{ "wglDXSetResourceShareHandleNV", nullptr } },
-        { (PRFuncPtr*)&fDXOpenDevice,            { "wglDXOpenDeviceNV",             nullptr } },
-        { (PRFuncPtr*)&fDXCloseDevice,           { "wglDXCloseDeviceNV",            nullptr } },
-        { (PRFuncPtr*)&fDXRegisterObject,        { "wglDXRegisterObjectNV",         nullptr } },
-        { (PRFuncPtr*)&fDXUnregisterObject,      { "wglDXUnregisterObjectNV",       nullptr } },
-        { (PRFuncPtr*)&fDXObjectAccess,          { "wglDXObjectAccessNV",           nullptr } },
-        { (PRFuncPtr*)&fDXLockObjects,           { "wglDXLockObjectsNV",            nullptr } },
-        { (PRFuncPtr*)&fDXUnlockObjects,         { "wglDXUnlockObjectsNV",          nullptr } },
-        { nullptr, { nullptr } }
+        SYMBOL(DXSetResourceShareHandleNV),
+        SYMBOL(DXOpenDeviceNV),
+        SYMBOL(DXCloseDeviceNV),
+        SYMBOL(DXRegisterObjectNV),
+        SYMBOL(DXUnregisterObjectNV),
+        SYMBOL(DXObjectAccessNV),
+        SYMBOL(DXLockObjectsNV),
+        SYMBOL(DXUnlockObjectsNV),
+        END_OF_SYMBOLS
     };
 
-    if (GLLibraryLoader::LoadSymbols(mOGLLibrary, &extensionsSymbols[0], lookupFunc)) {
-        const char* extString = fGetExtensionsString(mWindowDC);
+    if (GLLibraryLoader::LoadSymbols(mOGLLibrary, extensionsSymbols, lookupFunc)) {
+        const char* extString = mSymbols.fGetExtensionsStringARB(mWindowDC);
         MOZ_ASSERT(extString);
         MOZ_ASSERT(HasExtension(extString, "WGL_ARB_extensions_string"));
 
         if (HasExtension(extString, "WGL_ARB_create_context")) {
-            if (GLLibraryLoader::LoadSymbols(mOGLLibrary, &robustnessSymbols[0], lookupFunc)) {
+            if (GLLibraryLoader::LoadSymbols(mOGLLibrary, robustnessSymbols, lookupFunc)) {
                 if (HasExtension(extString, "WGL_ARB_create_context_robustness")) {
                     mHasRobustness = true;
                 }
             } else {
                 NS_ERROR("WGL supports ARB_create_context without supplying its functions.");
-                fCreateContextAttribs = nullptr;
+                ClearSymbols(robustnessSymbols);
             }
         }
 
         ////
 
         bool hasDXInterop2 = HasExtension(extString, "WGL_NV_DX_interop2");
         if (gfxVars::DXInterop2Blocked() &&
             !gfxPrefs::IgnoreDXInterop2Blacklist())
         {
             hasDXInterop2 = false;
         }
 
         if (hasDXInterop2) {
-            if (!GLLibraryLoader::LoadSymbols(mOGLLibrary, &dxInteropSymbols[0],
+            if (!GLLibraryLoader::LoadSymbols(mOGLLibrary, dxInteropSymbols,
                                               lookupFunc))
             {
                 NS_ERROR("WGL supports NV_DX_interop(2) without supplying its functions.");
-                fDXSetResourceShareHandle = nullptr;
-                fDXOpenDevice = nullptr;
-                fDXCloseDevice = nullptr;
-                fDXRegisterObject = nullptr;
-                fDXUnregisterObject = nullptr;
-                fDXObjectAccess = nullptr;
-                fDXLockObjects = nullptr;
-                fDXUnlockObjects = nullptr;
+                ClearSymbols(dxInteropSymbols);
             }
         }
     }
 
     // reset back to the previous context, just in case
-    fMakeCurrent(curDC, curCtx);
+    mSymbols.fMakeCurrent(curDC, curCtx);
 
     if (mHasRobustness) {
-        fDeleteContext(mWindowGLContext);
+        mSymbols.fDeleteContext(mWindowGLContext);
 
         const int attribs[] = {
             LOCAL_WGL_CONTEXT_FLAGS_ARB, LOCAL_WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB,
             LOCAL_WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, LOCAL_WGL_LOSE_CONTEXT_ON_RESET_ARB,
             0
         };
 
-        mWindowGLContext = fCreateContextAttribs(mWindowDC, nullptr, attribs);
+        mWindowGLContext = mSymbols.fCreateContextAttribsARB(mWindowDC, nullptr, attribs);
         if (!mWindowGLContext) {
             mHasRobustness = false;
-            mWindowGLContext = fCreateContext(mWindowDC);
+            mWindowGLContext = mSymbols.fCreateContext(mWindowDC);
         }
     }
 
     mInitialized = true;
 
     reporter.SetSuccessful();
     return true;
 }
 
+#undef SYMBOL
+#undef END_OF_SYMBOLS
+
 GLContextWGL::GLContextWGL(CreateContextFlags flags, const SurfaceCaps& caps,
                            bool isOffscreen, HDC aDC, HGLRC aContext, HWND aWindow)
     : GLContext(flags, caps, nullptr, isOffscreen),
       mDC(aDC),
       mContext(aContext),
       mWnd(aWindow),
       mPBuffer(nullptr),
       mPixelFormat(0),
@@ -297,32 +296,32 @@ GLContextWGL::GLContextWGL(CreateContext
     // See 899855
     SetProfileVersion(ContextProfile::OpenGLCompatibility, 200);
 }
 
 GLContextWGL::~GLContextWGL()
 {
     MarkDestroyed();
 
-    sWGLLib.fDeleteContext(mContext);
+    sWGLLib.mSymbols.fDeleteContext(mContext);
 
     if (mPBuffer)
-        sWGLLib.fDestroyPbuffer(mPBuffer);
+        sWGLLib.mSymbols.fDestroyPbuffer(mPBuffer);
     if (mWnd)
         DestroyWindow(mWnd);
 }
 
 bool
 GLContextWGL::Init()
 {
     if (!mDC || !mContext)
         return false;
 
     // see bug 929506 comment 29. wglGetProcAddress requires a current context.
-    if (!sWGLLib.fMakeCurrent(mDC, mContext))
+    if (!sWGLLib.mSymbols.fMakeCurrent(mDC, mContext))
         return false;
 
     SetupLookupFunction();
     if (!InitWithPrefix("gl", true))
         return false;
 
     return true;
 }
@@ -331,28 +330,28 @@ bool
 GLContextWGL::MakeCurrentImpl(bool aForce)
 {
     BOOL succeeded = true;
 
     // wglGetCurrentContext seems to just pull the HGLRC out
     // of its TLS slot, so no need to do our own tls slot.
     // You would think that wglMakeCurrent would avoid doing
     // work if mContext was already current, but not so much..
-    if (aForce || sWGLLib.fGetCurrentContext() != mContext) {
-        succeeded = sWGLLib.fMakeCurrent(mDC, mContext);
+    if (aForce || sWGLLib.mSymbols.fGetCurrentContext() != mContext) {
+        succeeded = sWGLLib.mSymbols.fMakeCurrent(mDC, mContext);
         NS_ASSERTION(succeeded, "Failed to make GL context current!");
     }
 
     return succeeded;
 }
 
 bool
 GLContextWGL::IsCurrent()
 {
-    return sWGLLib.fGetCurrentContext() == mContext;
+    return sWGLLib.mSymbols.fGetCurrentContext() == mContext;
 }
 
 void
 GLContextWGL::SetIsDoubleBuffered(bool aIsDB)
 {
     mIsDoubleBuffered = aIsDB;
 }
 
@@ -374,40 +373,40 @@ GLContextWGL::SwapBuffers() {
         return false;
     return ::SwapBuffers(mDC);
 }
 
 void
 GLContextWGL::GetWSIInfo(nsCString* const out) const
 {
     out->AppendLiteral("wglGetExtensionsString: ");
-    out->Append(sWGLLib.fGetExtensionsString(mDC));
+    out->Append(sWGLLib.mSymbols.fGetExtensionsStringARB(mDC));
 }
 
 bool
 GLContextWGL::SetupLookupFunction()
 {
     // Make sure that we have a ref to the OGL library;
     // when run under CodeXL, wglGetProcAddress won't return
     // the right thing for some core functions.
     MOZ_ASSERT(mLibrary == nullptr);
 
     mLibrary = sWGLLib.GetOGLLibrary();
-    mLookupFunc = (PlatformLookupFunction)sWGLLib.fGetProcAddress;
+    mLookupFunc = (PlatformLookupFunction)sWGLLib.mSymbols.fGetProcAddress;
     return true;
 }
 
 static bool
 GetMaxSize(HDC hDC, int format, IntSize& size)
 {
     int query[] = {LOCAL_WGL_MAX_PBUFFER_WIDTH_ARB, LOCAL_WGL_MAX_PBUFFER_HEIGHT_ARB};
     int result[2];
 
     // (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, int* piValues)
-    if (!sWGLLib.fGetPixelFormatAttribiv(hDC, format, 0, 2, query, result))
+    if (!sWGLLib.mSymbols.fGetPixelFormatAttribiv(hDC, format, 0, 2, query, result))
         return false;
 
     size.width = result[0];
     size.height = result[1];
     return true;
 }
 
 static bool
@@ -454,19 +453,19 @@ CreateForWidget(HWND aHwnd,
 
     if (sWGLLib.HasRobustness()) {
         int attribs[] = {
             LOCAL_WGL_CONTEXT_FLAGS_ARB, LOCAL_WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB,
             LOCAL_WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, LOCAL_WGL_LOSE_CONTEXT_ON_RESET_ARB,
             0
         };
 
-        context = sWGLLib.fCreateContextAttribs(dc, nullptr, attribs);
+        context = sWGLLib.mSymbols.fCreateContextAttribsARB(dc, nullptr, attribs);
     } else {
-        context = sWGLLib.fCreateContext(dc);
+        context = sWGLLib.mSymbols.fCreateContext(dc);
     }
 
     if (!context) {
         return nullptr;
     }
 
     SurfaceCaps caps = SurfaceCaps::ForRGBA();
     RefPtr<GLContextWGL> glContext = new GLContextWGL(CreateContextFlags::NONE, caps,
@@ -510,52 +509,52 @@ CreatePBufferOffscreenContext(CreateCont
         0
     };
 
     // We only need one!
     static const uint32_t kMaxFormats = 1024;
     int formats[kMaxFormats];
     uint32_t foundFormats;
     HDC windowDC = wgl.GetWindowDC();
-    if (!wgl.fChoosePixelFormat(windowDC, pfAttribs, nullptr, kMaxFormats, formats,
-                                &foundFormats)
+    if (!wgl.mSymbols.fChoosePixelFormat(windowDC, pfAttribs, nullptr, kMaxFormats,
+                                         formats, &foundFormats)
         || foundFormats == 0)
     {
         return nullptr;
     }
 
     // We don't care; just pick the first one.
     int chosenFormat = formats[0];
     if (!IsValidSizeForFormat(windowDC, chosenFormat, aSize))
         return nullptr;
 
     const int pbAttribs[] = { 0 };
-    HANDLE pbuffer = wgl.fCreatePbuffer(windowDC, chosenFormat, aSize.width, aSize.height,
-                                        pbAttribs);
+    HANDLE pbuffer = wgl.mSymbols.fCreatePbuffer(windowDC, chosenFormat, aSize.width,
+                                                 aSize.height, pbAttribs);
     if (!pbuffer) {
         return nullptr;
     }
 
-    HDC pbdc = wgl.fGetPbufferDC(pbuffer);
+    HDC pbdc = wgl.mSymbols.fGetPbufferDC(pbuffer);
     NS_ASSERTION(pbdc, "expected a dc");
 
     HGLRC context;
     if (wgl.HasRobustness()) {
         const int attribs[] = {
             LOCAL_WGL_CONTEXT_FLAGS_ARB, LOCAL_WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB,
             LOCAL_WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, LOCAL_WGL_LOSE_CONTEXT_ON_RESET_ARB,
             0
         };
-        context = wgl.fCreateContextAttribs(pbdc, nullptr, attribs);
+        context = wgl.mSymbols.fCreateContextAttribsARB(pbdc, nullptr, attribs);
     } else {
-        context = wgl.fCreateContext(pbdc);
+        context = wgl.mSymbols.fCreateContext(pbdc);
     }
 
     if (!context) {
-        wgl.fDestroyPbuffer(pbuffer);
+        wgl.mSymbols.fDestroyPbuffer(pbuffer);
         return nullptr;
     }
 
     SurfaceCaps dummyCaps = SurfaceCaps::Any();
     RefPtr<GLContextWGL> glContext = new GLContextWGL(flags, dummyCaps, true, pbuffer,
                                                       pbdc, context, chosenFormat);
     return glContext.forget();
 }
@@ -564,27 +563,27 @@ static already_AddRefed<GLContextWGL>
 CreateWindowOffscreenContext()
 {
     HDC dc;
     HWND win = sWGLLib.CreateDummyWindow(&dc);
     if (!win) {
         return nullptr;
     }
 
-    HGLRC context = sWGLLib.fCreateContext(dc);
+    HGLRC context = sWGLLib.mSymbols.fCreateContext(dc);
     if (sWGLLib.HasRobustness()) {
         int attribs[] = {
             LOCAL_WGL_CONTEXT_FLAGS_ARB, LOCAL_WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB,
             LOCAL_WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, LOCAL_WGL_LOSE_CONTEXT_ON_RESET_ARB,
             0
         };
 
-        context = sWGLLib.fCreateContextAttribs(dc, nullptr, attribs);
+        context = sWGLLib.mSymbols.fCreateContextAttribsARB(dc, nullptr, attribs);
     } else {
-        context = sWGLLib.fCreateContext(dc);
+        context = sWGLLib.mSymbols.fCreateContext(dc);
     }
 
     if (!context) {
         return nullptr;
     }
 
     SurfaceCaps caps = SurfaceCaps::ForRGBA();
     RefPtr<GLContextWGL> glContext = new GLContextWGL(CreateContextFlags::NONE, caps,
@@ -599,18 +598,18 @@ GLContextProviderWGL::CreateHeadless(Cre
     if (!sWGLLib.EnsureInitialized()) {
         return nullptr;
     }
 
     RefPtr<GLContextWGL> glContext;
 
     // Always try to create a pbuffer context first, because we
     // want the context isolation.
-    if (sWGLLib.fCreatePbuffer &&
-        sWGLLib.fChoosePixelFormat)
+    if (sWGLLib.mSymbols.fCreatePbuffer &&
+        sWGLLib.mSymbols.fChoosePixelFormat)
     {
         IntSize dummySize = IntSize(16, 16);
         glContext = CreatePBufferOffscreenContext(flags, dummySize);
     }
 
     // If it failed, then create a window context and use a FBO.
     if (!glContext) {
         glContext = CreateWindowOffscreenContext();
--- a/gfx/gl/GLLibraryEGL.cpp
+++ b/gfx/gl/GLLibraryEGL.cpp
@@ -380,91 +380,88 @@ GLLibraryEGL::EnsureInitialized(bool for
     if (!mEGLLibrary) {
         NS_WARNING("Couldn't load EGL LIB.");
         *out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_LOAD_2");
         return false;
     }
 
 #endif // !Windows
 
-#define SYMBOL(name) \
-{ (PRFuncPtr*) &mSymbols.f##name, { "egl" #name, nullptr } }
+#define SYMBOL(X) { (PRFuncPtr*)&mSymbols.f##X, { "egl" #X, nullptr } }
+#define END_OF_SYMBOLS { nullptr, { nullptr } }
 
     GLLibraryLoader::SymLoadStruct earlySymbols[] = {
         SYMBOL(GetDisplay),
         SYMBOL(Terminate),
         SYMBOL(GetCurrentSurface),
         SYMBOL(GetCurrentContext),
         SYMBOL(MakeCurrent),
         SYMBOL(DestroyContext),
         SYMBOL(CreateContext),
         SYMBOL(DestroySurface),
         SYMBOL(CreateWindowSurface),
         SYMBOL(CreatePbufferSurface),
+        SYMBOL(CreatePbufferFromClientBuffer),
         SYMBOL(CreatePixmapSurface),
         SYMBOL(BindAPI),
         SYMBOL(Initialize),
         SYMBOL(ChooseConfig),
         SYMBOL(GetError),
         SYMBOL(GetConfigs),
         SYMBOL(GetConfigAttrib),
         SYMBOL(WaitNative),
         SYMBOL(GetProcAddress),
         SYMBOL(SwapBuffers),
         SYMBOL(CopyBuffers),
         SYMBOL(QueryString),
         SYMBOL(QueryContext),
         SYMBOL(BindTexImage),
         SYMBOL(ReleaseTexImage),
         SYMBOL(QuerySurface),
-        SYMBOL(CreatePbufferFromClientBuffer),
-        { nullptr, { nullptr } }
+        END_OF_SYMBOLS
     };
 
-    if (!GLLibraryLoader::LoadSymbols(mEGLLibrary, &earlySymbols[0])) {
+    if (!GLLibraryLoader::LoadSymbols(mEGLLibrary, earlySymbols)) {
         NS_WARNING("Couldn't find required entry points in EGL library (early init)");
         *out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_SYM");
         return false;
     }
 
-    GLLibraryLoader::SymLoadStruct optionalSymbols[] = {
-        // On Android 4.3 and up, certain features like ANDROID_native_fence_sync
-        // can only be queried by using a special eglQueryString.
-        { (PRFuncPtr*) &mSymbols.fQueryStringImplementationANDROID,
-          { "_Z35eglQueryStringImplementationANDROIDPvi", nullptr } },
-        { nullptr, { nullptr } }
-    };
-
-    // Do not warn about the failure to load this - see bug 1092191
-    Unused << GLLibraryLoader::LoadSymbols(mEGLLibrary, &optionalSymbols[0],
-                                           nullptr, nullptr, false);
+    {
+        const char internalFuncName[] = "_Z35eglQueryStringImplementationANDROIDPvi";
+        const auto& internalFunc = PR_FindFunctionSymbol(mEGLLibrary, internalFuncName);
+        if (internalFunc) {
+            *(PRFuncPtr*)&mSymbols.fQueryString = internalFunc;
+        }
+    }
 
     InitClientExtensions();
 
     const auto lookupFunction =
         (GLLibraryLoader::PlatformLookupFunction)mSymbols.fGetProcAddress;
 
+    const auto fnLoadSymbols = [&](const GLLibraryLoader::SymLoadStruct* symbols) {
+        if (GLLibraryLoader::LoadSymbols(mEGLLibrary, symbols, lookupFunction))
+            return true;
+
+        ClearSymbols(symbols);
+        return false;
+    };
+
     // Client exts are ready. (But not display exts!)
     if (IsExtensionSupported(ANGLE_platform_angle_d3d)) {
-        GLLibraryLoader::SymLoadStruct d3dSymbols[] = {
-            { (PRFuncPtr*)&mSymbols.fANGLEPlatformInitialize, { "ANGLEPlatformInitialize", nullptr } },
-            { (PRFuncPtr*)&mSymbols.fANGLEPlatformShutdown,   { "ANGLEPlatformShutdown", nullptr } },
-            { (PRFuncPtr*)&mSymbols.fGetPlatformDisplayEXT,   { "eglGetPlatformDisplayEXT", nullptr } },
-            { nullptr, { nullptr } }
+        const GLLibraryLoader::SymLoadStruct d3dSymbols[] = {
+            SYMBOL(ANGLEPlatformInitialize),
+            SYMBOL(ANGLEPlatformShutdown),
+            SYMBOL(GetPlatformDisplayEXT),
+            END_OF_SYMBOLS
         };
-
-        bool success = GLLibraryLoader::LoadSymbols(mEGLLibrary,
-                                                    &d3dSymbols[0],
-                                                    lookupFunction);
-        if (!success) {
+        if (!fnLoadSymbols(d3dSymbols)) {
             NS_ERROR("EGL supports ANGLE_platform_angle_d3d without exposing its functions!");
-
             MarkExtensionUnsupported(ANGLE_platform_angle_d3d);
-
-            mSymbols.fGetPlatformDisplayEXT = nullptr;
         }
     }
 
     // Check the ANGLE support the system has
     nsCOMPtr<nsIGfxInfo> gfxInfo = do_GetService("@mozilla.org/gfx/info;1");
     mIsANGLE = IsExtensionSupported(ANGLE_platform_angle);
 
     EGLDisplay chosenDisplay = nullptr;
@@ -529,124 +526,87 @@ GLLibraryEGL::EnsureInitialized(bool for
     mEGLDisplay = chosenDisplay;
 
     InitDisplayExtensions();
 
     ////////////////////////////////////
     // Alright, load display exts.
 
     if (IsExtensionSupported(KHR_lock_surface)) {
-        GLLibraryLoader::SymLoadStruct lockSymbols[] = {
-            { (PRFuncPtr*) &mSymbols.fLockSurface,   { "eglLockSurfaceKHR",   nullptr } },
-            { (PRFuncPtr*) &mSymbols.fUnlockSurface, { "eglUnlockSurfaceKHR", nullptr } },
-            { nullptr, { nullptr } }
+        const GLLibraryLoader::SymLoadStruct lockSymbols[] = {
+            SYMBOL(LockSurfaceKHR),
+            SYMBOL(UnlockSurfaceKHR),
+            END_OF_SYMBOLS
         };
-
-        bool success = GLLibraryLoader::LoadSymbols(mEGLLibrary,
-                                                    &lockSymbols[0],
-                                                    lookupFunction);
-        if (!success) {
+        if (!fnLoadSymbols(lockSymbols)) {
             NS_ERROR("EGL supports KHR_lock_surface without exposing its functions!");
-
             MarkExtensionUnsupported(KHR_lock_surface);
-
-            mSymbols.fLockSurface = nullptr;
-            mSymbols.fUnlockSurface = nullptr;
         }
     }
 
     if (IsExtensionSupported(ANGLE_surface_d3d_texture_2d_share_handle)) {
-        GLLibraryLoader::SymLoadStruct d3dSymbols[] = {
-            { (PRFuncPtr*) &mSymbols.fQuerySurfacePointerANGLE, { "eglQuerySurfacePointerANGLE", nullptr } },
-            { nullptr, { nullptr } }
+        const GLLibraryLoader::SymLoadStruct d3dSymbols[] = {
+            SYMBOL(QuerySurfacePointerANGLE),
+            END_OF_SYMBOLS
         };
-
-        bool success = GLLibraryLoader::LoadSymbols(mEGLLibrary,
-                                                    &d3dSymbols[0],
-                                                    lookupFunction);
-        if (!success) {
+        if (!fnLoadSymbols(d3dSymbols)) {
             NS_ERROR("EGL supports ANGLE_surface_d3d_texture_2d_share_handle without exposing its functions!");
-
             MarkExtensionUnsupported(ANGLE_surface_d3d_texture_2d_share_handle);
-
-            mSymbols.fQuerySurfacePointerANGLE = nullptr;
         }
     }
 
     if (IsExtensionSupported(KHR_fence_sync)) {
-        GLLibraryLoader::SymLoadStruct syncSymbols[] = {
-            { (PRFuncPtr*) &mSymbols.fCreateSync,     { "eglCreateSyncKHR",     nullptr } },
-            { (PRFuncPtr*) &mSymbols.fDestroySync,    { "eglDestroySyncKHR",    nullptr } },
-            { (PRFuncPtr*) &mSymbols.fClientWaitSync, { "eglClientWaitSyncKHR", nullptr } },
-            { (PRFuncPtr*) &mSymbols.fGetSyncAttrib,  { "eglGetSyncAttribKHR",  nullptr } },
-            { nullptr, { nullptr } }
+        const GLLibraryLoader::SymLoadStruct syncSymbols[] = {
+            SYMBOL(CreateSyncKHR),
+            SYMBOL(DestroySyncKHR),
+            SYMBOL(ClientWaitSyncKHR),
+            SYMBOL(GetSyncAttribKHR),
+            END_OF_SYMBOLS
         };
-
-        bool success = GLLibraryLoader::LoadSymbols(mEGLLibrary,
-                                                    &syncSymbols[0],
-                                                    lookupFunction);
-        if (!success) {
+        if (!fnLoadSymbols(syncSymbols)) {
             NS_ERROR("EGL supports KHR_fence_sync without exposing its functions!");
-
             MarkExtensionUnsupported(KHR_fence_sync);
-
-            mSymbols.fCreateSync = nullptr;
-            mSymbols.fDestroySync = nullptr;
-            mSymbols.fClientWaitSync = nullptr;
-            mSymbols.fGetSyncAttrib = nullptr;
         }
     }
 
     if (IsExtensionSupported(KHR_image) || IsExtensionSupported(KHR_image_base)) {
-        GLLibraryLoader::SymLoadStruct imageSymbols[] = {
-            { (PRFuncPtr*) &mSymbols.fCreateImage,  { "eglCreateImageKHR",  nullptr } },
-            { (PRFuncPtr*) &mSymbols.fDestroyImage, { "eglDestroyImageKHR", nullptr } },
-            { nullptr, { nullptr } }
+        const GLLibraryLoader::SymLoadStruct imageSymbols[] = {
+            SYMBOL(CreateImageKHR),
+            SYMBOL(DestroyImageKHR),
+            END_OF_SYMBOLS
         };
-
-        bool success = GLLibraryLoader::LoadSymbols(mEGLLibrary,
-                                                    &imageSymbols[0],
-                                                    lookupFunction);
-        if (!success) {
+        if (!fnLoadSymbols(imageSymbols)) {
             NS_ERROR("EGL supports KHR_image(_base) without exposing its functions!");
-
             MarkExtensionUnsupported(KHR_image);
             MarkExtensionUnsupported(KHR_image_base);
             MarkExtensionUnsupported(KHR_image_pixmap);
-
-            mSymbols.fCreateImage = nullptr;
-            mSymbols.fDestroyImage = nullptr;
         }
     } else {
         MarkExtensionUnsupported(KHR_image_pixmap);
     }
 
     if (IsExtensionSupported(ANDROID_native_fence_sync)) {
-        GLLibraryLoader::SymLoadStruct nativeFenceSymbols[] = {
-            { (PRFuncPtr*) &mSymbols.fDupNativeFenceFDANDROID, { "eglDupNativeFenceFDANDROID", nullptr } },
-            { nullptr, { nullptr } }
+        const GLLibraryLoader::SymLoadStruct nativeFenceSymbols[] = {
+            SYMBOL(DupNativeFenceFDANDROID),
+            END_OF_SYMBOLS
         };
-
-        bool success = GLLibraryLoader::LoadSymbols(mEGLLibrary,
-                                                    &nativeFenceSymbols[0],
-                                                    lookupFunction);
-        if (!success) {
+        if (!fnLoadSymbols(nativeFenceSymbols)) {
             NS_ERROR("EGL supports ANDROID_native_fence_sync without exposing its functions!");
-
             MarkExtensionUnsupported(ANDROID_native_fence_sync);
-
-            mSymbols.fDupNativeFenceFDANDROID = nullptr;
         }
     }
 
     mInitialized = true;
     reporter.SetSuccessful();
     return true;
 }
 
+#undef SYMBOL
+#undef END_OF_SYMBOLS
+
 template<size_t N>
 static void
 MarkExtensions(const char* rawExtString, bool shouldDumpExts, const char* extType,
                std::bitset<N>* const out)
 {
     MOZ_ASSERT(rawExtString);
 
     const nsDependentCString extString(rawExtString);
--- a/gfx/gl/GLLibraryEGL.h
+++ b/gfx/gl/GLLibraryEGL.h
@@ -105,68 +105,23 @@ namespace gl {
 #endif
 
 class GLContext;
 
 class GLLibraryEGL
 {
 public:
     GLLibraryEGL()
-        : mInitialized(false),
-          mEGLLibrary(nullptr),
-          mEGLDisplay(EGL_NO_DISPLAY),
-          mIsANGLE(false),
-          mIsWARP(false)
-    {
-        ClearSymbols();
-    }
-
-    void ClearSymbols() {
-        mSymbols.fANGLEPlatformInitialize = nullptr;
-        mSymbols.fANGLEPlatformShutdown = nullptr;
-        mSymbols.fGetDisplay = nullptr;
-        mSymbols.fGetPlatformDisplayEXT = nullptr;
-        mSymbols.fTerminate = nullptr;
-        mSymbols.fGetCurrentSurface = nullptr;
-        mSymbols.fGetCurrentContext = nullptr;
-        mSymbols.fMakeCurrent = nullptr;
-        mSymbols.fDestroyContext = nullptr;
-        mSymbols.fCreateContext = nullptr;
-        mSymbols.fDestroySurface = nullptr;
-        mSymbols.fCreateWindowSurface = nullptr;
-        mSymbols.fCreatePbufferSurface = nullptr;
-        mSymbols.fCreatePbufferFromClientBuffer = nullptr;
-        mSymbols.fCreatePixmapSurface = nullptr;
-        mSymbols.fBindAPI = nullptr;
-        mSymbols.fInitialize = nullptr;
-        mSymbols.fChooseConfig = nullptr;
-        mSymbols.fGetError = nullptr;
-        mSymbols.fGetConfigAttrib = nullptr;
-        mSymbols.fGetConfigs = nullptr;
-        mSymbols.fWaitNative = nullptr;
-        mSymbols.fGetProcAddress = nullptr;
-        mSymbols.fSwapBuffers = nullptr;
-        mSymbols.fCopyBuffers = nullptr;
-        mSymbols.fQueryString = nullptr;
-        mSymbols.fQueryStringImplementationANDROID = nullptr;
-        mSymbols.fQueryContext = nullptr;
-        mSymbols.fBindTexImage = nullptr;
-        mSymbols.fReleaseTexImage = nullptr;
-        mSymbols.fCreateImage = nullptr;
-        mSymbols.fDestroyImage = nullptr;
-        mSymbols.fLockSurface = nullptr;
-        mSymbols.fUnlockSurface = nullptr;
-        mSymbols.fQuerySurface = nullptr;
-        mSymbols.fQuerySurfacePointerANGLE = nullptr;
-        mSymbols.fCreateSync = nullptr;
-        mSymbols.fDestroySync = nullptr;
-        mSymbols.fClientWaitSync = nullptr;
-        mSymbols.fGetSyncAttrib = nullptr;
-        mSymbols.fDupNativeFenceFDANDROID = nullptr;
-    }
+        : mSymbols{nullptr}
+        , mInitialized(false)
+        , mEGLLibrary(nullptr)
+        , mEGLDisplay(EGL_NO_DISPLAY)
+        , mIsANGLE(false)
+        , mIsWARP(false)
+    { }
 
     void InitClientExtensions();
     void InitDisplayExtensions();
 
     /**
      * Known GL extensions that can be queried by
      * IsExtensionSupported.  The results of this are cached, and as
      * such it's safe to use this even in performance critical code.
@@ -197,16 +152,19 @@ public:
     void MarkExtensionUnsupported(EGLExtensions aKnownExtension) {
         mAvailableExtensions[aKnownExtension] = false;
     }
 
 protected:
     std::bitset<Extensions_Max> mAvailableExtensions;
 
 public:
+    GLLibraryLoader::PlatformLookupFunction GetLookupFunction() const {
+        return (GLLibraryLoader::PlatformLookupFunction)mSymbols.fGetProcAddress;
+    }
 
     EGLDisplay fGetDisplay(void* display_id)
     {
         BEFORE_GL_CALL;
         EGLDisplay disp = mSymbols.fGetDisplay(display_id);
         AFTER_GL_CALL;
         return disp;
     }
@@ -385,24 +343,19 @@ public:
         EGLBoolean b = mSymbols.fCopyBuffers(dpy, surface, target);
         AFTER_GL_CALL;
         return b;
     }
 
     const GLubyte* fQueryString(EGLDisplay dpy, EGLint name)
     {
         BEFORE_GL_CALL;
-        const GLubyte* b;
-        if (mSymbols.fQueryStringImplementationANDROID) {
-          b = mSymbols.fQueryStringImplementationANDROID(dpy, name);
-        } else {
-          b = mSymbols.fQueryString(dpy, name);
-        }
+        const auto ret = mSymbols.fQueryString(dpy, name);
         AFTER_GL_CALL;
-        return b;
+        return ret;
     }
 
     EGLBoolean fQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint* value)
     {
         BEFORE_GL_CALL;
         EGLBoolean b = mSymbols.fQueryContext(dpy, ctx, attribute, value);
         AFTER_GL_CALL;
         return b;
@@ -422,42 +375,42 @@ public:
         EGLBoolean b = mSymbols.fReleaseTexImage(dpy, surface, buffer);
         AFTER_GL_CALL;
         return b;
     }
 
     EGLImage fCreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint* attrib_list)
     {
          BEFORE_GL_CALL;
-         EGLImage i = mSymbols.fCreateImage(dpy, ctx, target, buffer, attrib_list);
+         EGLImage i = mSymbols.fCreateImageKHR(dpy, ctx, target, buffer, attrib_list);
          AFTER_GL_CALL;
          return i;
     }
 
     EGLBoolean fDestroyImage(EGLDisplay dpy, EGLImage image)
     {
         BEFORE_GL_CALL;
-        EGLBoolean b = mSymbols.fDestroyImage(dpy, image);
+        EGLBoolean b = mSymbols.fDestroyImageKHR(dpy, image);
         AFTER_GL_CALL;
         return b;
     }
 
     // New extension which allow us to lock texture and get raw image pointer
     EGLBoolean fLockSurface(EGLDisplay dpy, EGLSurface surface, const EGLint* attrib_list)
     {
         BEFORE_GL_CALL;
-        EGLBoolean b = mSymbols.fLockSurface(dpy, surface, attrib_list);
+        EGLBoolean b = mSymbols.fLockSurfaceKHR(dpy, surface, attrib_list);
         AFTER_GL_CALL;
         return b;
     }
 
     EGLBoolean fUnlockSurface(EGLDisplay dpy, EGLSurface surface)
     {
         BEFORE_GL_CALL;
-        EGLBoolean b = mSymbols.fUnlockSurface(dpy, surface);
+        EGLBoolean b = mSymbols.fUnlockSurfaceKHR(dpy, surface);
         AFTER_GL_CALL;
         return b;
     }
 
     EGLBoolean fQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint* value)
     {
         BEFORE_GL_CALL;
         EGLBoolean b = mSymbols.fQuerySurface(dpy, surface, attribute, value);
@@ -471,41 +424,41 @@ public:
         EGLBoolean b = mSymbols.fQuerySurfacePointerANGLE(dpy, surface, attribute, value);
         AFTER_GL_CALL;
         return b;
     }
 
     EGLSync fCreateSync(EGLDisplay dpy, EGLenum type, const EGLint* attrib_list)
     {
         BEFORE_GL_CALL;
-        EGLSync ret = mSymbols.fCreateSync(dpy, type, attrib_list);
+        EGLSync ret = mSymbols.fCreateSyncKHR(dpy, type, attrib_list);
         AFTER_GL_CALL;
         return ret;
     }
 
     EGLBoolean fDestroySync(EGLDisplay dpy, EGLSync sync)
     {
         BEFORE_GL_CALL;
-        EGLBoolean b = mSymbols.fDestroySync(dpy, sync);
+        EGLBoolean b = mSymbols.fDestroySyncKHR(dpy, sync);
         AFTER_GL_CALL;
         return b;
     }
 
     EGLint fClientWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout)
     {
         BEFORE_GL_CALL;
-        EGLint ret = mSymbols.fClientWaitSync(dpy, sync, flags, timeout);
+        EGLint ret = mSymbols.fClientWaitSyncKHR(dpy, sync, flags, timeout);
         AFTER_GL_CALL;
         return ret;
     }
 
     EGLBoolean fGetSyncAttrib(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLint* value)
     {
         BEFORE_GL_CALL;
-        EGLBoolean b = mSymbols.fGetSyncAttrib(dpy, sync, attribute, value);
+        EGLBoolean b = mSymbols.fGetSyncAttribKHR(dpy, sync, attribute, value);
         AFTER_GL_CALL;
         return b;
     }
 
     EGLint fDupNativeFenceFDANDROID(EGLDisplay dpy, EGLSync sync)
     {
         MOZ_ASSERT(mSymbols.fDupNativeFenceFDANDROID);
         BEFORE_GL_CALL;
@@ -567,112 +520,101 @@ public:
 
     bool ReadbackEGLImage(EGLImage image, gfx::DataSourceSurface* out_surface);
 
     bool EnsureInitialized(bool forceAccel, nsACString* const out_failureId);
 
     void DumpEGLConfig(EGLConfig cfg);
     void DumpEGLConfigs();
 
+private:
     struct {
-        typedef EGLDisplay (GLAPIENTRY * pfnGetDisplay)(void* display_id);
-        pfnGetDisplay fGetDisplay;
-        typedef EGLDisplay(GLAPIENTRY * pfnGetPlatformDisplayEXT)(EGLenum platform, void* native_display, const EGLint* attrib_list);
-        pfnGetPlatformDisplayEXT fGetPlatformDisplayEXT;
-        typedef EGLBoolean (GLAPIENTRY * pfnTerminate)(EGLDisplay dpy);
-        pfnTerminate fTerminate;
-        typedef EGLSurface (GLAPIENTRY * pfnGetCurrentSurface)(EGLint);
-        pfnGetCurrentSurface fGetCurrentSurface;
-        typedef EGLContext (GLAPIENTRY * pfnGetCurrentContext)(void);
-        pfnGetCurrentContext fGetCurrentContext;
-        typedef EGLBoolean (GLAPIENTRY * pfnMakeCurrent)(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
-        pfnMakeCurrent fMakeCurrent;
-        typedef EGLBoolean (GLAPIENTRY * pfnDestroyContext)(EGLDisplay dpy, EGLContext ctx);
-        pfnDestroyContext fDestroyContext;
-        typedef EGLContext (GLAPIENTRY * pfnCreateContext)(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint* attrib_list);
-        pfnCreateContext fCreateContext;
-        typedef EGLBoolean (GLAPIENTRY * pfnDestroySurface)(EGLDisplay dpy, EGLSurface surface);
-        pfnDestroySurface fDestroySurface;
-        typedef EGLSurface (GLAPIENTRY * pfnCreateWindowSurface)(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint* attrib_list);
-        pfnCreateWindowSurface fCreateWindowSurface;
-        typedef EGLSurface (GLAPIENTRY * pfnCreatePbufferSurface)(EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list);
-        pfnCreatePbufferSurface fCreatePbufferSurface;
-        typedef EGLSurface (GLAPIENTRY * pfnCreatePbufferFromClientBuffer)(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list);
-        pfnCreatePbufferFromClientBuffer fCreatePbufferFromClientBuffer;
-        typedef EGLSurface (GLAPIENTRY * pfnCreatePixmapSurface)(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint* attrib_list);
-        pfnCreatePixmapSurface fCreatePixmapSurface;
-        typedef EGLBoolean (GLAPIENTRY * pfnBindAPI)(EGLenum api);
-        pfnBindAPI fBindAPI;
-        typedef EGLBoolean (GLAPIENTRY * pfnInitialize)(EGLDisplay dpy, EGLint* major, EGLint* minor);
-        pfnInitialize fInitialize;
-        typedef EGLBoolean (GLAPIENTRY * pfnChooseConfig)(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size, EGLint* num_config);
-        pfnChooseConfig fChooseConfig;
-        typedef EGLint (GLAPIENTRY * pfnGetError)(void);
-        pfnGetError fGetError;
-        typedef EGLBoolean (GLAPIENTRY * pfnGetConfigAttrib)(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value);
-        pfnGetConfigAttrib fGetConfigAttrib;
-        typedef EGLBoolean (GLAPIENTRY * pfnGetConfigs)(EGLDisplay dpy, EGLConfig* configs, EGLint config_size, EGLint* num_config);
-        pfnGetConfigs fGetConfigs;
-        typedef EGLBoolean (GLAPIENTRY * pfnWaitNative)(EGLint engine);
-        pfnWaitNative fWaitNative;
-        typedef EGLCastToRelevantPtr (GLAPIENTRY * pfnGetProcAddress)(const char* procname);
-        pfnGetProcAddress fGetProcAddress;
-        typedef EGLBoolean (GLAPIENTRY * pfnSwapBuffers)(EGLDisplay dpy, EGLSurface surface);
-        pfnSwapBuffers fSwapBuffers;
-        typedef EGLBoolean (GLAPIENTRY * pfnCopyBuffers)(EGLDisplay dpy, EGLSurface surface,
-                                                         EGLNativePixmapType target);
-        pfnCopyBuffers fCopyBuffers;
-        typedef const GLubyte* (GLAPIENTRY * pfnQueryString)(EGLDisplay, EGLint name);
-        pfnQueryString fQueryString;
-        pfnQueryString fQueryStringImplementationANDROID;
-        typedef EGLBoolean (GLAPIENTRY * pfnQueryContext)(EGLDisplay dpy, EGLContext ctx,
-                                                          EGLint attribute, EGLint* value);
-        pfnQueryContext fQueryContext;
-        typedef EGLBoolean (GLAPIENTRY * pfnBindTexImage)(EGLDisplay, EGLSurface surface, EGLint buffer);
-        pfnBindTexImage fBindTexImage;
-        typedef EGLBoolean (GLAPIENTRY * pfnReleaseTexImage)(EGLDisplay, EGLSurface surface, EGLint buffer);
-        pfnReleaseTexImage fReleaseTexImage;
-        typedef EGLImage (GLAPIENTRY * pfnCreateImage)(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint* attrib_list);
-        pfnCreateImage fCreateImage;
-        typedef EGLBoolean (GLAPIENTRY * pfnDestroyImage)(EGLDisplay dpy, EGLImage image);
-        pfnDestroyImage fDestroyImage;
-
+        EGLCastToRelevantPtr (GLAPIENTRY * fGetProcAddress)(const char* procname);
+        EGLDisplay (GLAPIENTRY * fGetDisplay)(void* display_id);
+        EGLDisplay (GLAPIENTRY * fGetPlatformDisplayEXT)(EGLenum platform,
+                                                         void* native_display,
+                                                         const EGLint* attrib_list);
+        EGLBoolean (GLAPIENTRY * fTerminate)(EGLDisplay dpy);
+        EGLSurface (GLAPIENTRY * fGetCurrentSurface)(EGLint);
+        EGLContext (GLAPIENTRY * fGetCurrentContext)(void);
+        EGLBoolean (GLAPIENTRY * fMakeCurrent)(EGLDisplay dpy, EGLSurface draw,
+                                               EGLSurface read, EGLContext ctx);
+        EGLBoolean (GLAPIENTRY * fDestroyContext)(EGLDisplay dpy, EGLContext ctx);
+        EGLContext (GLAPIENTRY * fCreateContext)(EGLDisplay dpy, EGLConfig config,
+                                                 EGLContext share_context,
+                                                 const EGLint* attrib_list);
+        EGLBoolean (GLAPIENTRY * fDestroySurface)(EGLDisplay dpy, EGLSurface surface);
+        EGLSurface (GLAPIENTRY * fCreateWindowSurface)(EGLDisplay dpy, EGLConfig config,
+                                                       EGLNativeWindowType win,
+                                                       const EGLint* attrib_list);
+        EGLSurface (GLAPIENTRY * fCreatePbufferSurface)(EGLDisplay dpy, EGLConfig config,
+                                                        const EGLint* attrib_list);
+        EGLSurface (GLAPIENTRY * fCreatePbufferFromClientBuffer)(EGLDisplay dpy,
+                                                                 EGLenum buftype,
+                                                                 EGLClientBuffer buffer,
+                                                                 EGLConfig config,
+                                                                 const EGLint* attrib_list);
+        EGLSurface (GLAPIENTRY * fCreatePixmapSurface)(EGLDisplay dpy, EGLConfig config,
+                                                       EGLNativePixmapType pixmap,
+                                                       const EGLint* attrib_list);
+        EGLBoolean (GLAPIENTRY * fBindAPI)(EGLenum api);
+        EGLBoolean (GLAPIENTRY * fInitialize)(EGLDisplay dpy, EGLint* major,
+                                              EGLint* minor);
+        EGLBoolean (GLAPIENTRY * fChooseConfig)(EGLDisplay dpy, const EGLint* attrib_list,
+                                                EGLConfig* configs, EGLint config_size,
+                                                EGLint* num_config);
+        EGLint     (GLAPIENTRY * fGetError)(void);
+        EGLBoolean (GLAPIENTRY * fGetConfigAttrib)(EGLDisplay dpy, EGLConfig config,
+                                                   EGLint attribute, EGLint* value);
+        EGLBoolean (GLAPIENTRY * fGetConfigs)(EGLDisplay dpy, EGLConfig* configs,
+                                              EGLint config_size, EGLint* num_config);
+        EGLBoolean (GLAPIENTRY * fWaitNative)(EGLint engine);
+        EGLBoolean (GLAPIENTRY * fSwapBuffers)(EGLDisplay dpy, EGLSurface surface);
+        EGLBoolean (GLAPIENTRY * fCopyBuffers)(EGLDisplay dpy, EGLSurface surface,
+                                               EGLNativePixmapType target);
+        const GLubyte* (GLAPIENTRY * fQueryString)(EGLDisplay, EGLint name);
+        EGLBoolean (GLAPIENTRY * fQueryContext)(EGLDisplay dpy, EGLContext ctx,
+                                                EGLint attribute, EGLint* value);
+        EGLBoolean (GLAPIENTRY * fBindTexImage)(EGLDisplay, EGLSurface surface,
+                                                EGLint buffer);
+        EGLBoolean (GLAPIENTRY * fReleaseTexImage)(EGLDisplay, EGLSurface surface,
+                                                   EGLint buffer);
+        EGLImage   (GLAPIENTRY * fCreateImageKHR)(EGLDisplay dpy, EGLContext ctx,
+                                                  EGLenum target, EGLClientBuffer buffer,
+                                                  const EGLint* attrib_list);
+        EGLBoolean (GLAPIENTRY * fDestroyImageKHR)(EGLDisplay dpy, EGLImage image);
         // New extension which allow us to lock texture and get raw image pointer
-        typedef EGLBoolean (GLAPIENTRY * pfnLockSurface)(EGLDisplay dpy, EGLSurface surface, const EGLint* attrib_list);
-        pfnLockSurface fLockSurface;
-        typedef EGLBoolean (GLAPIENTRY * pfnUnlockSurface)(EGLDisplay dpy, EGLSurface surface);
-        pfnUnlockSurface fUnlockSurface;
-        typedef EGLBoolean (GLAPIENTRY * pfnQuerySurface)(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint* value);
-        pfnQuerySurface fQuerySurface;
-
-        typedef EGLBoolean (GLAPIENTRY * pfnQuerySurfacePointerANGLE)(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void** value);
-        pfnQuerySurfacePointerANGLE fQuerySurfacePointerANGLE;
-
-        typedef EGLSync (GLAPIENTRY * pfnCreateSync)(EGLDisplay dpy, EGLenum type, const EGLint* attrib_list);
-        pfnCreateSync fCreateSync;
-        typedef EGLBoolean (GLAPIENTRY * pfnDestroySync)(EGLDisplay dpy, EGLSync sync);
-        pfnDestroySync fDestroySync;
-        typedef EGLint (GLAPIENTRY * pfnClientWaitSync)(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout);
-        pfnClientWaitSync fClientWaitSync;
-        typedef EGLBoolean (GLAPIENTRY * pfnGetSyncAttrib)(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLint* value);
-        pfnGetSyncAttrib fGetSyncAttrib;
-        typedef EGLint (GLAPIENTRY * pfnDupNativeFenceFDANDROID)(EGLDisplay dpy, EGLSync sync);
-        pfnDupNativeFenceFDANDROID fDupNativeFenceFDANDROID;
-
-        typedef void (GLAPIENTRY * pfnANGLEPlatformInitialize)(angle::Platform* platform);
-        pfnANGLEPlatformInitialize fANGLEPlatformInitialize;
-        typedef void (GLAPIENTRY * pfnANGLEPlatformShutdown)();
-        pfnANGLEPlatformShutdown fANGLEPlatformShutdown;
+        EGLBoolean (GLAPIENTRY * fLockSurfaceKHR)(EGLDisplay dpy, EGLSurface surface,
+                                                  const EGLint* attrib_list);
+        EGLBoolean (GLAPIENTRY * fUnlockSurfaceKHR)(EGLDisplay dpy, EGLSurface surface);
+        EGLBoolean (GLAPIENTRY * fQuerySurface)(EGLDisplay dpy, EGLSurface surface,
+                                                EGLint attribute, EGLint* value);
+        EGLBoolean (GLAPIENTRY * fQuerySurfacePointerANGLE)(EGLDisplay dpy,
+                                                            EGLSurface surface,
+                                                            EGLint attribute,
+                                                            void** value);
+        EGLSync    (GLAPIENTRY * fCreateSyncKHR)(EGLDisplay dpy, EGLenum type,
+                                                 const EGLint* attrib_list);
+        EGLBoolean (GLAPIENTRY * fDestroySyncKHR)(EGLDisplay dpy, EGLSync sync);
+        EGLint     (GLAPIENTRY * fClientWaitSyncKHR)(EGLDisplay dpy, EGLSync sync,
+                                                     EGLint flags,
+                                                     EGLTime timeout);
+        EGLBoolean (GLAPIENTRY * fGetSyncAttribKHR)(EGLDisplay dpy, EGLSync sync,
+                                                    EGLint attribute, EGLint* value);
+        EGLint     (GLAPIENTRY * fDupNativeFenceFDANDROID)(EGLDisplay dpy, EGLSync sync);
+        void       (GLAPIENTRY * fANGLEPlatformInitialize)(angle::Platform* platform);
+        void       (GLAPIENTRY * fANGLEPlatformShutdown)();
     } mSymbols;
 
 #ifdef DEBUG
     static void BeforeGLCall(const char* glFunction);
     static void AfterGLCall(const char* glFunction);
 #endif
 
+public:
 #ifdef MOZ_B2G
     EGLContext CachedCurrentContext() {
         return sCurrentContext.get();
     }
     void UnsetCachedCurrentContext() {
         sCurrentContext.set(nullptr);
     }
     void SetCachedCurrentContext(EGLContext aCtx) {
--- a/gfx/gl/GLLibraryLoader.cpp
+++ b/gfx/gl/GLLibraryLoader.cpp
@@ -113,11 +113,19 @@ GLLibraryLoader::LoadSymbols(PRLibrary* 
         }
 
         ss++;
     }
 
     return failCount == 0 ? true : false;
 }
 
+/*static*/ void
+GLLibraryLoader::ClearSymbols(const SymLoadStruct* const firstStruct)
+{
+    for (auto cur = firstStruct; cur->symPointer; ++cur) {
+        *cur->symPointer = nullptr;
+    }
+}
+
 } /* namespace gl */
 } /* namespace mozilla */
 
--- a/gfx/gl/GLLibraryLoader.h
+++ b/gfx/gl/GLLibraryLoader.h
@@ -31,16 +31,18 @@ public:
         const char* symNames[MAX_SYMBOL_NAMES];
     } SymLoadStruct;
 
     bool LoadSymbols(const SymLoadStruct* firstStruct,
                      bool tryplatform = false,
                      const char* prefix = nullptr,
                      bool warnOnFailure = true);
 
+    static void ClearSymbols(const SymLoadStruct* firstStruct);
+
     PRFuncPtr LookupSymbol(const char* symname);
 
     /*
      * Static version of the functions in this class
      */
     static PRFuncPtr LookupSymbol(PRLibrary* lib,
                                   const char* symname,
                                   PlatformLookupFunction lookupFunction = nullptr);
--- a/gfx/gl/GLXLibrary.h
+++ b/gfx/gl/GLXLibrary.h
@@ -2,82 +2,58 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef GFX_GLXLIBRARY_H
 #define GFX_GLXLIBRARY_H
 
 #include "GLContextTypes.h"
+#include "prlink.h"
 typedef realGLboolean GLboolean;
 
 // stuff from glx.h
 #include "X11/Xlib.h"
 typedef struct __GLXcontextRec* GLXContext;
 typedef XID GLXPixmap;
 typedef XID GLXDrawable;
 /* GLX 1.3 and later */
 typedef struct __GLXFBConfigRec* GLXFBConfig;
-typedef XID GLXFBConfigID;
-typedef XID GLXContextID;
-typedef XID GLXWindow;
-typedef XID GLXPbuffer;
 // end of stuff from glx.h
 #include "prenv.h"
 
 struct PRLibrary;
 class gfxASurface;
 
 namespace mozilla {
 namespace gl {
 
 class GLXLibrary
 {
 public:
-    constexpr GLXLibrary()
-    : xDestroyContextInternal(nullptr)
-    , xMakeCurrentInternal(nullptr)
-    , xGetCurrentContextInternal(nullptr)
-    , xGetProcAddressInternal(nullptr)
-    , xChooseFBConfigInternal(nullptr)
-    , xGetFBConfigsInternal(nullptr)
-    , xCreateNewContextInternal(nullptr)
-    , xGetFBConfigAttribInternal(nullptr)
-    , xSwapBuffersInternal(nullptr)
-    , xQueryExtensionsStringInternal(nullptr)
-    , xGetClientStringInternal(nullptr)
-    , xQueryServerStringInternal(nullptr)
-    , xCreatePixmapInternal(nullptr)
-    , xCreateGLXPixmapWithConfigInternal(nullptr)
-    , xDestroyPixmapInternal(nullptr)
-    , xQueryVersionInternal(nullptr)
-    , xBindTexImageInternal(nullptr)
-    , xReleaseTexImageInternal(nullptr)
-    , xWaitGLInternal(nullptr)
-    , xWaitXInternal(nullptr)
-    , xCreateContextAttribsInternal(nullptr)
-    , xGetVideoSyncInternal(nullptr)
-    , xWaitVideoSyncInternal(nullptr)
-    , xSwapIntervalInternal(nullptr)
-    , mInitialized(false), mTriedInitializing(false)
-    , mUseTextureFromPixmap(false), mDebug(false)
-    , mHasRobustness(false), mHasCreateContextAttribs(false)
-    , mHasVideoSync(false)
-    , mIsATI(false), mIsNVIDIA(false)
-    , mClientIsMesa(false)
-    , mOGLLibrary(nullptr)
+    GLXLibrary()
+        : mSymbols{nullptr}
+        , mInitialized(false)
+        , mTriedInitializing(false)
+        , mUseTextureFromPixmap(false)
+        , mDebug(false)
+        , mHasRobustness(false)
+        , mHasCreateContextAttribs(false)
+        , mHasVideoSync(false)
+        , mIsATI(false), mIsNVIDIA(false)
+        , mClientIsMesa(false)
+        , mOGLLibrary(nullptr)
     {}
 
     void xDestroyContext(Display* display, GLXContext context);
     Bool xMakeCurrent(Display* display,
                       GLXDrawable drawable,
                       GLXContext context);
 
     GLXContext xGetCurrentContext();
-    static void* xGetProcAddress(const char* procName);
     GLXFBConfig* xChooseFBConfig(Display* display,
                                  int screen,
                                  const int* attrib_list,
                                  int* nelements);
     GLXFBConfig* xGetFBConfigs(Display* display,
                                int screen,
                                int* nelements);
     GLXContext xCreateNewContext(Display* display,
@@ -135,118 +111,57 @@ public:
     void ReleaseTexImage(Display* aDisplay, GLXPixmap aPixmap);
     void UpdateTexImage(Display* aDisplay, GLXPixmap aPixmap);
 
     bool UseTextureFromPixmap() { return mUseTextureFromPixmap; }
     bool HasRobustness() { return mHasRobustness; }
     bool HasCreateContextAttribs() { return mHasCreateContextAttribs; }
     bool SupportsTextureFromPixmap(gfxASurface* aSurface);
     bool SupportsVideoSync();
-    bool SupportsSwapControl() const { return bool(xSwapIntervalInternal); }
+    bool SupportsSwapControl() const { return bool(mSymbols.fSwapIntervalEXT); }
     bool IsATI() { return mIsATI; }
     bool IsMesa() { return mClientIsMesa; }
 
-private:
-
-    typedef void (GLAPIENTRY * PFNGLXDESTROYCONTEXTPROC) (Display*,
-                                                          GLXContext);
-    PFNGLXDESTROYCONTEXTPROC xDestroyContextInternal;
-    typedef Bool (GLAPIENTRY * PFNGLXMAKECURRENTPROC) (Display*,
-                                                       GLXDrawable,
-                                                       GLXContext);
-    PFNGLXMAKECURRENTPROC xMakeCurrentInternal;
-    typedef GLXContext (GLAPIENTRY * PFNGLXGETCURRENTCONTEXT) ();
-    PFNGLXGETCURRENTCONTEXT xGetCurrentContextInternal;
-    typedef void* (GLAPIENTRY * PFNGLXGETPROCADDRESSPROC) (const char*);
-    PFNGLXGETPROCADDRESSPROC xGetProcAddressInternal;
-    typedef GLXFBConfig* (GLAPIENTRY * PFNGLXCHOOSEFBCONFIG) (Display*,
-                                                              int,
-                                                              const int*,
-                                                              int*);
-    PFNGLXCHOOSEFBCONFIG xChooseFBConfigInternal;
-    typedef GLXFBConfig* (GLAPIENTRY * PFNGLXGETFBCONFIGS) (Display*,
-                                                            int,
-                                                            int*);
-    PFNGLXGETFBCONFIGS xGetFBConfigsInternal;
-    typedef GLXContext (GLAPIENTRY * PFNGLXCREATENEWCONTEXT) (Display*,
-                                                              GLXFBConfig,
-                                                              int,
-                                                              GLXContext,
-                                                              Bool);
-    PFNGLXCREATENEWCONTEXT xCreateNewContextInternal;
-    typedef int (GLAPIENTRY * PFNGLXGETFBCONFIGATTRIB) (Display*,
-                                                        GLXFBConfig,
-                                                        int,
-                                                        int*);
-    PFNGLXGETFBCONFIGATTRIB xGetFBConfigAttribInternal;
-
-    typedef void (GLAPIENTRY * PFNGLXSWAPBUFFERS) (Display*,
-                                                   GLXDrawable);
-    PFNGLXSWAPBUFFERS xSwapBuffersInternal;
-    typedef const char* (GLAPIENTRY * PFNGLXQUERYEXTENSIONSSTRING) (Display*,
-                                                                    int);
-    PFNGLXQUERYEXTENSIONSSTRING xQueryExtensionsStringInternal;
-    typedef const char* (GLAPIENTRY * PFNGLXGETCLIENTSTRING) (Display*,
-                                                              int);
-    PFNGLXGETCLIENTSTRING xGetClientStringInternal;
-    typedef const char* (GLAPIENTRY * PFNGLXQUERYSERVERSTRING) (Display*,
-                                                                int,
-                                                                int);
-    PFNGLXQUERYSERVERSTRING xQueryServerStringInternal;
+    PRFuncPtr GetGetProcAddress() const {
+        return (PRFuncPtr)mSymbols.fGetProcAddress;
+    }
 
-    typedef GLXPixmap (GLAPIENTRY * PFNGLXCREATEPIXMAP) (Display*,
-                                                         GLXFBConfig,
-                                                         Pixmap,
-                                                         const int*);
-    PFNGLXCREATEPIXMAP xCreatePixmapInternal;
-    typedef GLXPixmap (GLAPIENTRY * PFNGLXCREATEGLXPIXMAPWITHCONFIG)
-                                                        (Display*,
-                                                         GLXFBConfig,
-                                                         Pixmap);
-    PFNGLXCREATEGLXPIXMAPWITHCONFIG xCreateGLXPixmapWithConfigInternal;
-    typedef void (GLAPIENTRY * PFNGLXDESTROYPIXMAP) (Display*,
-                                                     GLXPixmap);
-    PFNGLXDESTROYPIXMAP xDestroyPixmapInternal;
-    typedef Bool (GLAPIENTRY * PFNGLXQUERYVERSION) (Display*,
-                                                    int*,
-                                                    int*);
-    PFNGLXQUERYVERSION xQueryVersionInternal;
-
-    typedef void (GLAPIENTRY * PFNGLXBINDTEXIMAGE) (Display*,
-                                                    GLXDrawable,
-                                                    int,
-                                                    const int*);
-    PFNGLXBINDTEXIMAGE xBindTexImageInternal;
-
-    typedef void (GLAPIENTRY * PFNGLXRELEASETEXIMAGE) (Display*,
-                                                       GLXDrawable,
-                                                       int);
-    PFNGLXRELEASETEXIMAGE xReleaseTexImageInternal;
-
-    typedef void (GLAPIENTRY * PFNGLXWAITGL) ();
-    PFNGLXWAITGL xWaitGLInternal;
-
-    typedef void (GLAPIENTRY * PFNGLXWAITX) ();
-    PFNGLXWAITGL xWaitXInternal;
-
-    typedef GLXContext (GLAPIENTRY * PFNGLXCREATECONTEXTATTRIBS) (Display*,
-                                                                  GLXFBConfig,
-                                                                  GLXContext,
-                                                                  Bool,
-                                                                  const int*);
-    PFNGLXCREATECONTEXTATTRIBS xCreateContextAttribsInternal;
-
-    typedef int (GLAPIENTRY * PFNGLXGETVIDEOSYNCSGI) (unsigned int* count);
-    PFNGLXGETVIDEOSYNCSGI xGetVideoSyncInternal;
-
-    typedef int (GLAPIENTRY * PFNGLXWAITVIDEOSYNCSGI) (int divisor, int remainder, unsigned int* count);
-    PFNGLXWAITVIDEOSYNCSGI xWaitVideoSyncInternal;
-
-    typedef void (GLAPIENTRY * PFNGLXSWAPINTERVALEXT) (Display* dpy, GLXDrawable drawable, int interval);
-    PFNGLXSWAPINTERVALEXT xSwapIntervalInternal;
+private:
+    struct {
+        void         (GLAPIENTRY *fDestroyContext) (Display*, GLXContext);
+        Bool         (GLAPIENTRY *fMakeCurrent) (Display*, GLXDrawable, GLXContext);
+        GLXContext   (GLAPIENTRY *fGetCurrentContext) ();
+        void*        (GLAPIENTRY *fGetProcAddress) (const char*);
+        GLXFBConfig* (GLAPIENTRY *fChooseFBConfig) (Display*, int, const int*, int*);
+        GLXFBConfig* (GLAPIENTRY *fGetFBConfigs) (Display*, int, int*);
+        GLXContext   (GLAPIENTRY *fCreateNewContext) (Display*, GLXFBConfig, int,
+                                                      GLXContext, Bool);
+        int          (GLAPIENTRY *fGetFBConfigAttrib) (Display*, GLXFBConfig, int, int*);
+        void         (GLAPIENTRY *fSwapBuffers) (Display*, GLXDrawable);
+        const char*  (GLAPIENTRY *fQueryExtensionsString) (Display*, int);
+        const char*  (GLAPIENTRY *fGetClientString) (Display*, int);
+        const char*  (GLAPIENTRY *fQueryServerString) (Display*, int, int);
+        GLXPixmap    (GLAPIENTRY *fCreatePixmap) (Display*, GLXFBConfig, Pixmap,
+                                                  const int*);
+        GLXPixmap    (GLAPIENTRY *fCreateGLXPixmapWithConfig) (Display*, GLXFBConfig,
+                                                              Pixmap);
+        void         (GLAPIENTRY *fDestroyPixmap) (Display*, GLXPixmap);
+        Bool         (GLAPIENTRY *fQueryVersion) (Display*, int*, int*);
+        void         (GLAPIENTRY *fWaitGL) ();
+        void         (GLAPIENTRY *fWaitX) ();
+        void         (GLAPIENTRY *fBindTexImageEXT) (Display*, GLXDrawable, int,
+                                                     const int*);
+        void         (GLAPIENTRY *fReleaseTexImageEXT) (Display*, GLXDrawable, int);
+        GLXContext   (GLAPIENTRY *fCreateContextAttribsARB) (Display*, GLXFBConfig,
+                                                             GLXContext, Bool,
+                                                             const int*);
+        int          (GLAPIENTRY *fGetVideoSyncSGI) (unsigned int*);
+        int          (GLAPIENTRY *fWaitVideoSyncSGI) (int, int, unsigned int*);
+        void         (GLAPIENTRY *fSwapIntervalEXT) (Display*, GLXDrawable, int);
+    } mSymbols;
 
 #ifdef DEBUG
     void BeforeGLXCall();
     void AfterGLXCall();
 #endif
 
     bool mInitialized;
     bool mTriedInitializing;
--- a/gfx/gl/SharedSurfaceD3D11Interop.cpp
+++ b/gfx/gl/SharedSurfaceD3D11Interop.cpp
@@ -132,17 +132,17 @@ public:
         if (!d3d) {
             gfxCriticalNote << "DXInterop2Device::Open: Failed to create D3D11 device.";
             return nullptr;
         }
 
         if (!gl->MakeCurrent())
             return nullptr;
 
-        const auto interopDevice = wgl->fDXOpenDevice(d3d);
+        const auto interopDevice = wgl->mSymbols.fDXOpenDeviceNV(d3d);
         if (!interopDevice) {
             gfxCriticalNote << "DXInterop2Device::Open: DXOpenDevice failed.";
             return nullptr;
         }
 
         return MakeAndAddRef<DXInterop2Device>(wgl, d3d, interopDevice, gl);
     }
 
@@ -152,17 +152,17 @@ public:
         , mD3D(d3d)
         , mInteropDevice(interopDevice)
         , mGL(gl)
     { }
 
     ~DXInterop2Device() {
         const auto isCurrent = mGL->MakeCurrent();
 
-        if (mWGL->fDXCloseDevice(mInteropDevice))
+        if (mWGL->mSymbols.fDXCloseDeviceNV(mInteropDevice))
             return;
 
         if (isCurrent) {
             // That shouldn't have failed.
             const uint32_t error = GetLastError();
             const nsPrintfCString errorMessage("wglDXCloseDevice(0x%p) failed:"
                                                " GetLastError(): %u\n",
                                                mInteropDevice, error);
@@ -171,83 +171,83 @@ public:
     }
 
     HANDLE RegisterObject(void* d3dObject, GLuint name, GLenum type,
                           GLenum access) const
     {
         if (!mGL->MakeCurrent())
             return nullptr;
 
-        const auto ret = mWGL->fDXRegisterObject(mInteropDevice, d3dObject, name, type,
-                                                 access);
+        const auto& ret = mWGL->mSymbols.fDXRegisterObjectNV(mInteropDevice, d3dObject,
+                                                             name, type, access);
         if (ret)
             return ret;
 
         const uint32_t error = GetLastError();
         const nsPrintfCString errorMessage("wglDXRegisterObject(0x%p, 0x%p, %u, 0x%04x,"
                                            " 0x%04x) failed: GetLastError(): %u\n",
                                            mInteropDevice, d3dObject, name, type, access,
                                            error);
         gfxCriticalNote << errorMessage.BeginReading();
         return nullptr;
     }
 
     bool UnregisterObject(HANDLE lockHandle) const {
         const auto isCurrent = mGL->MakeCurrent();
 
-        if (mWGL->fDXUnregisterObject(mInteropDevice, lockHandle))
+        if (mWGL->mSymbols.fDXUnregisterObjectNV(mInteropDevice, lockHandle))
             return true;
 
         if (!isCurrent) {
             // That shouldn't have failed.
             const uint32_t error = GetLastError();
             const nsPrintfCString errorMessage("wglDXUnregisterObject(0x%p, 0x%p) failed:"
                                                " GetLastError(): %u\n",
                                                mInteropDevice, lockHandle, error);
             gfxCriticalError() << errorMessage.BeginReading();
         }
         return false;
     }
 
     bool LockObject(HANDLE lockHandle) const {
         MOZ_ASSERT(mGL->IsCurrent());
 
-        if (mWGL->fDXLockObjects(mInteropDevice, 1, &lockHandle))
+        if (mWGL->mSymbols.fDXLockObjectsNV(mInteropDevice, 1, &lockHandle))
             return true;
 
         if (!mGL->MakeCurrent())
             return false;
 
         gfxCriticalNote << "wglDXLockObjects called without mGL being current."
                         << " Retrying after MakeCurrent.";
 
-        if (mWGL->fDXLockObjects(mInteropDevice, 1, &lockHandle))
+        if (mWGL->mSymbols.fDXLockObjectsNV(mInteropDevice, 1, &lockHandle))
             return true;
 
         const uint32_t error = GetLastError();
         const nsPrintfCString errorMessage("wglDXLockObjects(0x%p, 1, {0x%p}) failed:"
                                            " GetLastError(): %u\n",
                                            mInteropDevice, lockHandle, error);
         gfxCriticalError() << errorMessage.BeginReading();
         return false;
     }
 
     bool UnlockObject(HANDLE lockHandle) const {
         MOZ_ASSERT(mGL->IsCurrent());
 
-        if (mWGL->fDXUnlockObjects(mInteropDevice, 1, &lockHandle))
+        if (mWGL->mSymbols.fDXUnlockObjectsNV(mInteropDevice, 1, &lockHandle))
             return true;
 
         if (!mGL->MakeCurrent())
             return false;
 
         gfxCriticalNote << "wglDXUnlockObjects called without mGL being current."
                         << " Retrying after MakeCurrent.";
 
-        if (mWGL->fDXUnlockObjects(mInteropDevice, 1, &lockHandle))
+        if (mWGL->mSymbols.fDXUnlockObjectsNV(mInteropDevice, 1, &lockHandle))
             return true;
 
         const uint32_t error = GetLastError();
         const nsPrintfCString errorMessage("wglDXUnlockObjects(0x%p, 1, {0x%p}) failed:"
                                            " GetLastError(): %u\n",
                                            mInteropDevice, lockHandle, error);
         gfxCriticalError() << errorMessage.BeginReading();
         return false;
--- a/gfx/gl/WGLLibrary.h
+++ b/gfx/gl/WGLLibrary.h
@@ -10,101 +10,72 @@ struct PRLibrary;
 
 namespace mozilla {
 namespace gl {
 
 class WGLLibrary
 {
 public:
     WGLLibrary()
-      : mInitialized(false)
+      : mSymbols{nullptr}
+      , mInitialized(false)
       , mOGLLibrary(nullptr)
       , mHasRobustness(false)
       , mWindow (0)
       , mWindowDC(0)
       , mWindowGLContext(0)
       , mWindowPixelFormat(0)
-    {}
-
-    typedef HGLRC (GLAPIENTRY * PFNWGLCREATECONTEXTPROC) (HDC);
-    PFNWGLCREATECONTEXTPROC fCreateContext;
-    typedef BOOL (GLAPIENTRY * PFNWGLDELETECONTEXTPROC) (HGLRC);
-    PFNWGLDELETECONTEXTPROC fDeleteContext;
-    typedef BOOL (GLAPIENTRY * PFNWGLMAKECURRENTPROC) (HDC, HGLRC);
-    PFNWGLMAKECURRENTPROC fMakeCurrent;
-    typedef PROC (GLAPIENTRY * PFNWGLGETPROCADDRESSPROC) (LPCSTR);
-    PFNWGLGETPROCADDRESSPROC fGetProcAddress;
-    typedef HGLRC (GLAPIENTRY * PFNWGLGETCURRENTCONTEXT) (void);
-    PFNWGLGETCURRENTCONTEXT fGetCurrentContext;
-    typedef HDC (GLAPIENTRY * PFNWGLGETCURRENTDC) (void);
-    PFNWGLGETCURRENTDC fGetCurrentDC;
-    typedef BOOL (GLAPIENTRY * PFNWGLSHARELISTS) (HGLRC oldContext, HGLRC newContext);
-    PFNWGLSHARELISTS fShareLists;
-
-    typedef HANDLE (WINAPI * PFNWGLCREATEPBUFFERPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int* piAttribList);
-    PFNWGLCREATEPBUFFERPROC fCreatePbuffer;
-    typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERPROC) (HANDLE hPbuffer);
-    PFNWGLDESTROYPBUFFERPROC fDestroyPbuffer;
-    typedef HDC (WINAPI * PFNWGLGETPBUFFERDCPROC) (HANDLE hPbuffer);
-    PFNWGLGETPBUFFERDCPROC fGetPbufferDC;
-
-    typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEPROC) (HANDLE hPbuffer, int iBuffer);
-    PFNWGLBINDTEXIMAGEPROC fBindTexImage;
-    typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEPROC) (HANDLE hPbuffer, int iBuffer);
-    PFNWGLRELEASETEXIMAGEPROC fReleaseTexImage;
-
-    typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATPROC) (HDC hdc, const int* piAttribIList, const FLOAT* pfAttribFList, UINT nMaxFormats, int* piFormats, UINT* nNumFormats);
-    PFNWGLCHOOSEPIXELFORMATPROC fChoosePixelFormat;
-    typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, int* piValues);
-    PFNWGLGETPIXELFORMATATTRIBIVPROC fGetPixelFormatAttribiv;
+    { }
 
-    typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGPROC) (HDC hdc);
-    PFNWGLGETEXTENSIONSSTRINGPROC fGetExtensionsString;
-
-    typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSPROC) (HDC hdc, HGLRC hShareContext, const int* attribList);
-    PFNWGLCREATECONTEXTATTRIBSPROC fCreateContextAttribs;
-
-    // WGL_NV_DX_interop:
-    // BOOL wglDXSetResourceShareHandleNV(void* dxObject, HANDLE shareHandle);
-    typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLEPROC) (void* dxObject, HANDLE shareHandle);
-    PFNWGLDXSETRESOURCESHAREHANDLEPROC fDXSetResourceShareHandle;
-
-    // HANDLE wglDXOpenDeviceNV(void* dxDevice);
-    typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICEPROC) (void* dxDevice);
-    PFNWGLDXOPENDEVICEPROC fDXOpenDevice;
-
-    // BOOL wglDXCloseDeviceNV(HANDLE hDevice);
-    typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICEPROC) (HANDLE hDevice);
-    PFNWGLDXCLOSEDEVICEPROC fDXCloseDevice;
-
-    // HANDLE wglDXRegisterObjectNV(HANDLE hDevice, void* dxObject, GLuint name, GLenum type, GLenum access);
-    typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTPROC) (HANDLE hDevice, void* dxObject, GLuint name, GLenum type, GLenum access);
-    PFNWGLDXREGISTEROBJECTPROC fDXRegisterObject;
-
-    // BOOL wglDXUnregisterObjectNV(HANDLE hDevice, HANDLE hObject);
-    typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECT) (HANDLE hDevice, HANDLE hObject);
-    PFNWGLDXUNREGISTEROBJECT fDXUnregisterObject;
-
-    // BOOL wglDXObjectAccessNV(HANDLE hObject, GLenum access);
-    typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSPROC) (HANDLE hObject, GLenum access);
-    PFNWGLDXOBJECTACCESSPROC fDXObjectAccess;
-
-    // BOOL wglDXLockObjectsNV(HANDLE hDevice, GLint count, HANDLE* hObjects);
-    typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSPROC) (HANDLE hDevice, GLint count, HANDLE* hObjects);
-    PFNWGLDXLOCKOBJECTSPROC fDXLockObjects;
-
-    // BOOL wglDXUnlockObjectsNV(HANDLE hDevice, GLint count, HANDLE* hObjects);
-    typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSPROC) (HANDLE hDevice, GLint count, HANDLE* hObjects);
-    PFNWGLDXUNLOCKOBJECTSPROC fDXUnlockObjects;
+public:
+    struct {
+        HGLRC  (GLAPIENTRY * fCreateContext) (HDC);
+        BOOL   (GLAPIENTRY * fDeleteContext) (HGLRC);
+        BOOL   (GLAPIENTRY * fMakeCurrent) (HDC, HGLRC);
+        PROC   (GLAPIENTRY * fGetProcAddress) (LPCSTR);
+        HGLRC  (GLAPIENTRY * fGetCurrentContext) (void);
+        HDC    (GLAPIENTRY * fGetCurrentDC) (void);
+        BOOL   (GLAPIENTRY * fShareLists) (HGLRC oldContext, HGLRC newContext);
+        HANDLE (GLAPIENTRY * fCreatePbuffer) (HDC hDC, int iPixelFormat, int iWidth,
+                                              int iHeight, const int* piAttribList);
+        BOOL (GLAPIENTRY * fDestroyPbuffer) (HANDLE hPbuffer);
+        HDC  (GLAPIENTRY * fGetPbufferDC) (HANDLE hPbuffer);
+        BOOL (GLAPIENTRY * fBindTexImage) (HANDLE hPbuffer, int iBuffer);
+        BOOL (GLAPIENTRY * fReleaseTexImage) (HANDLE hPbuffer, int iBuffer);
+        BOOL (GLAPIENTRY * fChoosePixelFormat) (HDC hdc, const int* piAttribIList,
+                                                const FLOAT* pfAttribFList,
+                                                UINT nMaxFormats, int* piFormats,
+                                                UINT* nNumFormats);
+        BOOL (GLAPIENTRY * fGetPixelFormatAttribiv) (HDC hdc, int iPixelFormat,
+                                                     int iLayerPlane, UINT nAttributes,
+                                                     int* piAttributes, int* piValues);
+        const char* (GLAPIENTRY * fGetExtensionsStringARB) (HDC hdc);
+        HGLRC (GLAPIENTRY * fCreateContextAttribsARB) (HDC hdc, HGLRC hShareContext,
+                                                       const int* attribList);
+        // WGL_NV_DX_interop:
+        BOOL   (GLAPIENTRY * fDXSetResourceShareHandleNV) (void* dxObject,
+                                                           HANDLE shareHandle);
+        HANDLE (GLAPIENTRY * fDXOpenDeviceNV) (void* dxDevice);
+        BOOL   (GLAPIENTRY * fDXCloseDeviceNV) (HANDLE hDevice);
+        HANDLE (GLAPIENTRY * fDXRegisterObjectNV) (HANDLE hDevice, void* dxObject,
+                                                   GLuint name, GLenum type,
+                                                   GLenum access);
+        BOOL   (GLAPIENTRY * fDXUnregisterObjectNV) (HANDLE hDevice, HANDLE hObject);
+        BOOL   (GLAPIENTRY * fDXObjectAccessNV) (HANDLE hObject, GLenum access);
+        BOOL   (GLAPIENTRY * fDXLockObjectsNV) (HANDLE hDevice, GLint count,
+                                                HANDLE* hObjects);
+        BOOL   (GLAPIENTRY * fDXUnlockObjectsNV) (HANDLE hDevice, GLint count,
+                                                  HANDLE* hObjects);
+    } mSymbols;
 
     bool EnsureInitialized();
     HWND CreateDummyWindow(HDC* aWindowDC = nullptr);
 
     bool HasRobustness() const { return mHasRobustness; }
-    bool HasDXInterop2() const { return bool(fDXOpenDevice); }
+    bool HasDXInterop2() const { return bool(mSymbols.fDXOpenDeviceNV); }
     bool IsInitialized() const { return mInitialized; }
     HWND GetWindow() const { return mWindow; }
     HDC GetWindowDC() const {return mWindowDC; }
     HGLRC GetWindowGLContext() const {return mWindowGLContext; }
     int GetWindowPixelFormat() const { return mWindowPixelFormat; }
     PRLibrary* GetOGLLibrary() { return mOGLLibrary; }
 
 private: