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 GL_EGL_STATE_H 16 #define GL_EGL_STATE_H 17 #include <cstdint> 18 #include "GLES/gl.h" 19 #include "GLES2/gl2.h" 20 #include "GLES2/gl2ext.h" 21 #include "EGL/egl.h" 22 #include "EGL/eglext.h" 23 namespace OHOS { 24 namespace HDI { 25 namespace DISPLAY { 26 class GlEglState { 27 public: 28 bool Init(NativeWindowType nativeWindow); 29 bool Init(uint32_t width, uint32_t height); 30 void SwapBuffer(); 31 void MakeCurrent(); GetDisplay()32 EGLDisplay GetDisplay() 33 { 34 return eglDisplay_; 35 } 36 37 private: 38 void CreateEglSurface(EGLNativeWindowType nativeWindow); 39 bool Init(const EGLint surfaceType); 40 NativeWindowType nativeWindow_ = 0; 41 EGLDisplay eglDisplay_ = EGL_DEFAULT_DISPLAY; 42 EGLSurface eglSurface_ = EGL_NO_SURFACE; 43 EGLConfig eglConfig_ = EGL_NO_CONFIG_KHR; 44 EGLContext eglContext_ = EGL_NO_CONTEXT; 45 }; 46 } 47 } 48 } 49 #endif // GL_EGL_STATE_H