Check for EGL_NO_SURFACE and similar in GlUtil
`== null` does not check for equality with EGL_NO_SURFACE, EGL_NO_CONTEXT, or EGL_NO_DISPLAY. PiperOrigin-RevId: 657651835
This commit is contained in:
parent
04bfeec751
commit
3f49f5c157
@ -293,7 +293,7 @@ public final class GlUtil {
|
||||
sharedContext,
|
||||
contextAttributes,
|
||||
/* offset= */ 0);
|
||||
if (eglContext == null) {
|
||||
if (eglContext == null || eglContext.equals(EGL14.EGL_NO_CONTEXT)) {
|
||||
EGL14.eglTerminate(eglDisplay);
|
||||
throw new GlException(
|
||||
"eglCreateContext() failed to create a valid context. The device may not support EGL"
|
||||
@ -778,13 +778,13 @@ public final class GlUtil {
|
||||
*/
|
||||
public static void destroyEglContext(
|
||||
@Nullable EGLDisplay eglDisplay, @Nullable EGLContext eglContext) throws GlException {
|
||||
if (eglDisplay == null) {
|
||||
if (eglDisplay == null || eglDisplay.equals(EGL14.EGL_NO_DISPLAY)) {
|
||||
return;
|
||||
}
|
||||
EGL14.eglMakeCurrent(
|
||||
eglDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT);
|
||||
checkEglException("Error releasing context");
|
||||
if (eglContext != null) {
|
||||
if (eglContext != null && !eglContext.equals(EGL14.EGL_NO_CONTEXT)) {
|
||||
EGL14.eglDestroyContext(eglDisplay, eglContext);
|
||||
checkEglException("Error destroying context");
|
||||
}
|
||||
@ -800,7 +800,10 @@ public final class GlUtil {
|
||||
*/
|
||||
public static void destroyEglSurface(
|
||||
@Nullable EGLDisplay eglDisplay, @Nullable EGLSurface eglSurface) throws GlException {
|
||||
if (eglDisplay == null || eglSurface == null) {
|
||||
if (eglDisplay == null || eglDisplay.equals(EGL14.EGL_NO_DISPLAY)) {
|
||||
return;
|
||||
}
|
||||
if (eglSurface == null || eglSurface.equals(EGL14.EGL_NO_SURFACE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user