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