Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(663)

Unified Diff: talk/app/webrtc/java/android/org/webrtc/EglBase10.java

Issue 1461083002: Use EGL14 if supported on Android (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixed tests Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: talk/app/webrtc/java/android/org/webrtc/EglBase10.java
diff --git a/talk/app/webrtc/java/android/org/webrtc/EglBase.java b/talk/app/webrtc/java/android/org/webrtc/EglBase10.java
similarity index 90%
copy from talk/app/webrtc/java/android/org/webrtc/EglBase.java
copy to talk/app/webrtc/java/android/org/webrtc/EglBase10.java
index 1de34d254e30cbc9bc48b2b7c4d4b2699dee3224..f9793b023c101553297e00f09ad21be71f8e6cd1 100644
--- a/talk/app/webrtc/java/android/org/webrtc/EglBase.java
+++ b/talk/app/webrtc/java/android/org/webrtc/EglBase10.java
@@ -42,10 +42,11 @@ import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.egl.EGLSurface;
/**
- * Holds EGL state and utility methods for handling an EGLContext, an EGLDisplay, and an EGLSurface.
+ * Holds EGL state and utility methods for handling an EGL10 EGLContext, an EGLDisplay,
+ * and an EGLSurface.
*/
-public class EglBase {
- private static final String TAG = "EglBase";
+class EglBase10 extends Egl {
+ private static final String TAG = "EglBase10";
// These constants are taken from EGL14.EGL_OPENGL_ES2_BIT and EGL14.EGL_CONTEXT_CLIENT_VERSION.
// https://android.googlesource.com/platform/frameworks/base/+/master/opengl/java/android/opengl/EGL14.java
// This is similar to how GlSurfaceView does:
@@ -62,26 +63,16 @@ public class EglBase {
private EGLDisplay eglDisplay;
private EGLSurface eglSurface = EGL10.EGL_NO_SURFACE;
- // EGLConfig constructor type. Influences eglChooseConfig arguments.
- public static enum ConfigType {
- // No special parameters.
- PLAIN,
- // Configures with EGL_SURFACE_TYPE = EGL_PBUFFER_BIT.
- PIXEL_BUFFER,
- // Configures with EGL_RECORDABLE_ANDROID = 1.
- // Discourages EGL from using pixel formats that cannot efficiently be
- // converted to something usable by the video encoder.
- RECORDABLE
- }
+ public static class Egl10Context implements Context {
magjed_webrtc 2015/11/25 10:53:19 I prefer just Context as name (if it's possible).
+ public final EGLContext eglContext;
- // Create root context without any EGLSurface or parent EGLContext. This can be used for branching
- // new contexts that share data.
- public EglBase() {
- this(EGL10.EGL_NO_CONTEXT, ConfigType.PLAIN);
+ Egl10Context(EGLContext eglContext) {
+ this.eglContext = eglContext;
+ }
}
// Create a new context with the specified config type, sharing data with sharedContext.
- public EglBase(EGLContext sharedContext, ConfigType configType) {
+ EglBase10(Egl10Context sharedContext, ConfigType configType) {
this.egl = (EGL10) EGLContext.getEGL();
this.configType = configType;
eglDisplay = getEglDisplay();
@@ -89,7 +80,7 @@ public class EglBase {
eglContext = createEglContext(sharedContext, eglDisplay, eglConfig);
}
- // Create EGLSurface from the Android Surface.
+ @Override
public void createSurface(Surface surface) {
/**
* We have to wrap Surface in a SurfaceHolder because for some reason eglCreateWindowSurface
@@ -114,6 +105,7 @@ public class EglBase {
return false;
}
+ @Deprecated
@Override
public void setType(int i) {}
@@ -157,6 +149,7 @@ public class EglBase {
}
// Create EGLSurface from the Android SurfaceTexture.
+ @Override
public void createSurface(SurfaceTexture surfaceTexture) {
createSurfaceInternal(surfaceTexture);
}
@@ -181,10 +174,12 @@ public class EglBase {
}
// Create dummy 1x1 pixel buffer surface so the context can be made current.
+ @Override
public void createDummyPbufferSurface() {
createPbufferSurface(1, 1);
}
+ @Override
public void createPbufferSurface(int width, int height) {
checkIsNotReleased();
if (configType != ConfigType.PIXEL_BUFFER) {
@@ -201,26 +196,31 @@ public class EglBase {
}
}
- public EGLContext getContext() {
- return eglContext;
+ @Override
+ public Context getEglContext() {
+ return new Egl10Context(eglContext);
}
+ @Override
public boolean hasSurface() {
return eglSurface != EGL10.EGL_NO_SURFACE;
}
+ @Override
public int surfaceWidth() {
final int widthArray[] = new int[1];
egl.eglQuerySurface(eglDisplay, eglSurface, EGL10.EGL_WIDTH, widthArray);
return widthArray[0];
}
+ @Override
public int surfaceHeight() {
final int heightArray[] = new int[1];
egl.eglQuerySurface(eglDisplay, eglSurface, EGL10.EGL_HEIGHT, heightArray);
return heightArray[0];
}
+ @Override
public void releaseSurface() {
if (eglSurface != EGL10.EGL_NO_SURFACE) {
egl.eglDestroySurface(eglDisplay, eglSurface);
@@ -235,6 +235,7 @@ public class EglBase {
}
}
+ @Override
public void release() {
checkIsNotReleased();
releaseSurface();
@@ -246,6 +247,7 @@ public class EglBase {
eglConfig = null;
}
+ @Override
public void makeCurrent() {
checkIsNotReleased();
if (eglSurface == EGL10.EGL_NO_SURFACE) {
@@ -257,6 +259,7 @@ public class EglBase {
}
// Detach the current EGL context, so that it can be made current on another thread.
+ @Override
public void detachCurrent() {
if (!egl.eglMakeCurrent(
eglDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT)) {
@@ -264,6 +267,7 @@ public class EglBase {
}
}
+ @Override
public void swapBuffers() {
checkIsNotReleased();
if (eglSurface == EGL10.EGL_NO_SURFACE) {
@@ -324,10 +328,12 @@ public class EglBase {
// Return an EGLConfig, or die trying.
private EGLContext createEglContext(
- EGLContext sharedContext, EGLDisplay eglDisplay, EGLConfig eglConfig) {
+ Egl10Context sharedContext, EGLDisplay eglDisplay, EGLConfig eglConfig) {
int[] contextAttributes = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE};
+ EGLContext rootContext =
+ sharedContext == null ? EGL10.EGL_NO_CONTEXT : sharedContext.eglContext;
EGLContext eglContext =
- egl.eglCreateContext(eglDisplay, eglConfig, sharedContext, contextAttributes);
+ egl.eglCreateContext(eglDisplay, eglConfig, rootContext, contextAttributes);
if (eglContext == EGL10.EGL_NO_CONTEXT) {
throw new RuntimeException("Failed to create EGL context");
}

Powered by Google App Engine
This is Rietveld 408576698