1 /* 2 ** Copyright 2011, The Android Open Source Project 3 ** 4 ** Licensed under the Apache License, Version 2.0 (the "License"); 5 ** you may not use this file except in compliance with the License. 6 ** You may obtain a copy of the License at 7 ** 8 ** http://www.apache.org/licenses/LICENSE-2.0 9 ** 10 ** Unless required by applicable law or agreed to in writing, software 11 ** distributed under the License is distributed on an "AS IS" BASIS, 12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 ** See the License for the specific language governing permissions and 14 ** limitations under the License. 15 */ 16 17 #ifndef ANDROID_EGLDEFS_H 18 #define ANDROID_EGLDEFS_H 19 20 #include "../hooks.h" 21 #include "egl_platform_entries.h" 22 23 #include <log/log.h> 24 25 #define VERSION_MAJOR 1 26 #define VERSION_MINOR 4 27 #define EGL_MAKE_VERSION(major, minor, patch) (((major) << 22) | ((minor) << 12) | (patch)) 28 29 // ---------------------------------------------------------------------------- 30 namespace android { 31 // ---------------------------------------------------------------------------- 32 33 // EGLDisplay are global, not attached to a given thread 34 const unsigned int NUM_DISPLAYS = 1; 35 36 // ---------------------------------------------------------------------------- 37 38 extern char const * const platform_names[]; 39 40 // clang-format off 41 struct egl_connection_t { 42 enum { 43 GLESv1_INDEX = 0, 44 GLESv2_INDEX = 1 45 }; 46 egl_connection_tegl_connection_t47 inline egl_connection_t() : dso(nullptr), 48 libEgl(nullptr), 49 libGles1(nullptr), 50 libGles2(nullptr), 51 systemDriverUnloaded(false) { 52 53 char const* const* entries = platform_names; 54 EGLFuncPointer* curr = reinterpret_cast<EGLFuncPointer*>(&platform); 55 while (*entries) { 56 const char* name = *entries; 57 EGLFuncPointer f = FindPlatformImplAddr(name); 58 59 if (f == nullptr) { 60 // If no entry found, update the lookup table: sPlatformImplMap 61 ALOGE("No entry found in platform lookup table for %s", name); 62 } 63 64 *curr++ = f; 65 entries++; 66 } 67 } 68 69 void * dso; 70 gl_hooks_t * hooks[2]; 71 EGLint major; 72 EGLint minor; 73 EGLint driverVersion; 74 egl_t egl; 75 76 // Functions implemented or redirected by platform libraries 77 platform_impl_t platform; 78 79 void* libEgl; 80 void* libGles1; 81 void* libGles2; 82 83 bool systemDriverUnloaded; 84 bool shouldUseAngle; // Should we attempt to load ANGLE 85 bool angleDecided; // Have we tried to load ANGLE 86 bool useAngle; // Was ANGLE successfully loaded 87 EGLint angleBackend; 88 void* vendorEGL; 89 }; 90 // clang-format on 91 92 // ---------------------------------------------------------------------------- 93 94 extern gl_hooks_t gHooks[2]; 95 extern gl_hooks_t gHooksNoContext; 96 extern pthread_key_t gGLWrapperKey; 97 extern "C" void gl_unimplemented(); 98 extern "C" void gl_noop(); 99 100 extern char const * const gl_names[]; 101 extern char const * const gl_names_1[]; 102 extern char const * const egl_names[]; 103 104 extern egl_connection_t gEGLImpl; 105 106 // ---------------------------------------------------------------------------- 107 }; // namespace android 108 // ---------------------------------------------------------------------------- 109 110 #endif /* ANDROID_EGLDEFS_H */ 111