Bug fixes to EglBase10Impl.getNativeEglContext.
- Use matching config to avoid EGL_BAD_MATCH. - Use the same display in both eglMakeCurrent calls to avoid EGL_BAD_ACCESS on subsequent calls because the context was not successfully unbound. Bug: webrtc:12471 Change-Id: Ifdf4bd94cdfd14b683959b8703d75a2a46ec1226 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/207861 Reviewed-by: Paulina Hensman <phensman@webrtc.org> Commit-Queue: Sami Kalliomäki <sakal@webrtc.org> Cr-Commit-Position: refs/heads/master@{#33279}
This commit is contained in:
committed by
Commit Bot
parent
067b050213
commit
bdf78cb5bb
@ -41,6 +41,7 @@ class EglBase10Impl implements EglBase10 {
|
||||
private static class Context implements EglBase10.Context {
|
||||
private final EGL10 egl;
|
||||
private final EGLContext eglContext;
|
||||
private final EGLConfig eglContextConfig;
|
||||
|
||||
@Override
|
||||
public EGLContext getRawContext() {
|
||||
@ -50,21 +51,23 @@ class EglBase10Impl implements EglBase10 {
|
||||
@Override
|
||||
public long getNativeEglContext() {
|
||||
EGLContext previousContext = egl.eglGetCurrentContext();
|
||||
EGLDisplay previousDisplay = egl.eglGetCurrentDisplay();
|
||||
EGLDisplay currentDisplay = egl.eglGetCurrentDisplay();
|
||||
EGLSurface previousDrawSurface = egl.eglGetCurrentSurface(EGL10.EGL_DRAW);
|
||||
EGLSurface previousReadSurface = egl.eglGetCurrentSurface(EGL10.EGL_READ);
|
||||
EGLSurface tempEglSurface = null;
|
||||
|
||||
EGLDisplay defaultDisplay = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
|
||||
if (currentDisplay == EGL10.EGL_NO_DISPLAY) {
|
||||
currentDisplay = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
|
||||
}
|
||||
|
||||
try {
|
||||
if (previousContext != eglContext) {
|
||||
int[] surfaceAttribs = {EGL10.EGL_WIDTH, 1, EGL10.EGL_HEIGHT, 1, EGL10.EGL_NONE};
|
||||
EGLConfig eglConfig = getEglConfig(egl, defaultDisplay, EglBase.CONFIG_PIXEL_BUFFER);
|
||||
|
||||
tempEglSurface = egl.eglCreatePbufferSurface(defaultDisplay, eglConfig, surfaceAttribs);
|
||||
if (!egl.eglMakeCurrent(defaultDisplay, tempEglSurface, tempEglSurface, eglContext)) {
|
||||
throw new RuntimeException("Failed to make temporary EGL surface active.");
|
||||
tempEglSurface =
|
||||
egl.eglCreatePbufferSurface(currentDisplay, eglContextConfig, surfaceAttribs);
|
||||
if (!egl.eglMakeCurrent(currentDisplay, tempEglSurface, tempEglSurface, eglContext)) {
|
||||
throw new RuntimeException(
|
||||
"Failed to make temporary EGL surface active: " + egl.eglGetError());
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,15 +75,16 @@ class EglBase10Impl implements EglBase10 {
|
||||
} finally {
|
||||
if (tempEglSurface != null) {
|
||||
egl.eglMakeCurrent(
|
||||
previousDisplay, previousDrawSurface, previousReadSurface, previousContext);
|
||||
egl.eglDestroySurface(defaultDisplay, tempEglSurface);
|
||||
currentDisplay, previousDrawSurface, previousReadSurface, previousContext);
|
||||
egl.eglDestroySurface(currentDisplay, tempEglSurface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Context(EGL10 egl, EGLContext eglContext) {
|
||||
public Context(EGL10 egl, EGLContext eglContext, EGLConfig eglContextConfig) {
|
||||
this.egl = egl;
|
||||
this.eglContext = eglContext;
|
||||
this.eglContextConfig = eglContextConfig;
|
||||
}
|
||||
}
|
||||
|
||||
@ -210,7 +214,7 @@ class EglBase10Impl implements EglBase10 {
|
||||
|
||||
@Override
|
||||
public org.webrtc.EglBase.Context getEglBaseContext() {
|
||||
return new Context(egl, eglContext);
|
||||
return new Context(egl, eglContext, eglConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user