Chromium Code Reviews| Index: talk/app/webrtc/java/android/org/webrtc/Egl.java |
| diff --git a/talk/app/webrtc/java/android/org/webrtc/Egl.java b/talk/app/webrtc/java/android/org/webrtc/Egl.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..56a6a2c3e531149568b312c9196f82eccdb95787 |
| --- /dev/null |
| +++ b/talk/app/webrtc/java/android/org/webrtc/Egl.java |
| @@ -0,0 +1,95 @@ |
| +/* |
| + * libjingle |
| + * Copyright 2015 Google Inc. |
| + * |
| + * Redistribution and use in source and binary forms, with or without |
| + * modification, are permitted provided that the following conditions are met: |
| + * |
| + * 1. Redistributions of source code must retain the above copyright notice, |
| + * this list of conditions and the following disclaimer. |
| + * 2. Redistributions in binary form must reproduce the above copyright notice, |
| + * this list of conditions and the following disclaimer in the documentation |
| + * and/or other materials provided with the distribution. |
| + * 3. The name of the author may not be used to endorse or promote products |
| + * derived from this software without specific prior written permission. |
| + * |
| + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| + */ |
| + |
| +package org.webrtc; |
| + |
| +import android.graphics.SurfaceTexture; |
| +import android.view.Surface; |
| + |
| +/** |
| + * Holds EGL state and utility methods for handling an EGLContext, an EGLDisplay, and an EGLSurface. |
| + * Depending on Android version, either EGL 10 or EGL14 will be used. |
| + */ |
| +public abstract class Egl { |
| + |
| + // 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 |
| + } |
| + |
| + // EGL version independent wrapper for an actual EGLContext. |
| + public static interface Context { |
| + } |
| + |
| + // Create a new context with the specified config type, sharing data with sharedContext. |
| + // |sharedContext| can be null. |
| + public static Egl create(Context sharedContext, ConfigType configType) { |
| + return (sharedContext == null && EglBase14.isEGL14Supported() |
|
magjed_webrtc
2015/11/25 10:53:19
This is correct precedence, but we typically have
|
| + || sharedContext instanceof EglBase14.Egl14Context) |
| + ? new EglBase14((EglBase14.Egl14Context) sharedContext, configType) |
| + : new EglBase10((EglBase10.Egl10Context) sharedContext, configType); |
| + } |
| + |
| + public static Egl create() { |
| + return create(null, ConfigType.PLAIN); |
| + } |
| + |
| + public abstract void createSurface(Surface surface); |
| + // Create EGLSurface from the Android SurfaceTexture. |
| + public abstract void createSurface(SurfaceTexture surfaceTexture); |
| + |
| + // Create dummy 1x1 pixel buffer surface so the context can be made current. |
| + public abstract void createDummyPbufferSurface(); |
| + |
| + public abstract void createPbufferSurface(int width, int height); |
| + |
| + public abstract Context getEglContext(); |
| + |
| + public abstract boolean hasSurface(); |
| + |
| + public abstract int surfaceWidth(); |
| + |
| + public abstract int surfaceHeight(); |
| + |
| + public abstract void releaseSurface(); |
| + |
| + public abstract void release(); |
| + |
| + public abstract void makeCurrent(); |
| + |
| + // Detach the current EGL context, so that it can be made current on another thread. |
| + public abstract void detachCurrent(); |
| + |
| + public abstract void swapBuffers(); |
| +} |