st/xa: Fix crosscompile builds with nonstandard ld locations
[mesa.git] / src / egl / main / egldisplay.h
1 #ifndef EGLDISPLAY_INCLUDED
2 #define EGLDISPLAY_INCLUDED
3
4
5 #include "egltypedefs.h"
6 #include "egldefines.h"
7 #include "eglmutex.h"
8 #include "eglarray.h"
9
10
11 enum _egl_platform_type {
12 _EGL_PLATFORM_WINDOWS,
13 _EGL_PLATFORM_X11,
14 _EGL_PLATFORM_WAYLAND,
15 _EGL_PLATFORM_DRM,
16 _EGL_PLATFORM_FBDEV,
17
18 _EGL_NUM_PLATFORMS,
19 _EGL_INVALID_PLATFORM = -1
20 };
21 typedef enum _egl_platform_type _EGLPlatformType;
22
23
24 enum _egl_resource_type {
25 _EGL_RESOURCE_CONTEXT,
26 _EGL_RESOURCE_SURFACE,
27 _EGL_RESOURCE_IMAGE,
28 _EGL_RESOURCE_SYNC,
29
30 _EGL_NUM_RESOURCES
31 };
32 /* this cannot and need not go into egltypedefs.h */
33 typedef enum _egl_resource_type _EGLResourceType;
34
35
36 /**
37 * A resource of a display.
38 */
39 struct _egl_resource
40 {
41 /* which display the resource belongs to */
42 _EGLDisplay *Display;
43 EGLBoolean IsLinked;
44 EGLint RefCount;
45
46 /* used to link resources of the same type */
47 _EGLResource *Next;
48 };
49
50
51 /**
52 * Optional EGL extensions info.
53 */
54 struct _egl_extensions
55 {
56 EGLBoolean MESA_screen_surface;
57 EGLBoolean MESA_copy_context;
58 EGLBoolean MESA_drm_display;
59 EGLBoolean MESA_drm_image;
60
61 EGLBoolean WL_bind_wayland_display;
62
63 EGLBoolean KHR_image_base;
64 EGLBoolean KHR_image_pixmap;
65 EGLBoolean KHR_vg_parent_image;
66 EGLBoolean KHR_gl_texture_2D_image;
67 EGLBoolean KHR_gl_texture_cubemap_image;
68 EGLBoolean KHR_gl_texture_3D_image;
69 EGLBoolean KHR_gl_renderbuffer_image;
70
71 EGLBoolean KHR_reusable_sync;
72 EGLBoolean KHR_fence_sync;
73
74 EGLBoolean KHR_surfaceless_gles1;
75 EGLBoolean KHR_surfaceless_gles2;
76 EGLBoolean KHR_surfaceless_opengl;
77
78 EGLBoolean NOK_swap_region;
79 EGLBoolean NOK_texture_from_pixmap;
80 };
81
82
83 struct _egl_display
84 {
85 /* used to link displays */
86 _EGLDisplay *Next;
87
88 _EGLMutex Mutex;
89
90 _EGLPlatformType Platform; /**< The type of the platform display */
91 void *PlatformDisplay; /**< A pointer to the platform display */
92
93 _EGLDriver *Driver; /**< Matched driver of the display */
94 EGLBoolean Initialized; /**< True if the display is initialized */
95
96 /* options that affect how the driver initializes the display */
97 struct {
98 EGLBoolean TestOnly; /**< Driver should not set fields when true */
99 EGLBoolean UseFallback; /**< Use fallback driver (sw or less features) */
100 } Options;
101
102 /* these fields are set by the driver during init */
103 void *DriverData; /**< Driver private data */
104 EGLint VersionMajor; /**< EGL major version */
105 EGLint VersionMinor; /**< EGL minor version */
106 EGLint ClientAPIs; /**< Bitmask of APIs supported (EGL_xxx_BIT) */
107 _EGLExtensions Extensions; /**< Extensions supported */
108
109 /* these fields are derived from above */
110 char VersionString[1000]; /**< EGL_VERSION */
111 char ClientAPIsString[1000]; /**< EGL_CLIENT_APIS */
112 char ExtensionsString[_EGL_MAX_EXTENSIONS_LEN]; /**< EGL_EXTENSIONS */
113
114 _EGLArray *Screens;
115 _EGLArray *Configs;
116
117 /* lists of resources */
118 _EGLResource *ResourceLists[_EGL_NUM_RESOURCES];
119 };
120
121
122 extern _EGLPlatformType
123 _eglGetNativePlatform(void);
124
125
126 extern void
127 _eglFiniDisplay(void);
128
129
130 extern _EGLDisplay *
131 _eglFindDisplay(_EGLPlatformType plat, void *plat_dpy);
132
133
134 PUBLIC void
135 _eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *dpy);
136
137
138 PUBLIC void
139 _eglCleanupDisplay(_EGLDisplay *disp);
140
141
142 extern EGLBoolean
143 _eglCheckDisplayHandle(EGLDisplay dpy);
144
145
146 PUBLIC EGLBoolean
147 _eglCheckResource(void *res, _EGLResourceType type, _EGLDisplay *dpy);
148
149
150 /**
151 * Lookup a handle to find the linked display.
152 * Return NULL if the handle has no corresponding linked display.
153 */
154 static INLINE _EGLDisplay *
155 _eglLookupDisplay(EGLDisplay display)
156 {
157 _EGLDisplay *dpy = (_EGLDisplay *) display;
158 if (!_eglCheckDisplayHandle(display))
159 dpy = NULL;
160 return dpy;
161 }
162
163
164 /**
165 * Return the handle of a linked display, or EGL_NO_DISPLAY.
166 */
167 static INLINE EGLDisplay
168 _eglGetDisplayHandle(_EGLDisplay *dpy)
169 {
170 return (EGLDisplay) ((dpy) ? dpy : EGL_NO_DISPLAY);
171 }
172
173
174 extern void
175 _eglInitResource(_EGLResource *res, EGLint size, _EGLDisplay *dpy);
176
177
178 PUBLIC void
179 _eglGetResource(_EGLResource *res);
180
181
182 PUBLIC EGLBoolean
183 _eglPutResource(_EGLResource *res);
184
185
186 extern void
187 _eglLinkResource(_EGLResource *res, _EGLResourceType type);
188
189
190 extern void
191 _eglUnlinkResource(_EGLResource *res, _EGLResourceType type);
192
193
194 /**
195 * Return true if the resource is linked.
196 */
197 static INLINE EGLBoolean
198 _eglIsResourceLinked(_EGLResource *res)
199 {
200 return res->IsLinked;
201 }
202
203
204 #endif /* EGLDISPLAY_INCLUDED */