Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(406)

Side by Side Diff: talk/app/webrtc/java/android/org/webrtc/EglBase.java

Issue 1343163003: Partial revert of r9936. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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.opengl.EGL14; 30 import android.opengl.EGL14;
31 import android.opengl.EGLConfig; 31 import android.opengl.EGLConfig;
32 import android.opengl.EGLContext; 32 import android.opengl.EGLContext;
33 import android.opengl.EGLDisplay; 33 import android.opengl.EGLDisplay;
34 import android.opengl.EGLSurface; 34 import android.opengl.EGLSurface;
35 import android.util.Log;
35 import android.view.Surface; 36 import android.view.Surface;
36 37
37 import org.webrtc.Logging;
38
39 /** 38 /**
40 * Holds EGL state and utility methods for handling an EGLContext, an EGLDisplay , and an EGLSurface. 39 * Holds EGL state and utility methods for handling an EGLContext, an EGLDisplay , and an EGLSurface.
41 */ 40 */
42 public final class EglBase { 41 public final class EglBase {
43 private static final String TAG = "EglBase"; 42 private static final String TAG = "EglBase";
44 private static final int EGL14_SDK_VERSION = android.os.Build.VERSION_CODES.JE LLY_BEAN_MR1; 43 private static final int EGL14_SDK_VERSION = android.os.Build.VERSION_CODES.JE LLY_BEAN_MR1;
45 private static final int CURRENT_SDK_VERSION = android.os.Build.VERSION.SDK_IN T; 44 private static final int CURRENT_SDK_VERSION = android.os.Build.VERSION.SDK_IN T;
46 // Android-specific extension. 45 // Android-specific extension.
47 private static final int EGL_RECORDABLE_ANDROID = 0x3142; 46 private static final int EGL_RECORDABLE_ANDROID = 0x3142;
48 47
49 private EGLContext eglContext; 48 private EGLContext eglContext;
50 private ConfigType configType; 49 private ConfigType configType;
51 private EGLConfig eglConfig; 50 private EGLConfig eglConfig;
52 private EGLDisplay eglDisplay; 51 private EGLDisplay eglDisplay;
53 private EGLSurface eglSurface = EGL14.EGL_NO_SURFACE; 52 private EGLSurface eglSurface = EGL14.EGL_NO_SURFACE;
54 53
55 public static boolean isEGL14Supported() { 54 public static boolean isEGL14Supported() {
56 Logging.d(TAG, "SDK version: " + CURRENT_SDK_VERSION); 55 Log.d(TAG, "SDK version: " + CURRENT_SDK_VERSION);
57 return (CURRENT_SDK_VERSION >= EGL14_SDK_VERSION); 56 return (CURRENT_SDK_VERSION >= EGL14_SDK_VERSION);
58 } 57 }
59 58
60 // EGLConfig constructor type. Influences eglChooseConfig arguments. 59 // EGLConfig constructor type. Influences eglChooseConfig arguments.
61 public static enum ConfigType { 60 public static enum ConfigType {
62 // No special parameters. 61 // No special parameters.
63 PLAIN, 62 PLAIN,
64 // Configures with EGL_SURFACE_TYPE = EGL_PBUFFER_BIT. 63 // Configures with EGL_SURFACE_TYPE = EGL_PBUFFER_BIT.
65 PIXEL_BUFFER, 64 PIXEL_BUFFER,
66 // Configures with EGL_RECORDABLE_ANDROID = 1. 65 // Configures with EGL_RECORDABLE_ANDROID = 1.
(...skipping 13 matching lines...) Expand all
80 this.configType = configType; 79 this.configType = configType;
81 eglDisplay = getEglDisplay(); 80 eglDisplay = getEglDisplay();
82 eglConfig = getEglConfig(eglDisplay, configType); 81 eglConfig = getEglConfig(eglDisplay, configType);
83 eglContext = createEglContext(sharedContext, eglDisplay, eglConfig); 82 eglContext = createEglContext(sharedContext, eglDisplay, eglConfig);
84 } 83 }
85 84
86 // Create EGLSurface from the Android Surface. 85 // Create EGLSurface from the Android Surface.
87 public void createSurface(Surface surface) { 86 public void createSurface(Surface surface) {
88 checkIsNotReleased(); 87 checkIsNotReleased();
89 if (configType == ConfigType.PIXEL_BUFFER) { 88 if (configType == ConfigType.PIXEL_BUFFER) {
90 Logging.w(TAG, "This EGL context is configured for PIXEL_BUFFER, but uses regular Surface"); 89 Log.w(TAG, "This EGL context is configured for PIXEL_BUFFER, but uses regu lar Surface");
91 } 90 }
92 if (eglSurface != EGL14.EGL_NO_SURFACE) { 91 if (eglSurface != EGL14.EGL_NO_SURFACE) {
93 throw new RuntimeException("Already has an EGLSurface"); 92 throw new RuntimeException("Already has an EGLSurface");
94 } 93 }
95 int[] surfaceAttribs = {EGL14.EGL_NONE}; 94 int[] surfaceAttribs = {EGL14.EGL_NONE};
96 eglSurface = EGL14.eglCreateWindowSurface(eglDisplay, eglConfig, surface, su rfaceAttribs, 0); 95 eglSurface = EGL14.eglCreateWindowSurface(eglDisplay, eglConfig, surface, su rfaceAttribs, 0);
97 if (eglSurface == EGL14.EGL_NO_SURFACE) { 96 if (eglSurface == EGL14.EGL_NO_SURFACE) {
98 throw new RuntimeException("Failed to create window surface"); 97 throw new RuntimeException("Failed to create window surface");
99 } 98 }
100 } 99 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 EGLContext sharedContext, EGLDisplay eglDisplay, EGLConfig eglConfig) { 246 EGLContext sharedContext, EGLDisplay eglDisplay, EGLConfig eglConfig) {
248 int[] contextAttributes = {EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NO NE}; 247 int[] contextAttributes = {EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NO NE};
249 EGLContext eglContext = 248 EGLContext eglContext =
250 EGL14.eglCreateContext(eglDisplay, eglConfig, sharedContext, contextAttr ibutes, 0); 249 EGL14.eglCreateContext(eglDisplay, eglConfig, sharedContext, contextAttr ibutes, 0);
251 if (eglContext == EGL14.EGL_NO_CONTEXT) { 250 if (eglContext == EGL14.EGL_NO_CONTEXT) {
252 throw new RuntimeException("Failed to create EGL context"); 251 throw new RuntimeException("Failed to create EGL context");
253 } 252 }
254 return eglContext; 253 return eglContext;
255 } 254 }
256 } 255 }
OLDNEW
« no previous file with comments | « talk/app/webrtc/java/android/org/webrtc/CameraEnumerator.java ('k') | talk/app/webrtc/java/android/org/webrtc/GlShader.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698