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 EGL_MANAGER_H 17 #define EGL_MANAGER_H 18 19 #include <GLES3/gl32.h> 20 #include <EGL/egl.h> 21 #include <EGL/eglext.h> 22 #include "../../effectChain/include/ec_log.h" 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 namespace OHOS { 29 namespace Rosen { 30 class EglManager { 31 public: 32 static constexpr int EGL_SUPPORT_VERSION = 3; 33 static constexpr int EGL_LIMIT_VERSION = 4; GetInstance()34 static EglManager& GetInstance() 35 { 36 static EglManager manager; 37 return manager; 38 } 39 ~EglManager()40 ~EglManager() {} 41 EGLConfig GetConfig(int version, EGLDisplay eglDisplay); 42 void Init(); 43 44 private: EglManager()45 EglManager() : EGLDisplay_(EGL_NO_DISPLAY), EGLConfig_(nullptr), EGLContext_(EGL_NO_CONTEXT), 46 currentSurface_(nullptr) {} 47 EglManager(const EglManager&) = delete; 48 EglManager& operator=(const EglManager&) = delete; 49 EGLDisplay EGLDisplay_; 50 EGLConfig EGLConfig_; 51 EGLContext EGLContext_; 52 EGLSurface currentSurface_; 53 NativeWindow *EGLWindow_ = nullptr; 54 bool initialized_ = false; 55 int EGLWidth_ = 0; 56 int EGLHeight_ = 0; 57 }; 58 } // namespace Rosen 59 } // namespace OHOS 60 61 #ifdef __cplusplus 62 } 63 #endif 64 65 #endif // EGL_MANAGER_H 66