• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // This header is used to define the EGLDispatch structure that contains
29 // pointers to the EGL shared library used by libOpenglRender. Normally,
30 // this will be our own libEGL_translator, but one could imagine a
31 // vendor-specific being used instead.
32 
33 // There is a single global instance of this structure, named |s_egl|,
34 // which must be initialized by calling init_egl_dispatch() before use.
35 
36 // Note that our code requires the implementation of misc EGL extensions
37 // including eglSetSwapRectangleANDROID(), see RenderEGL_extensions_functions.h
38 // for a full list.
39 
40 #define RENDER_EGL_DEFINE_TYPE(return_type, function_name, signature) \
41     typedef return_type (EGLAPIENTRY *function_name ## _t) signature;
42 
43 #define RENDER_EGL_DECLARE_MEMBER(return_type, function_name, signature) \
44     function_name ## _t function_name;
45 
46 // Define function typedefs.
47 LIST_RENDER_EGL_FUNCTIONS(RENDER_EGL_DEFINE_TYPE)
48 LIST_RENDER_EGL_EXTENSIONS_FUNCTIONS(RENDER_EGL_DEFINE_TYPE)
49 LIST_RENDER_EGL_SNAPSHOT_FUNCTIONS(RENDER_EGL_DEFINE_TYPE)
50 
51 // Define EGLDispatch structure.
52 struct EGLDispatch {
53     LIST_RENDER_EGL_FUNCTIONS(RENDER_EGL_DECLARE_MEMBER)
54     LIST_RENDER_EGL_EXTENSIONS_FUNCTIONS(RENDER_EGL_DECLARE_MEMBER)
55     LIST_RENDER_EGL_SNAPSHOT_FUNCTIONS(RENDER_EGL_DECLARE_MEMBER)
56 
57     bool initialized = false;
58 };
59 
60 // Initialize EGLDispatch function. Return true on success, false on failure.
61 bool init_egl_dispatch();
62 
63 // Global EGLDispatch instance. Call init_egl_dispatch() before using it.
64 extern EGLDispatch s_egl;
65