blob: 5fbffbd16c017feb527e4f74862f2dc70971b1d2 [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
Mathias Agopian39c24a22013-04-04 23:17:56 -070020#include "../hooks.h"
Cody Northrop9d5d33d2018-10-15 18:32:14 -060021#include "egl_platform_entries.h"
22
Charlie Lao840bd532020-01-16 17:34:37 -080023#include <log/log.h>
24
Mathias Agopian7773c432012-02-13 20:06:08 -080025#define VERSION_MAJOR 1
26#define VERSION_MINOR 4
Courtney Goeltzenleuchter015ed672018-07-27 13:43:23 -060027#define EGL_MAKE_VERSION(major, minor, patch) (((major) << 22) | ((minor) << 12) | (patch))
Mathias Agopian7773c432012-02-13 20:06:08 -080028
Mathias Agopian1cadb252011-05-23 17:26:14 -070029// ----------------------------------------------------------------------------
30namespace android {
31// ----------------------------------------------------------------------------
32
Mathias Agopian1cadb252011-05-23 17:26:14 -070033// EGLDisplay are global, not attached to a given thread
34const unsigned int NUM_DISPLAYS = 1;
35
Mathias Agopian1cadb252011-05-23 17:26:14 -070036// ----------------------------------------------------------------------------
37
Cody Northrop9d5d33d2018-10-15 18:32:14 -060038extern char const * const platform_names[];
39
Courtney Goeltzenleuchter015ed672018-07-27 13:43:23 -060040// clang-format off
Mathias Agopian7773c432012-02-13 20:06:08 -080041struct egl_connection_t {
42 enum {
43 GLESv1_INDEX = 0,
44 GLESv2_INDEX = 1
45 };
46
Yiwei Zhang5e21eb32019-06-05 00:26:03 -070047 inline egl_connection_t() : dso(nullptr),
48 libEgl(nullptr),
49 libGles1(nullptr),
50 libGles2(nullptr),
51 systemDriverUnloaded(false) {
Cody Northrop9d5d33d2018-10-15 18:32:14 -060052
53 char const* const* entries = platform_names;
54 EGLFuncPointer* curr = reinterpret_cast<EGLFuncPointer*>(&platform);
55 while (*entries) {
56 const char* name = *entries;
57 EGLFuncPointer f = FindPlatformImplAddr(name);
58
59 if (f == nullptr) {
60 // If no entry found, update the lookup table: sPlatformImplMap
61 ALOGE("No entry found in platform lookup table for %s", name);
62 }
63
64 *curr++ = f;
65 entries++;
66 }
67 }
Cody Northrop68d10352018-10-15 07:22:09 -060068
Mathias Agopian1cadb252011-05-23 17:26:14 -070069 void * dso;
70 gl_hooks_t * hooks[2];
71 EGLint major;
72 EGLint minor;
Courtney Goeltzenleuchter015ed672018-07-27 13:43:23 -060073 EGLint driverVersion;
Mathias Agopian1cadb252011-05-23 17:26:14 -070074 egl_t egl;
Jesse Hallc07b5202013-07-04 12:08:16 -070075
Cody Northrop68d10352018-10-15 07:22:09 -060076 // Functions implemented or redirected by platform libraries
77 platform_impl_t platform;
78
Michael Chockc0ec5e22014-01-27 08:14:33 -080079 void* libEgl;
Jesse Hallc07b5202013-07-04 12:08:16 -070080 void* libGles1;
81 void* libGles2;
Cody Northrop1f00e172018-04-02 11:23:31 -060082
Yiwei Zhang5e21eb32019-06-05 00:26:03 -070083 bool systemDriverUnloaded;
Charlie Lao840bd532020-01-16 17:34:37 -080084 bool useAngle; // Was ANGLE successfully loaded
Mathias Agopian1cadb252011-05-23 17:26:14 -070085};
Courtney Goeltzenleuchter015ed672018-07-27 13:43:23 -060086// clang-format on
Mathias Agopian1cadb252011-05-23 17:26:14 -070087
88// ----------------------------------------------------------------------------
89
Mathias Agopianada798b2012-02-13 17:09:30 -080090extern gl_hooks_t gHooks[2];
Mathias Agopian1cadb252011-05-23 17:26:14 -070091extern gl_hooks_t gHooksNoContext;
92extern pthread_key_t gGLWrapperKey;
93extern "C" void gl_unimplemented();
Mathias Agopian48d438d2012-01-28 21:44:00 -080094extern "C" void gl_noop();
Mathias Agopian1cadb252011-05-23 17:26:14 -070095
96extern char const * const gl_names[];
Yiwei Zhang7cc58922018-10-10 11:37:43 -070097extern char const * const gl_names_1[];
Mathias Agopian1cadb252011-05-23 17:26:14 -070098extern char const * const egl_names[];
99
Mathias Agopianada798b2012-02-13 17:09:30 -0800100extern egl_connection_t gEGLImpl;
Mathias Agopian1cadb252011-05-23 17:26:14 -0700101
102// ----------------------------------------------------------------------------
103}; // namespace android
104// ----------------------------------------------------------------------------
105
106#endif /* ANDROID_EGLDEFS_H */