OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 package org.webrtc; | 11 package org.webrtc; |
12 | 12 |
13 import android.graphics.SurfaceTexture; | 13 import android.graphics.SurfaceTexture; |
14 import android.view.Surface; | 14 import android.view.Surface; |
15 | 15 |
16 import javax.microedition.khronos.egl.EGL10; | 16 import javax.microedition.khronos.egl.EGL10; |
17 | 17 |
18 /** | 18 /** |
19 * Holds EGL state and utility methods for handling an egl 1.0 EGLContext, an EG
LDisplay, | 19 * Holds EGL state and utility methods for handling an egl 1.0 EGLContext, an EG
LDisplay, |
20 * and an EGLSurface. | 20 * and an EGLSurface. |
21 */ | 21 */ |
22 @SuppressWarnings("StaticOrDefaultInterfaceMethod") | 22 public abstract class EglBase { |
23 public interface EglBase { | |
24 // EGL wrapper for an actual EGLContext. | 23 // EGL wrapper for an actual EGLContext. |
25 public static class Context {} | 24 public static class Context {} |
26 | 25 |
27 // According to the documentation, EGL can be used from multiple threads at th
e same time if each | 26 // According to the documentation, EGL can be used from multiple threads at th
e same time if each |
28 // thread has its own EGLContext, but in practice it deadlocks on some devices
when doing this. | 27 // thread has its own EGLContext, but in practice it deadlocks on some devices
when doing this. |
29 // Therefore, synchronize on this global lock before calling dangerous EGL fun
ctions that might | 28 // Therefore, synchronize on this global lock before calling dangerous EGL fun
ctions that might |
30 // deadlock. See https://bugs.chromium.org/p/webrtc/issues/detail?id=5702 for
more info. | 29 // deadlock. See https://bugs.chromium.org/p/webrtc/issues/detail?id=5702 for
more info. |
31 public static final Object lock = new Object(); | 30 public static final Object lock = new Object(); |
32 | 31 |
33 // These constants are taken from EGL14.EGL_OPENGL_ES2_BIT and EGL14.EGL_CONTE
XT_CLIENT_VERSION. | 32 // These constants are taken from EGL14.EGL_OPENGL_ES2_BIT and EGL14.EGL_CONTE
XT_CLIENT_VERSION. |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 133 |
135 /** | 134 /** |
136 * Explicitly create a root EGl 1.4 context with the specified config attribut
es | 135 * Explicitly create a root EGl 1.4 context with the specified config attribut
es |
137 * and shared context. | 136 * and shared context. |
138 */ | 137 */ |
139 public static EglBase createEgl14( | 138 public static EglBase createEgl14( |
140 android.opengl.EGLContext sharedContext, int[] configAttributes) { | 139 android.opengl.EGLContext sharedContext, int[] configAttributes) { |
141 return new EglBase14(new EglBase14.Context(sharedContext), configAttributes)
; | 140 return new EglBase14(new EglBase14.Context(sharedContext), configAttributes)
; |
142 } | 141 } |
143 | 142 |
144 void createSurface(Surface surface); | 143 public abstract void createSurface(Surface surface); |
145 | 144 |
146 // Create EGLSurface from the Android SurfaceTexture. | 145 // Create EGLSurface from the Android SurfaceTexture. |
147 void createSurface(SurfaceTexture surfaceTexture); | 146 public abstract void createSurface(SurfaceTexture surfaceTexture); |
148 | 147 |
149 // Create dummy 1x1 pixel buffer surface so the context can be made current. | 148 // Create dummy 1x1 pixel buffer surface so the context can be made current. |
150 void createDummyPbufferSurface(); | 149 public abstract void createDummyPbufferSurface(); |
151 | 150 |
152 void createPbufferSurface(int width, int height); | 151 public abstract void createPbufferSurface(int width, int height); |
153 | 152 |
154 Context getEglBaseContext(); | 153 public abstract Context getEglBaseContext(); |
155 | 154 |
156 boolean hasSurface(); | 155 public abstract boolean hasSurface(); |
157 | 156 |
158 int surfaceWidth(); | 157 public abstract int surfaceWidth(); |
159 | 158 |
160 int surfaceHeight(); | 159 public abstract int surfaceHeight(); |
161 | 160 |
162 void releaseSurface(); | 161 public abstract void releaseSurface(); |
163 | 162 |
164 void release(); | 163 public abstract void release(); |
165 | 164 |
166 void makeCurrent(); | 165 public abstract void makeCurrent(); |
167 | 166 |
168 // Detach the current EGL context, so that it can be made current on another t
hread. | 167 // Detach the current EGL context, so that it can be made current on another t
hread. |
169 void detachCurrent(); | 168 public abstract void detachCurrent(); |
170 | 169 |
171 void swapBuffers(); | 170 public abstract void swapBuffers(); |
172 | 171 |
173 void swapBuffers(long presentationTimeStampNs); | 172 public abstract void swapBuffers(long presentationTimeStampNs); |
174 } | 173 } |
OLD | NEW |