Mathias Agopian | de58697 | 2009-05-28 17:39:03 -0700 | [diff] [blame] | 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 | |
Mathias Agopian | 311b479 | 2017-02-28 15:00:49 -0800 | [diff] [blame] | 20 | #include <stdint.h> |
Mathias Agopian | de58697 | 2009-05-28 17:39:03 -0700 | [diff] [blame] | 21 | |
| 22 | #include <utils/Errors.h> |
| 23 | #include <utils/Singleton.h> |
Mathias Agopian | de58697 | 2009-05-28 17:39:03 -0700 | [diff] [blame] | 24 | |
| 25 | #include <EGL/egl.h> |
| 26 | |
| 27 | // ---------------------------------------------------------------------------- |
| 28 | namespace android { |
| 29 | // ---------------------------------------------------------------------------- |
| 30 | |
Mathias Agopian | 618fa10 | 2009-10-14 02:06:37 -0700 | [diff] [blame] | 31 | struct egl_connection_t; |
Mathias Agopian | de58697 | 2009-05-28 17:39:03 -0700 | [diff] [blame] | 32 | |
Mathias Agopian | 311b479 | 2017-02-28 15:00:49 -0800 | [diff] [blame] | 33 | class Loader : public Singleton<Loader> { |
Mathias Agopian | de58697 | 2009-05-28 17:39:03 -0700 | [diff] [blame] | 34 | friend class Singleton<Loader>; |
| 35 | |
Mathias Agopian | 311b479 | 2017-02-28 15:00:49 -0800 | [diff] [blame] | 36 | typedef __eglMustCastToProperFunctionPointerType (* getProcAddressType)(const char*); |
Mathias Agopian | de58697 | 2009-05-28 17:39:03 -0700 | [diff] [blame] | 37 | |
| 38 | enum { |
| 39 | EGL = 0x01, |
| 40 | GLESv1_CM = 0x02, |
| 41 | GLESv2 = 0x04 |
| 42 | }; |
| 43 | struct driver_t { |
Chih-Hung Hsieh | e8761d6 | 2016-09-01 11:26:34 -0700 | [diff] [blame] | 44 | explicit driver_t(void* gles); |
Mathias Agopian | de58697 | 2009-05-28 17:39:03 -0700 | [diff] [blame] | 45 | ~driver_t(); |
| 46 | status_t set(void* hnd, int32_t api); |
| 47 | void* dso[3]; |
| 48 | }; |
| 49 | |
Mathias Agopian | de58697 | 2009-05-28 17:39:03 -0700 | [diff] [blame] | 50 | getProcAddressType getProcAddress; |
Jesse Hall | 7a8d83e | 2016-12-20 15:24:28 -0800 | [diff] [blame] | 51 | |
Mathias Agopian | de58697 | 2009-05-28 17:39:03 -0700 | [diff] [blame] | 52 | public: |
| 53 | ~Loader(); |
| 54 | |
Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 55 | void* open(egl_connection_t* cnx); |
Mathias Agopian | de58697 | 2009-05-28 17:39:03 -0700 | [diff] [blame] | 56 | status_t close(void* driver); |
| 57 | |
| 58 | private: |
| 59 | Loader(); |
Mathias Agopian | 9938142 | 2013-04-23 20:52:29 +0200 | [diff] [blame] | 60 | void *load_driver(const char* kind, egl_connection_t* cnx, uint32_t mask); |
Mathias Agopian | de58697 | 2009-05-28 17:39:03 -0700 | [diff] [blame] | 61 | |
| 62 | static __attribute__((noinline)) |
| 63 | void init_api(void* dso, |
| 64 | char const * const * api, |
| 65 | __eglMustCastToProperFunctionPointerType* curr, |
| 66 | getProcAddressType getProcAddress); |
| 67 | }; |
| 68 | |
| 69 | // ---------------------------------------------------------------------------- |
| 70 | }; // namespace android |
| 71 | // ---------------------------------------------------------------------------- |
| 72 | |
| 73 | #endif /* ANDROID_EGL_LOADER_H */ |