• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
20 #include <log/log.h>
21 
22 #include "../hooks.h"
23 #include "egl_platform_entries.h"
24 
25 #define VERSION_MAJOR 1
26 #define VERSION_MINOR 4
27 #define EGL_MAKE_VERSION(major, minor, patch) (((major) << 22) | ((minor) << 12) | (patch))
28 
29 namespace android {
30 
31 // EGLDisplay are global, not attached to a given thread
32 const unsigned int NUM_DISPLAYS = 1;
33 
34 extern const char* const platform_names[];
35 
36 struct egl_connection_t {
37     enum { GLESv1_INDEX = 0, GLESv2_INDEX = 1 };
38 
egl_connection_tegl_connection_t39     inline egl_connection_t()
40           : dso(nullptr),
41             libEgl(nullptr),
42             libGles1(nullptr),
43             libGles2(nullptr),
44             systemDriverUnloaded(false) {
45         const char* const* entries = platform_names;
46         EGLFuncPointer* curr = reinterpret_cast<EGLFuncPointer*>(&platform);
47         while (*entries) {
48             const char* name = *entries;
49             EGLFuncPointer f = FindPlatformImplAddr(name);
50 
51             if (f == nullptr) {
52                 // If no entry found, update the lookup table: sPlatformImplMap
53                 ALOGE("No entry found in platform lookup table for %s", name);
54             }
55 
56             *curr++ = f;
57             entries++;
58         }
59     }
60 
61     void* dso;
62     gl_hooks_t* hooks[2];
63     EGLint major;
64     EGLint minor;
65     EGLint driverVersion;
66     egl_t egl;
67 
68     // Functions implemented or redirected by platform libraries
69     platform_impl_t platform;
70 
71     void* libEgl;
72     void* libGles1;
73     void* libGles2;
74 
75     bool systemDriverUnloaded;
76     bool useAngle; // Was ANGLE successfully loaded
77 };
78 
79 extern gl_hooks_t gHooks[2];
80 extern gl_hooks_t gHooksNoContext;
81 extern pthread_key_t gGLWrapperKey;
82 extern "C" void gl_unimplemented();
83 extern "C" void gl_noop();
84 extern const char* const gl_names[];
85 extern const char* const gl_names_1[];
86 extern const char* const egl_names[];
87 extern egl_connection_t gEGLImpl;
88 
89 }; // namespace android
90 
91 #endif /* ANDROID_EGLDEFS_H */
92