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