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,
|
sharedContext,
|
||||||
contextAttributes,
|
contextAttributes,
|
||||||
/* offset= */ 0);
|
/* offset= */ 0);
|
||||||
if (eglContext == null) {
|
if (eglContext == null || eglContext.equals(EGL14.EGL_NO_CONTEXT)) {
|
||||||
EGL14.eglTerminate(eglDisplay);
|
EGL14.eglTerminate(eglDisplay);
|
||||||
throw new GlException(
|
throw new GlException(
|
||||||
"eglCreateContext() failed to create a valid context. The device may not support EGL"
|
"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(
|
public static void destroyEglContext(
|
||||||
@Nullable EGLDisplay eglDisplay, @Nullable EGLContext eglContext) throws GlException {
|
@Nullable EGLDisplay eglDisplay, @Nullable EGLContext eglContext) throws GlException {
|
||||||
if (eglDisplay == null) {
|
if (eglDisplay == null || eglDisplay.equals(EGL14.EGL_NO_DISPLAY)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EGL14.eglMakeCurrent(
|
EGL14.eglMakeCurrent(
|
||||||
eglDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT);
|
eglDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT);
|
||||||
checkEglException("Error releasing context");
|
checkEglException("Error releasing context");
|
||||||
if (eglContext != null) {
|
if (eglContext != null && !eglContext.equals(EGL14.EGL_NO_CONTEXT)) {
|
||||||
EGL14.eglDestroyContext(eglDisplay, eglContext);
|
EGL14.eglDestroyContext(eglDisplay, eglContext);
|
||||||
checkEglException("Error destroying context");
|
checkEglException("Error destroying context");
|
||||||
}
|
}
|
||||||
@ -800,7 +800,10 @@ public final class GlUtil {
|
|||||||
*/
|
*/
|
||||||
public static void destroyEglSurface(
|
public static void destroyEglSurface(
|
||||||
@Nullable EGLDisplay eglDisplay, @Nullable EGLSurface eglSurface) throws GlException {
|
@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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user