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 #include "OpenGLESDispatch/EGLDispatch.h"
17
18 #include <stdio.h>
19 #include <stdlib.h>
20
21 EGLDispatch s_egl;
22
23 #define RENDER_EGL_LOAD_FIELD_STATIC(return_type, function_name, signature) \
24 s_egl. function_name = (function_name ## _t) (translator::egl::function_name); \
25
26 #define RENDER_EGL_LOAD_FIELD_WITH_EGL(return_type, function_name, signature) \
27 if ((!s_egl. function_name) && s_egl.eglGetProcAddress) s_egl. function_name = \
28 (function_name ## _t) s_egl.eglGetProcAddress(#function_name); \
29
30 #define RENDER_EGL_LOAD_OPTIONAL_FIELD_STATIC(return_type, function_name, signature) \
31 if (s_egl.eglGetProcAddress) s_egl. function_name = \
32 (function_name ## _t) s_egl.eglGetProcAddress(#function_name); \
33 if (!s_egl.function_name || !s_egl.eglGetProcAddress) \
34 RENDER_EGL_LOAD_FIELD_STATIC(return_type, function_name, signature)
35
init_egl_dispatch()36 bool init_egl_dispatch() {
37 if (s_egl.initialized) return true;
38
39 LIST_RENDER_EGL_FUNCTIONS(RENDER_EGL_LOAD_FIELD_STATIC)
40 LIST_RENDER_EGL_FUNCTIONS(RENDER_EGL_LOAD_FIELD_WITH_EGL)
41 LIST_RENDER_EGL_EXTENSIONS_FUNCTIONS(RENDER_EGL_LOAD_OPTIONAL_FIELD_STATIC)
42 LIST_RENDER_EGL_SNAPSHOT_FUNCTIONS(RENDER_EGL_LOAD_FIELD_STATIC)
43
44 s_egl.initialized = true;
45 return true;
46 }
47