Commit 7d93f2d4 by huangdarwin Committed by Oliver Woodman

Transformer GL: Remove UnsupportedEglVersionException().

UnsupportedEglVersionException() is only used once, and seems a bit too
specific for Transformer. Also, it's possible for eglCreateContext to fail for
other reasons besides lack of support, so it wasn't always accurate when
thrown.

It is possible for devices not to support EGL version 2.0 though, per
https://source.android.com/devices/graphics/implement-opengl-es, which doesn't
specify the EGL version that must be supported.

PiperOrigin-RevId: 415489396
parent 18248733
...@@ -53,9 +53,6 @@ public final class GlUtil { ...@@ -53,9 +53,6 @@ public final class GlUtil {
} }
} }
/** Thrown when the required EGL version is not supported by the device. */
public static final class UnsupportedEglVersionException extends Exception {}
/** /**
* Represents a GLSL shader program. * Represents a GLSL shader program.
* *
...@@ -259,15 +256,9 @@ public final class GlUtil { ...@@ -259,15 +256,9 @@ public final class GlUtil {
return Api17.createEglDisplay(); return Api17.createEglDisplay();
} }
/** /** Returns a new {@link EGLContext} for the specified {@link EGLDisplay}. */
* Returns a new {@link EGLContext} for the specified {@link EGLDisplay}.
*
* @throws UnsupportedEglVersionException If the device does not support EGL version 2. {@code
* eglDisplay} is terminated before the exception is thrown in this case.
*/
@RequiresApi(17) @RequiresApi(17)
public static EGLContext createEglContext(EGLDisplay eglDisplay) public static EGLContext createEglContext(EGLDisplay eglDisplay) {
throws UnsupportedEglVersionException {
return Api17.createEglContext(eglDisplay); return Api17.createEglContext(eglDisplay);
} }
...@@ -637,8 +628,7 @@ public final class GlUtil { ...@@ -637,8 +628,7 @@ public final class GlUtil {
} }
@DoNotInline @DoNotInline
public static EGLContext createEglContext(EGLDisplay eglDisplay) public static EGLContext createEglContext(EGLDisplay eglDisplay) {
throws UnsupportedEglVersionException {
int[] contextAttributes = {EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE}; int[] contextAttributes = {EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE};
EGLContext eglContext = EGLContext eglContext =
EGL14.eglCreateContext( EGL14.eglCreateContext(
...@@ -649,7 +639,9 @@ public final class GlUtil { ...@@ -649,7 +639,9 @@ public final class GlUtil {
/* offset= */ 0); /* offset= */ 0);
if (eglContext == null) { if (eglContext == null) {
EGL14.eglTerminate(eglDisplay); EGL14.eglTerminate(eglDisplay);
throw new UnsupportedEglVersionException(); throwGlException(
"eglCreateContext() failed to create a valid context. The device may not support EGL"
+ " version 2");
} }
checkGlError(); checkGlError();
return eglContext; return eglContext;
......
...@@ -60,12 +60,7 @@ import java.util.concurrent.atomic.AtomicInteger; ...@@ -60,12 +60,7 @@ import java.util.concurrent.atomic.AtomicInteger;
Surface outputSurface, Surface outputSurface,
Transformer.DebugViewProvider debugViewProvider) { Transformer.DebugViewProvider debugViewProvider) {
EGLDisplay eglDisplay = GlUtil.createEglDisplay(); EGLDisplay eglDisplay = GlUtil.createEglDisplay();
EGLContext eglContext; EGLContext eglContext = GlUtil.createEglContext(eglDisplay);
try {
eglContext = GlUtil.createEglContext(eglDisplay);
} catch (GlUtil.UnsupportedEglVersionException e) {
throw new IllegalStateException("EGL version is unsupported", e);
}
EGLSurface eglSurface = GlUtil.getEglSurface(eglDisplay, outputSurface); EGLSurface eglSurface = GlUtil.getEglSurface(eglDisplay, outputSurface);
GlUtil.focusSurface(eglDisplay, eglContext, eglSurface, outputWidth, outputHeight); GlUtil.focusSurface(eglDisplay, eglContext, eglSurface, outputWidth, outputHeight);
int textureId = GlUtil.createExternalTexture(); int textureId = GlUtil.createExternalTexture();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment