1 /* 2 ** Copyright 2009, 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_EGL_LOADER_H 18 #define ANDROID_EGL_LOADER_H 19 20 #include <stdint.h> 21 22 #include <EGL/egl.h> 23 24 // ---------------------------------------------------------------------------- 25 namespace android { 26 // ---------------------------------------------------------------------------- 27 28 struct egl_connection_t; 29 30 class Loader { 31 typedef __eglMustCastToProperFunctionPointerType (* getProcAddressType)(const char*); 32 33 enum { 34 EGL = 0x01, 35 GLESv1_CM = 0x02, 36 GLESv2 = 0x04, 37 PLATFORM = 0x08 38 }; 39 struct driver_t { 40 explicit driver_t(void* gles); 41 ~driver_t(); 42 // returns -errno 43 int set(void* hnd, int32_t api); 44 void* dso[3]; 45 }; 46 47 getProcAddressType getProcAddress; 48 49 public: 50 static Loader& getInstance(); 51 ~Loader(); 52 53 void* open(egl_connection_t* cnx); 54 void close(egl_connection_t* cnx); 55 56 private: 57 Loader(); 58 driver_t* attempt_to_load_angle(egl_connection_t* cnx); 59 driver_t* attempt_to_load_updated_driver(egl_connection_t* cnx); 60 driver_t* attempt_to_load_system_driver(egl_connection_t* cnx, const char* suffix, const bool exact); 61 void unload_system_driver(egl_connection_t* cnx); 62 void initialize_api(void* dso, egl_connection_t* cnx, uint32_t mask); 63 void init_angle_backend(void* dso, egl_connection_t* cnx); 64 65 static __attribute__((noinline)) 66 void init_api(void* dso, 67 char const * const * api, 68 char const * const * ref_api, 69 __eglMustCastToProperFunctionPointerType* curr, 70 getProcAddressType getProcAddress); 71 }; 72 73 // ---------------------------------------------------------------------------- 74 }; // namespace android 75 // ---------------------------------------------------------------------------- 76 77 #endif /* ANDROID_EGL_LOADER_H */ 78