diff --git a/mobile/android/base/gfx/GLController.java b/mobile/android/base/gfx/GLController.java index ff8f4ded610..900662e37ba 100644 --- a/mobile/android/base/gfx/GLController.java +++ b/mobile/android/base/gfx/GLController.java @@ -20,48 +20,6 @@ import javax.microedition.khronos.egl.EGLContext; import javax.microedition.khronos.egl.EGLDisplay; import javax.microedition.khronos.egl.EGLSurface; -/** - * EGLPreloadingThread is purely a preloading optimization, not something - * we rely on for anything else than performance. We will be initializing - * EGL in GLController::initEGL() when we need it, but having EGL initialization - * already previously done by EGLPreloadingThread::run() will make it much - * faster for GLController to do again. - * - * For example, here are some timings recorded on two devices: - * - * Device | EGLPreloadingThread::run() | GLController::initEGL() - * -----------------------+----------------------------+------------------------ - * Nexus S (Android 2.3) | ~ 80 ms | < 0.1 ms - * Nexus 10 (Android 4.3) | ~ 35 ms | < 0.1 ms - */ -class EGLPreloadingThread extends Thread -{ - private static final String LOGTAG = "EGLPreloadingThread"; - private EGL10 mEGL; - private EGLDisplay mEGLDisplay; - - public EGLPreloadingThread() - { - } - - @Override - public void run() - { - mEGL = (EGL10)EGLContext.getEGL(); - mEGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); - if (mEGLDisplay == EGL10.EGL_NO_DISPLAY) { - Log.w(LOGTAG, "Can't get EGL display!"); - return; - } - - int[] returnedVersion = new int[2]; - if (!mEGL.eglInitialize(mEGLDisplay, returnedVersion)) { - Log.w(LOGTAG, "eglInitialize failed"); - return; - } - } -} - /** * This class is a singleton that tracks EGL and compositor things over * the lifetime of Fennec running. @@ -89,7 +47,6 @@ public class GLController { private EGL10 mEGL; private EGLDisplay mEGLDisplay; private EGLConfig mEGLConfig; - private final EGLPreloadingThread mEGLPreloadingThread; private EGLSurface mEGLSurfaceForCompositor; private static final int LOCAL_EGL_OPENGL_ES2_BIT = 4; @@ -113,12 +70,6 @@ public class GLController { }; private GLController() { - if (AppConstants.Versions.preICS) { - mEGLPreloadingThread = new EGLPreloadingThread(); - mEGLPreloadingThread.start(); - } else { - mEGLPreloadingThread = null; - } } static GLController getInstance(LayerView view) { @@ -211,19 +162,6 @@ public class GLController { return; } - // This join() should not be necessary, but makes this code a bit easier to think about. - // The EGLPreloadingThread should long be done by now, and even if it's not, - // it shouldn't be a problem to be initializing EGL from two different threads. - // Still, having this join() here means that we don't have to wonder about what - // kind of caveats might exist with EGL initialization reentrancy on various drivers. - if (mEGLPreloadingThread != null) { - try { - mEGLPreloadingThread.join(); - } catch (InterruptedException e) { - Log.w(LOGTAG, "EGLPreloadingThread interrupted", e); - } - } - mEGL = (EGL10)EGLContext.getEGL(); mEGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); @@ -232,20 +170,18 @@ public class GLController { return; } - if (AppConstants.Versions.preICS) { - // while calling eglInitialize here should not be necessary as it was already called - // by the EGLPreloadingThread, it really doesn't cost much to call it again here, - // and makes this code easier to think about: EGLPreloadingThread is only a - // preloading optimization, not something we rely on for anything else. - // - // Also note that while calling eglInitialize isn't necessary on Android 4.x - // (at least Android's HardwareRenderer does it for us already), it is necessary - // on Android 2.x. - int[] returnedVersion = new int[2]; - if (!mEGL.eglInitialize(mEGLDisplay, returnedVersion)) { - Log.w(LOGTAG, "eglInitialize failed"); - return; - } + // while calling eglInitialize here should not be necessary as it was already called + // by the EGLPreloadingThread, it really doesn't cost much to call it again here, + // and makes this code easier to think about: EGLPreloadingThread is only a + // preloading optimization, not something we rely on for anything else. + // + // Also note that while calling eglInitialize isn't necessary on Android 4.x + // (at least Android's HardwareRenderer does it for us already), it is necessary + // on Android 2.x. + int[] returnedVersion = new int[2]; + if (!mEGL.eglInitialize(mEGLDisplay, returnedVersion)) { + Log.w(LOGTAG, "eglInitialize failed"); + return; } mEGLConfig = chooseConfig();