1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #ifndef GL_DISPATCHH 17 #define GL_DISPATCHH 18 19 #include <GLES/gl.h> 20 #include <GLES2/gl2.h> 21 #include <GLES3/gl3.h> 22 23 #include "base/Lock.h" 24 25 #include "OpenGLESDispatch/gldefs.h" 26 #include "OpenGLESDispatch/gles_functions.h" 27 #include "GLutils.h" 28 29 #include <functional> 30 31 #define GLAPIENTRY GL_APIENTRY 32 typedef void (*FUNCPTR_NO_ARGS_RET_VOID)(); 33 typedef int (*FUNCPTR_NO_ARGS_RET_INT)(); 34 typedef GLsync (*FUNCPTR_FENCE_SYNC)(GLenum, GLbitfield); 35 typedef GLenum (*FUNCPTR_CLIENT_WAIT_SYNC)(GLsync, GLbitfield, GLuint64); 36 typedef void (*FUNCPTR_DELETE_SYNC)(GLsync); 37 typedef void (*FUNCPTR_WAIT_SYNC)(GLsync, GLbitfield, GLuint64); 38 typedef void (*FUNCPTR_GET_SYNC_IV)(GLsync, GLenum pname, GLsizei bufsize, GLsizei *length, GLint *values); 39 40 class GlLibrary; 41 42 #define GLES_DECLARE_METHOD(return_type, function_name, signature, args) \ 43 static return_type (*function_name) signature; 44 45 using EGLGetProcAddressFunc = std::function<void*(const char* name)>; 46 47 class GLDispatch { 48 public: 49 // Constructor. 50 GLDispatch(); 51 52 bool isInitialized() const; 53 void dispatchFuncs(GLESVersion version, GlLibrary* glLib, EGLGetProcAddressFunc eglGPA); 54 GLESVersion getGLESVersion() const; 55 56 LIST_GLES_FUNCTIONS(GLES_DECLARE_METHOD, GLES_DECLARE_METHOD) 57 58 private: 59 bool m_isLoaded; 60 GLESVersion m_version; 61 static android::base::Lock s_lock; 62 }; 63 64 #endif // GL_DISPATCH_H 65