blob: d0435e7ea0c2853be350ba3fbb1f536556865ebe [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
20#include <ctype.h>
21#include <string.h>
22#include <errno.h>
23
24#include <utils/Errors.h>
25#include <utils/Singleton.h>
26#include <utils/String8.h>
Mathias Agopiande586972009-05-28 17:39:03 -070027
Jesse Hall7a8d83e2016-12-20 15:24:28 -080028#include <gui/GraphicsEnv.h>
29
Mathias Agopiande586972009-05-28 17:39:03 -070030#include <EGL/egl.h>
31
32// ----------------------------------------------------------------------------
33namespace android {
34// ----------------------------------------------------------------------------
35
Mathias Agopian618fa102009-10-14 02:06:37 -070036struct egl_connection_t;
Mathias Agopiande586972009-05-28 17:39:03 -070037
38class Loader : public Singleton<Loader>
39{
40 friend class Singleton<Loader>;
41
42 typedef __eglMustCastToProperFunctionPointerType (*getProcAddressType)(
43 const char*);
44
45 enum {
46 EGL = 0x01,
47 GLESv1_CM = 0x02,
48 GLESv2 = 0x04
49 };
50 struct driver_t {
Chih-Hung Hsiehe8761d62016-09-01 11:26:34 -070051 explicit driver_t(void* gles);
Mathias Agopiande586972009-05-28 17:39:03 -070052 ~driver_t();
53 status_t set(void* hnd, int32_t api);
54 void* dso[3];
55 };
56
Mathias Agopiande586972009-05-28 17:39:03 -070057 getProcAddressType getProcAddress;
Jesse Hall7a8d83e2016-12-20 15:24:28 -080058
59 void* mLibGui;
60 decltype(android_getDriverNamespace)* mGetDriverNamespace;
61
Mathias Agopiande586972009-05-28 17:39:03 -070062public:
63 ~Loader();
64
Mathias Agopianada798b2012-02-13 17:09:30 -080065 void* open(egl_connection_t* cnx);
Mathias Agopiande586972009-05-28 17:39:03 -070066 status_t close(void* driver);
67
68private:
69 Loader();
Mathias Agopian99381422013-04-23 20:52:29 +020070 void *load_driver(const char* kind, egl_connection_t* cnx, uint32_t mask);
Mathias Agopiande586972009-05-28 17:39:03 -070071
72 static __attribute__((noinline))
73 void init_api(void* dso,
74 char const * const * api,
75 __eglMustCastToProperFunctionPointerType* curr,
76 getProcAddressType getProcAddress);
77};
78
79// ----------------------------------------------------------------------------
80}; // namespace android
81// ----------------------------------------------------------------------------
82
83#endif /* ANDROID_EGL_LOADER_H */