Rev 5563 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5563 | serge | 1 | /************************************************************************** |
2 | * |
||
3 | * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. |
||
4 | * Copyright 2009-2010 Chia-I Wu |
||
5 | * Copyright 2010-2011 LunarG, Inc. |
||
6 | * All Rights Reserved. |
||
7 | * |
||
8 | * Permission is hereby granted, free of charge, to any person obtaining a |
||
9 | * copy of this software and associated documentation files (the |
||
10 | * "Software"), to deal in the Software without restriction, including |
||
11 | * without limitation the rights to use, copy, modify, merge, publish, |
||
12 | * distribute, sub license, and/or sell copies of the Software, and to |
||
13 | * permit persons to whom the Software is furnished to do so, subject to |
||
14 | * the following conditions: |
||
15 | * |
||
16 | * The above copyright notice and this permission notice (including the |
||
17 | * next paragraph) shall be included in all copies or substantial portions |
||
18 | * of the Software. |
||
19 | * |
||
20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||
21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||
22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||
23 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||
24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||
25 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||
26 | * DEALINGS IN THE SOFTWARE. |
||
27 | * |
||
28 | **************************************************************************/ |
||
29 | |||
30 | |||
31 | /** |
||
32 | * Public EGL API entrypoints |
||
33 | * |
||
34 | * Generally, we use the EGLDisplay parameter as a key to lookup the |
||
35 | * appropriate device driver handle, then jump though the driver's |
||
36 | * dispatch table to handle the function. |
||
37 | * |
||
38 | * That allows us the option of supporting multiple, simultaneous, |
||
39 | * heterogeneous hardware devices in the future. |
||
40 | * |
||
41 | * The EGLDisplay, EGLConfig, EGLContext and EGLSurface types are |
||
42 | * opaque handles. Internal objects are linked to a display to |
||
43 | * create the handles. |
||
44 | * |
||
45 | * For each public API entry point, the opaque handles are looked up |
||
46 | * before being dispatched to the drivers. When it fails to look up |
||
47 | * a handle, one of |
||
48 | * |
||
49 | * EGL_BAD_DISPLAY |
||
50 | * EGL_BAD_CONFIG |
||
51 | * EGL_BAD_CONTEXT |
||
52 | * EGL_BAD_SURFACE |
||
53 | * EGL_BAD_SCREEN_MESA |
||
54 | * EGL_BAD_MODE_MESA |
||
55 | * |
||
56 | * is generated and the driver function is not called. An |
||
57 | * uninitialized EGLDisplay has no driver associated with it. When |
||
58 | * such display is detected, |
||
59 | * |
||
60 | * EGL_NOT_INITIALIZED |
||
61 | * |
||
62 | * is generated. |
||
63 | * |
||
64 | * Some of the entry points use current display, context, or surface |
||
65 | * implicitly. For such entry points, the implicit objects are also |
||
66 | * checked before calling the driver function. Other than the |
||
67 | * errors listed above, |
||
68 | * |
||
69 | * EGL_BAD_CURRENT_SURFACE |
||
70 | * |
||
71 | * may also be generated. |
||
72 | * |
||
73 | * Notes on naming conventions: |
||
74 | * |
||
75 | * eglFooBar - public EGL function |
||
76 | * EGL_FOO_BAR - public EGL token |
||
77 | * EGLDatatype - public EGL datatype |
||
78 | * |
||
79 | * _eglFooBar - private EGL function |
||
80 | * _EGLDatatype - private EGL datatype, typedef'd struct |
||
81 | * _egl_struct - private EGL struct, non-typedef'd |
||
82 | * |
||
83 | */ |
||
84 | |||
85 | |||
86 | #include |
||
87 | #include |
||
88 | #include |
||
89 | |||
90 | #include "eglcontext.h" |
||
91 | #include "egldisplay.h" |
||
92 | #include "egltypedefs.h" |
||
93 | #include "eglcurrent.h" |
||
94 | #include "egldriver.h" |
||
95 | #include "eglsurface.h" |
||
96 | #include "eglconfig.h" |
||
97 | #include "eglscreen.h" |
||
98 | #include "eglmode.h" |
||
99 | #include "eglimage.h" |
||
100 | #include "eglsync.h" |
||
101 | |||
102 | |||
103 | /** |
||
104 | * Macros to help return an API entrypoint. |
||
105 | * |
||
106 | * These macros will unlock the display and record the error code. |
||
107 | */ |
||
108 | #define RETURN_EGL_ERROR(disp, err, ret) \ |
||
109 | do { \ |
||
110 | if (disp) \ |
||
111 | _eglUnlockDisplay(disp); \ |
||
112 | /* EGL error codes are non-zero */ \ |
||
113 | if (err) \ |
||
114 | _eglError(err, __FUNCTION__); \ |
||
115 | return ret; \ |
||
116 | } while (0) |
||
117 | |||
118 | #define RETURN_EGL_SUCCESS(disp, ret) \ |
||
119 | RETURN_EGL_ERROR(disp, EGL_SUCCESS, ret) |
||
120 | |||
121 | /* record EGL_SUCCESS only when ret evaluates to true */ |
||
122 | #define RETURN_EGL_EVAL(disp, ret) \ |
||
123 | RETURN_EGL_ERROR(disp, (ret) ? EGL_SUCCESS : 0, ret) |
||
124 | |||
125 | |||
126 | /* |
||
127 | * A bunch of macros and checks to simplify error checking. |
||
128 | */ |
||
129 | |||
130 | #define _EGL_CHECK_DISPLAY(disp, ret, drv) \ |
||
131 | do { \ |
||
132 | drv = _eglCheckDisplay(disp, __FUNCTION__); \ |
||
133 | if (!drv) \ |
||
134 | RETURN_EGL_ERROR(disp, 0, ret); \ |
||
135 | } while (0) |
||
136 | |||
137 | #define _EGL_CHECK_OBJECT(disp, type, obj, ret, drv) \ |
||
138 | do { \ |
||
139 | drv = _eglCheck ## type(disp, obj, __FUNCTION__); \ |
||
140 | if (!drv) \ |
||
141 | RETURN_EGL_ERROR(disp, 0, ret); \ |
||
142 | } while (0) |
||
143 | |||
144 | #define _EGL_CHECK_SURFACE(disp, surf, ret, drv) \ |
||
145 | _EGL_CHECK_OBJECT(disp, Surface, surf, ret, drv) |
||
146 | |||
147 | #define _EGL_CHECK_CONTEXT(disp, context, ret, drv) \ |
||
148 | _EGL_CHECK_OBJECT(disp, Context, context, ret, drv) |
||
149 | |||
150 | #define _EGL_CHECK_CONFIG(disp, conf, ret, drv) \ |
||
151 | _EGL_CHECK_OBJECT(disp, Config, conf, ret, drv) |
||
152 | |||
153 | #define _EGL_CHECK_SCREEN(disp, scrn, ret, drv) \ |
||
154 | _EGL_CHECK_OBJECT(disp, Screen, scrn, ret, drv) |
||
155 | |||
156 | #define _EGL_CHECK_MODE(disp, m, ret, drv) \ |
||
157 | _EGL_CHECK_OBJECT(disp, Mode, m, ret, drv) |
||
158 | |||
159 | #define _EGL_CHECK_SYNC(disp, s, ret, drv) \ |
||
160 | _EGL_CHECK_OBJECT(disp, Sync, s, ret, drv) |
||
161 | |||
162 | |||
163 | static INLINE _EGLDriver * |
||
164 | _eglCheckDisplay(_EGLDisplay *disp, const char *msg) |
||
165 | { |
||
166 | if (!disp) { |
||
167 | _eglError(EGL_BAD_DISPLAY, msg); |
||
168 | return NULL; |
||
169 | } |
||
170 | if (!disp->Initialized) { |
||
171 | _eglError(EGL_NOT_INITIALIZED, msg); |
||
172 | return NULL; |
||
173 | } |
||
174 | return disp->Driver; |
||
175 | } |
||
176 | |||
177 | |||
178 | static INLINE _EGLDriver * |
||
179 | _eglCheckSurface(_EGLDisplay *disp, _EGLSurface *surf, const char *msg) |
||
180 | { |
||
181 | _EGLDriver *drv = _eglCheckDisplay(disp, msg); |
||
182 | if (!drv) |
||
183 | return NULL; |
||
184 | if (!surf) { |
||
185 | _eglError(EGL_BAD_SURFACE, msg); |
||
186 | return NULL; |
||
187 | } |
||
188 | return drv; |
||
189 | } |
||
190 | |||
191 | |||
192 | static INLINE _EGLDriver * |
||
193 | _eglCheckContext(_EGLDisplay *disp, _EGLContext *context, const char *msg) |
||
194 | { |
||
195 | _EGLDriver *drv = _eglCheckDisplay(disp, msg); |
||
196 | if (!drv) |
||
197 | return NULL; |
||
198 | if (!context) { |
||
199 | _eglError(EGL_BAD_CONTEXT, msg); |
||
200 | return NULL; |
||
201 | } |
||
202 | return drv; |
||
203 | } |
||
204 | |||
205 | |||
206 | static INLINE _EGLDriver * |
||
207 | _eglCheckConfig(_EGLDisplay *disp, _EGLConfig *conf, const char *msg) |
||
208 | { |
||
209 | _EGLDriver *drv = _eglCheckDisplay(disp, msg); |
||
210 | if (!drv) |
||
211 | return NULL; |
||
212 | if (!conf) { |
||
213 | _eglError(EGL_BAD_CONFIG, msg); |
||
214 | return NULL; |
||
215 | } |
||
216 | return drv; |
||
217 | } |
||
218 | |||
219 | |||
220 | static INLINE _EGLDriver * |
||
221 | _eglCheckSync(_EGLDisplay *disp, _EGLSync *s, const char *msg) |
||
222 | { |
||
223 | _EGLDriver *drv = _eglCheckDisplay(disp, msg); |
||
224 | if (!drv) |
||
225 | return NULL; |
||
226 | if (!s) { |
||
227 | _eglError(EGL_BAD_PARAMETER, msg); |
||
228 | return NULL; |
||
229 | } |
||
230 | return drv; |
||
231 | } |
||
232 | |||
233 | |||
234 | #ifdef EGL_MESA_screen_surface |
||
235 | |||
236 | |||
237 | static INLINE _EGLDriver * |
||
238 | _eglCheckScreen(_EGLDisplay *disp, _EGLScreen *scrn, const char *msg) |
||
239 | { |
||
240 | _EGLDriver *drv = _eglCheckDisplay(disp, msg); |
||
241 | if (!drv) |
||
242 | return NULL; |
||
243 | if (!scrn) { |
||
244 | _eglError(EGL_BAD_SCREEN_MESA, msg); |
||
245 | return NULL; |
||
246 | } |
||
247 | return drv; |
||
248 | } |
||
249 | |||
250 | |||
251 | static INLINE _EGLDriver * |
||
252 | _eglCheckMode(_EGLDisplay *disp, _EGLMode *m, const char *msg) |
||
253 | { |
||
254 | _EGLDriver *drv = _eglCheckDisplay(disp, msg); |
||
255 | if (!drv) |
||
256 | return NULL; |
||
257 | if (!m) { |
||
258 | _eglError(EGL_BAD_MODE_MESA, msg); |
||
259 | return NULL; |
||
260 | } |
||
261 | return drv; |
||
262 | } |
||
263 | |||
264 | |||
265 | #endif /* EGL_MESA_screen_surface */ |
||
266 | |||
267 | |||
268 | /** |
||
269 | * Lookup and lock a display. |
||
270 | */ |
||
271 | static INLINE _EGLDisplay * |
||
272 | _eglLockDisplay(EGLDisplay display) |
||
273 | { |
||
274 | _EGLDisplay *dpy = _eglLookupDisplay(display); |
||
275 | if (dpy) |
||
276 | _eglLockMutex(&dpy->Mutex); |
||
277 | return dpy; |
||
278 | } |
||
279 | |||
280 | |||
281 | /** |
||
282 | * Unlock a display. |
||
283 | */ |
||
284 | static INLINE void |
||
285 | _eglUnlockDisplay(_EGLDisplay *dpy) |
||
286 | { |
||
287 | _eglUnlockMutex(&dpy->Mutex); |
||
288 | } |
||
289 | |||
290 | |||
291 | /** |
||
292 | * This is typically the first EGL function that an application calls. |
||
293 | * It associates a private _EGLDisplay object to the native display. |
||
294 | */ |
||
295 | EGLDisplay EGLAPIENTRY |
||
296 | eglGetDisplay(EGLNativeDisplayType nativeDisplay) |
||
297 | { |
||
298 | _EGLPlatformType plat = _eglGetNativePlatform(nativeDisplay); |
||
299 | _EGLDisplay *dpy = _eglFindDisplay(plat, (void *) nativeDisplay); |
||
300 | return _eglGetDisplayHandle(dpy); |
||
301 | } |
||
302 | |||
303 | |||
304 | /** |
||
305 | * This is typically the second EGL function that an application calls. |
||
306 | * Here we load/initialize the actual hardware driver. |
||
307 | */ |
||
308 | EGLBoolean EGLAPIENTRY |
||
309 | eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) |
||
310 | { |
||
311 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
312 | |||
313 | if (!disp) |
||
314 | RETURN_EGL_ERROR(NULL, EGL_BAD_DISPLAY, EGL_FALSE); |
||
315 | |||
316 | if (!disp->Initialized) { |
||
317 | if (!_eglMatchDriver(disp, EGL_FALSE)) |
||
318 | RETURN_EGL_ERROR(disp, EGL_NOT_INITIALIZED, EGL_FALSE); |
||
319 | |||
320 | /* limit to APIs supported by core */ |
||
321 | disp->ClientAPIs &= _EGL_API_ALL_BITS; |
||
322 | } |
||
323 | |||
324 | /* Update applications version of major and minor if not NULL */ |
||
325 | if ((major != NULL) && (minor != NULL)) { |
||
326 | *major = disp->VersionMajor; |
||
327 | *minor = disp->VersionMinor; |
||
328 | } |
||
329 | |||
330 | RETURN_EGL_SUCCESS(disp, EGL_TRUE); |
||
331 | } |
||
332 | |||
333 | |||
334 | EGLBoolean EGLAPIENTRY |
||
335 | eglTerminate(EGLDisplay dpy) |
||
336 | { |
||
337 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
338 | |||
339 | if (!disp) |
||
340 | RETURN_EGL_ERROR(NULL, EGL_BAD_DISPLAY, EGL_FALSE); |
||
341 | |||
342 | if (disp->Initialized) { |
||
343 | _EGLDriver *drv = disp->Driver; |
||
344 | |||
345 | drv->API.Terminate(drv, disp); |
||
346 | /* do not reset disp->Driver */ |
||
347 | disp->Initialized = EGL_FALSE; |
||
348 | } |
||
349 | |||
350 | RETURN_EGL_SUCCESS(disp, EGL_TRUE); |
||
351 | } |
||
352 | |||
353 | |||
354 | const char * EGLAPIENTRY |
||
355 | eglQueryString(EGLDisplay dpy, EGLint name) |
||
356 | { |
||
357 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
358 | _EGLDriver *drv; |
||
359 | const char *ret; |
||
360 | |||
361 | _EGL_CHECK_DISPLAY(disp, NULL, drv); |
||
362 | ret = drv->API.QueryString(drv, disp, name); |
||
363 | |||
364 | RETURN_EGL_EVAL(disp, ret); |
||
365 | } |
||
366 | |||
367 | |||
368 | EGLBoolean EGLAPIENTRY |
||
369 | eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, |
||
370 | EGLint config_size, EGLint *num_config) |
||
371 | { |
||
372 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
373 | _EGLDriver *drv; |
||
374 | EGLBoolean ret; |
||
375 | |||
376 | _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); |
||
377 | ret = drv->API.GetConfigs(drv, disp, configs, config_size, num_config); |
||
378 | |||
379 | RETURN_EGL_EVAL(disp, ret); |
||
380 | } |
||
381 | |||
382 | |||
383 | EGLBoolean EGLAPIENTRY |
||
384 | eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, |
||
385 | EGLint config_size, EGLint *num_config) |
||
386 | { |
||
387 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
388 | _EGLDriver *drv; |
||
389 | EGLBoolean ret; |
||
390 | |||
391 | _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); |
||
392 | ret = drv->API.ChooseConfig(drv, disp, attrib_list, configs, |
||
393 | config_size, num_config); |
||
394 | |||
395 | RETURN_EGL_EVAL(disp, ret); |
||
396 | } |
||
397 | |||
398 | |||
399 | EGLBoolean EGLAPIENTRY |
||
400 | eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, |
||
401 | EGLint attribute, EGLint *value) |
||
402 | { |
||
403 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
404 | _EGLConfig *conf = _eglLookupConfig(config, disp); |
||
405 | _EGLDriver *drv; |
||
406 | EGLBoolean ret; |
||
407 | |||
408 | _EGL_CHECK_CONFIG(disp, conf, EGL_FALSE, drv); |
||
409 | ret = drv->API.GetConfigAttrib(drv, disp, conf, attribute, value); |
||
410 | |||
411 | RETURN_EGL_EVAL(disp, ret); |
||
412 | } |
||
413 | |||
414 | |||
415 | EGLContext EGLAPIENTRY |
||
416 | eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_list, |
||
417 | const EGLint *attrib_list) |
||
418 | { |
||
419 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
420 | _EGLConfig *conf = _eglLookupConfig(config, disp); |
||
421 | _EGLContext *share = _eglLookupContext(share_list, disp); |
||
422 | _EGLDriver *drv; |
||
423 | _EGLContext *context; |
||
424 | EGLContext ret; |
||
425 | |||
426 | _EGL_CHECK_DISPLAY(disp, EGL_NO_CONTEXT, drv); |
||
427 | |||
428 | if (!config) { |
||
429 | /* config may be NULL if surfaceless */ |
||
430 | if (!disp->Extensions.KHR_surfaceless_context) |
||
431 | RETURN_EGL_ERROR(disp, EGL_BAD_CONFIG, EGL_NO_CONTEXT); |
||
432 | } |
||
433 | |||
434 | if (!share && share_list != EGL_NO_CONTEXT) |
||
435 | RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_NO_CONTEXT); |
||
436 | |||
437 | context = drv->API.CreateContext(drv, disp, conf, share, attrib_list); |
||
438 | ret = (context) ? _eglLinkContext(context) : EGL_NO_CONTEXT; |
||
439 | |||
440 | RETURN_EGL_EVAL(disp, ret); |
||
441 | } |
||
442 | |||
443 | |||
444 | EGLBoolean EGLAPIENTRY |
||
445 | eglDestroyContext(EGLDisplay dpy, EGLContext ctx) |
||
446 | { |
||
447 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
448 | _EGLContext *context = _eglLookupContext(ctx, disp); |
||
449 | _EGLDriver *drv; |
||
450 | EGLBoolean ret; |
||
451 | |||
452 | _EGL_CHECK_CONTEXT(disp, context, EGL_FALSE, drv); |
||
453 | _eglUnlinkContext(context); |
||
454 | ret = drv->API.DestroyContext(drv, disp, context); |
||
455 | |||
456 | RETURN_EGL_EVAL(disp, ret); |
||
457 | } |
||
458 | |||
459 | |||
460 | EGLBoolean EGLAPIENTRY |
||
461 | eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, |
||
462 | EGLContext ctx) |
||
463 | { |
||
464 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
465 | _EGLContext *context = _eglLookupContext(ctx, disp); |
||
466 | _EGLSurface *draw_surf = _eglLookupSurface(draw, disp); |
||
467 | _EGLSurface *read_surf = _eglLookupSurface(read, disp); |
||
468 | _EGLDriver *drv; |
||
469 | EGLBoolean ret; |
||
470 | |||
471 | if (!disp) |
||
472 | RETURN_EGL_ERROR(disp, EGL_BAD_DISPLAY, EGL_FALSE); |
||
473 | drv = disp->Driver; |
||
474 | |||
475 | /* display is allowed to be uninitialized under certain condition */ |
||
476 | if (!disp->Initialized) { |
||
477 | if (draw != EGL_NO_SURFACE || read != EGL_NO_SURFACE || |
||
478 | ctx != EGL_NO_CONTEXT) |
||
479 | RETURN_EGL_ERROR(disp, EGL_BAD_DISPLAY, EGL_FALSE); |
||
480 | } |
||
481 | if (!drv) |
||
482 | RETURN_EGL_SUCCESS(disp, EGL_TRUE); |
||
483 | |||
484 | if (!context && ctx != EGL_NO_CONTEXT) |
||
485 | RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_FALSE); |
||
486 | if (!draw_surf || !read_surf) { |
||
487 | /* surfaces may be NULL if surfaceless */ |
||
488 | if (!disp->Extensions.KHR_surfaceless_context) |
||
489 | RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE); |
||
490 | |||
491 | if ((!draw_surf && draw != EGL_NO_SURFACE) || |
||
492 | (!read_surf && read != EGL_NO_SURFACE)) |
||
493 | RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE); |
||
494 | if (draw_surf || read_surf) |
||
495 | RETURN_EGL_ERROR(disp, EGL_BAD_MATCH, EGL_FALSE); |
||
496 | } |
||
497 | |||
498 | ret = drv->API.MakeCurrent(drv, disp, draw_surf, read_surf, context); |
||
499 | |||
500 | RETURN_EGL_EVAL(disp, ret); |
||
501 | } |
||
502 | |||
503 | |||
504 | EGLBoolean EGLAPIENTRY |
||
505 | eglQueryContext(EGLDisplay dpy, EGLContext ctx, |
||
506 | EGLint attribute, EGLint *value) |
||
507 | { |
||
508 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
509 | _EGLContext *context = _eglLookupContext(ctx, disp); |
||
510 | _EGLDriver *drv; |
||
511 | EGLBoolean ret; |
||
512 | |||
513 | _EGL_CHECK_CONTEXT(disp, context, EGL_FALSE, drv); |
||
514 | ret = drv->API.QueryContext(drv, disp, context, attribute, value); |
||
515 | |||
516 | RETURN_EGL_EVAL(disp, ret); |
||
517 | } |
||
518 | |||
519 | |||
520 | EGLSurface EGLAPIENTRY |
||
521 | eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, |
||
522 | EGLNativeWindowType window, const EGLint *attrib_list) |
||
523 | { |
||
524 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
525 | _EGLConfig *conf = _eglLookupConfig(config, disp); |
||
526 | _EGLDriver *drv; |
||
527 | _EGLSurface *surf; |
||
528 | EGLSurface ret; |
||
529 | |||
530 | _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv); |
||
531 | if (disp->Platform != _eglGetNativePlatform(disp->PlatformDisplay)) |
||
532 | RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE); |
||
533 | |||
534 | surf = drv->API.CreateWindowSurface(drv, disp, conf, window, attrib_list); |
||
535 | ret = (surf) ? _eglLinkSurface(surf) : EGL_NO_SURFACE; |
||
536 | |||
537 | RETURN_EGL_EVAL(disp, ret); |
||
538 | } |
||
539 | |||
540 | |||
541 | EGLSurface EGLAPIENTRY |
||
542 | eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, |
||
543 | EGLNativePixmapType pixmap, const EGLint *attrib_list) |
||
544 | { |
||
545 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
546 | _EGLConfig *conf = _eglLookupConfig(config, disp); |
||
547 | _EGLDriver *drv; |
||
548 | _EGLSurface *surf; |
||
549 | EGLSurface ret; |
||
550 | |||
551 | _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv); |
||
552 | if (disp->Platform != _eglGetNativePlatform(disp->PlatformDisplay)) |
||
553 | RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_PIXMAP, EGL_NO_SURFACE); |
||
554 | |||
555 | surf = drv->API.CreatePixmapSurface(drv, disp, conf, pixmap, attrib_list); |
||
556 | ret = (surf) ? _eglLinkSurface(surf) : EGL_NO_SURFACE; |
||
557 | |||
558 | RETURN_EGL_EVAL(disp, ret); |
||
559 | } |
||
560 | |||
561 | |||
562 | EGLSurface EGLAPIENTRY |
||
563 | eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, |
||
564 | const EGLint *attrib_list) |
||
565 | { |
||
566 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
567 | _EGLConfig *conf = _eglLookupConfig(config, disp); |
||
568 | _EGLDriver *drv; |
||
569 | _EGLSurface *surf; |
||
570 | EGLSurface ret; |
||
571 | |||
572 | _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv); |
||
573 | |||
574 | surf = drv->API.CreatePbufferSurface(drv, disp, conf, attrib_list); |
||
575 | ret = (surf) ? _eglLinkSurface(surf) : EGL_NO_SURFACE; |
||
576 | |||
577 | RETURN_EGL_EVAL(disp, ret); |
||
578 | } |
||
579 | |||
580 | |||
581 | EGLBoolean EGLAPIENTRY |
||
582 | eglDestroySurface(EGLDisplay dpy, EGLSurface surface) |
||
583 | { |
||
584 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
585 | _EGLSurface *surf = _eglLookupSurface(surface, disp); |
||
586 | _EGLDriver *drv; |
||
587 | EGLBoolean ret; |
||
588 | |||
589 | _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); |
||
590 | _eglUnlinkSurface(surf); |
||
591 | ret = drv->API.DestroySurface(drv, disp, surf); |
||
592 | |||
593 | RETURN_EGL_EVAL(disp, ret); |
||
594 | } |
||
595 | |||
596 | EGLBoolean EGLAPIENTRY |
||
597 | eglQuerySurface(EGLDisplay dpy, EGLSurface surface, |
||
598 | EGLint attribute, EGLint *value) |
||
599 | { |
||
600 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
601 | _EGLSurface *surf = _eglLookupSurface(surface, disp); |
||
602 | _EGLDriver *drv; |
||
603 | EGLBoolean ret; |
||
604 | |||
605 | _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); |
||
606 | ret = drv->API.QuerySurface(drv, disp, surf, attribute, value); |
||
607 | |||
608 | RETURN_EGL_EVAL(disp, ret); |
||
609 | } |
||
610 | |||
611 | EGLBoolean EGLAPIENTRY |
||
612 | eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, |
||
613 | EGLint attribute, EGLint value) |
||
614 | { |
||
615 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
616 | _EGLSurface *surf = _eglLookupSurface(surface, disp); |
||
617 | _EGLDriver *drv; |
||
618 | EGLBoolean ret; |
||
619 | |||
620 | _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); |
||
621 | ret = drv->API.SurfaceAttrib(drv, disp, surf, attribute, value); |
||
622 | |||
623 | RETURN_EGL_EVAL(disp, ret); |
||
624 | } |
||
625 | |||
626 | |||
627 | EGLBoolean EGLAPIENTRY |
||
628 | eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) |
||
629 | { |
||
630 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
631 | _EGLSurface *surf = _eglLookupSurface(surface, disp); |
||
632 | _EGLDriver *drv; |
||
633 | EGLBoolean ret; |
||
634 | |||
635 | _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); |
||
636 | ret = drv->API.BindTexImage(drv, disp, surf, buffer); |
||
637 | |||
638 | RETURN_EGL_EVAL(disp, ret); |
||
639 | } |
||
640 | |||
641 | |||
642 | EGLBoolean EGLAPIENTRY |
||
643 | eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) |
||
644 | { |
||
645 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
646 | _EGLSurface *surf = _eglLookupSurface(surface, disp); |
||
647 | _EGLDriver *drv; |
||
648 | EGLBoolean ret; |
||
649 | |||
650 | _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); |
||
651 | ret = drv->API.ReleaseTexImage(drv, disp, surf, buffer); |
||
652 | |||
653 | RETURN_EGL_EVAL(disp, ret); |
||
654 | } |
||
655 | |||
656 | |||
657 | EGLBoolean EGLAPIENTRY |
||
658 | eglSwapInterval(EGLDisplay dpy, EGLint interval) |
||
659 | { |
||
660 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
661 | _EGLContext *ctx = _eglGetCurrentContext(); |
||
662 | _EGLSurface *surf; |
||
663 | _EGLDriver *drv; |
||
664 | EGLBoolean ret; |
||
665 | |||
666 | _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); |
||
667 | |||
668 | if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT || |
||
669 | ctx->Resource.Display != disp) |
||
670 | RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_FALSE); |
||
671 | |||
672 | surf = ctx->DrawSurface; |
||
673 | if (_eglGetSurfaceHandle(surf) == EGL_NO_SURFACE) |
||
674 | RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE); |
||
675 | |||
676 | ret = drv->API.SwapInterval(drv, disp, surf, interval); |
||
677 | |||
678 | RETURN_EGL_EVAL(disp, ret); |
||
679 | } |
||
680 | |||
681 | |||
682 | EGLBoolean EGLAPIENTRY |
||
683 | eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) |
||
684 | { |
||
685 | _EGLContext *ctx = _eglGetCurrentContext(); |
||
686 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
687 | _EGLSurface *surf = _eglLookupSurface(surface, disp); |
||
688 | _EGLDriver *drv; |
||
689 | EGLBoolean ret; |
||
690 | |||
691 | _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); |
||
692 | |||
693 | /* surface must be bound to current context in EGL 1.4 */ |
||
694 | if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT || |
||
695 | surf != ctx->DrawSurface) |
||
696 | RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE); |
||
697 | |||
698 | ret = drv->API.SwapBuffers(drv, disp, surf); |
||
699 | |||
700 | RETURN_EGL_EVAL(disp, ret); |
||
701 | } |
||
702 | |||
703 | |||
704 | #ifdef EGL_EXT_swap_buffers_with_damage |
||
705 | |||
706 | EGLBoolean EGLAPIENTRY |
||
707 | eglSwapBuffersWithDamageEXT(EGLDisplay dpy, EGLSurface surface, |
||
708 | EGLint *rects, EGLint n_rects) |
||
709 | { |
||
710 | _EGLContext *ctx = _eglGetCurrentContext(); |
||
711 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
712 | _EGLSurface *surf = _eglLookupSurface(surface, disp); |
||
713 | _EGLDriver *drv; |
||
714 | EGLBoolean ret; |
||
715 | |||
716 | _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); |
||
717 | |||
718 | /* surface must be bound to current context in EGL 1.4 */ |
||
719 | if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT || |
||
720 | surf != ctx->DrawSurface) |
||
721 | RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE); |
||
722 | |||
723 | if ((n_rects > 0 && rects == NULL) || n_rects < 0) |
||
724 | RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); |
||
725 | |||
726 | ret = drv->API.SwapBuffersWithDamageEXT(drv, disp, surf, rects, n_rects); |
||
727 | |||
728 | RETURN_EGL_EVAL(disp, ret); |
||
729 | } |
||
730 | |||
731 | #endif /* EGL_EXT_swap_buffers_with_damage */ |
||
732 | |||
733 | EGLBoolean EGLAPIENTRY |
||
734 | eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) |
||
735 | { |
||
736 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
737 | _EGLSurface *surf = _eglLookupSurface(surface, disp); |
||
738 | _EGLDriver *drv; |
||
739 | EGLBoolean ret; |
||
740 | |||
741 | _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); |
||
742 | if (disp->Platform != _eglGetNativePlatform(disp->PlatformDisplay)) |
||
743 | RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_PIXMAP, EGL_FALSE); |
||
744 | ret = drv->API.CopyBuffers(drv, disp, surf, target); |
||
745 | |||
746 | RETURN_EGL_EVAL(disp, ret); |
||
747 | } |
||
748 | |||
749 | |||
750 | EGLBoolean EGLAPIENTRY |
||
751 | eglWaitClient(void) |
||
752 | { |
||
753 | _EGLContext *ctx = _eglGetCurrentContext(); |
||
754 | _EGLDisplay *disp; |
||
755 | _EGLDriver *drv; |
||
756 | EGLBoolean ret; |
||
757 | |||
758 | if (!ctx) |
||
759 | RETURN_EGL_SUCCESS(NULL, EGL_TRUE); |
||
760 | |||
761 | disp = ctx->Resource.Display; |
||
762 | _eglLockMutex(&disp->Mutex); |
||
763 | |||
764 | /* let bad current context imply bad current surface */ |
||
765 | if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT || |
||
766 | _eglGetSurfaceHandle(ctx->DrawSurface) == EGL_NO_SURFACE) |
||
767 | RETURN_EGL_ERROR(disp, EGL_BAD_CURRENT_SURFACE, EGL_FALSE); |
||
768 | |||
769 | /* a valid current context implies an initialized current display */ |
||
770 | assert(disp->Initialized); |
||
771 | drv = disp->Driver; |
||
772 | ret = drv->API.WaitClient(drv, disp, ctx); |
||
773 | |||
774 | RETURN_EGL_EVAL(disp, ret); |
||
775 | } |
||
776 | |||
777 | |||
778 | EGLBoolean EGLAPIENTRY |
||
779 | eglWaitGL(void) |
||
780 | { |
||
781 | _EGLThreadInfo *t = _eglGetCurrentThread(); |
||
782 | EGLint api_index = t->CurrentAPIIndex; |
||
783 | EGLint es_index = _eglConvertApiToIndex(EGL_OPENGL_ES_API); |
||
784 | EGLBoolean ret; |
||
785 | |||
786 | if (api_index != es_index && _eglIsCurrentThreadDummy()) |
||
787 | RETURN_EGL_ERROR(NULL, EGL_BAD_ALLOC, EGL_FALSE); |
||
788 | |||
789 | t->CurrentAPIIndex = es_index; |
||
790 | ret = eglWaitClient(); |
||
791 | t->CurrentAPIIndex = api_index; |
||
792 | return ret; |
||
793 | } |
||
794 | |||
795 | |||
796 | EGLBoolean EGLAPIENTRY |
||
797 | eglWaitNative(EGLint engine) |
||
798 | { |
||
799 | _EGLContext *ctx = _eglGetCurrentContext(); |
||
800 | _EGLDisplay *disp; |
||
801 | _EGLDriver *drv; |
||
802 | EGLBoolean ret; |
||
803 | |||
804 | if (!ctx) |
||
805 | RETURN_EGL_SUCCESS(NULL, EGL_TRUE); |
||
806 | |||
807 | disp = ctx->Resource.Display; |
||
808 | _eglLockMutex(&disp->Mutex); |
||
809 | |||
810 | /* let bad current context imply bad current surface */ |
||
811 | if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT || |
||
812 | _eglGetSurfaceHandle(ctx->DrawSurface) == EGL_NO_SURFACE) |
||
813 | RETURN_EGL_ERROR(disp, EGL_BAD_CURRENT_SURFACE, EGL_FALSE); |
||
814 | |||
815 | /* a valid current context implies an initialized current display */ |
||
816 | assert(disp->Initialized); |
||
817 | drv = disp->Driver; |
||
818 | ret = drv->API.WaitNative(drv, disp, engine); |
||
819 | |||
820 | RETURN_EGL_EVAL(disp, ret); |
||
821 | } |
||
822 | |||
823 | |||
824 | EGLDisplay EGLAPIENTRY |
||
825 | eglGetCurrentDisplay(void) |
||
826 | { |
||
827 | _EGLContext *ctx = _eglGetCurrentContext(); |
||
828 | EGLDisplay ret; |
||
829 | |||
830 | ret = (ctx) ? _eglGetDisplayHandle(ctx->Resource.Display) : EGL_NO_DISPLAY; |
||
831 | |||
832 | RETURN_EGL_SUCCESS(NULL, ret); |
||
833 | } |
||
834 | |||
835 | |||
836 | EGLContext EGLAPIENTRY |
||
837 | eglGetCurrentContext(void) |
||
838 | { |
||
839 | _EGLContext *ctx = _eglGetCurrentContext(); |
||
840 | EGLContext ret; |
||
841 | |||
842 | ret = _eglGetContextHandle(ctx); |
||
843 | |||
844 | RETURN_EGL_SUCCESS(NULL, ret); |
||
845 | } |
||
846 | |||
847 | |||
848 | EGLSurface EGLAPIENTRY |
||
849 | eglGetCurrentSurface(EGLint readdraw) |
||
850 | { |
||
851 | _EGLContext *ctx = _eglGetCurrentContext(); |
||
852 | EGLint err = EGL_SUCCESS; |
||
853 | _EGLSurface *surf; |
||
854 | EGLSurface ret; |
||
855 | |||
856 | if (!ctx) |
||
857 | RETURN_EGL_SUCCESS(NULL, EGL_NO_SURFACE); |
||
858 | |||
859 | switch (readdraw) { |
||
860 | case EGL_DRAW: |
||
861 | surf = ctx->DrawSurface; |
||
862 | break; |
||
863 | case EGL_READ: |
||
864 | surf = ctx->ReadSurface; |
||
865 | break; |
||
866 | default: |
||
867 | surf = NULL; |
||
868 | err = EGL_BAD_PARAMETER; |
||
869 | break; |
||
870 | } |
||
871 | |||
872 | ret = _eglGetSurfaceHandle(surf); |
||
873 | |||
874 | RETURN_EGL_ERROR(NULL, err, ret); |
||
875 | } |
||
876 | |||
877 | |||
878 | EGLint EGLAPIENTRY |
||
879 | eglGetError(void) |
||
880 | { |
||
881 | _EGLThreadInfo *t = _eglGetCurrentThread(); |
||
882 | EGLint e = t->LastError; |
||
883 | if (!_eglIsCurrentThreadDummy()) |
||
884 | t->LastError = EGL_SUCCESS; |
||
885 | return e; |
||
886 | } |
||
887 | |||
888 | |||
889 | __eglMustCastToProperFunctionPointerType EGLAPIENTRY |
||
890 | eglGetProcAddress(const char *procname) |
||
891 | { |
||
892 | static const struct { |
||
893 | const char *name; |
||
894 | _EGLProc function; |
||
895 | } egl_functions[] = { |
||
896 | /* core functions should not be queryable, but, well... */ |
||
897 | #ifdef _EGL_GET_CORE_ADDRESSES |
||
898 | /* alphabetical order */ |
||
899 | { "eglBindAPI", (_EGLProc) eglBindAPI }, |
||
900 | { "eglBindTexImage", (_EGLProc) eglBindTexImage }, |
||
901 | { "eglChooseConfig", (_EGLProc) eglChooseConfig }, |
||
902 | { "eglCopyBuffers", (_EGLProc) eglCopyBuffers }, |
||
903 | { "eglCreateContext", (_EGLProc) eglCreateContext }, |
||
904 | { "eglCreatePbufferFromClientBuffer", (_EGLProc) eglCreatePbufferFromClientBuffer }, |
||
905 | { "eglCreatePbufferSurface", (_EGLProc) eglCreatePbufferSurface }, |
||
906 | { "eglCreatePixmapSurface", (_EGLProc) eglCreatePixmapSurface }, |
||
907 | { "eglCreateWindowSurface", (_EGLProc) eglCreateWindowSurface }, |
||
908 | { "eglDestroyContext", (_EGLProc) eglDestroyContext }, |
||
909 | { "eglDestroySurface", (_EGLProc) eglDestroySurface }, |
||
910 | { "eglGetConfigAttrib", (_EGLProc) eglGetConfigAttrib }, |
||
911 | { "eglGetConfigs", (_EGLProc) eglGetConfigs }, |
||
912 | { "eglGetCurrentContext", (_EGLProc) eglGetCurrentContext }, |
||
913 | { "eglGetCurrentDisplay", (_EGLProc) eglGetCurrentDisplay }, |
||
914 | { "eglGetCurrentSurface", (_EGLProc) eglGetCurrentSurface }, |
||
915 | { "eglGetDisplay", (_EGLProc) eglGetDisplay }, |
||
916 | { "eglGetError", (_EGLProc) eglGetError }, |
||
917 | { "eglGetProcAddress", (_EGLProc) eglGetProcAddress }, |
||
918 | { "eglInitialize", (_EGLProc) eglInitialize }, |
||
919 | { "eglMakeCurrent", (_EGLProc) eglMakeCurrent }, |
||
920 | { "eglQueryAPI", (_EGLProc) eglQueryAPI }, |
||
921 | { "eglQueryContext", (_EGLProc) eglQueryContext }, |
||
922 | { "eglQueryString", (_EGLProc) eglQueryString }, |
||
923 | { "eglQuerySurface", (_EGLProc) eglQuerySurface }, |
||
924 | { "eglReleaseTexImage", (_EGLProc) eglReleaseTexImage }, |
||
925 | { "eglReleaseThread", (_EGLProc) eglReleaseThread }, |
||
926 | { "eglSurfaceAttrib", (_EGLProc) eglSurfaceAttrib }, |
||
927 | { "eglSwapBuffers", (_EGLProc) eglSwapBuffers }, |
||
928 | { "eglSwapInterval", (_EGLProc) eglSwapInterval }, |
||
929 | { "eglTerminate", (_EGLProc) eglTerminate }, |
||
930 | { "eglWaitClient", (_EGLProc) eglWaitClient }, |
||
931 | { "eglWaitGL", (_EGLProc) eglWaitGL }, |
||
932 | { "eglWaitNative", (_EGLProc) eglWaitNative }, |
||
933 | #endif /* _EGL_GET_CORE_ADDRESSES */ |
||
934 | #ifdef EGL_MESA_screen_surface |
||
935 | { "eglChooseModeMESA", (_EGLProc) eglChooseModeMESA }, |
||
936 | { "eglGetModesMESA", (_EGLProc) eglGetModesMESA }, |
||
937 | { "eglGetModeAttribMESA", (_EGLProc) eglGetModeAttribMESA }, |
||
938 | { "eglCopyContextMESA", (_EGLProc) eglCopyContextMESA }, |
||
939 | { "eglGetScreensMESA", (_EGLProc) eglGetScreensMESA }, |
||
940 | { "eglCreateScreenSurfaceMESA", (_EGLProc) eglCreateScreenSurfaceMESA }, |
||
941 | { "eglShowScreenSurfaceMESA", (_EGLProc) eglShowScreenSurfaceMESA }, |
||
942 | { "eglScreenPositionMESA", (_EGLProc) eglScreenPositionMESA }, |
||
943 | { "eglQueryScreenMESA", (_EGLProc) eglQueryScreenMESA }, |
||
944 | { "eglQueryScreenSurfaceMESA", (_EGLProc) eglQueryScreenSurfaceMESA }, |
||
945 | { "eglQueryScreenModeMESA", (_EGLProc) eglQueryScreenModeMESA }, |
||
946 | { "eglQueryModeStringMESA", (_EGLProc) eglQueryModeStringMESA }, |
||
947 | #endif /* EGL_MESA_screen_surface */ |
||
948 | #ifdef EGL_MESA_drm_display |
||
949 | { "eglGetDRMDisplayMESA", (_EGLProc) eglGetDRMDisplayMESA }, |
||
950 | #endif |
||
951 | { "eglCreateImageKHR", (_EGLProc) eglCreateImageKHR }, |
||
952 | { "eglDestroyImageKHR", (_EGLProc) eglDestroyImageKHR }, |
||
6114 | serge | 953 | { "eglCreatePlanarImage", (_EGLProc) eglCreatePlanarImage }, |
954 | { "eglDestroyPlanarImage", (_EGLProc) eglDestroyPlanarImage }, |
||
5563 | serge | 955 | { "eglCreateSyncKHR", (_EGLProc) eglCreateSyncKHR }, |
956 | { "eglDestroySyncKHR", (_EGLProc) eglDestroySyncKHR }, |
||
957 | { "eglClientWaitSyncKHR", (_EGLProc) eglClientWaitSyncKHR }, |
||
958 | { "eglSignalSyncKHR", (_EGLProc) eglSignalSyncKHR }, |
||
959 | { "eglGetSyncAttribKHR", (_EGLProc) eglGetSyncAttribKHR }, |
||
960 | #ifdef EGL_NOK_swap_region |
||
961 | { "eglSwapBuffersRegionNOK", (_EGLProc) eglSwapBuffersRegionNOK }, |
||
962 | #endif |
||
963 | #ifdef EGL_MESA_drm_image |
||
964 | { "eglCreateDRMImageMESA", (_EGLProc) eglCreateDRMImageMESA }, |
||
965 | { "eglExportDRMImageMESA", (_EGLProc) eglExportDRMImageMESA }, |
||
966 | #endif |
||
967 | #ifdef EGL_WL_bind_wayland_display |
||
968 | { "eglBindWaylandDisplayWL", (_EGLProc) eglBindWaylandDisplayWL }, |
||
969 | { "eglUnbindWaylandDisplayWL", (_EGLProc) eglUnbindWaylandDisplayWL }, |
||
970 | { "eglQueryWaylandBufferWL", (_EGLProc) eglQueryWaylandBufferWL }, |
||
971 | #endif |
||
972 | { "eglPostSubBufferNV", (_EGLProc) eglPostSubBufferNV }, |
||
973 | #ifdef EGL_EXT_swap_buffers_with_damage |
||
974 | { "eglSwapBuffersWithDamageEXT", (_EGLProc) eglSwapBuffersWithDamageEXT }, |
||
975 | #endif |
||
976 | { NULL, NULL } |
||
977 | }; |
||
978 | EGLint i; |
||
979 | _EGLProc ret; |
||
980 | |||
981 | if (!procname) |
||
982 | RETURN_EGL_SUCCESS(NULL, NULL); |
||
983 | |||
984 | ret = NULL; |
||
985 | if (strncmp(procname, "egl", 3) == 0) { |
||
986 | for (i = 0; egl_functions[i].name; i++) { |
||
987 | if (strcmp(egl_functions[i].name, procname) == 0) { |
||
988 | ret = egl_functions[i].function; |
||
989 | break; |
||
990 | } |
||
991 | } |
||
992 | } |
||
993 | if (!ret) |
||
994 | ret = _eglGetDriverProc(procname); |
||
995 | |||
996 | RETURN_EGL_SUCCESS(NULL, ret); |
||
997 | } |
||
998 | |||
999 | |||
1000 | #ifdef EGL_MESA_screen_surface |
||
1001 | |||
1002 | |||
1003 | /* |
||
1004 | * EGL_MESA_screen extension |
||
1005 | */ |
||
1006 | |||
1007 | EGLBoolean EGLAPIENTRY |
||
1008 | eglChooseModeMESA(EGLDisplay dpy, EGLScreenMESA screen, |
||
1009 | const EGLint *attrib_list, EGLModeMESA *modes, |
||
1010 | EGLint modes_size, EGLint *num_modes) |
||
1011 | { |
||
1012 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1013 | _EGLScreen *scrn = _eglLookupScreen(screen, disp); |
||
1014 | _EGLDriver *drv; |
||
1015 | EGLBoolean ret; |
||
1016 | |||
1017 | _EGL_CHECK_SCREEN(disp, scrn, EGL_FALSE, drv); |
||
1018 | ret = drv->API.ChooseModeMESA(drv, disp, scrn, attrib_list, |
||
1019 | modes, modes_size, num_modes); |
||
1020 | |||
1021 | RETURN_EGL_EVAL(disp, ret); |
||
1022 | } |
||
1023 | |||
1024 | |||
1025 | EGLBoolean EGLAPIENTRY |
||
1026 | eglGetModesMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *modes, |
||
1027 | EGLint mode_size, EGLint *num_mode) |
||
1028 | { |
||
1029 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1030 | _EGLScreen *scrn = _eglLookupScreen(screen, disp); |
||
1031 | _EGLDriver *drv; |
||
1032 | EGLBoolean ret; |
||
1033 | |||
1034 | _EGL_CHECK_SCREEN(disp, scrn, EGL_FALSE, drv); |
||
1035 | ret = drv->API.GetModesMESA(drv, disp, scrn, modes, mode_size, num_mode); |
||
1036 | |||
1037 | RETURN_EGL_EVAL(disp, ret); |
||
1038 | } |
||
1039 | |||
1040 | |||
1041 | EGLBoolean EGLAPIENTRY |
||
1042 | eglGetModeAttribMESA(EGLDisplay dpy, EGLModeMESA mode, |
||
1043 | EGLint attribute, EGLint *value) |
||
1044 | { |
||
1045 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1046 | _EGLMode *m = _eglLookupMode(mode, disp); |
||
1047 | _EGLDriver *drv; |
||
1048 | EGLBoolean ret; |
||
1049 | |||
1050 | _EGL_CHECK_MODE(disp, m, EGL_FALSE, drv); |
||
1051 | ret = drv->API.GetModeAttribMESA(drv, disp, m, attribute, value); |
||
1052 | |||
1053 | RETURN_EGL_EVAL(disp, ret); |
||
1054 | } |
||
1055 | |||
1056 | |||
1057 | EGLBoolean EGLAPIENTRY |
||
1058 | eglCopyContextMESA(EGLDisplay dpy, EGLContext source, EGLContext dest, |
||
1059 | EGLint mask) |
||
1060 | { |
||
1061 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1062 | _EGLContext *source_context = _eglLookupContext(source, disp); |
||
1063 | _EGLContext *dest_context = _eglLookupContext(dest, disp); |
||
1064 | _EGLDriver *drv; |
||
1065 | EGLBoolean ret; |
||
1066 | |||
1067 | _EGL_CHECK_CONTEXT(disp, source_context, EGL_FALSE, drv); |
||
1068 | if (!dest_context) |
||
1069 | RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_FALSE); |
||
1070 | |||
1071 | ret = drv->API.CopyContextMESA(drv, disp, |
||
1072 | source_context, dest_context, mask); |
||
1073 | |||
1074 | RETURN_EGL_EVAL(disp, ret); |
||
1075 | } |
||
1076 | |||
1077 | |||
1078 | EGLBoolean EGLAPIENTRY |
||
1079 | eglGetScreensMESA(EGLDisplay dpy, EGLScreenMESA *screens, |
||
1080 | EGLint max_screens, EGLint *num_screens) |
||
1081 | { |
||
1082 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1083 | _EGLDriver *drv; |
||
1084 | EGLBoolean ret; |
||
1085 | |||
1086 | _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); |
||
1087 | ret = drv->API.GetScreensMESA(drv, disp, screens, max_screens, num_screens); |
||
1088 | |||
1089 | RETURN_EGL_EVAL(disp, ret); |
||
1090 | } |
||
1091 | |||
1092 | |||
1093 | EGLSurface EGLAPIENTRY |
||
1094 | eglCreateScreenSurfaceMESA(EGLDisplay dpy, EGLConfig config, |
||
1095 | const EGLint *attrib_list) |
||
1096 | { |
||
1097 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1098 | _EGLConfig *conf = _eglLookupConfig(config, disp); |
||
1099 | _EGLDriver *drv; |
||
1100 | _EGLSurface *surf; |
||
1101 | EGLSurface ret; |
||
1102 | |||
1103 | _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv); |
||
1104 | |||
1105 | surf = drv->API.CreateScreenSurfaceMESA(drv, disp, conf, attrib_list); |
||
1106 | ret = (surf) ? _eglLinkSurface(surf) : EGL_NO_SURFACE; |
||
1107 | |||
1108 | RETURN_EGL_EVAL(disp, ret); |
||
1109 | } |
||
1110 | |||
1111 | |||
1112 | EGLBoolean EGLAPIENTRY |
||
1113 | eglShowScreenSurfaceMESA(EGLDisplay dpy, EGLint screen, |
||
1114 | EGLSurface surface, EGLModeMESA mode) |
||
1115 | { |
||
1116 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1117 | _EGLScreen *scrn = _eglLookupScreen((EGLScreenMESA) screen, disp); |
||
1118 | _EGLSurface *surf = _eglLookupSurface(surface, disp); |
||
1119 | _EGLMode *m = _eglLookupMode(mode, disp); |
||
1120 | _EGLDriver *drv; |
||
1121 | EGLBoolean ret; |
||
1122 | |||
1123 | _EGL_CHECK_SCREEN(disp, scrn, EGL_FALSE, drv); |
||
1124 | if (!surf && surface != EGL_NO_SURFACE) |
||
1125 | RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE); |
||
1126 | if (!m && mode != EGL_NO_MODE_MESA) |
||
1127 | RETURN_EGL_ERROR(disp, EGL_BAD_MODE_MESA, EGL_FALSE); |
||
1128 | |||
1129 | ret = drv->API.ShowScreenSurfaceMESA(drv, disp, scrn, surf, m); |
||
1130 | |||
1131 | RETURN_EGL_EVAL(disp, ret); |
||
1132 | } |
||
1133 | |||
1134 | |||
1135 | EGLBoolean EGLAPIENTRY |
||
1136 | eglScreenPositionMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLint x, EGLint y) |
||
1137 | { |
||
1138 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1139 | _EGLScreen *scrn = _eglLookupScreen(screen, disp); |
||
1140 | _EGLDriver *drv; |
||
1141 | EGLBoolean ret; |
||
1142 | |||
1143 | _EGL_CHECK_SCREEN(disp, scrn, EGL_FALSE, drv); |
||
1144 | ret = drv->API.ScreenPositionMESA(drv, disp, scrn, x, y); |
||
1145 | |||
1146 | RETURN_EGL_EVAL(disp, ret); |
||
1147 | } |
||
1148 | |||
1149 | |||
1150 | EGLBoolean EGLAPIENTRY |
||
1151 | eglQueryScreenMESA(EGLDisplay dpy, EGLScreenMESA screen, |
||
1152 | EGLint attribute, EGLint *value) |
||
1153 | { |
||
1154 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1155 | _EGLScreen *scrn = _eglLookupScreen(screen, disp); |
||
1156 | _EGLDriver *drv; |
||
1157 | EGLBoolean ret; |
||
1158 | |||
1159 | _EGL_CHECK_SCREEN(disp, scrn, EGL_FALSE, drv); |
||
1160 | ret = drv->API.QueryScreenMESA(drv, disp, scrn, attribute, value); |
||
1161 | |||
1162 | RETURN_EGL_EVAL(disp, ret); |
||
1163 | } |
||
1164 | |||
1165 | |||
1166 | EGLBoolean EGLAPIENTRY |
||
1167 | eglQueryScreenSurfaceMESA(EGLDisplay dpy, EGLScreenMESA screen, |
||
1168 | EGLSurface *surface) |
||
1169 | { |
||
1170 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1171 | _EGLScreen *scrn = _eglLookupScreen((EGLScreenMESA) screen, disp); |
||
1172 | _EGLDriver *drv; |
||
1173 | _EGLSurface *surf; |
||
1174 | EGLBoolean ret; |
||
1175 | |||
1176 | _EGL_CHECK_SCREEN(disp, scrn, EGL_FALSE, drv); |
||
1177 | ret = drv->API.QueryScreenSurfaceMESA(drv, disp, scrn, &surf); |
||
1178 | if (ret && surface) |
||
1179 | *surface = _eglGetSurfaceHandle(surf); |
||
1180 | |||
1181 | RETURN_EGL_EVAL(disp, ret); |
||
1182 | } |
||
1183 | |||
1184 | |||
1185 | EGLBoolean EGLAPIENTRY |
||
1186 | eglQueryScreenModeMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *mode) |
||
1187 | { |
||
1188 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1189 | _EGLScreen *scrn = _eglLookupScreen((EGLScreenMESA) screen, disp); |
||
1190 | _EGLDriver *drv; |
||
1191 | _EGLMode *m; |
||
1192 | EGLBoolean ret; |
||
1193 | |||
1194 | _EGL_CHECK_SCREEN(disp, scrn, EGL_FALSE, drv); |
||
1195 | ret = drv->API.QueryScreenModeMESA(drv, disp, scrn, &m); |
||
1196 | if (ret && mode) |
||
1197 | *mode = m->Handle; |
||
1198 | |||
1199 | RETURN_EGL_EVAL(disp, ret); |
||
1200 | } |
||
1201 | |||
1202 | |||
1203 | const char * EGLAPIENTRY |
||
1204 | eglQueryModeStringMESA(EGLDisplay dpy, EGLModeMESA mode) |
||
1205 | { |
||
1206 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1207 | _EGLMode *m = _eglLookupMode(mode, disp); |
||
1208 | _EGLDriver *drv; |
||
1209 | const char *ret; |
||
1210 | |||
1211 | _EGL_CHECK_MODE(disp, m, NULL, drv); |
||
1212 | ret = drv->API.QueryModeStringMESA(drv, disp, m); |
||
1213 | |||
1214 | RETURN_EGL_EVAL(disp, ret); |
||
1215 | } |
||
1216 | |||
1217 | |||
1218 | #endif /* EGL_MESA_screen_surface */ |
||
1219 | |||
1220 | |||
1221 | #ifdef EGL_MESA_drm_display |
||
1222 | |||
1223 | EGLDisplay EGLAPIENTRY |
||
1224 | eglGetDRMDisplayMESA(int fd) |
||
1225 | { |
||
1226 | _EGLDisplay *dpy = _eglFindDisplay(_EGL_PLATFORM_DRM, (void *) (intptr_t) fd); |
||
1227 | return _eglGetDisplayHandle(dpy); |
||
1228 | } |
||
1229 | |||
1230 | #endif /* EGL_MESA_drm_display */ |
||
1231 | |||
1232 | /** |
||
1233 | ** EGL 1.2 |
||
1234 | **/ |
||
1235 | |||
1236 | /** |
||
1237 | * Specify the client API to use for subsequent calls including: |
||
1238 | * eglCreateContext() |
||
1239 | * eglGetCurrentContext() |
||
1240 | * eglGetCurrentDisplay() |
||
1241 | * eglGetCurrentSurface() |
||
1242 | * eglMakeCurrent(when the ctx parameter is EGL NO CONTEXT) |
||
1243 | * eglWaitClient() |
||
1244 | * eglWaitNative() |
||
1245 | * See section 3.7 "Rendering Context" in the EGL specification for details. |
||
1246 | */ |
||
1247 | EGLBoolean EGLAPIENTRY |
||
1248 | eglBindAPI(EGLenum api) |
||
1249 | { |
||
1250 | _EGLThreadInfo *t = _eglGetCurrentThread(); |
||
1251 | |||
1252 | if (_eglIsCurrentThreadDummy()) |
||
1253 | RETURN_EGL_ERROR(NULL, EGL_BAD_ALLOC, EGL_FALSE); |
||
1254 | |||
1255 | if (!_eglIsApiValid(api)) |
||
1256 | RETURN_EGL_ERROR(NULL, EGL_BAD_PARAMETER, EGL_FALSE); |
||
1257 | |||
1258 | t->CurrentAPIIndex = _eglConvertApiToIndex(api); |
||
1259 | |||
1260 | RETURN_EGL_SUCCESS(NULL, EGL_TRUE); |
||
1261 | } |
||
1262 | |||
1263 | |||
1264 | /** |
||
1265 | * Return the last value set with eglBindAPI(). |
||
1266 | */ |
||
1267 | EGLenum EGLAPIENTRY |
||
1268 | eglQueryAPI(void) |
||
1269 | { |
||
1270 | _EGLThreadInfo *t = _eglGetCurrentThread(); |
||
1271 | EGLenum ret; |
||
1272 | |||
1273 | /* returns one of EGL_OPENGL_API, EGL_OPENGL_ES_API or EGL_OPENVG_API */ |
||
1274 | ret = _eglConvertApiFromIndex(t->CurrentAPIIndex); |
||
1275 | |||
1276 | RETURN_EGL_SUCCESS(NULL, ret); |
||
1277 | } |
||
1278 | |||
1279 | |||
1280 | EGLSurface EGLAPIENTRY |
||
1281 | eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, |
||
1282 | EGLClientBuffer buffer, EGLConfig config, |
||
1283 | const EGLint *attrib_list) |
||
1284 | { |
||
1285 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1286 | _EGLConfig *conf = _eglLookupConfig(config, disp); |
||
1287 | _EGLDriver *drv; |
||
1288 | _EGLSurface *surf; |
||
1289 | EGLSurface ret; |
||
1290 | |||
1291 | _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv); |
||
1292 | |||
1293 | surf = drv->API.CreatePbufferFromClientBuffer(drv, disp, buftype, buffer, |
||
1294 | conf, attrib_list); |
||
1295 | ret = (surf) ? _eglLinkSurface(surf) : EGL_NO_SURFACE; |
||
1296 | |||
1297 | RETURN_EGL_EVAL(disp, ret); |
||
1298 | } |
||
1299 | |||
1300 | |||
1301 | EGLBoolean EGLAPIENTRY |
||
1302 | eglReleaseThread(void) |
||
1303 | { |
||
1304 | /* unbind current contexts */ |
||
1305 | if (!_eglIsCurrentThreadDummy()) { |
||
1306 | _EGLThreadInfo *t = _eglGetCurrentThread(); |
||
1307 | EGLint api_index = t->CurrentAPIIndex; |
||
1308 | EGLint i; |
||
1309 | |||
1310 | for (i = 0; i < _EGL_API_NUM_APIS; i++) { |
||
1311 | _EGLContext *ctx = t->CurrentContexts[i]; |
||
1312 | if (ctx) { |
||
1313 | _EGLDisplay *disp = ctx->Resource.Display; |
||
1314 | _EGLDriver *drv; |
||
1315 | |||
1316 | t->CurrentAPIIndex = i; |
||
1317 | |||
1318 | _eglLockMutex(&disp->Mutex); |
||
1319 | drv = disp->Driver; |
||
1320 | (void) drv->API.MakeCurrent(drv, disp, NULL, NULL, NULL); |
||
1321 | _eglUnlockMutex(&disp->Mutex); |
||
1322 | } |
||
1323 | } |
||
1324 | |||
1325 | t->CurrentAPIIndex = api_index; |
||
1326 | } |
||
1327 | |||
1328 | _eglDestroyCurrentThread(); |
||
1329 | |||
1330 | RETURN_EGL_SUCCESS(NULL, EGL_TRUE); |
||
1331 | } |
||
1332 | |||
1333 | |||
1334 | EGLImageKHR EGLAPIENTRY |
||
1335 | eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, |
||
1336 | EGLClientBuffer buffer, const EGLint *attr_list) |
||
1337 | { |
||
1338 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1339 | _EGLContext *context = _eglLookupContext(ctx, disp); |
||
1340 | _EGLDriver *drv; |
||
1341 | _EGLImage *img; |
||
1342 | EGLImageKHR ret; |
||
1343 | |||
1344 | _EGL_CHECK_DISPLAY(disp, EGL_NO_IMAGE_KHR, drv); |
||
1345 | if (!disp->Extensions.KHR_image_base) |
||
1346 | RETURN_EGL_EVAL(disp, EGL_NO_IMAGE_KHR); |
||
1347 | if (!context && ctx != EGL_NO_CONTEXT) |
||
1348 | RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_NO_IMAGE_KHR); |
||
1349 | |||
1350 | img = drv->API.CreateImageKHR(drv, |
||
1351 | disp, context, target, buffer, attr_list); |
||
1352 | ret = (img) ? _eglLinkImage(img) : EGL_NO_IMAGE_KHR; |
||
1353 | |||
1354 | RETURN_EGL_EVAL(disp, ret); |
||
1355 | } |
||
1356 | |||
6114 | serge | 1357 | EGLImageKHR EGLAPIENTRY |
1358 | eglCreatePlanarImage(EGLDisplay dpy, EGLContext ctx, |
||
1359 | EGLClientBuffer buffer, const EGLint *attr_list) |
||
1360 | { |
||
1361 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1362 | _EGLContext *context = _eglLookupContext(ctx, disp); |
||
1363 | _EGLDriver *drv; |
||
1364 | _EGLImage *img; |
||
5563 | serge | 1365 | |
6114 | serge | 1366 | _EGL_CHECK_DISPLAY(disp, EGL_NO_IMAGE_KHR, drv); |
1367 | if (!disp->Extensions.KHR_image_base) |
||
1368 | RETURN_EGL_EVAL(disp, EGL_NO_IMAGE_KHR); |
||
1369 | if (!context && ctx != EGL_NO_CONTEXT) |
||
1370 | RETURN_EGL_ERROR(disp, EGL_BAD_CONTEXT, EGL_NO_IMAGE_KHR); |
||
1371 | |||
1372 | img = drv->API.CreatePlanarImage(drv, |
||
1373 | disp, context, buffer, attr_list); |
||
1374 | |||
1375 | return (EGLImageKHR)img; |
||
1376 | } |
||
1377 | |||
5563 | serge | 1378 | EGLBoolean EGLAPIENTRY |
1379 | eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image) |
||
1380 | { |
||
1381 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1382 | _EGLImage *img = _eglLookupImage(image, disp); |
||
1383 | _EGLDriver *drv; |
||
1384 | EGLBoolean ret; |
||
1385 | |||
1386 | _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); |
||
1387 | if (!disp->Extensions.KHR_image_base) |
||
1388 | RETURN_EGL_EVAL(disp, EGL_FALSE); |
||
1389 | if (!img) |
||
1390 | RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); |
||
1391 | |||
1392 | _eglUnlinkImage(img); |
||
1393 | ret = drv->API.DestroyImageKHR(drv, disp, img); |
||
1394 | |||
1395 | RETURN_EGL_EVAL(disp, ret); |
||
1396 | } |
||
1397 | |||
6114 | serge | 1398 | EGLBoolean EGLAPIENTRY |
1399 | eglDestroyPlanarImage(EGLDisplay dpy, EGLImageKHR image) |
||
1400 | { |
||
1401 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1402 | _EGLImage *img = (_EGLImage*)image; |
||
1403 | _EGLDriver *drv; |
||
1404 | EGLBoolean ret; |
||
5563 | serge | 1405 | |
6114 | serge | 1406 | _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); |
1407 | if (!disp->Extensions.KHR_image_base) |
||
1408 | RETURN_EGL_EVAL(disp, EGL_FALSE); |
||
1409 | if (!img) |
||
1410 | RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); |
||
1411 | |||
1412 | // ret = drv->API.DestroyImageKHR(drv, disp, img); |
||
1413 | |||
1414 | RETURN_EGL_EVAL(disp, ret); |
||
1415 | } |
||
1416 | |||
5563 | serge | 1417 | EGLSyncKHR EGLAPIENTRY |
1418 | eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list) |
||
1419 | { |
||
1420 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1421 | _EGLDriver *drv; |
||
1422 | _EGLSync *sync; |
||
1423 | EGLSyncKHR ret; |
||
1424 | |||
1425 | _EGL_CHECK_DISPLAY(disp, EGL_NO_SYNC_KHR, drv); |
||
1426 | if (!disp->Extensions.KHR_reusable_sync) |
||
1427 | RETURN_EGL_EVAL(disp, EGL_NO_SYNC_KHR); |
||
1428 | |||
1429 | sync = drv->API.CreateSyncKHR(drv, disp, type, attrib_list); |
||
1430 | ret = (sync) ? _eglLinkSync(sync) : EGL_NO_SYNC_KHR; |
||
1431 | |||
1432 | RETURN_EGL_EVAL(disp, ret); |
||
1433 | } |
||
1434 | |||
1435 | |||
1436 | EGLBoolean EGLAPIENTRY |
||
1437 | eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync) |
||
1438 | { |
||
1439 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1440 | _EGLSync *s = _eglLookupSync(sync, disp); |
||
1441 | _EGLDriver *drv; |
||
1442 | EGLBoolean ret; |
||
1443 | |||
1444 | _EGL_CHECK_SYNC(disp, s, EGL_FALSE, drv); |
||
1445 | assert(disp->Extensions.KHR_reusable_sync); |
||
1446 | |||
1447 | _eglUnlinkSync(s); |
||
1448 | ret = drv->API.DestroySyncKHR(drv, disp, s); |
||
1449 | |||
1450 | RETURN_EGL_EVAL(disp, ret); |
||
1451 | } |
||
1452 | |||
1453 | |||
1454 | EGLint EGLAPIENTRY |
||
1455 | eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout) |
||
1456 | { |
||
1457 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1458 | _EGLSync *s = _eglLookupSync(sync, disp); |
||
1459 | _EGLDriver *drv; |
||
1460 | EGLint ret; |
||
1461 | |||
1462 | _EGL_CHECK_SYNC(disp, s, EGL_FALSE, drv); |
||
1463 | assert(disp->Extensions.KHR_reusable_sync); |
||
1464 | ret = drv->API.ClientWaitSyncKHR(drv, disp, s, flags, timeout); |
||
1465 | |||
1466 | RETURN_EGL_EVAL(disp, ret); |
||
1467 | } |
||
1468 | |||
1469 | |||
1470 | EGLBoolean EGLAPIENTRY |
||
1471 | eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode) |
||
1472 | { |
||
1473 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1474 | _EGLSync *s = _eglLookupSync(sync, disp); |
||
1475 | _EGLDriver *drv; |
||
1476 | EGLBoolean ret; |
||
1477 | |||
1478 | _EGL_CHECK_SYNC(disp, s, EGL_FALSE, drv); |
||
1479 | assert(disp->Extensions.KHR_reusable_sync); |
||
1480 | ret = drv->API.SignalSyncKHR(drv, disp, s, mode); |
||
1481 | |||
1482 | RETURN_EGL_EVAL(disp, ret); |
||
1483 | } |
||
1484 | |||
1485 | |||
1486 | EGLBoolean EGLAPIENTRY |
||
1487 | eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value) |
||
1488 | { |
||
1489 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1490 | _EGLSync *s = _eglLookupSync(sync, disp); |
||
1491 | _EGLDriver *drv; |
||
1492 | EGLBoolean ret; |
||
1493 | |||
1494 | _EGL_CHECK_SYNC(disp, s, EGL_FALSE, drv); |
||
1495 | assert(disp->Extensions.KHR_reusable_sync); |
||
1496 | ret = drv->API.GetSyncAttribKHR(drv, disp, s, attribute, value); |
||
1497 | |||
1498 | RETURN_EGL_EVAL(disp, ret); |
||
1499 | } |
||
1500 | |||
1501 | |||
1502 | #ifdef EGL_NOK_swap_region |
||
1503 | |||
1504 | EGLBoolean EGLAPIENTRY |
||
1505 | eglSwapBuffersRegionNOK(EGLDisplay dpy, EGLSurface surface, |
||
1506 | EGLint numRects, const EGLint *rects) |
||
1507 | { |
||
1508 | _EGLContext *ctx = _eglGetCurrentContext(); |
||
1509 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1510 | _EGLSurface *surf = _eglLookupSurface(surface, disp); |
||
1511 | _EGLDriver *drv; |
||
1512 | EGLBoolean ret; |
||
1513 | |||
1514 | _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); |
||
1515 | |||
1516 | if (!disp->Extensions.NOK_swap_region) |
||
1517 | RETURN_EGL_EVAL(disp, EGL_FALSE); |
||
1518 | |||
1519 | /* surface must be bound to current context in EGL 1.4 */ |
||
1520 | if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT || |
||
1521 | surf != ctx->DrawSurface) |
||
1522 | RETURN_EGL_ERROR(disp, EGL_BAD_SURFACE, EGL_FALSE); |
||
1523 | |||
1524 | ret = drv->API.SwapBuffersRegionNOK(drv, disp, surf, numRects, rects); |
||
1525 | |||
1526 | RETURN_EGL_EVAL(disp, ret); |
||
1527 | } |
||
1528 | |||
1529 | #endif /* EGL_NOK_swap_region */ |
||
1530 | |||
1531 | |||
1532 | #ifdef EGL_MESA_drm_image |
||
1533 | |||
1534 | EGLImageKHR EGLAPIENTRY |
||
1535 | eglCreateDRMImageMESA(EGLDisplay dpy, const EGLint *attr_list) |
||
1536 | { |
||
1537 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1538 | _EGLDriver *drv; |
||
1539 | _EGLImage *img; |
||
1540 | EGLImageKHR ret; |
||
1541 | |||
1542 | _EGL_CHECK_DISPLAY(disp, EGL_NO_IMAGE_KHR, drv); |
||
1543 | if (!disp->Extensions.MESA_drm_image) |
||
1544 | RETURN_EGL_EVAL(disp, EGL_NO_IMAGE_KHR); |
||
1545 | |||
1546 | img = drv->API.CreateDRMImageMESA(drv, disp, attr_list); |
||
1547 | ret = (img) ? _eglLinkImage(img) : EGL_NO_IMAGE_KHR; |
||
1548 | |||
1549 | RETURN_EGL_EVAL(disp, ret); |
||
1550 | } |
||
1551 | |||
1552 | EGLBoolean EGLAPIENTRY |
||
1553 | eglExportDRMImageMESA(EGLDisplay dpy, EGLImageKHR image, |
||
1554 | EGLint *name, EGLint *handle, EGLint *stride) |
||
1555 | { |
||
1556 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1557 | _EGLImage *img = _eglLookupImage(image, disp); |
||
1558 | _EGLDriver *drv; |
||
1559 | EGLBoolean ret; |
||
1560 | |||
1561 | _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); |
||
1562 | assert(disp->Extensions.MESA_drm_image); |
||
1563 | |||
1564 | if (!img) |
||
1565 | RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); |
||
1566 | |||
1567 | ret = drv->API.ExportDRMImageMESA(drv, disp, img, name, handle, stride); |
||
1568 | |||
1569 | RETURN_EGL_EVAL(disp, ret); |
||
1570 | } |
||
1571 | |||
1572 | EGLImageKHR EGLAPIENTRY |
||
1573 | eglGetBufferImage(EGLDisplay dpy, EGLSurface surface, EGLint type) |
||
1574 | { |
||
1575 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1576 | _EGLDriver *drv; |
||
1577 | EGLImageKHR ret; |
||
1578 | |||
1579 | _EGL_CHECK_DISPLAY(disp, EGL_NO_IMAGE_KHR, drv); |
||
1580 | if (!disp->Extensions.MESA_drm_image) |
||
1581 | RETURN_EGL_EVAL(disp, EGL_NO_IMAGE_KHR); |
||
1582 | |||
1583 | ret = drv->API.GetImageFB(drv, disp, surface, type); |
||
1584 | |||
1585 | RETURN_EGL_EVAL(disp, ret); |
||
1586 | } |
||
1587 | |||
1588 | #endif |
||
1589 | |||
1590 | #ifdef EGL_WL_bind_wayland_display |
||
1591 | struct wl_display; |
||
1592 | |||
1593 | EGLBoolean EGLAPIENTRY |
||
1594 | eglBindWaylandDisplayWL(EGLDisplay dpy, struct wl_display *display) |
||
1595 | { |
||
1596 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1597 | _EGLDriver *drv; |
||
1598 | EGLBoolean ret; |
||
1599 | |||
1600 | _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); |
||
1601 | assert(disp->Extensions.WL_bind_wayland_display); |
||
1602 | |||
1603 | if (!display) |
||
1604 | RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); |
||
1605 | |||
1606 | ret = drv->API.BindWaylandDisplayWL(drv, disp, display); |
||
1607 | |||
1608 | RETURN_EGL_EVAL(disp, ret); |
||
1609 | } |
||
1610 | |||
1611 | EGLBoolean EGLAPIENTRY |
||
1612 | eglUnbindWaylandDisplayWL(EGLDisplay dpy, struct wl_display *display) |
||
1613 | { |
||
1614 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1615 | _EGLDriver *drv; |
||
1616 | EGLBoolean ret; |
||
1617 | |||
1618 | _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); |
||
1619 | assert(disp->Extensions.WL_bind_wayland_display); |
||
1620 | |||
1621 | if (!display) |
||
1622 | RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); |
||
1623 | |||
1624 | ret = drv->API.UnbindWaylandDisplayWL(drv, disp, display); |
||
1625 | |||
1626 | RETURN_EGL_EVAL(disp, ret); |
||
1627 | } |
||
1628 | |||
1629 | EGLBoolean EGLAPIENTRY |
||
1630 | eglQueryWaylandBufferWL(EGLDisplay dpy,struct wl_buffer *buffer, |
||
1631 | EGLint attribute, EGLint *value) |
||
1632 | { |
||
1633 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1634 | _EGLDriver *drv; |
||
1635 | EGLBoolean ret; |
||
1636 | |||
1637 | _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); |
||
1638 | assert(disp->Extensions.WL_bind_wayland_display); |
||
1639 | |||
1640 | if (!buffer) |
||
1641 | RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); |
||
1642 | |||
1643 | ret = drv->API.QueryWaylandBufferWL(drv, disp, buffer, attribute, value); |
||
1644 | |||
1645 | RETURN_EGL_EVAL(disp, ret); |
||
1646 | } |
||
1647 | #endif |
||
1648 | |||
1649 | |||
1650 | EGLBoolean EGLAPIENTRY |
||
1651 | eglPostSubBufferNV(EGLDisplay dpy, EGLSurface surface, |
||
1652 | EGLint x, EGLint y, EGLint width, EGLint height) |
||
1653 | { |
||
1654 | _EGLDisplay *disp = _eglLockDisplay(dpy); |
||
1655 | _EGLSurface *surf = _eglLookupSurface(surface, disp); |
||
1656 | _EGLDriver *drv; |
||
1657 | EGLBoolean ret; |
||
1658 | |||
1659 | _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv); |
||
1660 | |||
1661 | if (!disp->Extensions.NV_post_sub_buffer) |
||
1662 | RETURN_EGL_EVAL(disp, EGL_FALSE); |
||
1663 | |||
1664 | ret = drv->API.PostSubBufferNV(drv, disp, surf, x, y, width, height); |
||
1665 | |||
1666 | RETURN_EGL_EVAL(disp, ret); |
||
1667 | }>> |