summaryrefslogtreecommitdiff
path: root/core/java/android/os/GraphicsEnvironment.java
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2017-01-21 05:04:21 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-01-21 05:04:24 +0000
commitf2a54b6a39e62eb6d0538180b831705d2e629a29 (patch)
tree7d9bd35a71d46ebf390eb2f354bbc6713493c2bf /core/java/android/os/GraphicsEnvironment.java
parentc281fd12af719d71322aed3c4410bf0a4cccdbd2 (diff)
parentfd104e7fde7f53700da58cbab57d73b938b837a7 (diff)
Merge "Load EGL early in Activity launch, instead of in Zygote" into nyc-mr2-dev
Diffstat (limited to 'core/java/android/os/GraphicsEnvironment.java')
-rw-r--r--core/java/android/os/GraphicsEnvironment.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/core/java/android/os/GraphicsEnvironment.java b/core/java/android/os/GraphicsEnvironment.java
index 4b130ed1adc8..20de370fa344 100644
--- a/core/java/android/os/GraphicsEnvironment.java
+++ b/core/java/android/os/GraphicsEnvironment.java
@@ -19,6 +19,7 @@ package android.os;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
+import android.opengl.EGL14;
import android.os.SystemProperties;
import android.util.Log;
@@ -34,6 +35,23 @@ public final class GraphicsEnvironment {
private static final String PROPERTY_GFX_DRIVER = "ro.gfx.driver.0";
public static void setupGraphicsEnvironment(Context context) {
+ chooseDriver(context);
+
+ // Now that we've figured out which driver to use for this process, load and initialize it.
+ // This can take multiple frame periods, and it would otherwise happen as part of the first
+ // frame, increasing first-frame latency. Starting it here, as a low-priority background
+ // thread, means that it's usually done long before we start drawing the first frame,
+ // without significantly disrupting other activity launch work.
+ Thread eglInitThread = new Thread(
+ () -> {
+ Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
+ EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
+ },
+ "EGL Init");
+ eglInitThread.start();
+ }
+
+ private static void chooseDriver(Context context) {
String driverPackageName = SystemProperties.get(PROPERTY_GFX_DRIVER);
if (driverPackageName == null || driverPackageName.isEmpty()) {
return;