Chromium Code Reviews| Index: talk/app/webrtc/java/android/org/webrtc/EglBase.java |
| diff --git a/talk/app/webrtc/java/android/org/webrtc/EglBase.java b/talk/app/webrtc/java/android/org/webrtc/EglBase.java |
| index 1de34d254e30cbc9bc48b2b7c4d4b2699dee3224..ffca1d93cad0cdbe679c7acf31e3b2ad03a54997 100644 |
| --- a/talk/app/webrtc/java/android/org/webrtc/EglBase.java |
| +++ b/talk/app/webrtc/java/android/org/webrtc/EglBase.java |
| @@ -57,35 +57,53 @@ public class EglBase { |
| private final EGL10 egl; |
| private EGLContext eglContext; |
| - private ConfigType configType; |
| private EGLConfig eglConfig; |
| 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 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 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); |
| + this(EGL10.EGL_NO_CONTEXT, CONFIG_PLAIN); |
| } |
| // Create a new context with the specified config type, sharing data with sharedContext. |
| - public EglBase(EGLContext sharedContext, ConfigType configType) { |
| + public EglBase(EGLContext sharedContext, int[] configAttributes) { |
| this.egl = (EGL10) EGLContext.getEGL(); |
| - this.configType = configType; |
| eglDisplay = getEglDisplay(); |
| - eglConfig = getEglConfig(eglDisplay, configType); |
| + eglConfig = getEglConfig(eglDisplay, configAttributes); |
| eglContext = createEglContext(sharedContext, eglDisplay, eglConfig); |
| } |
| @@ -167,9 +185,6 @@ public class EglBase { |
| throw new IllegalStateException("Input must be either a SurfaceHolder or SurfaceTexture"); |
| } |
| checkIsNotReleased(); |
| - if (configType == ConfigType.PIXEL_BUFFER) { |
|
perkj_webrtc
2015/12/07 12:53:50
Why remove these logs?
nisse-webrtc
2015/12/08 10:00:21
Because the configType enum no longer exists. To k
|
| - Logging.w(TAG, "This EGL context is configured for PIXEL_BUFFER, but uses regular Surface"); |
| - } |
| if (eglSurface != EGL10.EGL_NO_SURFACE) { |
| throw new RuntimeException("Already has an EGLSurface"); |
| } |
| @@ -187,10 +202,6 @@ public class EglBase { |
| public void createPbufferSurface(int width, int height) { |
| checkIsNotReleased(); |
| - if (configType != ConfigType.PIXEL_BUFFER) { |
|
perkj_webrtc
2015/12/07 12:53:50
dito? Why remove?
|
| - throw new RuntimeException( |
| - "This EGL context is not configured to use a pixel buffer: " + configType); |
| - } |
| if (eglSurface != EGL10.EGL_NO_SURFACE) { |
| throw new RuntimeException("Already has an EGLSurface"); |
| } |
| @@ -286,38 +297,12 @@ public class EglBase { |
| } |
| // Return an EGLConfig, or die trying. |
| - private EGLConfig getEglConfig(EGLDisplay eglDisplay, ConfigType configType) { |
| - // Always RGB888, GLES2. |
| - int[] configAttributes = { |
| - 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, 0, // Allocate dummy fields for specific options. |
| - EGL10.EGL_NONE |
| - }; |
| - |
| - // Fill in dummy fields based on configType. |
| - switch (configType) { |
| - case PLAIN: |
| - break; |
| - case PIXEL_BUFFER: |
| - configAttributes[configAttributes.length - 3] = EGL10.EGL_SURFACE_TYPE; |
| - configAttributes[configAttributes.length - 2] = EGL10.EGL_PBUFFER_BIT; |
| - break; |
| - case RECORDABLE: |
| - configAttributes[configAttributes.length - 3] = EGL_RECORDABLE_ANDROID; |
| - configAttributes[configAttributes.length - 2] = 1; |
| - break; |
| - default: |
| - throw new IllegalArgumentException(); |
| - } |
| - |
| + private EGLConfig getEglConfig(EGLDisplay eglDisplay, int[] configAttributes) { |
| EGLConfig[] configs = new EGLConfig[1]; |
| int[] numConfigs = new int[1]; |
| if (!egl.eglChooseConfig( |
| eglDisplay, configAttributes, configs, configs.length, numConfigs)) { |
| - throw new RuntimeException("Unable to find RGB888 " + configType + " EGL config"); |
| + throw new RuntimeException("Unable to find any matching EGL config"); |
| } |
| return configs[0]; |
| } |