e1cbbac837cf4ca42d05fce2556ab7cb00c820c2
[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 EGLNativeDisplayType NativeDisplay;
28 EGLDisplay Handle;
29
30 const char *DriverName;
31 _EGLDriver *Driver;
32 void *DriverData; /* private to driver */
33
34 int APImajor, APIminor; /**< as returned by eglInitialize() */
35 char Version[1000]; /**< initialized from APImajor/minor, DriverName */
36
37 /** Bitmask of supported APIs (EGL_xx_BIT) set by the driver during init */
38 EGLint ClientAPIsMask;
39 char ClientAPIs[1000]; /**< updated by eglQueryString */
40
41 _EGLExtensions Extensions;
42
43 int LargestPbuffer;
44
45 EGLint NumScreens;
46 _EGLScreen **Screens; /* array [NumScreens] */
47
48 EGLint NumConfigs;
49 _EGLConfig **Configs; /* array [NumConfigs] of ptr to _EGLConfig */
50
51 /* lists of linked contexts and surface */
52 _EGLContext *ContextList;
53 _EGLSurface *SurfaceList;
54
55 /* hash table to map surfaces to handles */
56 _EGLHashtable *SurfaceHash;
57
58 #ifdef _EGL_PLATFORM_X
59 Display *Xdpy;
60 #endif
61 };
62
63
64 extern _EGLDisplay *
65 _eglNewDisplay(NativeDisplayType displayName);
66
67
68 extern EGLDisplay
69 _eglLinkDisplay(_EGLDisplay *dpy);
70
71
72 extern void
73 _eglUnlinkDisplay(_EGLDisplay *dpy);
74
75
76 extern EGLDisplay
77 _eglGetDisplayHandle(_EGLDisplay *display);
78
79
80 extern _EGLDisplay *
81 _eglLookupDisplay(EGLDisplay dpy);
82
83
84 /**
85 * Return true if the display is linked.
86 */
87 static INLINE EGLBoolean
88 _eglIsDisplayLinked(_EGLDisplay *dpy)
89 {
90 return (EGLBoolean) (_eglGetDisplayHandle(dpy) != EGL_NO_DISPLAY);
91 }
92
93
94 extern _EGLDisplay *
95 _eglFindDisplay(NativeDisplayType nativeDisplay);
96
97
98 extern void
99 _eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *dpy);
100
101
102 extern void
103 _eglCleanupDisplay(_EGLDisplay *disp);
104
105
106 extern EGLContext
107 _eglLinkContext(_EGLContext *ctx, _EGLDisplay *dpy);
108
109
110 extern void
111 _eglUnlinkContext(_EGLContext *ctx);
112
113
114 extern EGLContext
115 _eglGetContextHandle(_EGLContext *ctx);
116
117
118 extern _EGLContext *
119 _eglLookupContext(EGLContext ctx, _EGLDisplay *dpy);
120
121
122 /**
123 * Return true if the context is linked to a display.
124 */
125 static INLINE EGLBoolean
126 _eglIsContextLinked(_EGLContext *ctx)
127 {
128 return (EGLBoolean) (_eglGetContextHandle(ctx) != EGL_NO_CONTEXT);
129 }
130
131 extern EGLSurface
132 _eglLinkSurface(_EGLSurface *surf, _EGLDisplay *dpy);
133
134
135 extern void
136 _eglUnlinkSurface(_EGLSurface *surf);
137
138
139 extern EGLSurface
140 _eglGetSurfaceHandle(_EGLSurface *);
141
142
143 extern _EGLSurface *
144 _eglLookupSurface(EGLSurface surf, _EGLDisplay *dpy);
145
146
147 /**
148 * Return true if the surface is linked to a display.
149 */
150 static INLINE EGLBoolean
151 _eglIsSurfaceLinked(_EGLSurface *surf)
152 {
153 return (EGLBoolean) (_eglGetSurfaceHandle(surf) != EGL_NO_SURFACE);
154 }
155
156
157 /**
158 * Cast an unsigned int to a pointer.
159 */
160 static INLINE void *
161 _eglUIntToPointer(unsigned int v)
162 {
163 return (void *) ((uintptr_t) v);
164 }
165
166
167 /**
168 * Cast a pointer to an unsigned int. The pointer must be one that is
169 * returned by _eglUIntToPointer.
170 */
171 static INLINE unsigned int
172 _eglPointerToUInt(const void *p)
173 {
174 return (unsigned int) ((uintptr_t) p);
175 }
176
177
178 #endif /* EGLDISPLAY_INCLUDED */