Loader.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 <ctype.h>
  19. #include <string.h>
  20. #include <errno.h>
  21. #include <utils/Errors.h>
  22. #include <utils/Singleton.h>
  23. #include <utils/String8.h>
  24. #include <EGL/egl.h>
  25. // ----------------------------------------------------------------------------
  26. namespace android {
  27. // ----------------------------------------------------------------------------
  28. struct egl_connection_t;
  29. class Loader : public Singleton<Loader>
  30. {
  31. friend class Singleton<Loader>;
  32. typedef __eglMustCastToProperFunctionPointerType (*getProcAddressType)(
  33. const char*);
  34. enum {
  35. EGL = 0x01,
  36. GLESv1_CM = 0x02,
  37. GLESv2 = 0x04
  38. };
  39. struct driver_t {
  40. driver_t(void* gles);
  41. ~driver_t();
  42. status_t set(void* hnd, int32_t api);
  43. void* dso[3];
  44. };
  45. getProcAddressType getProcAddress;
  46. public:
  47. ~Loader();
  48. void* open(egl_connection_t* cnx);
  49. status_t close(void* driver);
  50. private:
  51. Loader();
  52. void *load_driver(const char* kind, egl_connection_t* cnx, uint32_t mask);
  53. static __attribute__((noinline))
  54. void init_api(void* dso,
  55. char const * const * api,
  56. __eglMustCastToProperFunctionPointerType* curr,
  57. getProcAddressType getProcAddress);
  58. };
  59. // ----------------------------------------------------------------------------
  60. }; // namespace android
  61. // ----------------------------------------------------------------------------
  62. #endif /* ANDROID_EGL_LOADER_H */