egl: Add wayland platform
[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 KHR_image_base;
62 EGLBoolean KHR_image_pixmap;
63 EGLBoolean KHR_vg_parent_image;
64 EGLBoolean KHR_gl_texture_2D_image;
65 EGLBoolean KHR_gl_texture_cubemap_image;
66 EGLBoolean KHR_gl_texture_3D_image;
67 EGLBoolean KHR_gl_renderbuffer_image;
68
69 EGLBoolean KHR_reusable_sync;
70 EGLBoolean KHR_fence_sync;
71
72 EGLBoolean KHR_surfaceless_gles1;
73 EGLBoolean KHR_surfaceless_gles2;
74 EGLBoolean KHR_surfaceless_opengl;
75
76 EGLBoolean NOK_swap_region;
77 EGLBoolean NOK_texture_from_pixmap;
78 };
79
80
81 struct _egl_display
82 {
83 /* used to link displays */
84 _EGLDisplay *Next;
85
86 _EGLMutex Mutex;
87
88 _EGLPlatformType Platform; /**< The type of the platform display */
89 void *PlatformDisplay; /**< A pointer to the platform display */
90
91 _EGLDriver *Driver; /**< Matched driver of the display */
92 EGLBoolean Initialized; /**< True if the display is initialized */
93
94 /* options that affect how the driver initializes the display */
95 struct {
96 EGLBoolean TestOnly; /**< Driver should not set fields when true */
97 EGLBoolean UseFallback; /**< Use fallback driver (sw or less features) */
98 } Options;
99
100 /* these fields are set by the driver during init */
101 void *DriverData; /**< Driver private data */
102 EGLint VersionMajor; /**< EGL major version */
103 EGLint VersionMinor; /**< EGL minor version */
104 EGLint ClientAPIs; /**< Bitmask of APIs supported (EGL_xxx_BIT) */
105 _EGLExtensions Extensions; /**< Extensions supported */
106
107 /* these fields are derived from above */
108 char VersionString[1000]; /**< EGL_VERSION */
109 char ClientAPIsString[1000]; /**< EGL_CLIENT_APIS */
110 char ExtensionsString[_EGL_MAX_EXTENSIONS_LEN]; /**< EGL_EXTENSIONS */
111
112 _EGLArray *Screens;
113 _EGLArray *Configs;
114
115 /* lists of resources */
116 _EGLResource *ResourceLists[_EGL_NUM_RESOURCES];
117 };
118
119
120 extern _EGLPlatformType
121 _eglGetNativePlatform(void);
122
123
124 extern void
125 _eglFiniDisplay(void);
126
127
128 extern _EGLDisplay *
129 _eglFindDisplay(_EGLPlatformType plat, void *plat_dpy);
130
131
132 PUBLIC void
133 _eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *dpy);
134
135
136 PUBLIC void
137 _eglCleanupDisplay(_EGLDisplay *disp);
138
139
140 extern EGLBoolean
141 _eglCheckDisplayHandle(EGLDisplay dpy);
142
143
144 PUBLIC EGLBoolean
145 _eglCheckResource(void *res, _EGLResourceType type, _EGLDisplay *dpy);
146
147
148 /**
149 * Lookup a handle to find the linked display.
150 * Return NULL if the handle has no corresponding linked display.
151 */
152 static INLINE _EGLDisplay *
153 _eglLookupDisplay(EGLDisplay display)
154 {
155 _EGLDisplay *dpy = (_EGLDisplay *) display;
156 if (!_eglCheckDisplayHandle(display))
157 dpy = NULL;
158 return dpy;
159 }
160
161
162 /**
163 * Return the handle of a linked display, or EGL_NO_DISPLAY.
164 */
165 static INLINE EGLDisplay
166 _eglGetDisplayHandle(_EGLDisplay *dpy)
167 {
168 return (EGLDisplay) ((dpy) ? dpy : EGL_NO_DISPLAY);
169 }
170
171
172 extern void
173 _eglInitResource(_EGLResource *res, EGLint size, _EGLDisplay *dpy);
174
175
176 PUBLIC void
177 _eglGetResource(_EGLResource *res);
178
179
180 PUBLIC EGLBoolean
181 _eglPutResource(_EGLResource *res);
182
183
184 extern void
185 _eglLinkResource(_EGLResource *res, _EGLResourceType type);
186
187
188 extern void
189 _eglUnlinkResource(_EGLResource *res, _EGLResourceType type);
190
191
192 /**
193 * Return true if the resource is linked.
194 */
195 static INLINE EGLBoolean
196 _eglIsResourceLinked(_EGLResource *res)
197 {
198 return res->IsLinked;
199 }
200
201
202 #endif /* EGLDISPLAY_INCLUDED */