blob: 4e9d7d0d26bd3855bad898be91dda2d5b4745d16 [file] [log] [blame]
Mathias Agopian1cadb252011-05-23 17:26:14 -07001/*
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
Charlie Lao95c7aea2020-01-10 11:12:03 -080020#include <cutils/properties.h>
21#include <log/log.h>
22
Mathias Agopian39c24a22013-04-04 23:17:56 -070023#include "../hooks.h"
Cody Northrop9d5d33d2018-10-15 18:32:14 -060024#include "egl_platform_entries.h"
25
Mathias Agopian7773c432012-02-13 20:06:08 -080026#define VERSION_MAJOR 1
27#define VERSION_MINOR 4
Courtney Goeltzenleuchter015ed672018-07-27 13:43:23 -060028#define EGL_MAKE_VERSION(major, minor, patch) (((major) << 22) | ((minor) << 12) | (patch))
Mathias Agopian7773c432012-02-13 20:06:08 -080029
Mathias Agopian1cadb252011-05-23 17:26:14 -070030// ----------------------------------------------------------------------------
31namespace android {
32// ----------------------------------------------------------------------------
33
Mathias Agopian1cadb252011-05-23 17:26:14 -070034// EGLDisplay are global, not attached to a given thread
35const unsigned int NUM_DISPLAYS = 1;
36
Mathias Agopian1cadb252011-05-23 17:26:14 -070037// ----------------------------------------------------------------------------
38
Cody Northrop9d5d33d2018-10-15 18:32:14 -060039extern char const * const platform_names[];
40
Courtney Goeltzenleuchter015ed672018-07-27 13:43:23 -060041// clang-format off
Mathias Agopian7773c432012-02-13 20:06:08 -080042struct egl_connection_t {
43 enum {
44 GLESv1_INDEX = 0,
45 GLESv2_INDEX = 1
46 };
47
Charlie Lao95c7aea2020-01-10 11:12:03 -080048 enum {
49 GLES_NO_DRIVER = 0, // no driver is loaded
50 GLES_SYSTEM_COMBO_DRIVER = 1, // GLES combo driver in system folder is loaded
51 GLES_SYSTEM_STANDALONE_DRIVER = 2, // standalone system drivers are loaded
52 GLES_ANGLE_STANDALONE_DRIVER = 3, // ANGLE (always standalone) drivers are loaded.
53 GLES_UPDATED_COMBO_DRIVER = 4, // GLES combo driver in updated driver folder is loaded
54 GLES_UPDATED_STANDALONE_DRIVER = 5, // standalone drivers in updated driver folder are loaded
55 };
56
Yiwei Zhang5e21eb32019-06-05 00:26:03 -070057 inline egl_connection_t() : dso(nullptr),
58 libEgl(nullptr),
59 libGles1(nullptr),
60 libGles2(nullptr),
61 systemDriverUnloaded(false) {
Cody Northrop9d5d33d2018-10-15 18:32:14 -060062
63 char const* const* entries = platform_names;
64 EGLFuncPointer* curr = reinterpret_cast<EGLFuncPointer*>(&platform);
65 while (*entries) {
66 const char* name = *entries;
67 EGLFuncPointer f = FindPlatformImplAddr(name);
68
69 if (f == nullptr) {
70 // If no entry found, update the lookup table: sPlatformImplMap
71 ALOGE("No entry found in platform lookup table for %s", name);
72 }
73
74 *curr++ = f;
75 entries++;
76 }
77 }
Cody Northrop68d10352018-10-15 07:22:09 -060078
Mathias Agopian1cadb252011-05-23 17:26:14 -070079 void * dso;
80 gl_hooks_t * hooks[2];
81 EGLint major;
82 EGLint minor;
Courtney Goeltzenleuchter015ed672018-07-27 13:43:23 -060083 EGLint driverVersion;
Mathias Agopian1cadb252011-05-23 17:26:14 -070084 egl_t egl;
Jesse Hallc07b5202013-07-04 12:08:16 -070085
Cody Northrop68d10352018-10-15 07:22:09 -060086 // Functions implemented or redirected by platform libraries
87 platform_impl_t platform;
88
Michael Chockc0ec5e22014-01-27 08:14:33 -080089 void* libEgl;
Jesse Hallc07b5202013-07-04 12:08:16 -070090 void* libGles1;
91 void* libGles2;
Cody Northrop1f00e172018-04-02 11:23:31 -060092
Yiwei Zhang5e21eb32019-06-05 00:26:03 -070093 bool systemDriverUnloaded;
Tim Van Patten5f744f12018-12-12 11:46:21 -070094 bool shouldUseAngle; // Should we attempt to load ANGLE
95 bool angleDecided; // Have we tried to load ANGLE
Courtney Goeltzenleuchter555f1df2018-09-25 14:34:29 -060096 EGLint angleBackend;
Charlie Lao95c7aea2020-01-10 11:12:03 -080097 int loadedDriverType;
Cody Northrop1f00e172018-04-02 11:23:31 -060098 void* vendorEGL;
Charlie Lao95c7aea2020-01-10 11:12:03 -080099 bool systemDriverUseExactName;
100 bool systemDriverUseProperty;
101 char systemDriverProperty[PROPERTY_VALUE_MAX + 1];
Mathias Agopian1cadb252011-05-23 17:26:14 -0700102};
Courtney Goeltzenleuchter015ed672018-07-27 13:43:23 -0600103// clang-format on
Mathias Agopian1cadb252011-05-23 17:26:14 -0700104
105// ----------------------------------------------------------------------------
106
Mathias Agopianada798b2012-02-13 17:09:30 -0800107extern gl_hooks_t gHooks[2];
Mathias Agopian1cadb252011-05-23 17:26:14 -0700108extern gl_hooks_t gHooksNoContext;
109extern pthread_key_t gGLWrapperKey;
110extern "C" void gl_unimplemented();
Mathias Agopian48d438d2012-01-28 21:44:00 -0800111extern "C" void gl_noop();
Mathias Agopian1cadb252011-05-23 17:26:14 -0700112
113extern char const * const gl_names[];
Yiwei Zhang7cc58922018-10-10 11:37:43 -0700114extern char const * const gl_names_1[];
Mathias Agopian1cadb252011-05-23 17:26:14 -0700115extern char const * const egl_names[];
116
Mathias Agopianada798b2012-02-13 17:09:30 -0800117extern egl_connection_t gEGLImpl;
Mathias Agopian1cadb252011-05-23 17:26:14 -0700118
119// ----------------------------------------------------------------------------
120}; // namespace android
121// ----------------------------------------------------------------------------
122
123#endif /* ANDROID_EGLDEFS_H */