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