Destroy GL context when releasing dummy surface
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=165293386
This commit is contained in:
parent
757bcf7c63
commit
f8e47553e8
@ -34,6 +34,7 @@ import static android.opengl.EGL14.EGL_WINDOW_BIT;
|
|||||||
import static android.opengl.EGL14.eglChooseConfig;
|
import static android.opengl.EGL14.eglChooseConfig;
|
||||||
import static android.opengl.EGL14.eglCreateContext;
|
import static android.opengl.EGL14.eglCreateContext;
|
||||||
import static android.opengl.EGL14.eglCreatePbufferSurface;
|
import static android.opengl.EGL14.eglCreatePbufferSurface;
|
||||||
|
import static android.opengl.EGL14.eglDestroyContext;
|
||||||
import static android.opengl.EGL14.eglGetDisplay;
|
import static android.opengl.EGL14.eglGetDisplay;
|
||||||
import static android.opengl.EGL14.eglInitialize;
|
import static android.opengl.EGL14.eglInitialize;
|
||||||
import static android.opengl.EGL14.eglMakeCurrent;
|
import static android.opengl.EGL14.eglMakeCurrent;
|
||||||
@ -164,6 +165,8 @@ public final class DummySurface extends Surface {
|
|||||||
private static final int MSG_RELEASE = 3;
|
private static final int MSG_RELEASE = 3;
|
||||||
|
|
||||||
private final int[] textureIdHolder;
|
private final int[] textureIdHolder;
|
||||||
|
private EGLContext context;
|
||||||
|
private EGLDisplay display;
|
||||||
private Handler handler;
|
private Handler handler;
|
||||||
private SurfaceTexture surfaceTexture;
|
private SurfaceTexture surfaceTexture;
|
||||||
|
|
||||||
@ -248,7 +251,7 @@ public final class DummySurface extends Surface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initInternal(boolean secure) {
|
private void initInternal(boolean secure) {
|
||||||
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||||
Assertions.checkState(display != null, "eglGetDisplay failed");
|
Assertions.checkState(display != null, "eglGetDisplay failed");
|
||||||
|
|
||||||
int[] version = new int[2];
|
int[] version = new int[2];
|
||||||
@ -285,8 +288,8 @@ public final class DummySurface extends Surface {
|
|||||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||||
EGL_NONE};
|
EGL_NONE};
|
||||||
}
|
}
|
||||||
EGLContext context = eglCreateContext(display, config, android.opengl.EGL14.EGL_NO_CONTEXT,
|
context = eglCreateContext(display, config, android.opengl.EGL14.EGL_NO_CONTEXT, glAttributes,
|
||||||
glAttributes, 0);
|
0);
|
||||||
Assertions.checkState(context != null, "eglCreateContext failed");
|
Assertions.checkState(context != null, "eglCreateContext failed");
|
||||||
|
|
||||||
int[] pbufferAttributes;
|
int[] pbufferAttributes;
|
||||||
@ -316,12 +319,19 @@ public final class DummySurface extends Surface {
|
|||||||
|
|
||||||
private void releaseInternal() {
|
private void releaseInternal() {
|
||||||
try {
|
try {
|
||||||
|
if (surfaceTexture != null) {
|
||||||
surfaceTexture.release();
|
surfaceTexture.release();
|
||||||
} finally {
|
|
||||||
surface = null;
|
|
||||||
surfaceTexture = null;
|
|
||||||
glDeleteTextures(1, textureIdHolder, 0);
|
glDeleteTextures(1, textureIdHolder, 0);
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
if (context != null) {
|
||||||
|
eglDestroyContext(display, context);
|
||||||
|
}
|
||||||
|
display = null;
|
||||||
|
context = null;
|
||||||
|
surface = null;
|
||||||
|
surfaceTexture = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user