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 #pragma once
17 
18 extern "C" {
19     #include "OpenGLESDispatch/RenderEGL_functions.h"
20     #include "OpenGLESDispatch/RenderEGL_extensions_functions.h"
21     #include "OpenGLESDispatch/RenderEGL_snapshot_functions.h"
22 }
23 
24 #include "OpenGLESDispatch/RenderEGL_static_translator_namespaced_header.h"
25 #include "OpenGLESDispatch/RenderEGL_extensions_static_translator_namespaced_header.h"
26 #include "OpenGLESDispatch/RenderEGL_snapshot_static_translator_namespaced_header.h"
27 
28 namespace gfxstream {
29 namespace gl {
30 
31 // This header is used to define the EGLDispatch structure that contains
32 // pointers to the EGL shared library used by libOpenglRender. Normally,
33 // this will be our own libEGL_translator, but one could imagine a
34 // vendor-specific being used instead.
35 
36 // There is a single global instance of this structure, named |s_egl|,
37 // which must be initialized by calling init_egl_dispatch() before use.
38 
39 // Note that our code requires the implementation of misc EGL extensions
40 // including eglSetSwapRectangleANDROID(), see RenderEGL_extensions_functions.h
41 // for a full list.
42 
43 #define RENDER_EGL_DEFINE_TYPE(return_type, function_name, signature) \
44     typedef return_type (EGLAPIENTRY *function_name ## _t) signature;
45 
46 #define RENDER_EGL_DECLARE_MEMBER(return_type, function_name, signature) \
47     function_name ## _t function_name;
48 
49 // Define function typedefs.
50 LIST_RENDER_EGL_FUNCTIONS(RENDER_EGL_DEFINE_TYPE)
51 LIST_RENDER_EGL_EXTENSIONS_FUNCTIONS(RENDER_EGL_DEFINE_TYPE)
52 LIST_RENDER_EGL_SNAPSHOT_FUNCTIONS(RENDER_EGL_DEFINE_TYPE)
53 
54 // Define EGLDispatch structure.
55 struct EGLDispatch {
56     LIST_RENDER_EGL_FUNCTIONS(RENDER_EGL_DECLARE_MEMBER)
57     LIST_RENDER_EGL_EXTENSIONS_FUNCTIONS(RENDER_EGL_DECLARE_MEMBER)
58     LIST_RENDER_EGL_SNAPSHOT_FUNCTIONS(RENDER_EGL_DECLARE_MEMBER)
59 
60     bool initialized = false;
61 };
62 
63 // Initialize EGLDispatch function. Return true on success, false on failure.
64 bool init_egl_dispatch();
65 
66 // Global EGLDispatch instance. Call init_egl_dispatch() before using it.
67 extern EGLDispatch s_egl;
68 
69 }  // namespace gl
70 }  // namespace gfxstream
71