OSDN Git Service

egl: Add support for EGL_KHR_image_base.
[android-x86/external-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 #include "eglcontext.h"
7 #include "eglsurface.h"
8
9
10 /**
11  * Optional EGL extensions info.
12  */
13 struct _egl_extensions
14 {
15    EGLBoolean MESA_screen_surface;
16    EGLBoolean MESA_copy_context;
17    EGLBoolean KHR_image;
18    EGLBoolean KHR_image_base;
19    EGLBoolean KHR_image_pixmap;
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    _EGLImage *ImageList;
58 };
59
60
61 extern void
62 _eglFiniDisplay(void);
63
64
65 extern char *
66 _eglSplitDisplayString(const char *dpyString, const char **args);
67
68
69 extern _EGLDisplay *
70 _eglNewDisplay(NativeDisplayType displayName);
71
72
73 extern EGLDisplay
74 _eglLinkDisplay(_EGLDisplay *dpy);
75
76
77 extern void
78 _eglUnlinkDisplay(_EGLDisplay *dpy);
79
80
81 extern _EGLDisplay *
82 _eglFindDisplay(NativeDisplayType nativeDisplay);
83
84
85 extern void
86 _eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *dpy);
87
88
89 extern void
90 _eglCleanupDisplay(_EGLDisplay *disp);
91
92
93 extern EGLContext
94 _eglLinkContext(_EGLContext *ctx, _EGLDisplay *dpy);
95
96
97 extern void
98 _eglUnlinkContext(_EGLContext *ctx);
99
100
101 extern EGLSurface
102 _eglLinkSurface(_EGLSurface *surf, _EGLDisplay *dpy);
103
104
105 extern void
106 _eglUnlinkSurface(_EGLSurface *surf);
107
108
109 #ifndef _EGL_SKIP_HANDLE_CHECK
110
111
112 extern EGLBoolean
113 _eglCheckDisplayHandle(EGLDisplay dpy);
114
115
116 extern EGLBoolean
117 _eglCheckContextHandle(EGLContext ctx, _EGLDisplay *dpy);
118
119
120 extern EGLBoolean
121 _eglCheckSurfaceHandle(EGLSurface surf, _EGLDisplay *dpy);
122
123
124 #else /* !_EGL_SKIP_HANDLE_CHECK */
125
126 /* Only do a quick check.  This is NOT standard compliant. */
127
128 static INLINE EGLBoolean
129 _eglCheckDisplayHandle(EGLDisplay dpy)
130 {
131    return ((_EGLDisplay *) dpy != NULL);
132 }
133
134
135 static INLINE EGLBoolean
136 _eglCheckContextHandle(EGLContext ctx, _EGLDisplay *dpy)
137 {
138    _EGLContext *c = (_EGLContext *) ctx;
139    return (dpy && c && c->Display == dpy);
140 }
141
142
143 static INLINE EGLBoolean
144 _eglCheckSurfaceHandle(EGLSurface surf, _EGLDisplay *dpy)
145 {
146    _EGLSurface *s = (_EGLSurface *) surf;
147    return (dpy && s && s->Display == dpy);
148 }
149
150
151 #endif /* _EGL_SKIP_HANDLE_CHECK */
152
153
154 /**
155  * Lookup a handle to find the linked display.
156  * Return NULL if the handle has no corresponding linked display.
157  */
158 static INLINE _EGLDisplay *
159 _eglLookupDisplay(EGLDisplay display)
160 {
161    _EGLDisplay *dpy = (_EGLDisplay *) display;
162    if (!_eglCheckDisplayHandle(display))
163       dpy = NULL;
164    return dpy;
165 }
166
167
168 /**
169  * Return the handle of a linked display, or EGL_NO_DISPLAY.
170  */
171 static INLINE EGLDisplay
172 _eglGetDisplayHandle(_EGLDisplay *dpy)
173 {
174    return (EGLDisplay) ((dpy) ? dpy : EGL_NO_DISPLAY);
175 }
176
177
178 /**
179  * Return true if the display is linked.
180  */
181 static INLINE EGLBoolean
182 _eglIsDisplayLinked(_EGLDisplay *dpy)
183 {
184    return (EGLBoolean) (_eglGetDisplayHandle(dpy) != EGL_NO_DISPLAY);
185 }
186
187
188 /**
189  * Lookup a handle to find the linked context.
190  * Return NULL if the handle has no corresponding linked context.
191  */
192 static INLINE _EGLContext *
193 _eglLookupContext(EGLContext context, _EGLDisplay *dpy)
194 {
195    _EGLContext *ctx = (_EGLContext *) context;
196    if (!_eglCheckContextHandle(context, dpy))
197       ctx = NULL;
198    return ctx;
199 }
200
201
202 /**
203  * Return the handle of a linked context, or EGL_NO_CONTEXT.
204  */
205 static INLINE EGLContext
206 _eglGetContextHandle(_EGLContext *ctx)
207 {
208    return (EGLContext) ((ctx && ctx->Display) ? ctx : EGL_NO_CONTEXT);
209 }
210
211
212 /**
213  * Return true if the context is linked to a display.
214  */
215 static INLINE EGLBoolean
216 _eglIsContextLinked(_EGLContext *ctx)
217 {
218    return (EGLBoolean) (_eglGetContextHandle(ctx) != EGL_NO_CONTEXT);
219 }
220
221
222 /**
223  * Lookup a handle to find the linked surface.
224  * Return NULL if the handle has no corresponding linked surface.
225  */
226 static INLINE _EGLSurface *
227 _eglLookupSurface(EGLSurface surface, _EGLDisplay *dpy)
228 {
229    _EGLSurface *surf = (_EGLSurface *) surface;
230    if (!_eglCheckSurfaceHandle(surf, dpy))
231       surf = NULL;
232    return surf;
233 }
234
235
236 /**
237  * Return the handle of a linked surface, or EGL_NO_SURFACE.
238  */
239 static INLINE EGLSurface
240 _eglGetSurfaceHandle(_EGLSurface *surf)
241 {
242    return (EGLSurface) ((surf && surf->Display) ? surf : EGL_NO_SURFACE);
243 }
244
245
246 /**
247  * Return true if the surface is linked to a display.
248  */
249 static INLINE EGLBoolean
250 _eglIsSurfaceLinked(_EGLSurface *surf)
251 {
252    return (EGLBoolean) (_eglGetSurfaceHandle(surf) != EGL_NO_SURFACE);
253 }
254
255
256 /**
257  * Cast an unsigned int to a pointer.
258  */
259 static INLINE void *
260 _eglUIntToPointer(unsigned int v)
261 {
262    return (void *) ((uintptr_t) v);
263 }
264
265
266 /**
267  * Cast a pointer to an unsigned int.  The pointer must be one that is
268  * returned by _eglUIntToPointer.
269  */
270 static INLINE unsigned int
271 _eglPointerToUInt(const void *p)
272 {
273    return (unsigned int) ((uintptr_t) p);
274 }
275
276
277 #endif /* EGLDISPLAY_INCLUDED */