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 EGL_EXT_FUNCTION_H 16 #define EGL_EXT_FUNCTION_H 17 #include <cstdint> 18 #include <mutex> 19 #include "EGL/egl.h" 20 #include "EGL/eglext.h" 21 #include "GLES2/gl2.h" 22 #include "GLES2/gl2ext.h" 23 24 class EglExtFunction { 25 public: getInstance()26 static EglExtFunction getInstance() 27 { 28 static EglExtFunction instance; 29 static std::once_flag once; 30 std::call_once(once, [&]() { instance.Init(); }); 31 return instance; 32 } 33 34 bool Init(); // user must call the interface before using 35 EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, 36 const EGLint *attrib_list); 37 EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image); 38 void glEGLImageTargetTexture2DOES(EGLenum target, GLeglImageOES image); 39 void EGLImageTargetTexture2D(GLenum target, GLeglImageOES image); 40 41 private: 42 PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHRFunc_ = nullptr; 43 PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHRFunc_ = nullptr; 44 PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOESFunc_ = nullptr; 45 }; 46 47 #endif // EGL_EXT_FUNCTION_H