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.annotation.TargetApi; | 13 import android.annotation.TargetApi; |
14 import android.graphics.SurfaceTexture; | 14 import android.graphics.SurfaceTexture; |
15 import android.opengl.EGL14; | 15 import android.opengl.EGL14; |
16 import android.opengl.EGLConfig; | 16 import android.opengl.EGLConfig; |
17 import android.opengl.EGLContext; | 17 import android.opengl.EGLContext; |
18 import android.opengl.EGLDisplay; | 18 import android.opengl.EGLDisplay; |
19 import android.opengl.EGLExt; | 19 import android.opengl.EGLExt; |
20 import android.opengl.EGLSurface; | 20 import android.opengl.EGLSurface; |
21 import android.view.Surface; | 21 import android.view.Surface; |
22 | 22 |
23 /** | 23 /** |
24 * Holds EGL state and utility methods for handling an EGL14 EGLContext, an EGLD
isplay, | 24 * Holds EGL state and utility methods for handling an EGL14 EGLContext, an EGLD
isplay, |
25 * and an EGLSurface. | 25 * and an EGLSurface. |
26 */ | 26 */ |
27 @TargetApi(18) | 27 @TargetApi(18) |
28 class EglBase14 extends EglBase { | 28 class EglBase14 implements EglBase { |
29 private static final String TAG = "EglBase14"; | 29 private static final String TAG = "EglBase14"; |
30 private static final int EGLExt_SDK_VERSION = android.os.Build.VERSION_CODES.J
ELLY_BEAN_MR2; | 30 private static final int EGLExt_SDK_VERSION = android.os.Build.VERSION_CODES.J
ELLY_BEAN_MR2; |
31 private static final int CURRENT_SDK_VERSION = android.os.Build.VERSION.SDK_IN
T; | 31 private static final int CURRENT_SDK_VERSION = android.os.Build.VERSION.SDK_IN
T; |
32 private EGLContext eglContext; | 32 private EGLContext eglContext; |
33 private EGLConfig eglConfig; | 33 private EGLConfig eglConfig; |
34 private EGLDisplay eglDisplay; | 34 private EGLDisplay eglDisplay; |
35 private EGLSurface eglSurface = EGL14.EGL_NO_SURFACE; | 35 private EGLSurface eglSurface = EGL14.EGL_NO_SURFACE; |
36 | 36 |
37 // EGL 1.4 is supported from API 17. But EGLExt that is used for setting prese
ntation | 37 // EGL 1.4 is supported from API 17. But EGLExt that is used for setting prese
ntation |
38 // time stamp on a surface is supported from 18 so we require 18. | 38 // time stamp on a surface is supported from 18 so we require 18. |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 public void swapBuffers() { | 189 public void swapBuffers() { |
190 checkIsNotReleased(); | 190 checkIsNotReleased(); |
191 if (eglSurface == EGL14.EGL_NO_SURFACE) { | 191 if (eglSurface == EGL14.EGL_NO_SURFACE) { |
192 throw new RuntimeException("No EGLSurface - can't swap buffers"); | 192 throw new RuntimeException("No EGLSurface - can't swap buffers"); |
193 } | 193 } |
194 synchronized (EglBase.lock) { | 194 synchronized (EglBase.lock) { |
195 EGL14.eglSwapBuffers(eglDisplay, eglSurface); | 195 EGL14.eglSwapBuffers(eglDisplay, eglSurface); |
196 } | 196 } |
197 } | 197 } |
198 | 198 |
| 199 @Override |
199 public void swapBuffers(long timeStampNs) { | 200 public void swapBuffers(long timeStampNs) { |
200 checkIsNotReleased(); | 201 checkIsNotReleased(); |
201 if (eglSurface == EGL14.EGL_NO_SURFACE) { | 202 if (eglSurface == EGL14.EGL_NO_SURFACE) { |
202 throw new RuntimeException("No EGLSurface - can't swap buffers"); | 203 throw new RuntimeException("No EGLSurface - can't swap buffers"); |
203 } | 204 } |
204 synchronized (EglBase.lock) { | 205 synchronized (EglBase.lock) { |
205 // See | 206 // See |
206 // https://android.googlesource.com/platform/frameworks/native/+/tools_r22
.2/opengl/specs/EGL_ANDROID_presentation_time.txt | 207 // https://android.googlesource.com/platform/frameworks/native/+/tools_r22
.2/opengl/specs/EGL_ANDROID_presentation_time.txt |
207 EGLExt.eglPresentationTimeANDROID(eglDisplay, eglSurface, timeStampNs); | 208 EGLExt.eglPresentationTimeANDROID(eglDisplay, eglSurface, timeStampNs); |
208 EGL14.eglSwapBuffers(eglDisplay, eglSurface); | 209 EGL14.eglSwapBuffers(eglDisplay, eglSurface); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 synchronized (EglBase.lock) { | 257 synchronized (EglBase.lock) { |
257 eglContext = EGL14.eglCreateContext(eglDisplay, eglConfig, rootContext, co
ntextAttributes, 0); | 258 eglContext = EGL14.eglCreateContext(eglDisplay, eglConfig, rootContext, co
ntextAttributes, 0); |
258 } | 259 } |
259 if (eglContext == EGL14.EGL_NO_CONTEXT) { | 260 if (eglContext == EGL14.EGL_NO_CONTEXT) { |
260 throw new RuntimeException( | 261 throw new RuntimeException( |
261 "Failed to create EGL context: 0x" + Integer.toHexString(EGL14.eglGetE
rror())); | 262 "Failed to create EGL context: 0x" + Integer.toHexString(EGL14.eglGetE
rror())); |
262 } | 263 } |
263 return eglContext; | 264 return eglContext; |
264 } | 265 } |
265 } | 266 } |
OLD | NEW |