| Mathias Agopian | 1cadb25 | 2011-05-23 17:26:14 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | ** Copyright 2011, 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_EGLDEFS_H | 
|  | 18 | #define ANDROID_EGLDEFS_H | 
|  | 19 |  | 
| Yiwei Zhang | 8af0306 | 2020-08-12 21:28:15 -0700 | [diff] [blame] | 20 | #include <log/log.h> | 
|  | 21 |  | 
| Mathias Agopian | 39c24a2 | 2013-04-04 23:17:56 -0700 | [diff] [blame] | 22 | #include "../hooks.h" | 
| Cody Northrop | 9d5d33d | 2018-10-15 18:32:14 -0600 | [diff] [blame] | 23 | #include "egl_platform_entries.h" | 
|  | 24 |  | 
| Mathias Agopian | 7773c43 | 2012-02-13 20:06:08 -0800 | [diff] [blame] | 25 | #define VERSION_MAJOR 1 | 
|  | 26 | #define VERSION_MINOR 4 | 
| Courtney Goeltzenleuchter | 015ed67 | 2018-07-27 13:43:23 -0600 | [diff] [blame] | 27 | #define EGL_MAKE_VERSION(major, minor, patch) (((major) << 22) | ((minor) << 12) | (patch)) | 
| Mathias Agopian | 7773c43 | 2012-02-13 20:06:08 -0800 | [diff] [blame] | 28 |  | 
| Mathias Agopian | 1cadb25 | 2011-05-23 17:26:14 -0700 | [diff] [blame] | 29 | namespace android { | 
| Mathias Agopian | 1cadb25 | 2011-05-23 17:26:14 -0700 | [diff] [blame] | 30 |  | 
| Yiwei Zhang | 8af0306 | 2020-08-12 21:28:15 -0700 | [diff] [blame] | 31 | // EGLDisplay are global, not attached to a given thread | 
| Mathias Agopian | 1cadb25 | 2011-05-23 17:26:14 -0700 | [diff] [blame] | 32 | const unsigned int NUM_DISPLAYS = 1; | 
|  | 33 |  | 
| Yiwei Zhang | 8af0306 | 2020-08-12 21:28:15 -0700 | [diff] [blame] | 34 | extern const char* const platform_names[]; | 
| Mathias Agopian | 1cadb25 | 2011-05-23 17:26:14 -0700 | [diff] [blame] | 35 |  | 
| Mathias Agopian | 7773c43 | 2012-02-13 20:06:08 -0800 | [diff] [blame] | 36 | struct egl_connection_t { | 
| Yiwei Zhang | 8af0306 | 2020-08-12 21:28:15 -0700 | [diff] [blame] | 37 | enum { GLESv1_INDEX = 0, GLESv2_INDEX = 1 }; | 
| Mathias Agopian | 7773c43 | 2012-02-13 20:06:08 -0800 | [diff] [blame] | 38 |  | 
| Yiwei Zhang | 8af0306 | 2020-08-12 21:28:15 -0700 | [diff] [blame] | 39 | inline egl_connection_t() | 
|  | 40 | : dso(nullptr), | 
|  | 41 | libEgl(nullptr), | 
|  | 42 | libGles1(nullptr), | 
|  | 43 | libGles2(nullptr), | 
| Peiyong Lin | 2f51e75 | 2023-06-15 22:35:14 +0000 | [diff] [blame] | 44 | systemDriverUnloaded(false), | 
| Peiyong Lin | 9fc4cf3 | 2023-11-03 05:18:53 +0000 | [diff] [blame] | 45 | angleLoaded(false), | 
|  | 46 | angleGetDisplayPlatformFunc(nullptr), | 
|  | 47 | angleResetDisplayPlatformFunc(nullptr) { | 
| Yiwei Zhang | 8af0306 | 2020-08-12 21:28:15 -0700 | [diff] [blame] | 48 | const char* const* entries = platform_names; | 
| Cody Northrop | 9d5d33d | 2018-10-15 18:32:14 -0600 | [diff] [blame] | 49 | EGLFuncPointer* curr = reinterpret_cast<EGLFuncPointer*>(&platform); | 
|  | 50 | while (*entries) { | 
|  | 51 | const char* name = *entries; | 
|  | 52 | EGLFuncPointer f = FindPlatformImplAddr(name); | 
|  | 53 |  | 
|  | 54 | if (f == nullptr) { | 
|  | 55 | // If no entry found, update the lookup table: sPlatformImplMap | 
|  | 56 | ALOGE("No entry found in platform lookup table for %s", name); | 
|  | 57 | } | 
|  | 58 |  | 
|  | 59 | *curr++ = f; | 
|  | 60 | entries++; | 
|  | 61 | } | 
|  | 62 | } | 
| Cody Northrop | 68d1035 | 2018-10-15 07:22:09 -0600 | [diff] [blame] | 63 |  | 
| Yiwei Zhang | 8af0306 | 2020-08-12 21:28:15 -0700 | [diff] [blame] | 64 | void* dso; | 
|  | 65 | gl_hooks_t* hooks[2]; | 
|  | 66 | EGLint major; | 
|  | 67 | EGLint minor; | 
|  | 68 | EGLint driverVersion; | 
|  | 69 | egl_t egl; | 
| Jesse Hall | c07b520 | 2013-07-04 12:08:16 -0700 | [diff] [blame] | 70 |  | 
| Cody Northrop | 68d1035 | 2018-10-15 07:22:09 -0600 | [diff] [blame] | 71 | // Functions implemented or redirected by platform libraries | 
| Yiwei Zhang | 8af0306 | 2020-08-12 21:28:15 -0700 | [diff] [blame] | 72 | platform_impl_t platform; | 
| Cody Northrop | 68d1035 | 2018-10-15 07:22:09 -0600 | [diff] [blame] | 73 |  | 
| Yiwei Zhang | 8af0306 | 2020-08-12 21:28:15 -0700 | [diff] [blame] | 74 | void* libEgl; | 
|  | 75 | void* libGles1; | 
|  | 76 | void* libGles2; | 
| Cody Northrop | 1f00e17 | 2018-04-02 11:23:31 -0600 | [diff] [blame] | 77 |  | 
| Yiwei Zhang | 8af0306 | 2020-08-12 21:28:15 -0700 | [diff] [blame] | 78 | bool systemDriverUnloaded; | 
| Peiyong Lin | 2f51e75 | 2023-06-15 22:35:14 +0000 | [diff] [blame] | 79 | bool angleLoaded; // Was ANGLE successfully loaded | 
| Peiyong Lin | 9fc4cf3 | 2023-11-03 05:18:53 +0000 | [diff] [blame] | 80 |  | 
|  | 81 | void* angleGetDisplayPlatformFunc; | 
|  | 82 | void* angleResetDisplayPlatformFunc; | 
| Mathias Agopian | 1cadb25 | 2011-05-23 17:26:14 -0700 | [diff] [blame] | 83 | }; | 
| Mathias Agopian | 1cadb25 | 2011-05-23 17:26:14 -0700 | [diff] [blame] | 84 |  | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 85 | extern gl_hooks_t gHooks[2]; | 
| Mathias Agopian | 1cadb25 | 2011-05-23 17:26:14 -0700 | [diff] [blame] | 86 | extern gl_hooks_t gHooksNoContext; | 
|  | 87 | extern pthread_key_t gGLWrapperKey; | 
|  | 88 | extern "C" void gl_unimplemented(); | 
| Mathias Agopian | 48d438d | 2012-01-28 21:44:00 -0800 | [diff] [blame] | 89 | extern "C" void gl_noop(); | 
| Yiwei Zhang | 8af0306 | 2020-08-12 21:28:15 -0700 | [diff] [blame] | 90 | extern const char* const gl_names[]; | 
|  | 91 | extern const char* const gl_names_1[]; | 
|  | 92 | extern const char* const egl_names[]; | 
| Mathias Agopian | ada798b | 2012-02-13 17:09:30 -0800 | [diff] [blame] | 93 | extern egl_connection_t gEGLImpl; | 
| Mathias Agopian | 1cadb25 | 2011-05-23 17:26:14 -0700 | [diff] [blame] | 94 |  | 
| Mathias Agopian | 1cadb25 | 2011-05-23 17:26:14 -0700 | [diff] [blame] | 95 | }; // namespace android | 
| Mathias Agopian | 1cadb25 | 2011-05-23 17:26:14 -0700 | [diff] [blame] | 96 |  | 
|  | 97 | #endif /* ANDROID_EGLDEFS_H */ |