Bug 1344433 - Fix ANGLE symbol loading. - r=daoshengmu draft
authorJeff Gilbert <jgilbert@mozilla.com>
Fri, 03 Mar 2017 20:38:57 -0800
changeset 493551 584d81639d7375fef0db66811c610e60b78d6879
parent 493550 f29fb486aefaf2e0832f37acfc7b935f57a6919b
child 494229 6144f7e245a7407e5fa41081b8daad60d081b239
push id47799
push userbmo:jgilbert@mozilla.com
push dateSat, 04 Mar 2017 22:02:43 +0000
reviewersdaoshengmu
bugs1344433
milestone54.0a1
Bug 1344433 - Fix ANGLE symbol loading. - r=daoshengmu MozReview-Commit-ID: 2lUJJ8k3AsT
gfx/gl/GLLibraryEGL.cpp
--- a/gfx/gl/GLLibraryEGL.cpp
+++ b/gfx/gl/GLLibraryEGL.cpp
@@ -441,36 +441,38 @@ GLLibraryEGL::EnsureInitialized(bool for
     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)) {
-        const GLLibraryLoader::SymLoadStruct d3dSymbols[] = {
-            SYMBOL(ANGLEPlatformInitialize),
-            SYMBOL(ANGLEPlatformShutdown),
-            SYMBOL(GetPlatformDisplayEXT),
-            END_OF_SYMBOLS
-        };
-        if (!fnLoadSymbols(d3dSymbols)) {
-            NS_ERROR("EGL supports ANGLE_platform_angle_d3d without exposing its functions!");
-            MarkExtensionUnsupported(ANGLE_platform_angle_d3d);
-        }
-    }
-
     // 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;
 
+    // Client exts are ready. (But not display exts!)
+
+    if (mIsANGLE) {
+        MOZ_ASSERT(IsExtensionSupported(ANGLE_platform_angle_d3d));
+        const GLLibraryLoader::SymLoadStruct angleSymbols[] = {
+            { (PRFuncPtr*)&mSymbols.fANGLEPlatformInitialize, { "ANGLEPlatformInitialize", nullptr } },
+            { (PRFuncPtr*)&mSymbols.fANGLEPlatformShutdown, { "ANGLEPlatformShutdown", nullptr } },
+            SYMBOL(GetPlatformDisplayEXT),
+            END_OF_SYMBOLS
+        };
+        if (!fnLoadSymbols(angleSymbols)) {
+            gfxCriticalError() << "Failed to load ANGLE symbols!";
+            return false;
+        }
+    }
+
     if (IsExtensionSupported(ANGLE_platform_angle_d3d)) {
         nsCString accelAngleFailureId;
         bool accelAngleSupport = IsAccelAngleSupported(gfxInfo, &accelAngleFailureId);
         bool shouldTryAccel = forceAccel || accelAngleSupport;
         bool shouldTryWARP = !forceAccel; // Only if ANGLE not supported or fails
 
         // If WARP preferred, will override ANGLE support
         if (gfxPrefs::WebGLANGLEForceWARP()) {