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