From 76b65afddbc4af3d898f5d4a9430527a87841c57 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Thu, 21 Nov 2013 16:47:20 -0500 Subject: [PATCH] Bug 834243 - Revert to old behavior of holding off from starting the compositor until we have successfully preallocated its EGLSurface - r=snorp --- mobile/android/base/gfx/GLController.java | 28 +++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/mobile/android/base/gfx/GLController.java b/mobile/android/base/gfx/GLController.java index 780faa6d3244..169d85fa4a85 100644 --- a/mobile/android/base/gfx/GLController.java +++ b/mobile/android/base/gfx/GLController.java @@ -46,6 +46,7 @@ public class GLController { private EGL10 mEGL; private EGLDisplay mEGLDisplay; private EGLConfig mEGLConfig; + private EGLSurface mEGLSurfaceForCompositor; private static final int LOCAL_EGL_OPENGL_ES2_BIT = 4; @@ -84,6 +85,11 @@ public class GLController { mServerSurfaceValid = false; + if (mEGLSurfaceForCompositor != null) { + mEGL.eglDestroySurface(mEGLDisplay, mEGLSurfaceForCompositor); + mEGLSurfaceForCompositor = null; + } + // We need to coordinate with Gecko when pausing composition, to ensure // that Gecko never executes a draw event while the compositor is paused. // This is sent synchronously to make sure that we don't attempt to use @@ -132,6 +138,10 @@ public class GLController { return; } + if (!AttemptPreallocateEGLSurfaceForCompositor()) { + return; + } + // Only try to create the compositor if we have a valid surface and gecko is up. When these // two conditions are satisfied, we can be relatively sure that the compositor creation will // happen without needing to block anyhwere. Do it with a sync gecko event so that the @@ -215,12 +225,22 @@ public class GLController { throw new GLControllerException("No suitable EGL configuration found"); } - @GeneratableAndroidBridgeTarget(allowMultithread = true, stubName = "CreateEGLSurfaceForCompositorWrapper") - private EGLSurface createEGLSurfaceForCompositor() { - initEGL(); - return mEGL.eglCreateWindowSurface(mEGLDisplay, mEGLConfig, mView.getNativeWindow(), null); + private synchronized boolean AttemptPreallocateEGLSurfaceForCompositor() { + if (mEGLSurfaceForCompositor == null) { + initEGL(); + mEGLSurfaceForCompositor = mEGL.eglCreateWindowSurface(mEGLDisplay, mEGLConfig, mView.getNativeWindow(), null); + } + return mEGLSurfaceForCompositor != null; } + @GeneratableAndroidBridgeTarget(allowMultithread = true, stubName = "CreateEGLSurfaceForCompositorWrapper") + private synchronized EGLSurface createEGLSurfaceForCompositor() { + AttemptPreallocateEGLSurfaceForCompositor(); + EGLSurface result = mEGLSurfaceForCompositor; + mEGLSurfaceForCompositor = null; + return result; + } + private String getEGLError() { return "Error " + (mEGL == null ? "(no mEGL)" : mEGL.eglGetError()); }