a5c14530676d5a5dc86b07b5ed51b1a84b57cddb
[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_DRM,
15 _EGL_PLATFORM_FBDEV,
16
17 _EGL_NUM_PLATFORMS,
18 _EGL_INVALID_PLATFORM = -1
19 };
20 typedef enum _egl_platform_type _EGLPlatformType;
21
22
23 enum _egl_resource_type {
24 _EGL_RESOURCE_CONTEXT,
25 _EGL_RESOURCE_SURFACE,
26 _EGL_RESOURCE_IMAGE,
27 _EGL_RESOURCE_SYNC,
28
29 _EGL_NUM_RESOURCES
30 };
31 /* this cannot and need not go into egltypedefs.h */
32 typedef enum _egl_resource_type _EGLResourceType;
33
34
35 /**
36 * A resource of a display.
37 */
38 struct _egl_resource
39 {
40 /* which display the resource belongs to */
41 _EGLDisplay *Display;
42 EGLBoolean IsLinked;
43
44 /* used to link resources of the same type */
45 _EGLResource *Next;
46 };
47
48
49 /**
50 * Optional EGL extensions info.
51 */
52 struct _egl_extensions
53 {
54 EGLBoolean MESA_screen_surface;
55 EGLBoolean MESA_copy_context;
56 EGLBoolean MESA_drm_display;
57
58 EGLBoolean KHR_image_base;
59 EGLBoolean KHR_image_pixmap;
60 EGLBoolean KHR_vg_parent_image;
61 EGLBoolean KHR_gl_texture_2D_image;
62 EGLBoolean KHR_gl_texture_cubemap_image;
63 EGLBoolean KHR_gl_texture_3D_image;
64 EGLBoolean KHR_gl_renderbuffer_image;
65
66 EGLBoolean KHR_reusable_sync;
67
68 EGLBoolean KHR_surfaceless_gles1;
69 EGLBoolean KHR_surfaceless_gles2;
70 EGLBoolean KHR_surfaceless_opengl;
71
72 EGLBoolean NOK_swap_region;
73 EGLBoolean NOK_texture_from_pixmap;
74
75 char String[_EGL_MAX_EXTENSIONS_LEN];
76 };
77
78
79 struct _egl_display
80 {
81 /* used to link displays */
82 _EGLDisplay *Next;
83
84 _EGLMutex Mutex;
85
86 _EGLPlatformType Platform;
87 void *PlatformDisplay;
88
89 EGLBoolean Initialized; /**< True if the display is initialized */
90 _EGLDriver *Driver;
91 void *DriverData; /* private to driver */
92
93 int APImajor, APIminor; /**< as returned by eglInitialize() */
94 char Version[1000]; /**< initialized from APImajor/minor, DriverName */
95
96 /** Bitmask of supported APIs (EGL_xx_BIT) set by the driver during init */
97 EGLint ClientAPIsMask;
98 char ClientAPIs[1000]; /**< updated by eglQueryString */
99
100 _EGLExtensions Extensions;
101
102 _EGLArray *Screens;
103 _EGLArray *Configs;
104
105 /* lists of resources */
106 _EGLResource *ResourceLists[_EGL_NUM_RESOURCES];
107 };
108
109
110 extern _EGLPlatformType
111 _eglGetNativePlatform(void);
112
113
114 extern void
115 _eglFiniDisplay(void);
116
117
118 extern _EGLDisplay *
119 _eglFindDisplay(_EGLPlatformType plat, void *plat_dpy);
120
121
122 PUBLIC void
123 _eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *dpy);
124
125
126 PUBLIC void
127 _eglCleanupDisplay(_EGLDisplay *disp);
128
129
130 extern EGLBoolean
131 _eglCheckDisplayHandle(EGLDisplay dpy);
132
133
134 PUBLIC EGLBoolean
135 _eglCheckResource(void *res, _EGLResourceType type, _EGLDisplay *dpy);
136
137
138 /**
139 * Lookup a handle to find the linked display.
140 * Return NULL if the handle has no corresponding linked display.
141 */
142 static INLINE _EGLDisplay *
143 _eglLookupDisplay(EGLDisplay display)
144 {
145 _EGLDisplay *dpy = (_EGLDisplay *) display;
146 if (!_eglCheckDisplayHandle(display))
147 dpy = NULL;
148 return dpy;
149 }
150
151
152 /**
153 * Return the handle of a linked display, or EGL_NO_DISPLAY.
154 */
155 static INLINE EGLDisplay
156 _eglGetDisplayHandle(_EGLDisplay *dpy)
157 {
158 return (EGLDisplay) ((dpy) ? dpy : EGL_NO_DISPLAY);
159 }
160
161
162 extern void
163 _eglLinkResource(_EGLResource *res, _EGLResourceType type, _EGLDisplay *dpy);
164
165
166 extern void
167 _eglUnlinkResource(_EGLResource *res, _EGLResourceType type);
168
169
170 /**
171 * Return true if the resource is linked.
172 */
173 static INLINE EGLBoolean
174 _eglIsResourceLinked(_EGLResource *res)
175 {
176 return res->IsLinked;
177 }
178
179
180 #endif /* EGLDISPLAY_INCLUDED */