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 bool InitBundleInfo(); 35 #if USE_IGRAPHICS_EXTENDS_HOOKS GetIGraphicsLogicStatus()36 bool GetIGraphicsLogicStatus() { return iGraphicsLogic; } 37 #endif 38 39 private: EglWrapperLayer()40 EglWrapperLayer() : initialized_(false), dlhandle_(nullptr) {}; 41 bool LoadLayers(void); 42 bool LoadLayerFuncs(const std::string& realLayerPath); 43 void InitLayers(EglWrapperDispatchTable *table); 44 void SetupLayerFuncTbl(EglWrapperDispatchTable *table); 45 46 std::vector<LayerInitFunc> layerInit_; 47 std::vector<LayerSetupFunc> layerSetup_; 48 std::vector<FunctionTable> layerFuncTbl_; 49 bool initialized_; 50 void *dlhandle_; 51 52 EglSystemLayersManager eglSystemLayersManager_; 53 #if USE_IGRAPHICS_EXTENDS_HOOKS 54 bool iGraphicsLogic = false; 55 #endif 56 }; 57 } // namespace OHOS 58 #endif // FRAMEWORKS_OPENGL_WRAPPER_EGL_WRAPPER_LAYER_H 59