19a4d4e542c113f5e49ac765a808708b5dc3c792
[mesa.git] / src / egl / main / egldisplay.h
1 #ifndef EGLDISPLAY_INCLUDED
2 #define EGLDISPLAY_INCLUDED
3
4 #ifdef _EGL_PLATFORM_X
5 #include <X11/Xlib.h>
6 #endif
7
8 #include "egltypedefs.h"
9 #include "eglhash.h"
10 #include "egldefines.h"
11
12
13 /**
14 * Optional EGL extensions info.
15 */
16 struct _egl_extensions
17 {
18 EGLBoolean MESA_screen_surface;
19 EGLBoolean MESA_copy_context;
20
21 char String[_EGL_MAX_EXTENSIONS_LEN];
22 };
23
24
25 struct _egl_display
26 {
27 /* used to link displays */
28 _EGLDisplay *Next;
29
30 EGLNativeDisplayType NativeDisplay;
31
32 const char *DriverName;
33 _EGLDriver *Driver;
34 void *DriverData; /* private to driver */
35
36 int APImajor, APIminor; /**< as returned by eglInitialize() */
37 char Version[1000]; /**< initialized from APImajor/minor, DriverName */
38
39 /** Bitmask of supported APIs (EGL_xx_BIT) set by the driver during init */
40 EGLint ClientAPIsMask;
41 char ClientAPIs[1000]; /**< updated by eglQueryString */
42
43 _EGLExtensions Extensions;
44
45 int LargestPbuffer;
46
47 EGLint NumScreens;
48 _EGLScreen **Screens; /* array [NumScreens] */
49
50 EGLint NumConfigs;
51 _EGLConfig **Configs; /* array [NumConfigs] of ptr to _EGLConfig */
52
53 /* lists of linked contexts and surface */
54 _EGLContext *ContextList;
55 _EGLSurface *SurfaceList;
56
57 #ifdef _EGL_PLATFORM_X
58 Display *Xdpy;
59 #endif
60 };
61
62
63 extern void
64 _eglFiniDisplay(void);
65
66
67 extern _EGLDisplay *
68 _eglNewDisplay(NativeDisplayType displayName);
69
70
71 extern EGLDisplay
72 _eglLinkDisplay(_EGLDisplay *dpy);
73
74
75 extern void
76 _eglUnlinkDisplay(_EGLDisplay *dpy);
77
78
79 extern EGLDisplay
80 _eglGetDisplayHandle(_EGLDisplay *display);
81
82
83 extern _EGLDisplay *
84 _eglLookupDisplay(EGLDisplay dpy);
85
86
87 /**
88 * Return true if the display is linked.
89 */
90 static INLINE EGLBoolean
91 _eglIsDisplayLinked(_EGLDisplay *dpy)
92 {
93 return (EGLBoolean) (_eglGetDisplayHandle(dpy) != EGL_NO_DISPLAY);
94 }
95
96
97 extern _EGLDisplay *
98 _eglFindDisplay(NativeDisplayType nativeDisplay);
99
100
101 extern void
102 _eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *dpy);
103
104
105 extern void
106 _eglCleanupDisplay(_EGLDisplay *disp);
107
108
109 extern EGLContext
110 _eglLinkContext(_EGLContext *ctx, _EGLDisplay *dpy);
111
112
113 extern void
114 _eglUnlinkContext(_EGLContext *ctx);
115
116
117 extern EGLContext
118 _eglGetContextHandle(_EGLContext *ctx);
119
120
121 extern _EGLContext *
122 _eglLookupContext(EGLContext ctx, _EGLDisplay *dpy);
123
124
125 /**
126 * Return true if the context is linked to a display.
127 */
128 static INLINE EGLBoolean
129 _eglIsContextLinked(_EGLContext *ctx)
130 {
131 return (EGLBoolean) (_eglGetContextHandle(ctx) != EGL_NO_CONTEXT);
132 }
133
134 extern EGLSurface
135 _eglLinkSurface(_EGLSurface *surf, _EGLDisplay *dpy);
136
137
138 extern void
139 _eglUnlinkSurface(_EGLSurface *surf);
140
141
142 extern EGLSurface
143 _eglGetSurfaceHandle(_EGLSurface *);
144
145
146 extern _EGLSurface *
147 _eglLookupSurface(EGLSurface surf, _EGLDisplay *dpy);
148
149
150 /**
151 * Return true if the surface is linked to a display.
152 */
153 static INLINE EGLBoolean
154 _eglIsSurfaceLinked(_EGLSurface *surf)
155 {
156 return (EGLBoolean) (_eglGetSurfaceHandle(surf) != EGL_NO_SURFACE);
157 }
158
159
160 /**
161 * Cast an unsigned int to a pointer.
162 */
163 static INLINE void *
164 _eglUIntToPointer(unsigned int v)
165 {
166 return (void *) ((uintptr_t) v);
167 }
168
169
170 /**
171 * Cast a pointer to an unsigned int. The pointer must be one that is
172 * returned by _eglUIntToPointer.
173 */
174 static INLINE unsigned int
175 _eglPointerToUInt(const void *p)
176 {
177 return (unsigned int) ((uintptr_t) p);
178 }
179
180
181 #endif /* EGLDISPLAY_INCLUDED */