Mathias Agopian | 9d17c05 | 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 | |
| 20 | #include <ctype.h> |
| 21 | #include <string.h> |
| 22 | #include <errno.h> |
| 23 | |
| 24 | #include <utils/Errors.h> |
| 25 | #include <utils/Singleton.h> |
| 26 | #include <utils/String8.h> |
Mathias Agopian | 9d17c05 | 2009-05-28 17:39:03 -0700 | [diff] [blame] | 27 | |
| 28 | #include <EGL/egl.h> |
| 29 | |
| 30 | // ---------------------------------------------------------------------------- |
| 31 | namespace android { |
| 32 | // ---------------------------------------------------------------------------- |
| 33 | |
Mathias Agopian | 6fc5699 | 2009-10-14 02:06:37 -0700 | [diff] [blame] | 34 | struct egl_connection_t; |
Mathias Agopian | 9d17c05 | 2009-05-28 17:39:03 -0700 | [diff] [blame] | 35 | |
| 36 | class Loader : public Singleton<Loader> |
| 37 | { |
| 38 | friend class Singleton<Loader>; |
| 39 | |
| 40 | typedef __eglMustCastToProperFunctionPointerType (*getProcAddressType)( |
| 41 | const char*); |
| 42 | |
| 43 | enum { |
| 44 | EGL = 0x01, |
| 45 | GLESv1_CM = 0x02, |
| 46 | GLESv2 = 0x04 |
| 47 | }; |
| 48 | struct driver_t { |
| 49 | driver_t(void* gles); |
| 50 | ~driver_t(); |
| 51 | status_t set(void* hnd, int32_t api); |
| 52 | void* dso[3]; |
| 53 | }; |
| 54 | |
Mathias Agopian | 8db8509 | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 55 | String8 mDriverTag; |
Mathias Agopian | 9d17c05 | 2009-05-28 17:39:03 -0700 | [diff] [blame] | 56 | getProcAddressType getProcAddress; |
| 57 | |
Mathias Agopian | 9d17c05 | 2009-05-28 17:39:03 -0700 | [diff] [blame] | 58 | public: |
| 59 | ~Loader(); |
| 60 | |
Mathias Agopian | 8db8509 | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 61 | void* open(egl_connection_t* cnx); |
Mathias Agopian | 9d17c05 | 2009-05-28 17:39:03 -0700 | [diff] [blame] | 62 | status_t close(void* driver); |
| 63 | |
| 64 | private: |
| 65 | Loader(); |
Brian Swetland | a21c200 | 2010-09-20 12:58:15 -0700 | [diff] [blame] | 66 | void *load_driver(const char* kind, const char *tag, egl_connection_t* cnx, uint32_t mask); |
Mathias Agopian | 9d17c05 | 2009-05-28 17:39:03 -0700 | [diff] [blame] | 67 | |
| 68 | static __attribute__((noinline)) |
| 69 | void init_api(void* dso, |
| 70 | char const * const * api, |
| 71 | __eglMustCastToProperFunctionPointerType* curr, |
| 72 | getProcAddressType getProcAddress); |
| 73 | }; |
| 74 | |
| 75 | // ---------------------------------------------------------------------------- |
| 76 | }; // namespace android |
| 77 | // ---------------------------------------------------------------------------- |
| 78 | |
| 79 | #endif /* ANDROID_EGL_LOADER_H */ |