Loader.h 2.3 KB

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