1#ifndef __eglplatform_h_
2#define __eglplatform_h_
3
4/*
5** Copyright 2007-2020 The Khronos Group Inc.
6** SPDX-License-Identifier: Apache-2.0
7*/
8
9/* Platform-specific types and definitions for egl.h
10 *
11 * Adopters may modify khrplatform.h and this file to suit their platform.
12 * You are encouraged to submit all modifications to the Khronos group so that
13 * they can be included in future versions of this file.  Please submit changes
14 * by filing an issue or pull request on the public Khronos EGL Registry, at
15 * https://www.github.com/KhronosGroup/EGL-Registry/
16 */
17
18#include <KHR/khrplatform.h>
19
20/* Macros used in EGL function prototype declarations.
21 *
22 * EGL functions should be prototyped as:
23 *
24 * EGLAPI return-type EGLAPIENTRY eglFunction(arguments);
25 * typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments);
26 *
27 * KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h
28 */
29
30#ifndef EGLAPI
31#define EGLAPI KHRONOS_APICALL
32#endif
33
34#ifndef EGLAPIENTRY
35#define EGLAPIENTRY  KHRONOS_APIENTRY
36#endif
37#define EGLAPIENTRYP EGLAPIENTRY*
38
39/* The types NativeDisplayType, NativeWindowType, and NativePixmapType
40 * are aliases of window-system-dependent types, such as X Display * or
41 * Windows Device Context. They must be defined in platform-specific
42 * code below. The EGL-prefixed versions of Native*Type are the same
43 * types, renamed in EGL 1.3 so all types in the API start with "EGL".
44 *
45 * Khronos STRONGLY RECOMMENDS that you use the default definitions
46 * provided below, since these changes affect both binary and source
47 * portability of applications using EGL running on different EGL
48 * implementations.
49 */
50
51#if defined(EGL_NO_PLATFORM_SPECIFIC_TYPES)
52
53typedef void *EGLNativeDisplayType;
54typedef void *EGLNativePixmapType;
55typedef void *EGLNativeWindowType;
56
57#elif defined(OHOS_PLATFORM)
58
59struct NativeWindow;
60
61typedef void*                   EGLNativeDisplayType;
62typedef void*                   EGLNativePixmapType;
63typedef struct NativeWindow*    EGLNativeWindowType;
64
65#elif defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */
66#ifndef WIN32_LEAN_AND_MEAN
67#define WIN32_LEAN_AND_MEAN 1
68#endif
69#include <windows.h>
70
71typedef HDC     EGLNativeDisplayType;
72typedef HBITMAP EGLNativePixmapType;
73typedef HWND    EGLNativeWindowType;
74
75#elif defined(__EMSCRIPTEN__)
76
77typedef int EGLNativeDisplayType;
78typedef int EGLNativePixmapType;
79typedef int EGLNativeWindowType;
80
81#elif defined(__WINSCW__) || defined(__SYMBIAN32__)  /* Symbian */
82
83typedef int   EGLNativeDisplayType;
84typedef void *EGLNativePixmapType;
85typedef void *EGLNativeWindowType;
86
87#elif defined(WL_EGL_PLATFORM)
88
89typedef struct wl_display     *EGLNativeDisplayType;
90typedef struct wl_egl_pixmap  *EGLNativePixmapType;
91typedef struct wl_egl_window  *EGLNativeWindowType;
92
93#elif defined(__GBM__)
94
95typedef struct gbm_device  *EGLNativeDisplayType;
96typedef struct gbm_bo      *EGLNativePixmapType;
97typedef void               *EGLNativeWindowType;
98
99#elif defined(__ANDROID__) || defined(ANDROID)
100
101struct ANativeWindow;
102struct egl_native_pixmap_t;
103
104typedef void*                           EGLNativeDisplayType;
105typedef struct egl_native_pixmap_t*     EGLNativePixmapType;
106typedef struct ANativeWindow*           EGLNativeWindowType;
107
108#elif defined(USE_OZONE)
109
110typedef intptr_t EGLNativeDisplayType;
111typedef intptr_t EGLNativePixmapType;
112typedef intptr_t EGLNativeWindowType;
113
114#elif defined(USE_X11)
115
116/* X11 (tentative)  */
117#include <X11/Xlib.h>
118#include <X11/Xutil.h>
119
120typedef Display *EGLNativeDisplayType;
121typedef Pixmap   EGLNativePixmapType;
122typedef Window   EGLNativeWindowType;
123
124#elif defined(__unix__)
125
126typedef void             *EGLNativeDisplayType;
127typedef khronos_uintptr_t EGLNativePixmapType;
128typedef khronos_uintptr_t EGLNativeWindowType;
129
130#elif defined(__APPLE__)
131
132typedef int   EGLNativeDisplayType;
133typedef void *EGLNativePixmapType;
134typedef void *EGLNativeWindowType;
135
136#elif defined(__HAIKU__)
137
138#include <kernel/image.h>
139
140typedef void              *EGLNativeDisplayType;
141typedef khronos_uintptr_t  EGLNativePixmapType;
142typedef khronos_uintptr_t  EGLNativeWindowType;
143
144#elif defined(__Fuchsia__)
145
146typedef void              *EGLNativeDisplayType;
147typedef khronos_uintptr_t  EGLNativePixmapType;
148typedef khronos_uintptr_t  EGLNativeWindowType;
149
150#else
151#error "Platform not recognized"
152#endif
153
154/* EGL 1.2 types, renamed for consistency in EGL 1.3 */
155typedef EGLNativeDisplayType NativeDisplayType;
156typedef EGLNativePixmapType  NativePixmapType;
157typedef EGLNativeWindowType  NativeWindowType;
158
159
160/* Define EGLint. This must be a signed integral type large enough to contain
161 * all legal attribute names and values passed into and out of EGL, whether
162 * their type is boolean, bitmask, enumerant (symbolic constant), integer,
163 * handle, or other.  While in general a 32-bit integer will suffice, if
164 * handles are 64 bit types, then EGLint should be defined as a signed 64-bit
165 * integer type.
166 */
167typedef khronos_int32_t EGLint;
168
169
170/* C++ / C typecast macros for special EGL handle values */
171#if defined(__cplusplus)
172#define EGL_CAST(type, value) (static_cast<type>(value))
173#else
174#define EGL_CAST(type, value) ((type) (value))
175#endif
176
177#endif /* __eglplatform_h */
178