• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef FRAMEWORKS_OPENGL_WRAPPER_EGL_WRAPPER_LAYER_H
16 #define FRAMEWORKS_OPENGL_WRAPPER_EGL_WRAPPER_LAYER_H
17 #include <string>
18 #include <vector>
19 #include <EGL/egl.h>
20 #include "egl_defs.h"
21 #include "egl_system_layers_manager.h"
22 
23 namespace OHOS {
24 using GetNextLayerAddr = void *(*)(void *, const char *);
25 using LayerInitFunc = EglWrapperFuncPointer (*)(const void *, GetNextLayerAddr);
26 using LayerSetupFunc = EglWrapperFuncPointer (*)(const char *, EglWrapperFuncPointer);
27 using FunctionTable = std::map<std::string, EglWrapperFuncPointer>;
28 
29 class EglWrapperLayer {
30 public:
31     static EglWrapperLayer& GetInstance();
32     ~EglWrapperLayer();
33     bool Init(EglWrapperDispatchTable *table);
34 #if USE_IGRAPHICS_EXTENDS_HOOKS
GetIGraphicsLogicStatus()35     bool GetIGraphicsLogicStatus() const { return iGraphicsLogic; }
36 #endif
37     bool InitBundleInfo();
38 
39 private:
EglWrapperLayer()40     EglWrapperLayer() : initialized_(false), dlhandle_(nullptr) {};
41     bool LoadLayers(void);
42     bool LoadLayers(const std::string& libname, const std::vector<std::string> &layerPaths);
43     bool DoLoadLayers(const std::vector<std::string>& layers);
44     bool LoadLayerFuncs(const std::string& realLayerPath);
45     void InitLayers(EglWrapperDispatchTable *table);
46     void SetupLayerFuncTbl(EglWrapperDispatchTable *table);
47 
48     std::vector<LayerInitFunc> layerInit_;
49     std::vector<LayerSetupFunc> layerSetup_;
50     std::vector<FunctionTable> layerFuncTbl_;
51     bool initialized_;
52     void *dlhandle_;
53     EglSystemLayersManager eglSystemLayersManager_;
54 #if USE_IGRAPHICS_EXTENDS_HOOKS
55     bool iGraphicsLogic = false;
56 #endif
57 };
58 } // namespace OHOS
59 #endif // FRAMEWORKS_OPENGL_WRAPPER_EGL_WRAPPER_LAYER_H
60