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 29 matching lines...) Expand all Loading... |
40 | 40 |
41 /** | 41 /** |
42 * Holds EGL state and utility methods for handling an EGL14 EGLContext, an EGLD
isplay, | 42 * Holds EGL state and utility methods for handling an EGL14 EGLContext, an EGLD
isplay, |
43 * and an EGLSurface. | 43 * and an EGLSurface. |
44 */ | 44 */ |
45 @TargetApi(17) | 45 @TargetApi(17) |
46 final class EglBase14 extends EglBase { | 46 final class EglBase14 extends EglBase { |
47 private static final String TAG = "EglBase14"; | 47 private static final String TAG = "EglBase14"; |
48 private static final int EGL14_SDK_VERSION = android.os.Build.VERSION_CODES.JE
LLY_BEAN_MR1; | 48 private static final int EGL14_SDK_VERSION = android.os.Build.VERSION_CODES.JE
LLY_BEAN_MR1; |
49 private static final int CURRENT_SDK_VERSION = android.os.Build.VERSION.SDK_IN
T; | 49 private static final int CURRENT_SDK_VERSION = android.os.Build.VERSION.SDK_IN
T; |
50 // Android-specific extension. | |
51 private static final int EGL_RECORDABLE_ANDROID = 0x3142; | |
52 | |
53 private EGLContext eglContext; | 50 private EGLContext eglContext; |
54 private EGLConfig eglConfig; | 51 private EGLConfig eglConfig; |
55 private EGLDisplay eglDisplay; | 52 private EGLDisplay eglDisplay; |
56 private EGLSurface eglSurface = EGL14.EGL_NO_SURFACE; | 53 private EGLSurface eglSurface = EGL14.EGL_NO_SURFACE; |
57 | 54 |
58 public static boolean isEGL14Supported() { | 55 public static boolean isEGL14Supported() { |
59 Logging.d(TAG, "SDK version: " + CURRENT_SDK_VERSION | 56 Logging.d(TAG, "SDK version: " + CURRENT_SDK_VERSION |
60 + ". isEGL14Supported: " + (CURRENT_SDK_VERSION >= EGL14_SDK_VERSION)); | 57 + ". isEGL14Supported: " + (CURRENT_SDK_VERSION >= EGL14_SDK_VERSION)); |
61 return (CURRENT_SDK_VERSION >= EGL14_SDK_VERSION); | 58 return (CURRENT_SDK_VERSION >= EGL14_SDK_VERSION); |
62 } | 59 } |
63 | 60 |
64 public static class Context extends EglBase.Context { | 61 public static class Context extends EglBase.Context { |
65 private final android.opengl.EGLContext egl14Context; | 62 private final android.opengl.EGLContext egl14Context; |
66 | 63 |
67 Context(android.opengl.EGLContext eglContext) { | 64 Context(android.opengl.EGLContext eglContext) { |
68 super(null); | |
69 this.egl14Context = eglContext; | 65 this.egl14Context = eglContext; |
70 } | 66 } |
71 } | 67 } |
72 | 68 |
73 // Create a new context with the specified config type, sharing data with shar
edContext. | 69 // Create a new context with the specified config type, sharing data with shar
edContext. |
74 // |sharedContext| may be null. | 70 // |sharedContext| may be null. |
75 EglBase14(EglBase14.Context sharedContext, int[] configAttributes) { | 71 EglBase14(EglBase14.Context sharedContext, int[] configAttributes) { |
76 super(true /* dummy */); | |
77 eglDisplay = getEglDisplay(); | 72 eglDisplay = getEglDisplay(); |
78 eglConfig = getEglConfig(eglDisplay, configAttributes); | 73 eglConfig = getEglConfig(eglDisplay, configAttributes); |
79 eglContext = createEglContext(sharedContext, eglDisplay, eglConfig); | 74 eglContext = createEglContext(sharedContext, eglDisplay, eglConfig); |
80 } | 75 } |
81 | 76 |
82 // Create EGLSurface from the Android Surface. | 77 // Create EGLSurface from the Android Surface. |
83 @Override | 78 @Override |
84 public void createSurface(Surface surface) { | 79 public void createSurface(Surface surface) { |
85 createSurfaceInternal(surface); | 80 createSurfaceInternal(surface); |
86 } | 81 } |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 EGLContext rootContext = | 232 EGLContext rootContext = |
238 sharedContext == null ? EGL14.EGL_NO_CONTEXT : sharedContext.egl14Contex
t; | 233 sharedContext == null ? EGL14.EGL_NO_CONTEXT : sharedContext.egl14Contex
t; |
239 EGLContext eglContext = | 234 EGLContext eglContext = |
240 EGL14.eglCreateContext(eglDisplay, eglConfig, rootContext, contextAttrib
utes, 0); | 235 EGL14.eglCreateContext(eglDisplay, eglConfig, rootContext, contextAttrib
utes, 0); |
241 if (eglContext == EGL14.EGL_NO_CONTEXT) { | 236 if (eglContext == EGL14.EGL_NO_CONTEXT) { |
242 throw new RuntimeException("Failed to create EGL context"); | 237 throw new RuntimeException("Failed to create EGL context"); |
243 } | 238 } |
244 return eglContext; | 239 return eglContext; |
245 } | 240 } |
246 } | 241 } |
OLD | NEW |