From c002936e4bd042db3024202b3e9696835a730cfa Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Mon, 24 Sep 2012 20:18:13 -0700 Subject: [PATCH] Trigger the log when EGL_NO_CONTEXT is returned by eglCreateContext Bug #7216919 Change-Id: If2059227d55e8ddb2d2673ee36029c3c92dd9a3d --- core/java/android/view/HardwareRenderer.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java index 49f9e9dec1407..39deca2a81252 100644 --- a/core/java/android/view/HardwareRenderer.java +++ b/core/java/android/view/HardwareRenderer.java @@ -864,12 +864,6 @@ public abstract class HardwareRenderer { if (mEglContext == null) { mEglContext = createContext(sEgl, sEglDisplay, sEglConfig); - if (mEglContext == null) { - //noinspection ConstantConditions - throw new IllegalStateException("Could not create an EGL context. " + - "eglCreateContext failed with error: " + - GLUtils.getEGLErrorString(sEgl.eglGetError())); - } sEglContextStorage.set(createManagedContext(mEglContext)); } } @@ -998,8 +992,15 @@ public abstract class HardwareRenderer { EGLContext createContext(EGL10 egl, EGLDisplay eglDisplay, EGLConfig eglConfig) { int[] attribs = { EGL_CONTEXT_CLIENT_VERSION, mGlVersion, EGL_NONE }; - return egl.eglCreateContext(eglDisplay, eglConfig, EGL_NO_CONTEXT, - mGlVersion != 0 ? attribs : null); + EGLContext context = egl.eglCreateContext(eglDisplay, eglConfig, EGL_NO_CONTEXT, + mGlVersion != 0 ? attribs : null); + if (context == null) { + //noinspection ConstantConditions + throw new IllegalStateException( + "Could not create an EGL context. eglCreateContext failed with error: " + + GLUtils.getEGLErrorString(sEgl.eglGetError())); + } + return context; } @Override