1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FRAMEWORKS_OPENGL_WRAPPER_EGL_WRAPPER_LOADER_H
17 #define FRAMEWORKS_OPENGL_WRAPPER_EGL_WRAPPER_LOADER_H
18 #include <EGL/egl.h>
19 
20 namespace OHOS {
21 struct EglWrapperDispatchTable;
22 struct EglHookTable;
23 struct GlHookTable;
24 
25 using FunctionPointerType = __eglMustCastToProperFunctionPointerType;
26 
27 class EglWrapperLoader {
28 public:
29     static EglWrapperLoader& GetInstance();
30     ~EglWrapperLoader();
31     bool Load(EglWrapperDispatchTable *table);
32     bool Unload(EglWrapperDispatchTable *table);
33     void *GetProcAddrFromDriver(const char *name);
34 private:
EglWrapperLoader()35     EglWrapperLoader() : dlEglHandle_(nullptr), dlGlHandle1_(nullptr),
36         dlGlHandle2_(nullptr), dlGlHandle3_(nullptr) {};
37     bool LoadEgl(const char *libName, EglHookTable *table);
38     void *LoadGl(const char *libName, char const * const *glName, FunctionPointerType *entry);
39     bool LoadVendorDriver(EglWrapperDispatchTable *table);
40     void *dlEglHandle_;
41     void *dlGlHandle1_;
42     void *dlGlHandle2_;
43     void *dlGlHandle3_;
44 };
45 } // namespace OHOS
46 #endif // FRAMEWORKS_OPENGL_WRAPPER_EGL_WRAPPER_LOADER_H
47