OLD | NEW |
---|---|
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 14 matching lines...) Expand all Loading... | |
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 package org.webrtc; | 28 package org.webrtc; |
29 | 29 |
30 import android.graphics.SurfaceTexture; | 30 import android.graphics.SurfaceTexture; |
31 import android.opengl.EGL14; | 31 import android.opengl.EGL14; |
32 import android.opengl.EGLConfig; | 32 import android.opengl.EGLConfig; |
33 import android.opengl.EGLContext; | 33 import android.opengl.EGLContext; |
34 import android.opengl.EGLDisplay; | 34 import android.opengl.EGLDisplay; |
35 import android.opengl.EGLExt; | |
35 import android.opengl.EGLSurface; | 36 import android.opengl.EGLSurface; |
36 import android.view.Surface; | 37 import android.view.Surface; |
37 | 38 |
38 import org.webrtc.Logging; | 39 import org.webrtc.Logging; |
39 | 40 |
40 /** | 41 /** |
41 * Holds EGL state and utility methods for handling an EGLContext, an EGLDisplay , and an EGLSurface. | 42 * Holds EGL state and utility methods for handling an EGLContext, an EGLDisplay , and an EGLSurface. |
42 */ | 43 */ |
43 public final class EglBase { | 44 public final class EglBase { |
44 private static final String TAG = "EglBase"; | 45 private static final String TAG = "EglBase"; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 } | 200 } |
200 | 201 |
201 public void swapBuffers() { | 202 public void swapBuffers() { |
202 checkIsNotReleased(); | 203 checkIsNotReleased(); |
203 if (eglSurface == EGL14.EGL_NO_SURFACE) { | 204 if (eglSurface == EGL14.EGL_NO_SURFACE) { |
204 throw new RuntimeException("No EGLSurface - can't swap buffers"); | 205 throw new RuntimeException("No EGLSurface - can't swap buffers"); |
205 } | 206 } |
206 EGL14.eglSwapBuffers(eglDisplay, eglSurface); | 207 EGL14.eglSwapBuffers(eglDisplay, eglSurface); |
207 } | 208 } |
208 | 209 |
210 public void swapBuffers(long timeStampNs) { | |
211 checkIsNotReleased(); | |
212 if (eglSurface == EGL14.EGL_NO_SURFACE) { | |
213 throw new RuntimeException("No EGLSurface - can't swap buffers"); | |
214 } | |
215 // See https://android.googlesource.com/platform/frameworks/native/+/tools_r22. 2/opengl/specs/EGL_ANDROID_presentation_time.txt | |
AlexG
2015/10/14 23:48:27
nit: alignment?
perkj_webrtc
2015/11/16 13:08:51
I remove this for now since I have not find a reas
| |
216 EGLExt.eglPresentationTimeANDROID(eglDisplay, eglSurface, timeStampNs); | |
217 EGL14.eglSwapBuffers(eglDisplay, eglSurface); | |
218 } | |
219 | |
209 // Return an EGLDisplay, or die trying. | 220 // Return an EGLDisplay, or die trying. |
210 private static EGLDisplay getEglDisplay() { | 221 private static EGLDisplay getEglDisplay() { |
211 EGLDisplay eglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY); | 222 EGLDisplay eglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY); |
212 if (eglDisplay == EGL14.EGL_NO_DISPLAY) { | 223 if (eglDisplay == EGL14.EGL_NO_DISPLAY) { |
213 throw new RuntimeException("Unable to get EGL14 display"); | 224 throw new RuntimeException("Unable to get EGL14 display"); |
214 } | 225 } |
215 int[] version = new int[2]; | 226 int[] version = new int[2]; |
216 if (!EGL14.eglInitialize(eglDisplay, version, 0, version, 1)) { | 227 if (!EGL14.eglInitialize(eglDisplay, version, 0, version, 1)) { |
217 throw new RuntimeException("Unable to initialize EGL14"); | 228 throw new RuntimeException("Unable to initialize EGL14"); |
218 } | 229 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
261 EGLContext sharedContext, EGLDisplay eglDisplay, EGLConfig eglConfig) { | 272 EGLContext sharedContext, EGLDisplay eglDisplay, EGLConfig eglConfig) { |
262 int[] contextAttributes = {EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NO NE}; | 273 int[] contextAttributes = {EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NO NE}; |
263 EGLContext eglContext = | 274 EGLContext eglContext = |
264 EGL14.eglCreateContext(eglDisplay, eglConfig, sharedContext, contextAttr ibutes, 0); | 275 EGL14.eglCreateContext(eglDisplay, eglConfig, sharedContext, contextAttr ibutes, 0); |
265 if (eglContext == EGL14.EGL_NO_CONTEXT) { | 276 if (eglContext == EGL14.EGL_NO_CONTEXT) { |
266 throw new RuntimeException("Failed to create EGL context"); | 277 throw new RuntimeException("Failed to create EGL context"); |
267 } | 278 } |
268 return eglContext; | 279 return eglContext; |
269 } | 280 } |
270 } | 281 } |
OLD | NEW |