| 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 74%
|
| copy from talk/app/webrtc/java/android/org/webrtc/EglBase.java
|
| copy to talk/app/webrtc/java/android/org/webrtc/EglBase10.java
|
| index c45aa29602ac62d8ff9b47c330b49e44a04299ad..f2aa9857faf09e223f40c610ab816d3f8969f84c 100644
|
| --- a/talk/app/webrtc/java/android/org/webrtc/EglBase.java
|
| +++ b/talk/app/webrtc/java/android/org/webrtc/EglBase10.java
|
| @@ -33,9 +33,6 @@ import android.graphics.Rect;
|
| import android.view.Surface;
|
| import android.view.SurfaceHolder;
|
|
|
| -import org.webrtc.Logging;
|
| -import org.webrtc.EglBase.Context;
|
| -
|
| import javax.microedition.khronos.egl.EGL10;
|
| import javax.microedition.khronos.egl.EGLConfig;
|
| import javax.microedition.khronos.egl.EGLContext;
|
| @@ -46,16 +43,9 @@ import javax.microedition.khronos.egl.EGLSurface;
|
| * Holds EGL state and utility methods for handling an egl 1.0 EGLContext, an EGLDisplay,
|
| * and an EGLSurface.
|
| */
|
| -public class EglBase {
|
| - private static final String TAG = "EglBase";
|
| - // 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:
|
| - // http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.1.1_r1/android/opengl/GLSurfaceView.java#760
|
| - private static final int EGL_OPENGL_ES2_BIT = 4;
|
| +final class EglBase10 extends EglBase {
|
| + // This constant is taken from EGL14.EGL_CONTEXT_CLIENT_VERSION.
|
| private static final int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
|
| - // Android-specific extension.
|
| - private static final int EGL_RECORDABLE_ANDROID = 0x3142;
|
|
|
| private final EGL10 egl;
|
| private EGLContext eglContext;
|
| @@ -64,7 +54,7 @@ public class EglBase {
|
| private EGLSurface eglSurface = EGL10.EGL_NO_SURFACE;
|
|
|
| // EGL wrapper for an actual EGLContext.
|
| - public static class Context {
|
| + public static class Context extends EglBase.Context {
|
| private final EGLContext eglContext;
|
|
|
| public Context(EGLContext eglContext) {
|
| @@ -72,85 +62,15 @@ public class EglBase {
|
| }
|
| }
|
|
|
| - public static final int[] CONFIG_PLAIN = {
|
| - EGL10.EGL_RED_SIZE, 8,
|
| - EGL10.EGL_GREEN_SIZE, 8,
|
| - EGL10.EGL_BLUE_SIZE, 8,
|
| - EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
| - EGL10.EGL_NONE
|
| - };
|
| - public static final int[] CONFIG_PIXEL_BUFFER = {
|
| - EGL10.EGL_RED_SIZE, 8,
|
| - EGL10.EGL_GREEN_SIZE, 8,
|
| - EGL10.EGL_BLUE_SIZE, 8,
|
| - EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
| - EGL10.EGL_SURFACE_TYPE, EGL10.EGL_PBUFFER_BIT,
|
| - EGL10.EGL_NONE
|
| - };
|
| - public static final int[] CONFIG_PIXEL_RGBA_BUFFER = {
|
| - EGL10.EGL_RED_SIZE, 8,
|
| - EGL10.EGL_GREEN_SIZE, 8,
|
| - EGL10.EGL_BLUE_SIZE, 8,
|
| - EGL10.EGL_ALPHA_SIZE, 8,
|
| - EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
| - EGL10.EGL_SURFACE_TYPE, EGL10.EGL_PBUFFER_BIT,
|
| - EGL10.EGL_NONE
|
| - };
|
| - public static final int[] CONFIG_RECORDABLE = {
|
| - EGL10.EGL_RED_SIZE, 8,
|
| - EGL10.EGL_GREEN_SIZE, 8,
|
| - EGL10.EGL_BLUE_SIZE, 8,
|
| - EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
| - EGL_RECORDABLE_ANDROID, 1,
|
| - EGL10.EGL_NONE
|
| - };
|
| -
|
| - // Create a new context with the specified config attributes, sharing data with sharedContext.
|
| - // |sharedContext| can be null.
|
| - public static EglBase create(Context sharedContext, int[] configAttributes) {
|
| - return (EglBase14.isEGL14Supported()
|
| - && (sharedContext == null || sharedContext instanceof EglBase14.Context))
|
| - ? new EglBase14((EglBase14.Context) sharedContext, configAttributes)
|
| - : new EglBase(sharedContext, configAttributes);
|
| - }
|
| -
|
| - public static EglBase create() {
|
| - return create(null, CONFIG_PLAIN);
|
| - }
|
| -
|
| - //Create root context without any EGLSurface or parent EGLContext. This can be used for branching
|
| - // new contexts that share data.
|
| - @Deprecated
|
| - public EglBase() {
|
| - this((Context) null, CONFIG_PLAIN);
|
| - }
|
| -
|
| - @Deprecated
|
| - public EglBase(EGLContext sharedContext, int[] configAttributes) {
|
| - this(new Context(sharedContext), configAttributes);
|
| - Logging.d(TAG, "EglBase created");
|
| - }
|
| -
|
| - @Deprecated
|
| - public EGLContext getContext() {
|
| - return eglContext;
|
| - }
|
| -
|
| // Create a new context with the specified config type, sharing data with sharedContext.
|
| - EglBase(Context sharedContext, int[] configAttributes) {
|
| + EglBase10(Context sharedContext, int[] configAttributes) {
|
| this.egl = (EGL10) EGLContext.getEGL();
|
| eglDisplay = getEglDisplay();
|
| eglConfig = getEglConfig(eglDisplay, configAttributes);
|
| eglContext = createEglContext(sharedContext, eglDisplay, eglConfig);
|
| }
|
|
|
| - // TODO(perkj): This is a hacky ctor used to allow us to create an EGLBase14. Remove this and
|
| - // make EglBase an abstract class once all applications have started using the create factory
|
| - // method.
|
| - protected EglBase(boolean dummy) {
|
| - this.egl = null;
|
| - }
|
| -
|
| + @Override
|
| public void createSurface(Surface surface) {
|
| /**
|
| * We have to wrap Surface in a SurfaceHolder because for some reason eglCreateWindowSurface
|
| @@ -219,6 +139,7 @@ public class EglBase {
|
| }
|
|
|
| // Create EGLSurface from the Android SurfaceTexture.
|
| + @Override
|
| public void createSurface(SurfaceTexture surfaceTexture) {
|
| createSurfaceInternal(surfaceTexture);
|
| }
|
| @@ -240,10 +161,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 (eglSurface != EGL10.EGL_NO_SURFACE) {
|
| @@ -256,26 +179,31 @@ public class EglBase {
|
| }
|
| }
|
|
|
| - public Context getEglBaseContext() {
|
| - return new Context(eglContext);
|
| + @Override
|
| + public org.webrtc.EglBase.Context getEglBaseContext() {
|
| + return new EglBase10.Context(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);
|
| @@ -290,6 +218,7 @@ public class EglBase {
|
| }
|
| }
|
|
|
| + @Override
|
| public void release() {
|
| checkIsNotReleased();
|
| releaseSurface();
|
| @@ -301,6 +230,7 @@ public class EglBase {
|
| eglConfig = null;
|
| }
|
|
|
| + @Override
|
| public void makeCurrent() {
|
| checkIsNotReleased();
|
| if (eglSurface == EGL10.EGL_NO_SURFACE) {
|
| @@ -312,6 +242,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)) {
|
| @@ -319,6 +250,7 @@ public class EglBase {
|
| }
|
| }
|
|
|
| + @Override
|
| public void swapBuffers() {
|
| checkIsNotReleased();
|
| if (eglSurface == EGL10.EGL_NO_SURFACE) {
|
|
|