OSDN Git Service

Load the emulation libraries only when qemu.gles=1
authorNicolas Capens <capn@google.com>
Fri, 6 Nov 2015 15:10:21 +0000 (10:10 -0500)
committerNicolas Capens <nicolascapens@google.com>
Thu, 19 Nov 2015 14:59:14 +0000 (14:59 +0000)
Bug 25467020

Change-Id: I4a47f369078af03e4146b3b96a7e7a8e8390da61
(cherry picked from commit 8404ebc7487ebcf317e88c78cbb81e238fb55c3f)

opengl/libs/EGL/Loader.cpp

index 0f58f96..e593a72 100644 (file)
@@ -68,7 +68,9 @@ ANDROID_SINGLETON_STATIC_INSTANCE( Loader )
  *  -1   -> not running inside the emulator
  *   0   -> running inside the emulator, but GPU emulation not supported
  *   1   -> running inside the emulator, GPU emulation is supported
- *          through the "emulation" config.
+ *          through the "emulation" host-side OpenGL ES implementation.
+ *   2   -> running inside the emulator, GPU emulation is supported
+ *          through a guest-side vendor driver's OpenGL ES implementation.
  */
 static int
 checkGlesEmulationStatus(void)
@@ -275,6 +277,30 @@ void *Loader::load_driver(const char* kind,
     public:
         static String8 find(const char* kind) {
             String8 result;
+            int emulationStatus = checkGlesEmulationStatus();
+            switch (emulationStatus) {
+                case 0:
+                    ALOGD("Emulator without GPU support detected. "
+                          "Fallback to legacy software renderer.");
+#if defined(__LP64__)
+                    result.setTo("/system/lib64/egl/libGLES_android.so");
+#else
+                    result.setTo("/system/lib/egl/libGLES_android.so");
+#endif
+                    return result;
+                case 1:
+                    // Use host-side OpenGL through the "emulation" library
+#if defined(__LP64__)
+                    result.appendFormat("/system/lib64/egl/lib%s_emulation.so", kind);
+#else
+                    result.appendFormat("/system/lib/egl/lib%s_emulation.so", kind);
+#endif
+                    return result;
+                default:
+                    // Not in emulator, or use other guest-side implementation
+                    break;
+            }
+
             String8 pattern;
             pattern.appendFormat("lib%s", kind);
             const char* const searchPaths[] = {
@@ -319,20 +345,6 @@ void *Loader::load_driver(const char* kind,
     private:
         static bool find(String8& result,
                 const String8& pattern, const char* const search, bool exact) {
-
-            // in the emulator case, we just return the hardcoded name
-            // of the software renderer.
-            if (checkGlesEmulationStatus() == 0) {
-                ALOGD("Emulator without GPU support detected. "
-                      "Fallback to software renderer.");
-#if defined(__LP64__)
-                result.setTo("/system/lib64/egl/libGLES_android.so");
-#else
-                result.setTo("/system/lib/egl/libGLES_android.so");
-#endif
-                return true;
-            }
-
             if (exact) {
                 String8 absolutePath;
                 absolutePath.appendFormat("%s/%s.so", search, pattern.string());