• 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             angleLoaded(false) {
46         const char* const* entries = platform_names;
47         EGLFuncPointer* curr = reinterpret_cast<EGLFuncPointer*>(&platform);
48         while (*entries) {
49             const char* name = *entries;
50             EGLFuncPointer f = FindPlatformImplAddr(name);
51 
52             if (f == nullptr) {
53                 // If no entry found, update the lookup table: sPlatformImplMap
54                 ALOGE("No entry found in platform lookup table for %s", name);
55             }
56 
57             *curr++ = f;
58             entries++;
59         }
60     }
61 
62     void* dso;
63     gl_hooks_t* hooks[2];
64     EGLint major;
65     EGLint minor;
66     EGLint driverVersion;
67     egl_t egl;
68 
69     // Functions implemented or redirected by platform libraries
70     platform_impl_t platform;
71 
72     void* libEgl;
73     void* libGles1;
74     void* libGles2;
75 
76     bool systemDriverUnloaded;
77     bool angleLoaded; // Was ANGLE successfully loaded
78 };
79 
80 extern gl_hooks_t gHooks[2];
81 extern gl_hooks_t gHooksNoContext;
82 extern pthread_key_t gGLWrapperKey;
83 extern "C" void gl_unimplemented();
84 extern "C" void gl_noop();
85 extern const char* const gl_names[];
86 extern const char* const gl_names_1[];
87 extern const char* const egl_names[];
88 extern egl_connection_t gEGLImpl;
89 
90 }; // namespace android
91 
92 #endif /* ANDROID_EGLDEFS_H */
93