Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * libjingle | |
| 3 * Copyright 2015 Google Inc. | |
| 4 * | |
| 5 * Redistribution and use in source and binary forms, with or without | |
| 6 * modification, are permitted provided that the following conditions are met: | |
| 7 * | |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | |
| 9 * this list of conditions and the following disclaimer. | |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | |
| 11 * this list of conditions and the following disclaimer in the documentation | |
| 12 * and/or other materials provided with the distribution. | |
| 13 * 3. The name of the author may not be used to endorse or promote products | |
| 14 * derived from this software without specific prior written permission. | |
| 15 * | |
| 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | |
| 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
| 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | |
| 19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | |
| 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |
| 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | |
| 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | |
| 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 26 */ | |
| 27 | |
| 28 package org.webrtc; | |
| 29 | |
| 30 import android.graphics.SurfaceTexture; | |
| 31 import android.view.Surface; | |
| 32 | |
| 33 /** | |
| 34 * Holds EGL state and utility methods for handling an EGLContext, an EGLDisplay , and an EGLSurface. | |
| 35 * Depending on Android version, either EGL 10 or EGL14 will be used. | |
| 36 */ | |
| 37 public abstract class Egl { | |
| 38 | |
| 39 // EGLConfig constructor type. Influences eglChooseConfig arguments. | |
| 40 public static enum ConfigType { | |
| 41 // No special parameters. | |
| 42 PLAIN, | |
| 43 // Configures with EGL_SURFACE_TYPE = EGL_PBUFFER_BIT. | |
| 44 PIXEL_BUFFER, | |
| 45 // Configures with EGL_RECORDABLE_ANDROID = 1. | |
| 46 // Discourages EGL from using pixel formats that cannot efficiently be | |
| 47 // converted to something usable by the video encoder. | |
| 48 RECORDABLE | |
| 49 } | |
| 50 | |
| 51 // EGL version independent wrapper for an actual EGLContext. | |
| 52 public static interface Context { | |
| 53 } | |
| 54 | |
| 55 // Create a new context with the specified config type, sharing data with shar edContext. | |
| 56 // |sharedContext| can be null. | |
| 57 public static Egl create(Context sharedContext, ConfigType configType) { | |
| 58 return (sharedContext == null && EglBase14.isEGL14Supported() | |
|
magjed_webrtc
2015/11/25 10:53:19
This is correct precedence, but we typically have
| |
| 59 || sharedContext instanceof EglBase14.Egl14Context) | |
| 60 ? new EglBase14((EglBase14.Egl14Context) sharedContext, configType) | |
| 61 : new EglBase10((EglBase10.Egl10Context) sharedContext, configType); | |
| 62 } | |
| 63 | |
| 64 public static Egl create() { | |
| 65 return create(null, ConfigType.PLAIN); | |
| 66 } | |
| 67 | |
| 68 public abstract void createSurface(Surface surface); | |
| 69 // Create EGLSurface from the Android SurfaceTexture. | |
| 70 public abstract void createSurface(SurfaceTexture surfaceTexture); | |
| 71 | |
| 72 // Create dummy 1x1 pixel buffer surface so the context can be made current. | |
| 73 public abstract void createDummyPbufferSurface(); | |
| 74 | |
| 75 public abstract void createPbufferSurface(int width, int height); | |
| 76 | |
| 77 public abstract Context getEglContext(); | |
| 78 | |
| 79 public abstract boolean hasSurface(); | |
| 80 | |
| 81 public abstract int surfaceWidth(); | |
| 82 | |
| 83 public abstract int surfaceHeight(); | |
| 84 | |
| 85 public abstract void releaseSurface(); | |
| 86 | |
| 87 public abstract void release(); | |
| 88 | |
| 89 public abstract void makeCurrent(); | |
| 90 | |
| 91 // Detach the current EGL context, so that it can be made current on another t hread. | |
| 92 public abstract void detachCurrent(); | |
| 93 | |
| 94 public abstract void swapBuffers(); | |
| 95 } | |
| OLD | NEW |