Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 14 additions & 19 deletions sdk/android/src/java/org/webrtc/EglBase10Impl.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ public long getNativeEglContext() {
tempEglSurface =
egl.eglCreatePbufferSurface(currentDisplay, eglContextConfig, surfaceAttribs);
if (!egl.eglMakeCurrent(currentDisplay, tempEglSurface, tempEglSurface, eglContext)) {
throw new GLException(egl.eglGetError(),
"Failed to make temporary EGL surface active: " + egl.eglGetError());
throwEglException(egl.eglGetError(), "Failed to make temporary EGL surface active");
}
}

Expand Down Expand Up @@ -162,8 +161,7 @@ public void makeCurrent(EGLSurface eglSurface) {

synchronized (EglBase.lock) {
if (!egl.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)) {
throw new GLException(egl.eglGetError(),
"eglMakeCurrent failed: 0x" + Integer.toHexString(egl.eglGetError()));
throwEglException(egl.eglGetError(), "eglMakeCurrent failed");
}
}
currentSurface = eglSurface;
Expand All @@ -173,8 +171,7 @@ public void detachCurrent() {
synchronized (EglBase.lock) {
if (!egl.eglMakeCurrent(
eglDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT)) {
throw new GLException(egl.eglGetError(),
"eglDetachCurrent failed: 0x" + Integer.toHexString(egl.eglGetError()));
throwEglException(egl.eglGetError(), "eglDetachCurrent failed");
}
}
currentSurface = EGL10.EGL_NO_SURFACE;
Expand Down Expand Up @@ -281,8 +278,7 @@ private void createSurfaceInternal(Object nativeWindow) {
eglSurface = egl.eglCreateWindowSurface(
eglConnection.getDisplay(), eglConnection.getConfig(), nativeWindow, surfaceAttribs);
if (eglSurface == EGL10.EGL_NO_SURFACE) {
throw new GLException(egl.eglGetError(),
"Failed to create window surface: 0x" + Integer.toHexString(egl.eglGetError()));
throwEglException(egl.eglGetError(), "Failed to create window surface");
}
}

Expand All @@ -303,9 +299,8 @@ public void createPbufferSurface(int width, int height) {
eglSurface = egl.eglCreatePbufferSurface(
eglConnection.getDisplay(), eglConnection.getConfig(), surfaceAttribs);
if (eglSurface == EGL10.EGL_NO_SURFACE) {
throw new GLException(egl.eglGetError(),
"Failed to create pixel buffer surface with size " + width + "x" + height + ": 0x"
+ Integer.toHexString(egl.eglGetError()));
throwEglException(egl.eglGetError(),
"Failed to create pixel buffer surface with size " + width + "x" + height);
}
}

Expand Down Expand Up @@ -394,13 +389,11 @@ public void swapBuffers(long timeStampNs) {
private static EGLDisplay getEglDisplay(EGL10 egl) {
EGLDisplay eglDisplay = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
if (eglDisplay == EGL10.EGL_NO_DISPLAY) {
throw new GLException(egl.eglGetError(),
"Unable to get EGL10 display: 0x" + Integer.toHexString(egl.eglGetError()));
throwEglException(egl.eglGetError(), "Unable to get EGL10 display");
}
int[] version = new int[2];
if (!egl.eglInitialize(eglDisplay, version)) {
throw new GLException(egl.eglGetError(),
"Unable to initialize EGL10: 0x" + Integer.toHexString(egl.eglGetError()));
throwEglException(egl.eglGetError(), "Unable to initialize EGL10");
}
return eglDisplay;
}
Expand All @@ -410,8 +403,7 @@ private static EGLConfig getEglConfig(EGL10 egl, EGLDisplay eglDisplay, int[] co
EGLConfig[] configs = new EGLConfig[1];
int[] numConfigs = new int[1];
if (!egl.eglChooseConfig(eglDisplay, configAttributes, configs, configs.length, numConfigs)) {
throw new GLException(
egl.eglGetError(), "eglChooseConfig failed: 0x" + Integer.toHexString(egl.eglGetError()));
throwEglException(egl.eglGetError(), "eglChooseConfig failed");
}
if (numConfigs[0] <= 0) {
throw new RuntimeException("Unable to find any matching EGL config");
Expand All @@ -436,11 +428,14 @@ private static EGLContext createEglContext(EGL10 egl, @Nullable EGLContext share
eglContext = egl.eglCreateContext(eglDisplay, eglConfig, rootContext, contextAttributes);
}
if (eglContext == EGL10.EGL_NO_CONTEXT) {
throw new GLException(egl.eglGetError(),
"Failed to create EGL context: 0x" + Integer.toHexString(egl.eglGetError()));
throwEglException(egl.eglGetError(), "Failed to create EGL context");
}
return eglContext;
}

private static void throwEglException(int error, String message) {
throw new GLException(error, message + ": 0x" + Integer.toHexString(error));
}

private static native long nativeGetCurrentNativeEGLContext();
}
30 changes: 13 additions & 17 deletions sdk/android/src/java/org/webrtc/EglBase14Impl.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ public void makeCurrent(EGLSurface eglSurface) {

synchronized (EglBase.lock) {
if (!EGL14.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)) {
throw new GLException(EGL14.eglGetError(),
"eglMakeCurrent failed: 0x" + Integer.toHexString(EGL14.eglGetError()));
throwEglException(EGL14.eglGetError(), "eglMakeCurrent failed");
}
}
currentSurface = eglSurface;
Expand All @@ -129,8 +128,7 @@ public void detachCurrent() {
synchronized (EglBase.lock) {
if (!EGL14.eglMakeCurrent(
eglDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT)) {
throw new GLException(EGL14.eglGetError(),
"eglDetachCurrent failed: 0x" + Integer.toHexString(EGL14.eglGetError()));
throwEglException(EGL14.eglGetError(), "eglDetachCurrent failed");
}
}
currentSurface = EGL14.EGL_NO_SURFACE;
Expand Down Expand Up @@ -173,8 +171,7 @@ private void createSurfaceInternal(Object surface) {
eglSurface = EGL14.eglCreateWindowSurface(
eglConnection.getDisplay(), eglConnection.getConfig(), surface, surfaceAttribs, 0);
if (eglSurface == EGL14.EGL_NO_SURFACE) {
throw new GLException(EGL14.eglGetError(),
"Failed to create window surface: 0x" + Integer.toHexString(EGL14.eglGetError()));
throwEglException(EGL14.eglGetError(), "Failed to create window surface");
}
}

Expand All @@ -193,9 +190,8 @@ public void createPbufferSurface(int width, int height) {
eglSurface = EGL14.eglCreatePbufferSurface(
eglConnection.getDisplay(), eglConnection.getConfig(), surfaceAttribs, 0);
if (eglSurface == EGL14.EGL_NO_SURFACE) {
throw new GLException(EGL14.eglGetError(),
"Failed to create pixel buffer surface with size " + width + "x" + height + ": 0x"
+ Integer.toHexString(EGL14.eglGetError()));
throwEglException(EGL14.eglGetError(),
"Failed to create pixel buffer surface with size " + width + "x" + height);
}
}

Expand Down Expand Up @@ -289,13 +285,11 @@ public void swapBuffers(long timeStampNs) {
private static EGLDisplay getEglDisplay() {
EGLDisplay eglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
if (eglDisplay == EGL14.EGL_NO_DISPLAY) {
throw new GLException(EGL14.eglGetError(),
"Unable to get EGL14 display: 0x" + Integer.toHexString(EGL14.eglGetError()));
throwEglException(EGL14.eglGetError(), "Unable to get EGL14 display");
}
int[] version = new int[2];
if (!EGL14.eglInitialize(eglDisplay, version, 0, version, 1)) {
throw new GLException(EGL14.eglGetError(),
"Unable to initialize EGL14: 0x" + Integer.toHexString(EGL14.eglGetError()));
throwEglException(EGL14.eglGetError(), "Unable to initialize EGL14");
}
return eglDisplay;
}
Expand All @@ -306,8 +300,7 @@ private static EGLConfig getEglConfig(EGLDisplay eglDisplay, int[] configAttribu
int[] numConfigs = new int[1];
if (!EGL14.eglChooseConfig(
eglDisplay, configAttributes, 0, configs, 0, configs.length, numConfigs, 0)) {
throw new GLException(EGL14.eglGetError(),
"eglChooseConfig failed: 0x" + Integer.toHexString(EGL14.eglGetError()));
throwEglException(EGL14.eglGetError(), "eglChooseConfig failed");
}
if (numConfigs[0] <= 0) {
throw new RuntimeException("Unable to find any matching EGL config");
Expand All @@ -332,9 +325,12 @@ private static EGLContext createEglContext(@Nullable EGLContext sharedContext,
eglContext = EGL14.eglCreateContext(eglDisplay, eglConfig, rootContext, contextAttributes, 0);
}
if (eglContext == EGL14.EGL_NO_CONTEXT) {
throw new GLException(EGL14.eglGetError(),
"Failed to create EGL context: 0x" + Integer.toHexString(EGL14.eglGetError()));
throwEglException(EGL14.eglGetError(), "Failed to create EGL context");
}
return eglContext;
}

private static void throwEglException(int error, String message) {
throw new GLException(error, message + ": 0x" + Integer.toHexString(error));
}
}