| 1 | /* |
| 2 | Copyright (c) 2012, Broadcom Europe Ltd |
| 3 | All rights reserved. |
| 4 | |
| 5 | Redistribution and use in source and binary forms, with or without |
| 6 | modification, are permitted provided that the following conditions are met: |
| 7 | * Redistributions of source code must retain the above copyright |
| 8 | notice, this list of conditions and the following disclaimer. |
| 9 | * Redistributions in binary form must reproduce the above copyright |
| 10 | notice, this list of conditions and the following disclaimer in the |
| 11 | documentation and/or other materials provided with the distribution. |
| 12 | * Neither the name of the copyright holder nor the |
| 13 | names of its contributors may be used to endorse or promote products |
| 14 | derived from this software without specific prior written permission. |
| 15 | |
| 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY |
| 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
| 28 | #include "interface/khronos/common/khrn_client_unmangle.h" |
| 29 | #include "interface/khronos/include/GLES/gl.h" |
| 30 | #include "interface/khronos/include/GLES/glext.h" |
| 31 | #include "interface/khronos/include/GLES2/gl2.h" |
| 32 | #include "interface/khronos/include/GLES2/gl2ext.h" |
| 33 | |
| 34 | #include "interface/khronos/common/khrn_int_common.h" |
| 35 | #include "interface/khronos/common/khrn_options.h" |
| 36 | |
| 37 | #include "interface/khronos/egl/egl_client_surface.h" |
| 38 | #include "interface/khronos/egl/egl_client_context.h" |
| 39 | #include "interface/khronos/egl/egl_client_config.h" |
| 40 | |
| 41 | #include "interface/khronos/common/khrn_client.h" |
| 42 | #include "interface/khronos/common/khrn_client_rpc.h" |
| 43 | #include "interface/khronos/include/VG/vgext.h" |
| 44 | |
| 45 | #ifdef RPC_DIRECT |
| 46 | #include "interface/khronos/egl/egl_int_impl.h" |
| 47 | #endif |
| 48 | |
| 49 | #if defined(WIN32) || defined(__mips__) |
| 50 | #include "interface/khronos/common/khrn_int_misc_impl.h" |
| 51 | #endif |
| 52 | |
| 53 | #ifdef KHRONOS_EGL_PLATFORM_OPENWFC |
| 54 | #include "interface/khronos/wf/wfc_client_stream.h" |
| 55 | #endif |
| 56 | |
| 57 | #if defined(RPC_DIRECT_MULTI) |
| 58 | #include "middleware/khronos/egl/egl_server.h" |
| 59 | #endif |
| 60 | |
| 61 | #include <stdlib.h> |
| 62 | #include <string.h> |
| 63 | |
| 64 | #ifdef __cplusplus |
| 65 | extern "C" { |
| 66 | #endif |
| 67 | |
| 68 | /* Mangle eglGetProcAddress */ |
| 69 | #include "interface/khronos/common/khrn_client_mangle.h" |
| 70 | |
| 71 | EGLAPI void EGLAPIENTRY (* eglGetProcAddress(const char *procname))(void) |
| 72 | { |
| 73 | /* Don't mangle the rest */ |
| 74 | #include "interface/khronos/common/khrn_client_unmangle.h" |
| 75 | #include "interface/khronos/include/EGL/eglext.h" |
| 76 | |
| 77 | /* TODO: any other functions we need to return here? */ |
| 78 | if(!procname) return (void(*)(void)) NULL; |
| 79 | |
| 80 | #if EGL_KHR_image |
| 81 | if (!strcmp(procname, "eglCreateImageKHR" )) |
| 82 | return (void(*)(void))eglCreateImageKHR; |
| 83 | if (!strcmp(procname, "eglDestroyImageKHR" )) |
| 84 | return (void(*)(void))eglDestroyImageKHR; |
| 85 | #endif |
| 86 | #ifdef GL_EXT_discard_framebuffer |
| 87 | if (!strcmp(procname, "glDiscardFramebufferEXT" )) |
| 88 | return (void(*)(void))glDiscardFramebufferEXT; |
| 89 | #endif |
| 90 | #ifdef GL_EXT_debug_marker |
| 91 | if (!strcmp(procname, "glInsertEventMarkerEXT" )) |
| 92 | return (void(*)(void))glInsertEventMarkerEXT; |
| 93 | if (!strcmp(procname, "glPushGroupMarkerEXT" )) |
| 94 | return (void(*)(void))glPushGroupMarkerEXT; |
| 95 | if (!strcmp(procname, "glPopGroupMarkerEXT" )) |
| 96 | return (void(*)(void))glPopGroupMarkerEXT; |
| 97 | #endif |
| 98 | #if GL_OES_point_size_array |
| 99 | if (!strcmp(procname, "glPointSizePointerOES" )) |
| 100 | return (void(*)(void))glPointSizePointerOES; |
| 101 | #endif |
| 102 | #if GL_OES_EGL_image |
| 103 | if (!strcmp(procname, "glEGLImageTargetTexture2DOES" )) |
| 104 | return (void(*)(void))glEGLImageTargetTexture2DOES; |
| 105 | if (!strcmp(procname, "glEGLImageTargetRenderbufferStorageOES" )) |
| 106 | return (void(*)(void))glEGLImageTargetRenderbufferStorageOES; |
| 107 | #endif |
| 108 | #if GL_OES_matrix_palette |
| 109 | if (!strcmp(procname, "glCurrentPaletteMatrixOES" )) |
| 110 | return (void(*)(void))glCurrentPaletteMatrixOES; |
| 111 | if (!strcmp(procname, "glLoadPaletteFromModelViewMatrixOES" )) |
| 112 | return (void(*)(void))glLoadPaletteFromModelViewMatrixOES; |
| 113 | if (!strcmp(procname, "glMatrixIndexPointerOES" )) |
| 114 | return (void(*)(void))glMatrixIndexPointerOES; |
| 115 | if (!strcmp(procname, "glWeightPointerOES" )) |
| 116 | return (void(*)(void))glWeightPointerOES; |
| 117 | #endif |
| 118 | #ifndef NO_OPENVG |
| 119 | #if VG_KHR_EGL_image |
| 120 | if (!strcmp(procname, "vgCreateEGLImageTargetKHR" )) |
| 121 | return (void(*)(void))vgCreateEGLImageTargetKHR; |
| 122 | #endif |
| 123 | #endif /* NO_OPENVG */ |
| 124 | #if EGL_KHR_lock_surface |
| 125 | if (!strcmp(procname, "eglLockSurfaceKHR" )) |
| 126 | return (void(*)(void))eglLockSurfaceKHR; |
| 127 | if (!strcmp(procname, "eglUnlockSurfaceKHR" )) |
| 128 | return (void(*)(void))eglUnlockSurfaceKHR; |
| 129 | #endif |
| 130 | #if EGL_KHR_sync |
| 131 | if (!strcmp(procname, "eglCreateSyncKHR" )) |
| 132 | return (void(*)(void))eglCreateSyncKHR; |
| 133 | if (!strcmp(procname, "eglDestroySyncKHR" )) |
| 134 | return (void(*)(void))eglDestroySyncKHR; |
| 135 | if (!strcmp(procname, "eglClientWaitSyncKHR" )) |
| 136 | return (void(*)(void))eglClientWaitSyncKHR; |
| 137 | if (!strcmp(procname, "eglSignalSyncKHR" )) |
| 138 | return (void(*)(void))eglSignalSyncKHR; |
| 139 | if (!strcmp(procname, "eglGetSyncAttribKHR" )) |
| 140 | return (void(*)(void))eglGetSyncAttribKHR; |
| 141 | #endif |
| 142 | #if EGL_BRCM_perf_monitor |
| 143 | if (!strcmp(procname, "eglInitPerfMonitorBRCM" )) |
| 144 | return (void(*)(void))eglInitPerfMonitorBRCM; |
| 145 | if (!strcmp(procname, "eglTermPerfMonitorBRCM" )) |
| 146 | return (void(*)(void))eglTermPerfMonitorBRCM; |
| 147 | #endif |
| 148 | #if EGL_BRCM_driver_monitor |
| 149 | if (!strcmp(procname, "eglInitDriverMonitorBRCM" )) |
| 150 | return (void(*)(void))eglInitDriverMonitorBRCM; |
| 151 | if (!strcmp(procname, "eglGetDriverMonitorXMLBRCM" )) |
| 152 | return (void(*)(void))eglGetDriverMonitorXMLBRCM; |
| 153 | if (!strcmp(procname, "eglTermDriverMonitorBRCM" )) |
| 154 | return (void(*)(void))eglTermDriverMonitorBRCM; |
| 155 | #endif |
| 156 | #if EGL_BRCM_perf_stats |
| 157 | if (!strcmp(procname, "eglPerfStatsResetBRCM" )) |
| 158 | return (void(*)(void))eglPerfStatsResetBRCM; |
| 159 | if (!strcmp(procname, "eglPerfStatsGetBRCM" )) |
| 160 | return (void(*)(void))eglPerfStatsGetBRCM; |
| 161 | #endif |
| 162 | #if EGL_BRCM_mem_usage |
| 163 | if (!strcmp(procname, "eglProcessMemUsageGetBRCM" )) |
| 164 | return (void(*)(void))eglProcessMemUsageGetBRCM; |
| 165 | #endif |
| 166 | #ifdef EXPORT_DESTROY_BY_PID |
| 167 | if (!strcmp(procname, "eglDestroyByPidBRCM" )) |
| 168 | return (void(*)(void))eglDestroyByPidBRCM; |
| 169 | #endif |
| 170 | #if GL_OES_draw_texture |
| 171 | if (!strcmp(procname, "glDrawTexsOES" )) |
| 172 | return (void(*)(void))glDrawTexsOES; |
| 173 | if (!strcmp(procname, "glDrawTexiOES" )) |
| 174 | return (void(*)(void))glDrawTexiOES; |
| 175 | if (!strcmp(procname, "glDrawTexxOES" )) |
| 176 | return (void(*)(void))glDrawTexxOES; |
| 177 | if (!strcmp(procname, "glDrawTexsvOES" )) |
| 178 | return (void(*)(void))glDrawTexsvOES; |
| 179 | if (!strcmp(procname, "glDrawTexivOES" )) |
| 180 | return (void(*)(void))glDrawTexivOES; |
| 181 | if (!strcmp(procname, "glDrawTexxvOES" )) |
| 182 | return (void(*)(void))glDrawTexxvOES; |
| 183 | if (!strcmp(procname, "glDrawTexfOES" )) |
| 184 | return (void(*)(void))glDrawTexfOES; |
| 185 | if (!strcmp(procname, "glDrawTexfvOES" )) |
| 186 | return (void(*)(void))glDrawTexfvOES; |
| 187 | #endif |
| 188 | |
| 189 | #if GL_OES_query_matrix |
| 190 | if (!strcmp(procname, "glQueryMatrixxOES" )) |
| 191 | return (void(*)(void))glQueryMatrixxOES; |
| 192 | #endif |
| 193 | |
| 194 | #if GL_OES_framebuffer_object |
| 195 | if (!strcmp(procname, "glIsRenderbufferOES" )) |
| 196 | return (void(*)(void))glIsRenderbufferOES; |
| 197 | if (!strcmp(procname, "glBindRenderbufferOES" )) |
| 198 | return (void(*)(void))glBindRenderbufferOES; |
| 199 | if (!strcmp(procname, "glDeleteRenderbuffersOES" )) |
| 200 | return (void(*)(void))glDeleteRenderbuffersOES; |
| 201 | if (!strcmp(procname, "glGenRenderbuffersOES" )) |
| 202 | return (void(*)(void))glGenRenderbuffersOES; |
| 203 | if (!strcmp(procname, "glRenderbufferStorageOES" )) |
| 204 | return (void(*)(void))glRenderbufferStorageOES; |
| 205 | if (!strcmp(procname, "glGetRenderbufferParameterivOES" )) |
| 206 | return (void(*)(void))glGetRenderbufferParameterivOES; |
| 207 | if (!strcmp(procname, "glIsFramebufferOES" )) |
| 208 | return (void(*)(void))glIsFramebufferOES; |
| 209 | if (!strcmp(procname, "glBindFramebufferOES" )) |
| 210 | return (void(*)(void))glBindFramebufferOES; |
| 211 | if (!strcmp(procname, "glDeleteFramebuffersOES" )) |
| 212 | return (void(*)(void))glDeleteFramebuffersOES; |
| 213 | if (!strcmp(procname, "glGenFramebuffersOES" )) |
| 214 | return (void(*)(void))glGenFramebuffersOES; |
| 215 | if (!strcmp(procname, "glCheckFramebufferStatusOES" )) |
| 216 | return (void(*)(void))glCheckFramebufferStatusOES; |
| 217 | if (!strcmp(procname, "glFramebufferRenderbufferOES" )) |
| 218 | return (void(*)(void))glFramebufferRenderbufferOES; |
| 219 | if (!strcmp(procname, "glFramebufferTexture2DOES" )) |
| 220 | return (void(*)(void))glFramebufferTexture2DOES; |
| 221 | if (!strcmp(procname, "glGetFramebufferAttachmentParameterivOES" )) |
| 222 | return (void(*)(void))glGetFramebufferAttachmentParameterivOES; |
| 223 | if (!strcmp(procname, "glGenerateMipmapOES" )) |
| 224 | return (void(*)(void))glGenerateMipmapOES; |
| 225 | #endif |
| 226 | |
| 227 | #if GL_OES_mapbuffer |
| 228 | if (!strcmp(procname, "glGetBufferPointervOES" )) |
| 229 | return (void(*)(void))glGetBufferPointervOES; |
| 230 | if (!strcmp(procname, "glMapBufferOES" )) |
| 231 | return (void(*)(void))glMapBufferOES; |
| 232 | if (!strcmp(procname, "glUnmapBufferOES" )) |
| 233 | return (void(*)(void))glUnmapBufferOES; |
| 234 | #endif |
| 235 | |
| 236 | #if EGL_proc_state_valid |
| 237 | if (!strcmp(procname, "eglProcStateValid" )) |
| 238 | return (void(*)(void))eglProcStateValid; |
| 239 | #endif |
| 240 | |
| 241 | #if EGL_BRCM_flush |
| 242 | if (!strcmp(procname, "eglFlushBRCM" )) |
| 243 | return (void(*)(void))eglFlushBRCM; |
| 244 | #endif |
| 245 | |
| 246 | #if EGL_BRCM_global_image |
| 247 | if (!strcmp(procname, "eglCreateGlobalImageBRCM" )) |
| 248 | return (void(*)(void))eglCreateGlobalImageBRCM; |
| 249 | if (!strcmp(procname, "eglCreateCopyGlobalImageBRCM" )) |
| 250 | return (void(*)(void))eglCreateCopyGlobalImageBRCM; |
| 251 | if (!strcmp(procname, "eglDestroyGlobalImageBRCM" )) |
| 252 | return (void(*)(void))eglDestroyGlobalImageBRCM; |
| 253 | if (!strcmp(procname, "eglQueryGlobalImageBRCM" )) |
| 254 | return (void(*)(void))eglQueryGlobalImageBRCM; |
| 255 | #endif |
| 256 | |
| 257 | return (void(*)(void)) NULL; |
| 258 | } |
| 259 | |
| 260 | #ifdef __cplusplus |
| 261 | } |
| 262 | #endif |
| 263 | |