blob: 93c33a824b3465fa77320f33625390c223ac6144 [file] [log] [blame]
Mathias Agopiande586972009-05-28 17:39:03 -07001/*
2 ** Copyright 2009, 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_EGL_LOADER_H
18#define ANDROID_EGL_LOADER_H
19
Mathias Agopian311b4792017-02-28 15:00:49 -080020#include <stdint.h>
Mathias Agopiande586972009-05-28 17:39:03 -070021
Mathias Agopiande586972009-05-28 17:39:03 -070022#include <EGL/egl.h>
23
24// ----------------------------------------------------------------------------
25namespace android {
26// ----------------------------------------------------------------------------
27
Mathias Agopian618fa102009-10-14 02:06:37 -070028struct egl_connection_t;
Mathias Agopiande586972009-05-28 17:39:03 -070029
Mathias Agopian65421432017-03-08 11:49:05 -080030class Loader {
Mathias Agopian311b4792017-02-28 15:00:49 -080031 typedef __eglMustCastToProperFunctionPointerType (* getProcAddressType)(const char*);
Mathias Agopiande586972009-05-28 17:39:03 -070032
33 enum {
34 EGL = 0x01,
35 GLESv1_CM = 0x02,
Cody Northrop87a562c2018-10-04 14:44:11 -060036 GLESv2 = 0x04,
37 PLATFORM = 0x08
Mathias Agopiande586972009-05-28 17:39:03 -070038 };
39 struct driver_t {
Chih-Hung Hsiehe8761d62016-09-01 11:26:34 -070040 explicit driver_t(void* gles);
Mathias Agopiande586972009-05-28 17:39:03 -070041 ~driver_t();
Mathias Agopian65421432017-03-08 11:49:05 -080042 // returns -errno
43 int set(void* hnd, int32_t api);
Mathias Agopiande586972009-05-28 17:39:03 -070044 void* dso[3];
45 };
46
Mathias Agopiande586972009-05-28 17:39:03 -070047 getProcAddressType getProcAddress;
Jesse Hall7a8d83e2016-12-20 15:24:28 -080048
Mathias Agopiande586972009-05-28 17:39:03 -070049public:
Mathias Agopian65421432017-03-08 11:49:05 -080050 static Loader& getInstance();
Mathias Agopiande586972009-05-28 17:39:03 -070051 ~Loader();
52
Mathias Agopianada798b2012-02-13 17:09:30 -080053 void* open(egl_connection_t* cnx);
Mathias Agopian65421432017-03-08 11:49:05 -080054 void close(void* driver);
Mathias Agopiande586972009-05-28 17:39:03 -070055
56private:
57 Loader();
Mathias Agopian99381422013-04-23 20:52:29 +020058 void *load_driver(const char* kind, egl_connection_t* cnx, uint32_t mask);
Mathias Agopiande586972009-05-28 17:39:03 -070059
60 static __attribute__((noinline))
61 void init_api(void* dso,
62 char const * const * api,
63 __eglMustCastToProperFunctionPointerType* curr,
64 getProcAddressType getProcAddress);
65};
66
67// ----------------------------------------------------------------------------
68}; // namespace android
69// ----------------------------------------------------------------------------
70
71#endif /* ANDROID_EGL_LOADER_H */