Move platform entries init earlier

Test: cts-tradefed run singleCommand cts -m CtsGpuToolsHostTestCases
Test: Chromium starts up
Test: deqp - EGL, GLES2, GLES3
Bug: 110883880
Change-Id: I07bdb9552c6cd568eef0aa0499bf8a027e404d34
diff --git a/opengl/libs/EGL/Loader.cpp b/opengl/libs/EGL/Loader.cpp
index cd227ca..31712fc 100644
--- a/opengl/libs/EGL/Loader.cpp
+++ b/opengl/libs/EGL/Loader.cpp
@@ -238,12 +238,12 @@
 
     setEmulatorGlesValue();
 
-    dso = load_driver("GLES", cnx, EGL | GLESv1_CM | GLESv2 | PLATFORM);
+    dso = load_driver("GLES", cnx, EGL | GLESv1_CM | GLESv2);
     if (dso) {
         hnd = new driver_t(dso);
     } else {
         // Always load EGL first
-        dso = load_driver("EGL", cnx, EGL | PLATFORM);
+        dso = load_driver("EGL", cnx, EGL);
         if (dso) {
             hnd = new driver_t(dso);
             hnd->set( load_driver("GLESv1_CM", cnx, GLESv1_CM), GLESv1_CM );
@@ -635,25 +635,6 @@
             return nullptr;
     }
 
-    if (mask & PLATFORM) {
-        // For each entrypoint tracked by the platform
-        char const* const* entries = platform_names;
-        EGLFuncPointer* curr = reinterpret_cast<EGLFuncPointer*>(&cnx->platform);
-
-        while (*entries) {
-            const char* name = *entries;
-            EGLFuncPointer f = FindPlatformImplAddr(name);
-
-            if (f == nullptr) {
-                // If no entry found, update the lookup table: sPlatformImplMap
-                ALOGE("No entry found in platform lookup table for %s", name);
-            }
-
-            *curr++ = f;
-            entries++;
-        }
-    }
-
     if (mask & EGL) {
         getProcAddress = (getProcAddressType)dlsym(dso, "eglGetProcAddress");
 
diff --git a/opengl/libs/EGL/egldefs.h b/opengl/libs/EGL/egldefs.h
index d8606d3..77654b0 100644
--- a/opengl/libs/EGL/egldefs.h
+++ b/opengl/libs/EGL/egldefs.h
@@ -18,6 +18,9 @@
 #define ANDROID_EGLDEFS_H
 
 #include "../hooks.h"
+#include "egl_platform_entries.h"
+
+#include <log/log.h>
 
 #define VERSION_MAJOR 1
 #define VERSION_MINOR 4
@@ -31,13 +34,31 @@
 
 // ----------------------------------------------------------------------------
 
+extern char const * const platform_names[];
+
 struct egl_connection_t {
     enum {
         GLESv1_INDEX = 0,
         GLESv2_INDEX = 1
     };
 
-    inline egl_connection_t() : dso(nullptr) { }
+    inline egl_connection_t() : dso(nullptr) {
+
+        char const* const* entries = platform_names;
+        EGLFuncPointer* curr = reinterpret_cast<EGLFuncPointer*>(&platform);
+        while (*entries) {
+            const char* name = *entries;
+            EGLFuncPointer f = FindPlatformImplAddr(name);
+
+            if (f == nullptr) {
+                // If no entry found, update the lookup table: sPlatformImplMap
+                ALOGE("No entry found in platform lookup table for %s", name);
+            }
+
+            *curr++ = f;
+            entries++;
+        }
+    }
 
     void *              dso;
     gl_hooks_t *        hooks[2];
@@ -68,7 +89,6 @@
 extern char const * const gl_names[];
 extern char const * const gl_names_1[];
 extern char const * const egl_names[];
-extern char const * const platform_names[];
 
 extern egl_connection_t gEGLImpl;