4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
7 * Stanislav Vorobiov <s.vorobiov@samsung.com>
8 * Jinhyung Jo <jinhyung.jo@samsung.com>
9 * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
34 #include "yagl_host_egl_calls.h"
35 #include "yagl_impl.h"
36 #include "yagl_display.h"
38 #include "yagl_egl_state.h"
39 #include "yagl_state.h"
40 #include "yagl_malloc.h"
41 #include "yagl_surface.h"
42 #include "yagl_context.h"
43 #include "yagl_image.h"
44 #include "yagl_fence.h"
45 #include "yagl_backend.h"
46 #include "yagl_render.h"
47 #include "yagl_native_platform.h"
48 #include "yagl_native_display.h"
49 #include "yagl_native_drawable.h"
50 #include "yagl_transport_egl.h"
51 #include "yagl_client_interface.h"
52 #include "yagl_client_image.h"
53 #include "yagl_client_context.h"
54 #include "yagl_sharegroup.h"
55 #include "yagl_tex_image_binding.h"
56 #ifdef YAGL_PLATFORM_X11
57 #include "x11/yagl_x11_platform.h"
59 #include "EGL/eglmesaext.h"
66 #define YAGL_SET_ERR(err) \
67 yagl_set_error(err); \
68 YAGL_LOG_ERROR("error = 0x%X", err)
70 #define YAGL_UNIMPLEMENTED(func, ret) \
71 YAGL_LOG_FUNC_SET(func); \
72 YAGL_LOG_WARN("NOT IMPLEMENTED!!!"); \
75 static int yagl_get_client_api(const EGLint *attrib_list, yagl_client_api *client_api)
79 switch (yagl_get_api()) {
80 case EGL_OPENGL_ES_API:
81 *client_api = yagl_client_api_gles1;
83 while (attrib_list[i] != EGL_NONE) {
84 switch (attrib_list[i]) {
85 case EGL_CONTEXT_CLIENT_VERSION:
86 if (attrib_list[i + 1] == 1) {
87 *client_api = yagl_client_api_gles1;
88 } else if (attrib_list[i + 1] == 2) {
89 *client_api = yagl_client_api_gles2;
90 } else if (attrib_list[i + 1] == 3) {
91 *client_api = yagl_client_api_gles3;
105 *client_api = yagl_client_api_ovg;
108 *client_api = yagl_client_api_ogl;
116 static __inline int yagl_validate_display(EGLDisplay dpy_,
117 struct yagl_display **dpy)
119 YAGL_LOG_FUNC_SET(yagl_validate_display);
121 *dpy = yagl_display_get(dpy_);
124 YAGL_SET_ERR(EGL_BAD_DISPLAY);
128 if (!yagl_display_is_prepared(*dpy)) {
129 YAGL_SET_ERR(EGL_NOT_INITIALIZED);
136 static __inline int yagl_validate_context(struct yagl_display *dpy,
138 struct yagl_context **ctx)
140 YAGL_LOG_FUNC_SET(yagl_validate_context);
142 *ctx = yagl_display_context_acquire(dpy, ctx_);
145 YAGL_SET_ERR(EGL_BAD_CONTEXT);
152 static __inline int yagl_validate_surface(struct yagl_display *dpy,
154 struct yagl_surface **sfc)
156 YAGL_LOG_FUNC_SET(yagl_validate_surface);
158 *sfc = yagl_display_surface_acquire(dpy, sfc_);
161 YAGL_SET_ERR(EGL_BAD_SURFACE);
168 static __inline int yagl_validate_image(struct yagl_display *dpy,
170 struct yagl_image **image)
172 YAGL_LOG_FUNC_SET(yagl_validate_image);
174 *image = yagl_display_image_acquire(dpy, image_);
177 YAGL_SET_ERR(EGL_BAD_PARAMETER);
184 static __inline int yagl_validate_fence(struct yagl_display *dpy,
186 struct yagl_fence **fence)
188 YAGL_LOG_FUNC_SET(yagl_validate_fence);
190 *fence = yagl_display_fence_acquire(dpy, sync_);
193 YAGL_SET_ERR(EGL_BAD_PARAMETER);
200 YAGL_API EGLint eglGetError()
204 YAGL_LOG_FUNC_ENTER(eglGetError, NULL);
206 retval = yagl_get_error();
208 YAGL_LOG_FUNC_EXIT_SPLIT(EGLint, retval);
213 YAGL_API EGLDisplay eglGetDisplay(EGLNativeDisplayType display_id)
215 struct yagl_native_platform *platform;
216 struct yagl_display *dpy;
217 EGLDisplay ret = EGL_NO_DISPLAY;
219 YAGL_LOG_FUNC_ENTER_SPLIT1(eglGetDisplay, EGLNativeDisplayType, display_id);
221 platform = yagl_guess_platform((yagl_os_display)display_id);
227 dpy = yagl_display_add(platform, (yagl_os_display)display_id);
230 YAGL_SET_ERR(EGL_BAD_DISPLAY);
231 YAGL_LOG_ERROR("unable to add display %p",
232 (yagl_os_display)display_id);
236 ret = (EGLDisplay)dpy->host_dpy;
238 YAGL_LOG_FUNC_EXIT_SPLIT(yagl_host_handle, dpy->host_dpy);
243 YAGL_LOG_FUNC_EXIT(NULL);
248 YAGL_API EGLBoolean eglInitialize(EGLDisplay dpy_, EGLint* major, EGLint* minor)
251 struct yagl_display *dpy;
253 YAGL_LOG_FUNC_ENTER(eglInitialize, "dpy = %u", (yagl_host_handle)dpy_);
255 dpy = yagl_display_get(dpy_);
258 YAGL_SET_ERR(EGL_BAD_DISPLAY);
262 if (!yagl_host_eglInitialize(dpy->host_dpy, major, minor, &error)) {
267 yagl_display_prepare(dpy);
269 YAGL_LOG_FUNC_EXIT("major = %d, minor = %d",
270 (major ? *major : -1),
271 (minor ? *minor : -1));
276 YAGL_LOG_FUNC_EXIT(NULL);
281 YAGL_API EGLBoolean eglTerminate(EGLDisplay dpy_)
284 struct yagl_display *dpy;
285 EGLBoolean ret = EGL_FALSE;
287 YAGL_LOG_FUNC_ENTER(eglTerminate, "dpy = %u", (yagl_host_handle)dpy_);
289 if (!yagl_validate_display(dpy_, &dpy)) {
293 ret = yagl_host_eglTerminate(dpy->host_dpy, &error);
296 yagl_display_terminate(dpy);
302 YAGL_LOG_FUNC_EXIT(NULL);
307 YAGL_API const char *eglQueryString(EGLDisplay dpy_, EGLint name)
309 const char *str = NULL;
311 YAGL_LOG_FUNC_ENTER(eglQueryString,
312 "dpy = %u, name = %d",
313 (yagl_host_handle)dpy_,
323 case EGL_CLIENT_APIS:
324 if (yagl_get_host_gl_version() < yagl_gl_3_1_es3) {
325 str = "OpenGL_ES OpenGL_ES2";
327 str = "OpenGL_ES OpenGL_ES2 OpenGL_ES3";
331 str = yagl_display_get_extensions(yagl_display_get(dpy_));
334 YAGL_SET_ERR(EGL_BAD_PARAMETER);
337 YAGL_LOG_FUNC_EXIT("%s", str);
342 YAGL_API EGLBoolean eglGetConfigs(EGLDisplay dpy,
349 YAGL_LOG_FUNC_ENTER(eglGetConfigs,
350 "dpy = %u, configs = %p, config_size = %d",
351 (yagl_host_handle)dpy,
356 YAGL_SET_ERR(EGL_BAD_PARAMETER);
360 if (!yagl_host_eglGetConfigs((yagl_host_handle)dpy,
361 (yagl_host_handle*)configs,
369 YAGL_LOG_FUNC_EXIT("num_config = %d", *num_config);
374 YAGL_LOG_FUNC_EXIT(NULL);
379 YAGL_API EGLBoolean eglChooseConfig(EGLDisplay dpy,
380 const EGLint *attrib_list,
387 YAGL_LOG_FUNC_ENTER(eglChooseConfig, "dpy = %u", (yagl_host_handle)dpy);
390 YAGL_SET_ERR(EGL_BAD_PARAMETER);
394 if (!yagl_host_eglChooseConfig((yagl_host_handle)dpy,
396 yagl_transport_attrib_list_count(attrib_list),
397 (yagl_host_handle*)configs,
405 YAGL_LOG_FUNC_EXIT("num_config = %d", *num_config);
410 YAGL_LOG_FUNC_EXIT(NULL);
415 YAGL_API EGLBoolean eglGetConfigAttrib(EGLDisplay dpy_,
421 struct yagl_display *dpy = NULL;
422 EGLBoolean ret = EGL_FALSE;
423 int visual_id = 0, visual_type = 0;
425 YAGL_LOG_FUNC_ENTER(eglGetConfigAttrib,
426 "dpy = %u, config = %u, attribute = 0x%X",
427 (yagl_host_handle)dpy_,
428 (yagl_host_handle)config,
431 if (!yagl_validate_display(dpy_, &dpy)) {
436 case EGL_NATIVE_VISUAL_ID:
437 case EGL_NATIVE_VISUAL_TYPE:
438 if (!dpy->native_dpy->get_visual(dpy->native_dpy,
441 YAGL_SET_ERR(EGL_BAD_CONFIG);
442 YAGL_LOG_ERROR("get_visual failed");
446 if (attribute == EGL_NATIVE_VISUAL_ID) {
449 *value = visual_type;
455 case EGL_Y_INVERTED_NOK:
456 if (dpy->native_dpy->platform->pixmaps_supported) {
457 *value = yagl_get_backend()->y_inverted;
463 ret = yagl_host_eglGetConfigAttrib((yagl_host_handle)dpy_,
464 (yagl_host_handle)config,
480 YAGL_LOG_FUNC_EXIT("value = 0x%X", (value ? *value : -1));
485 YAGL_LOG_FUNC_EXIT(NULL);
490 YAGL_API EGLSurface eglCreateWindowSurface(EGLDisplay dpy_,
492 EGLNativeWindowType win,
493 const EGLint *attrib_list)
496 struct yagl_display *dpy = NULL;
497 struct yagl_native_drawable *native_win = NULL;
498 struct yagl_surface *surface = NULL;
500 YAGL_LOG_FUNC_ENTER(eglCreateWindowSurface,
501 "dpy = %u, config = %u",
502 (yagl_host_handle)dpy_,
503 (yagl_host_handle)config);
505 if (!yagl_validate_display(dpy_, &dpy)) {
509 native_win = dpy->native_dpy->wrap_window(dpy->native_dpy,
510 (yagl_os_window)win);
516 surface = yagl_get_backend()->create_window_surface(dpy,
517 (yagl_host_handle)config,
522 native_win->destroy(native_win);
527 if (!yagl_display_surface_add(dpy, surface)) {
528 yagl_host_eglDestroySurface(dpy->host_dpy, surface->res.handle, &error);
529 YAGL_SET_ERR(EGL_BAD_ALLOC);
533 yagl_surface_release(surface);
535 YAGL_LOG_FUNC_EXIT("%p", yagl_surface_get_handle(surface));
537 return yagl_surface_get_handle(surface);
540 yagl_surface_release(surface);
542 YAGL_LOG_FUNC_EXIT(NULL);
544 return EGL_NO_SURFACE;
547 YAGL_API EGLSurface eglCreatePbufferSurface(EGLDisplay dpy_,
549 const EGLint *attrib_list)
552 struct yagl_display *dpy = NULL;
553 struct yagl_surface *surface = NULL;
555 YAGL_LOG_FUNC_ENTER(eglCreatePbufferSurface,
556 "dpy = %u, config = %u",
557 (yagl_host_handle)dpy_,
558 (yagl_host_handle)config);
560 if (!yagl_validate_display(dpy_, &dpy)) {
564 surface = yagl_get_backend()->create_pbuffer_surface(dpy,
565 (yagl_host_handle)config,
572 if (!yagl_display_surface_add(dpy, surface)) {
573 yagl_host_eglDestroySurface(dpy->host_dpy, surface->res.handle, &error);
574 YAGL_SET_ERR(EGL_BAD_ALLOC);
578 yagl_surface_release(surface);
580 YAGL_LOG_FUNC_EXIT("%p", yagl_surface_get_handle(surface));
582 return yagl_surface_get_handle(surface);
585 yagl_surface_release(surface);
587 YAGL_LOG_FUNC_EXIT(NULL);
589 return EGL_NO_SURFACE;
592 YAGL_API EGLSurface eglCreatePixmapSurface(EGLDisplay dpy_,
594 EGLNativePixmapType pixmap,
595 const EGLint *attrib_list)
598 struct yagl_display *dpy = NULL;
599 struct yagl_native_drawable *native_pixmap = NULL;
600 struct yagl_surface *surface = NULL;
602 YAGL_LOG_FUNC_ENTER(eglCreatePixmapSurface,
603 "dpy = %u, config = %u",
604 (yagl_host_handle)dpy_,
605 (yagl_host_handle)config);
607 if (!yagl_validate_display(dpy_, &dpy)) {
611 native_pixmap = dpy->native_dpy->wrap_pixmap(dpy->native_dpy,
612 (yagl_os_pixmap)pixmap);
614 if (!native_pixmap) {
618 surface = yagl_get_backend()->create_pixmap_surface(dpy,
619 (yagl_host_handle)config,
624 native_pixmap->destroy(native_pixmap);
625 native_pixmap = NULL;
629 if (!yagl_display_surface_add(dpy, surface)) {
630 yagl_host_eglDestroySurface(dpy->host_dpy, surface->res.handle, &error);
631 YAGL_SET_ERR(EGL_BAD_ALLOC);
635 yagl_surface_release(surface);
637 YAGL_LOG_FUNC_EXIT("%p", yagl_surface_get_handle(surface));
639 return yagl_surface_get_handle(surface);
642 yagl_surface_release(surface);
644 YAGL_LOG_FUNC_EXIT(NULL);
646 return EGL_NO_SURFACE;
649 YAGL_API EGLBoolean eglDestroySurface(EGLDisplay dpy_, EGLSurface surface_)
652 EGLBoolean res = EGL_FALSE;
653 struct yagl_display *dpy = NULL;
654 struct yagl_surface *surface = NULL;
656 YAGL_LOG_FUNC_ENTER(eglDestroySurface,
657 "dpy = %u, surface = %p",
658 (yagl_host_handle)dpy_,
661 if (!yagl_validate_display(dpy_, &dpy)) {
665 if (!yagl_validate_surface(dpy, surface_, &surface)) {
669 if (!yagl_host_eglDestroySurface(dpy->host_dpy, surface->res.handle, &error)) {
674 if (!yagl_display_surface_remove(dpy, surface_)) {
675 YAGL_LOG_ERROR("we're the one who destroy the surface, but surface isn't there!");
676 YAGL_SET_ERR(EGL_BAD_SURFACE);
683 yagl_surface_release(surface);
685 YAGL_LOG_FUNC_EXIT("%d", ((res == EGL_TRUE) ? 1 : 0));
690 YAGL_API EGLBoolean eglQuerySurface(EGLDisplay dpy_,
696 EGLBoolean retval = EGL_FALSE;
697 struct yagl_display *dpy = NULL;
698 struct yagl_surface *surface = NULL;
702 YAGL_LOG_FUNC_ENTER(eglQuerySurface,
703 "dpy = %u, surface = %p, attribute = 0x%X, value = %p",
704 (yagl_host_handle)dpy_,
709 if (!yagl_validate_display(dpy_, &dpy)) {
713 if (!yagl_validate_surface(dpy, surface_, &surface)) {
718 case EGL_BITMAP_POINTER_KHR:
719 ptr = yagl_surface_map(surface, &stride);
721 *value = (EGLint)ptr;
724 YAGL_SET_ERR(EGL_BAD_ACCESS);
727 case EGL_BITMAP_PITCH_KHR:
728 ptr = yagl_surface_map(surface, &stride);
733 YAGL_SET_ERR(EGL_BAD_ACCESS);
736 case EGL_BITMAP_ORIGIN_KHR:
737 *value = EGL_UPPER_LEFT_KHR;
740 case EGL_BITMAP_PIXEL_RED_OFFSET_KHR:
744 case EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR:
748 case EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR:
752 case EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR:
756 case EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR:
760 case EGL_BUFFER_AGE_EXT:
761 if (dpy->native_dpy->platform->buffer_age_supported &&
762 surface->native_drawable) {
763 *value = surface->native_drawable->get_buffer_age(surface->native_drawable);
769 retval = yagl_host_eglQuerySurface(dpy->host_dpy,
783 yagl_surface_release(surface);
785 YAGL_LOG_FUNC_EXIT("%d", ((retval == EGL_TRUE) ? 1 : 0));
790 YAGL_API EGLBoolean eglBindAPI(EGLenum api)
792 YAGL_LOG_FUNC_ENTER_SPLIT1(eglBindAPI, EGLenum, api);
794 if (api != EGL_OPENGL_ES_API) {
795 YAGL_SET_ERR(EGL_BAD_PARAMETER);
799 yagl_host_eglBindAPI(api);
802 YAGL_LOG_FUNC_EXIT_SPLIT(EGLBoolean, EGL_TRUE);
807 YAGL_API EGLenum eglQueryAPI()
811 YAGL_LOG_FUNC_ENTER_SPLIT0(eglQueryAPI);
813 ret = yagl_get_api();
815 YAGL_LOG_FUNC_EXIT_SPLIT(EGLenum, ret);
820 YAGL_API EGLBoolean eglWaitClient()
822 struct yagl_surface *draw_sfc;
824 YAGL_LOG_FUNC_ENTER_SPLIT0(eglWaitClient);
826 draw_sfc = yagl_get_draw_surface();
829 draw_sfc->wait_gl(draw_sfc);
832 YAGL_LOG_FUNC_EXIT(NULL);
837 YAGL_API EGLBoolean eglReleaseThread()
841 YAGL_LOG_FUNC_ENTER(eglReleaseThread, NULL);
843 if (!yagl_host_eglReleaseThread(&error)) {
850 YAGL_LOG_FUNC_EXIT("1");
855 YAGL_LOG_FUNC_EXIT(NULL);
860 YAGL_API EGLSurface eglCreatePbufferFromClientBuffer(EGLDisplay dpy,
862 EGLClientBuffer buffer,
864 const EGLint *attrib_list)
866 YAGL_UNIMPLEMENTED(eglCreatePbufferFromClientBuffer, EGL_NO_SURFACE);
869 YAGL_API EGLBoolean eglSurfaceAttrib(EGLDisplay dpy_,
875 EGLBoolean res = EGL_FALSE;
876 struct yagl_display *dpy = NULL;
877 struct yagl_surface *surface = NULL;
879 YAGL_LOG_FUNC_ENTER(eglSurfaceAttrib,
880 "dpy = %u, surface = %p, attribute = 0x%X, value = 0x%X",
881 (yagl_host_handle)dpy_,
886 if (!yagl_validate_display(dpy_, &dpy)) {
890 if (!yagl_validate_surface(dpy, surface_, &surface)) {
894 if (!yagl_host_eglSurfaceAttrib(dpy->host_dpy,
906 yagl_surface_release(surface);
908 YAGL_LOG_FUNC_EXIT("%d", ((res == EGL_TRUE) ? 1 : 0));
913 YAGL_API EGLBoolean eglBindTexImage(EGLDisplay dpy_,
917 EGLBoolean res = EGL_FALSE;
918 struct yagl_display *dpy = NULL;
919 struct yagl_surface *surface = NULL;
920 struct yagl_context *ctx = NULL;
921 struct yagl_client_interface *iface = NULL;
922 struct yagl_client_image *image = NULL;
923 struct yagl_tex_image_binding *binding = NULL;
925 YAGL_LOG_FUNC_ENTER(eglBindTexImage,
926 "dpy = %u, surface = %p, buffer = 0x%X",
927 (yagl_host_handle)dpy_,
931 iface = yagl_get_any_client_interface();
934 YAGL_SET_ERR(EGL_BAD_ALLOC);
938 ctx = yagl_get_context();
941 YAGL_LOG_WARN("No context");
946 if (!yagl_validate_display(dpy_, &dpy)) {
950 if (!yagl_validate_surface(dpy, surface_, &surface)) {
954 if (buffer != EGL_BACK_BUFFER) {
955 YAGL_SET_ERR(EGL_BAD_PARAMETER);
959 if (surface->type != EGL_PBUFFER_BIT) {
960 YAGL_SET_ERR(EGL_BAD_SURFACE);
964 image = surface->create_image(surface, iface);
970 binding = yagl_surface_create_tex_image_binding(surface, iface);
972 if (!ctx->client_ctx->bind_tex_image(ctx->client_ctx, image, binding)) {
974 YAGL_SET_ERR(EGL_BAD_ACCESS);
978 if (!yagl_surface_bind_tex_image(surface, binding)) {
979 iface->release_tex_image(iface, binding->cookie);
981 YAGL_SET_ERR(EGL_BAD_ACCESS);
988 yagl_surface_release(surface);
989 yagl_client_image_release(image);
991 YAGL_LOG_FUNC_EXIT("%d", ((res == EGL_TRUE) ? 1 : 0));
996 YAGL_API EGLBoolean eglReleaseTexImage(EGLDisplay dpy_,
1000 EGLBoolean res = EGL_FALSE;
1001 struct yagl_display *dpy = NULL;
1002 struct yagl_surface *surface = NULL;
1004 YAGL_LOG_FUNC_ENTER(eglReleaseTexImage,
1005 "dpy = %u, surface = %p, buffer = 0x%X",
1006 (yagl_host_handle)dpy_,
1010 if (!yagl_validate_display(dpy_, &dpy)) {
1014 if (!yagl_validate_surface(dpy, surface_, &surface)) {
1018 if (buffer != EGL_BACK_BUFFER) {
1019 YAGL_SET_ERR(EGL_BAD_PARAMETER);
1023 if (surface->type != EGL_PBUFFER_BIT) {
1024 YAGL_SET_ERR(EGL_BAD_SURFACE);
1028 yagl_surface_release_tex_image(surface);
1033 yagl_surface_release(surface);
1035 YAGL_LOG_FUNC_EXIT("%d", ((res == EGL_TRUE) ? 1 : 0));
1040 YAGL_API EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval)
1042 struct yagl_surface *draw_sfc;
1044 YAGL_LOG_FUNC_ENTER(eglSwapInterval,
1045 "dpy = %u, interval = %d",
1046 (yagl_host_handle)dpy,
1049 draw_sfc = yagl_get_draw_surface();
1051 if (draw_sfc && (draw_sfc->type == EGL_WINDOW_BIT)) {
1052 if (interval <= 0) {
1054 * Always make sure that swap interval is at least 1. Setting
1055 * to 0 makes little sense with tizen since tizen compositor
1056 * will still use a value of 1 and this will cause jagged rendering
1061 draw_sfc->set_swap_interval(draw_sfc, interval);
1064 YAGL_LOG_FUNC_EXIT("1");
1069 YAGL_API EGLContext eglCreateContext(EGLDisplay dpy_,
1071 EGLContext share_context_,
1072 const EGLint *attrib_list)
1075 struct yagl_display *dpy = NULL;
1076 struct yagl_context *share_context = NULL;
1077 struct yagl_sharegroup *sg = NULL;
1078 yagl_client_api client_api;
1079 struct yagl_client_interface *iface = NULL;
1080 yagl_host_handle host_context = 0;
1081 struct yagl_client_context *client_ctx = NULL;
1082 struct yagl_context *ctx = NULL;
1084 YAGL_LOG_FUNC_ENTER(eglCreateContext,
1085 "dpy = %u, config = %u, share_context = %u",
1086 (yagl_host_handle)dpy_,
1087 (yagl_host_handle)config,
1088 (yagl_host_handle)share_context_);
1090 if (!yagl_validate_display(dpy_, &dpy)) {
1094 if (share_context_) {
1095 if (!yagl_validate_context(dpy, share_context_, &share_context)) {
1098 sg = share_context->client_ctx->sg;
1099 yagl_sharegroup_acquire(sg);
1101 sg = yagl_sharegroup_create();
1104 if (!yagl_get_client_api(attrib_list, &client_api)) {
1105 YAGL_SET_ERR(EGL_BAD_ATTRIBUTE);
1109 if ((client_api == yagl_client_api_gles3) &&
1110 (yagl_get_host_gl_version() < yagl_gl_3_1_es3)) {
1111 YAGL_SET_ERR(EGL_BAD_ATTRIBUTE);
1115 iface = yagl_get_client_interface(client_api);
1118 YAGL_SET_ERR(EGL_BAD_ATTRIBUTE);
1123 yagl_host_eglCreateContext(dpy->host_dpy,
1124 (yagl_host_handle)config,
1125 (yagl_host_handle)share_context_,
1127 yagl_transport_attrib_list_count(attrib_list),
1130 if (!host_context) {
1131 YAGL_SET_ERR(error);
1135 client_ctx = iface->create_ctx(iface, client_api, sg);
1137 ctx = yagl_context_create(host_context, dpy, client_ctx);
1140 yagl_display_context_add(dpy, ctx);
1142 yagl_context_release(ctx);
1145 yagl_sharegroup_release(sg);
1146 yagl_context_release(share_context);
1148 YAGL_LOG_FUNC_EXIT("%u", host_context);
1150 return (EGLContext)host_context;
1153 YAGL_API EGLBoolean eglDestroyContext(EGLDisplay dpy_, EGLContext ctx)
1156 struct yagl_display *dpy = NULL;
1158 YAGL_LOG_FUNC_ENTER(eglDestroyContext,
1159 "dpy = %u, ctx = %u",
1160 (yagl_host_handle)dpy_,
1161 (yagl_host_handle)ctx);
1163 if (!yagl_validate_display(dpy_, &dpy)) {
1167 if (!yagl_host_eglDestroyContext(dpy->host_dpy, (yagl_host_handle)ctx, &error)) {
1168 YAGL_SET_ERR(error);
1172 yagl_display_context_remove(dpy, ctx);
1174 YAGL_LOG_FUNC_EXIT("1");
1179 YAGL_LOG_FUNC_EXIT(NULL);
1184 YAGL_API EGLBoolean eglMakeCurrent(EGLDisplay dpy_,
1189 EGLBoolean res = EGL_FALSE;
1190 int bad_match = ctx_ ? (!draw_ ^ !read_) : (draw_ || read_);
1191 struct yagl_display *dpy = NULL;
1192 struct yagl_surface *draw = NULL;
1193 struct yagl_surface *read = NULL;
1194 struct yagl_context *ctx = NULL;
1195 struct yagl_context *prev_ctx = NULL;
1197 YAGL_LOG_FUNC_ENTER(eglMakeCurrent,
1198 "dpy = %u, draw = %p, read = %p, ctx = %u",
1199 (yagl_host_handle)dpy_,
1202 (yagl_host_handle)ctx_);
1205 YAGL_SET_ERR(EGL_BAD_MATCH);
1209 prev_ctx = yagl_get_context();
1211 if (!draw_ && !read_ && !ctx_) {
1213 * Releasing context.
1217 if (dpy_ == EGL_NO_DISPLAY) {
1219 * Workaround for the case when dpy
1220 * passed is EGL_NO_DISPLAY and we're releasing
1221 * the current context.
1224 dpy_ = (EGLDisplay)prev_ctx->dpy->host_dpy;
1225 dpy = prev_ctx->dpy;
1227 if (!yagl_validate_display(dpy_, &dpy)) {
1233 * No current context and we're releasing, a no-op.
1240 * Making some context current.
1243 if (!yagl_validate_display(dpy_, &dpy)) {
1247 if (draw_ && !yagl_validate_surface(dpy, draw_, &draw)) {
1251 if (read_ && !yagl_validate_surface(dpy, read_, &read)) {
1255 ctx = yagl_display_context_acquire(dpy, ctx_);
1258 * A workaround for EffectsApp. It incorrectly calls
1259 * eglMakeCurrent(dpy, draw, read, NULL) which is not allowed
1260 * according to EGL standard. i.e. non-NULL surfaces and NULL context
1263 if (draw && read && !ctx) {
1265 yagl_context_acquire(ctx);
1269 YAGL_SET_ERR(EGL_BAD_CONTEXT);
1275 (ctx == prev_ctx) &&
1276 (ctx->dpy == dpy) &&
1277 (draw == yagl_get_draw_surface()) &&
1278 (read == yagl_get_read_surface())) {
1280 * Absolutely no change, skip.
1287 if ((draw && yagl_surface_locked(draw)) ||
1288 (read && yagl_surface_locked(read))) {
1289 YAGL_SET_ERR(EGL_BAD_ACCESS);
1293 if (!yagl_set_context(ctx, draw, read)) {
1295 * Context and/or surfaces are already
1296 * current to some other thread.
1298 YAGL_SET_ERR(EGL_BAD_ACCESS);
1302 yagl_render_invalidate(0);
1304 yagl_host_eglMakeCurrent((yagl_host_handle)dpy_,
1305 (draw ? draw->res.handle : 0),
1306 (read ? read->res.handle : 0),
1307 (ctx ? ctx->res.handle : 0));
1309 if (ctx && !ctx->client_ctx_prepared) {
1310 ctx->client_ctx->prepare(ctx->client_ctx);
1311 ctx->client_ctx_prepared = 1;
1317 yagl_surface_release(draw);
1318 yagl_surface_release(read);
1319 yagl_context_release(ctx);
1321 YAGL_LOG_FUNC_EXIT("%d", ((res == EGL_TRUE) ? 1 : 0));
1326 YAGL_API EGLContext eglGetCurrentContext(void)
1328 struct yagl_context *ctx;
1330 YAGL_LOG_FUNC_ENTER(eglGetCurrentContext, NULL);
1332 ctx = yagl_get_context();
1334 YAGL_LOG_FUNC_EXIT("%u", (ctx ? ctx->res.handle : 0));
1336 return (ctx ? (EGLContext)ctx->res.handle : EGL_NO_CONTEXT);
1339 YAGL_API EGLSurface eglGetCurrentSurface(EGLint readdraw)
1341 struct yagl_surface *sfc;
1342 EGLSurface ret = EGL_NO_SURFACE;
1344 YAGL_LOG_FUNC_ENTER(eglGetCurrentSurface, NULL);
1346 if (readdraw == EGL_READ) {
1347 sfc = yagl_get_read_surface();
1348 ret = (sfc ? yagl_surface_get_handle(sfc) : EGL_NO_SURFACE);
1349 } else if (readdraw == EGL_DRAW) {
1350 sfc = yagl_get_draw_surface();
1351 ret = (sfc ? yagl_surface_get_handle(sfc) : EGL_NO_SURFACE);
1353 YAGL_SET_ERR(EGL_BAD_PARAMETER);
1356 YAGL_LOG_FUNC_EXIT("%p", ret);
1361 YAGL_API EGLDisplay eglGetCurrentDisplay(void)
1363 struct yagl_context *ctx;
1365 YAGL_LOG_FUNC_ENTER(eglGetCurrentDisplay, NULL);
1367 ctx = yagl_get_context();
1369 YAGL_LOG_FUNC_EXIT("%u", (ctx ? ctx->dpy->host_dpy : 0));
1371 return (ctx ? (EGLDisplay)ctx->dpy->host_dpy : EGL_NO_DISPLAY);
1374 YAGL_API EGLBoolean eglQueryContext(EGLDisplay dpy_,
1380 EGLBoolean res = EGL_FALSE;
1381 struct yagl_display *dpy = NULL;
1382 struct yagl_context *ctx = NULL;
1384 YAGL_LOG_FUNC_ENTER(eglQueryContext,
1385 "dpy = %u, ctx = %u, attribute = 0x%X, value = %p",
1386 (yagl_host_handle)dpy_,
1387 (yagl_host_handle)ctx_,
1391 if (!yagl_validate_display(dpy_, &dpy)) {
1395 if (!yagl_validate_context(dpy, ctx_, &ctx)) {
1401 switch (attribute) {
1402 case EGL_CONTEXT_CLIENT_TYPE:
1403 switch (ctx->client_ctx->client_api) {
1404 case yagl_client_api_gles1:
1405 case yagl_client_api_gles2:
1406 case yagl_client_api_gles3:
1408 *value = EGL_OPENGL_ES_API;
1411 case yagl_client_api_ogl:
1413 *value = EGL_OPENGL_API;
1416 case yagl_client_api_ovg:
1418 *value = EGL_OPENVG_API;
1428 case EGL_CONTEXT_CLIENT_VERSION:
1429 switch (ctx->client_ctx->client_api) {
1430 case yagl_client_api_gles1:
1435 case yagl_client_api_gles2:
1440 case yagl_client_api_gles3:
1445 case yagl_client_api_ogl:
1446 case yagl_client_api_ovg:
1455 res = yagl_host_eglQueryContext(dpy->host_dpy,
1456 (yagl_host_handle)ctx_,
1462 YAGL_SET_ERR(error);
1469 yagl_context_release(ctx);
1471 YAGL_LOG_FUNC_EXIT("%d", ((res == EGL_TRUE) ? 1 : 0));
1476 YAGL_API EGLBoolean eglWaitGL()
1480 YAGL_LOG_FUNC_ENTER_SPLIT0(eglWaitGL);
1482 ret = eglWaitClient();
1484 YAGL_LOG_FUNC_EXIT(NULL);
1489 YAGL_API EGLBoolean eglWaitNative(EGLint engine)
1491 struct yagl_surface *draw_sfc;
1493 YAGL_LOG_FUNC_ENTER_SPLIT1(eglWaitNative, EGLint, engine);
1495 draw_sfc = yagl_get_draw_surface();
1498 draw_sfc->wait_x(draw_sfc);
1501 YAGL_LOG_FUNC_EXIT(NULL);
1506 YAGL_API EGLBoolean eglSwapBuffers(EGLDisplay dpy_, EGLSurface surface_)
1508 EGLBoolean res = EGL_FALSE;
1509 struct yagl_display *dpy = NULL;
1510 struct yagl_surface *surface = NULL;
1512 YAGL_LOG_FUNC_ENTER(eglSwapBuffers,
1513 "dpy = %u, surface = %p",
1514 (yagl_host_handle)dpy_,
1517 if (!yagl_validate_display(dpy_, &dpy)) {
1521 if (!yagl_validate_surface(dpy, surface_, &surface)) {
1525 if ((yagl_get_draw_surface() != surface) &&
1526 (yagl_get_read_surface() != surface)) {
1527 YAGL_SET_ERR(EGL_BAD_SURFACE);
1531 if (yagl_surface_locked(surface)) {
1532 YAGL_SET_ERR(EGL_BAD_ACCESS);
1536 if (surface->type != EGL_WINDOW_BIT) {
1541 if (!surface->swap_buffers(surface)) {
1547 #ifdef YAGL_PLATFORM_X11
1548 if (dpy->native_dpy->platform == &yagl_x11_platform) {
1550 * Normally one should not invalidate right after eglSwapBuffers,
1551 * instead invalidate should be called on first rendering call
1552 * after eglSwapBuffers (see yagl_render.h:yagl_render_invalidate).
1553 * But this doesn't work on Tizen mobile, without this invalidate
1554 * Tizen compositor may miss surface updates.
1555 * The problem is in "efl_sync" option of the compositor, which is 0
1556 * by default in upstream and 1 in Tizen. Setting it to 0 in
1557 * config doesn't seem to help, one had to manually change code:
1558 * e17-extra-modules/comp-tizen/src/e_mod_comp_cfdata.c:
1559 * cfg->efl_sync = 1;
1561 * cfg->efl_sync = 0;
1562 * AND set efl_sync to 0 in config to make this work.
1563 * When efl_sync is set to 1 the compositor acts like this:
1564 * + For normal X11 windows nothing is changed
1565 * + For e17 windows (created via ecore_x_window_new) it doesn't redraw
1566 * the screen on damage events, but only on special SYNC_DRAW_DONE
1567 * events that are sent from _ecore_evas_x_flush_post, which is called
1568 * after eglSwapBuffers, that's why things work when invalidate
1569 * is inside eglSwapBuffers, it finishes the swap before sending
1570 * SYNC_DRAW_DONE, but once we move invalidate to first rendering call
1571 * after eglSwapBuffers SYNC_DRAW_DONE starts to come before
1572 * uxa copy, thus, missing last frame.
1574 yagl_render_invalidate(0);
1579 yagl_surface_release(surface);
1581 YAGL_LOG_FUNC_EXIT("%d", res);
1586 YAGL_API EGLBoolean eglCopyBuffers(EGLDisplay dpy_,
1587 EGLSurface surface_,
1588 EGLNativePixmapType target)
1590 EGLBoolean res = EGL_FALSE;
1591 struct yagl_display *dpy = NULL;
1592 struct yagl_surface *surface = NULL;
1594 YAGL_LOG_FUNC_ENTER(eglCopyBuffers,
1595 "dpy = %u, surface = %p, target = %u",
1596 (yagl_host_handle)dpy_,
1600 if (!yagl_validate_display(dpy_, &dpy)) {
1604 if (!yagl_validate_surface(dpy, surface_, &surface)) {
1608 if ((yagl_get_draw_surface() != surface) &&
1609 (yagl_get_read_surface() != surface)) {
1610 YAGL_SET_ERR(EGL_BAD_SURFACE);
1614 if (yagl_surface_locked(surface)) {
1615 YAGL_SET_ERR(EGL_BAD_ACCESS);
1619 if (!surface->copy_buffers(surface, target)) {
1626 yagl_surface_release(surface);
1628 YAGL_LOG_FUNC_EXIT("%d", res);
1633 #ifndef EGL_NATIVE_SURFACE_TIZEN
1634 #define EGL_NATIVE_SURFACE_TIZEN 0x32A1
1637 YAGL_API EGLImageKHR eglCreateImageKHR(EGLDisplay dpy_,
1640 EGLClientBuffer buffer,
1641 const EGLint *attrib_list)
1643 EGLImageKHR ret = EGL_NO_IMAGE_KHR;
1644 struct yagl_client_interface *iface = NULL;
1645 struct yagl_display *dpy = NULL;
1646 struct yagl_context *ctx = NULL;
1647 struct yagl_native_drawable *native_buffer = NULL;
1648 struct yagl_image *image = NULL;
1651 YAGL_LOG_FUNC_ENTER(eglCreateImageKHR,
1652 "dpy = %u, ctx = %u, target = %u, buffer = %p",
1653 (yagl_host_handle)dpy_,
1654 (yagl_host_handle)ctx_,
1658 iface = yagl_get_any_client_interface();
1661 YAGL_SET_ERR(EGL_BAD_ALLOC);
1666 YAGL_SET_ERR(EGL_BAD_PARAMETER);
1670 if (!yagl_validate_display(dpy_, &dpy)) {
1675 case EGL_NATIVE_PIXMAP_KHR:
1676 if (!dpy->native_dpy->platform->pixmaps_supported) {
1677 YAGL_SET_ERR(EGL_BAD_PARAMETER);
1682 while (attrib_list[i] != EGL_NONE) {
1683 switch (attrib_list[i]) {
1684 case EGL_IMAGE_PRESERVED_KHR:
1687 YAGL_SET_ERR(EGL_BAD_ATTRIBUTE);
1695 native_buffer = dpy->native_dpy->wrap_pixmap(dpy->native_dpy,
1696 (yagl_os_pixmap)buffer);
1698 if (!native_buffer) {
1702 image = yagl_get_backend()->create_image_pixmap(dpy,
1707 native_buffer->destroy(native_buffer);
1712 case EGL_WAYLAND_BUFFER_WL:
1713 if (!dpy->native_dpy->WL_bind_wayland_display_supported) {
1714 YAGL_SET_ERR(EGL_BAD_PARAMETER);
1719 while (attrib_list[i] != EGL_NONE) {
1720 switch (attrib_list[i]) {
1721 case EGL_IMAGE_PRESERVED_KHR:
1722 case EGL_WAYLAND_PLANE_WL:
1725 YAGL_SET_ERR(EGL_BAD_ATTRIBUTE);
1733 image = yagl_get_backend()->create_image_wl_buffer(dpy,
1734 (struct wl_resource*)buffer,
1742 case EGL_GL_TEXTURE_2D_KHR:
1744 while (attrib_list[i] != EGL_NONE) {
1745 switch (attrib_list[i]) {
1746 case EGL_IMAGE_PRESERVED_KHR:
1747 case EGL_GL_TEXTURE_LEVEL_KHR:
1750 YAGL_SET_ERR(EGL_BAD_ATTRIBUTE);
1758 if (!yagl_validate_context(dpy, ctx_, &ctx)) {
1762 image = yagl_get_backend()->create_image_gl_texture_2d(dpy,
1764 (yagl_object_name)buffer,
1772 case EGL_NATIVE_SURFACE_TIZEN:
1774 while (attrib_list[i] != EGL_NONE) {
1775 switch (attrib_list[i]) {
1776 case EGL_IMAGE_PRESERVED_KHR:
1779 YAGL_SET_ERR(EGL_BAD_ATTRIBUTE);
1787 image = yagl_get_backend()->create_image_tizen_sfc(dpy,
1797 YAGL_SET_ERR(EGL_BAD_PARAMETER);
1801 if (!yagl_display_image_add(dpy, image)) {
1802 YAGL_SET_ERR(EGL_BAD_PARAMETER);
1806 ret = image->client_handle;
1809 yagl_image_release(image);
1811 yagl_context_release(ctx);
1813 YAGL_LOG_FUNC_EXIT("%p", ret);
1818 YAGL_API EGLBoolean eglDestroyImageKHR( EGLDisplay dpy_,
1819 EGLImageKHR image_ )
1821 EGLBoolean res = EGL_FALSE;
1822 struct yagl_display *dpy = NULL;
1823 struct yagl_image *image = NULL;
1825 YAGL_LOG_FUNC_ENTER(eglDestroyImageKHR,
1826 "dpy = %u, image = %p",
1827 (yagl_host_handle)dpy_,
1830 if (!yagl_validate_display(dpy_, &dpy)) {
1834 if (!yagl_validate_image(dpy, image_, &image)) {
1838 if (!yagl_display_image_remove(dpy, image_)) {
1839 YAGL_LOG_ERROR("we're the one who destroy the image, but it isn't there!");
1840 YAGL_SET_ERR(EGL_BAD_PARAMETER);
1847 yagl_image_release(image);
1849 YAGL_LOG_FUNC_EXIT("%d", ((res == EGL_TRUE) ? 1 : 0));
1854 YAGL_API EGLBoolean eglLockSurfaceKHR(EGLDisplay dpy_,
1855 EGLSurface surface_,
1856 const EGLint *attrib_list)
1858 EGLBoolean res = EGL_FALSE;
1859 struct yagl_display *dpy = NULL;
1860 struct yagl_surface *surface = NULL;
1865 YAGL_LOG_FUNC_ENTER(eglLockSurfaceKHR,
1866 "dpy = %u, surface = %p",
1867 (yagl_host_handle)dpy_,
1870 if (!yagl_validate_display(dpy_, &dpy)) {
1874 if (!yagl_validate_surface(dpy, surface_, &surface)) {
1879 while (attrib_list[i] != EGL_NONE) {
1880 switch (attrib_list[i]) {
1881 case EGL_MAP_PRESERVE_PIXELS_KHR:
1882 preserve = attrib_list[i + 1];
1884 case EGL_LOCK_USAGE_HINT_KHR:
1887 YAGL_SET_ERR(EGL_BAD_ATTRIBUTE);
1896 hint = EGL_READ_SURFACE_BIT_KHR | EGL_WRITE_SURFACE_BIT_KHR;
1898 hint = EGL_WRITE_SURFACE_BIT_KHR;
1901 if (!yagl_surface_lock(surface, hint)) {
1902 YAGL_SET_ERR(EGL_BAD_ACCESS);
1909 yagl_surface_release(surface);
1911 YAGL_LOG_FUNC_EXIT("%d", res);
1916 YAGL_API EGLBoolean eglUnlockSurfaceKHR(EGLDisplay dpy_,
1917 EGLSurface surface_)
1919 EGLBoolean res = EGL_FALSE;
1920 struct yagl_display *dpy = NULL;
1921 struct yagl_surface *surface = NULL;
1923 YAGL_LOG_FUNC_ENTER(eglUnlockSurfaceKHR,
1924 "dpy = %u, surface = %p",
1925 (yagl_host_handle)dpy_,
1928 if (!yagl_validate_display(dpy_, &dpy)) {
1932 if (!yagl_validate_surface(dpy, surface_, &surface)) {
1936 if (!yagl_surface_unlock(surface)) {
1937 YAGL_SET_ERR(EGL_BAD_ACCESS);
1941 yagl_surface_invalidate(surface);
1946 yagl_surface_release(surface);
1948 YAGL_LOG_FUNC_EXIT("%d", res);
1953 YAGL_API EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy_, EGLenum type, const EGLint *attrib_list)
1955 EGLSyncKHR ret = EGL_NO_SYNC_KHR;
1956 struct yagl_display *dpy = NULL;
1957 struct yagl_fence *fence = NULL;
1959 YAGL_LOG_FUNC_ENTER(eglCreateSyncKHR, "dpy = %u, type = %u",
1960 (yagl_host_handle)dpy_, type);
1962 if (type != EGL_SYNC_FENCE_KHR) {
1963 YAGL_SET_ERR(EGL_BAD_ATTRIBUTE);
1967 if (attrib_list && (attrib_list[0] != EGL_NONE)) {
1968 YAGL_SET_ERR(EGL_BAD_ATTRIBUTE);
1972 if (!yagl_validate_display(dpy_, &dpy)) {
1976 fence = yagl_get_backend()->create_fence(dpy);
1979 YAGL_SET_ERR(EGL_BAD_ACCESS);
1983 yagl_display_fence_add(dpy, fence);
1985 yagl_transport_flush(yagl_get_transport(), &fence->base);
1990 yagl_fence_release(fence);
1992 YAGL_LOG_FUNC_EXIT("%p", ret);
1997 YAGL_API EGLBoolean eglDestroySyncKHR(EGLDisplay dpy_, EGLSyncKHR sync_)
1999 EGLBoolean res = EGL_FALSE;
2000 struct yagl_display *dpy = NULL;
2001 struct yagl_fence *fence = NULL;
2003 YAGL_LOG_FUNC_ENTER(eglDestroySyncKHR, "dpy = %u, sync = %p",
2004 (yagl_host_handle)dpy_, sync_);
2006 if (!yagl_validate_display(dpy_, &dpy)) {
2010 if (!yagl_validate_fence(dpy, sync_, &fence)) {
2014 if (!yagl_display_fence_remove(dpy, sync_)) {
2015 YAGL_LOG_ERROR("we're the one who destroy the fence, but it isn't there!");
2016 YAGL_SET_ERR(EGL_BAD_PARAMETER);
2023 yagl_fence_release(fence);
2025 YAGL_LOG_FUNC_EXIT("%d", res);
2030 YAGL_API EGLint eglClientWaitSyncKHR(EGLDisplay dpy_, EGLSyncKHR sync_, EGLint flags, EGLTimeKHR timeout)
2032 EGLint res = EGL_FALSE;
2033 struct yagl_display *dpy = NULL;
2034 struct yagl_fence *fence = NULL;
2036 YAGL_LOG_FUNC_ENTER(eglClientWaitSyncKHR, "dpy = %u, sync = %p, flags = 0x%X, timeout = %u",
2037 (yagl_host_handle)dpy_, sync_, flags, (uint32_t)timeout);
2039 if (!yagl_validate_display(dpy_, &dpy)) {
2043 if (!yagl_validate_fence(dpy, sync_, &fence)) {
2048 res = fence->base.signaled(&fence->base) ? EGL_CONDITION_SATISFIED_KHR
2049 : EGL_TIMEOUT_EXPIRED_KHR;
2050 } else if (fence->base.wait(&fence->base)) {
2051 res = EGL_CONDITION_SATISFIED_KHR;
2053 YAGL_SET_ERR(EGL_BAD_ACCESS);
2057 yagl_fence_release(fence);
2059 YAGL_LOG_FUNC_EXIT("%d", res);
2064 YAGL_API EGLBoolean eglSignalSyncKHR(EGLDisplay dpy_, EGLSyncKHR sync_, EGLenum mode)
2066 YAGL_LOG_FUNC_ENTER(eglSignalSyncKHR, "dpy = %u, sync = %p, mode = 0x%X",
2067 (yagl_host_handle)dpy_, sync_, mode);
2069 YAGL_SET_ERR(EGL_BAD_MATCH);
2071 YAGL_LOG_FUNC_EXIT("%d", EGL_FALSE);
2076 YAGL_API EGLBoolean eglGetSyncAttribKHR(EGLDisplay dpy_, EGLSyncKHR sync_, EGLint attribute, EGLint *value)
2078 EGLBoolean res = EGL_FALSE;
2079 struct yagl_display *dpy = NULL;
2080 struct yagl_fence *fence = NULL;
2082 YAGL_LOG_FUNC_ENTER(eglGetSyncAttribKHR, "dpy = %u, sync = %p, attribute = 0x%X",
2083 (yagl_host_handle)dpy_, sync_, attribute);
2085 if (!yagl_validate_display(dpy_, &dpy)) {
2089 if (!yagl_validate_fence(dpy, sync_, &fence)) {
2093 switch (attribute) {
2094 case EGL_SYNC_TYPE_KHR:
2095 *value = EGL_SYNC_FENCE_KHR;
2098 case EGL_SYNC_STATUS_KHR:
2099 *value = fence->base.signaled(&fence->base) ? EGL_SIGNALED_KHR
2100 : EGL_UNSIGNALED_KHR;
2103 case EGL_SYNC_CONDITION_KHR:
2104 *value = EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR;
2108 YAGL_SET_ERR(EGL_BAD_ATTRIBUTE);
2113 yagl_fence_release(fence);
2115 YAGL_LOG_FUNC_EXIT("%d", res);
2120 #ifdef YAGL_PLATFORM_WAYLAND
2124 YAGL_API EGLBoolean eglBindWaylandDisplayWL(EGLDisplay dpy_,
2125 struct wl_display *display)
2127 EGLBoolean res = EGL_FALSE;
2128 struct yagl_display *dpy = NULL;
2130 YAGL_LOG_FUNC_ENTER(eglBindWaylandDisplayWL,
2131 "dpy = %u, display = %p",
2132 (yagl_host_handle)dpy_,
2135 if (!yagl_validate_display(dpy_, &dpy)) {
2140 YAGL_SET_ERR(EGL_BAD_PARAMETER);
2144 if (!dpy->native_dpy->WL_bind_wayland_display_supported) {
2145 YAGL_SET_ERR(EGL_BAD_PARAMETER);
2149 res = yagl_native_display_bind_wl_display(dpy->native_dpy, display);
2152 YAGL_LOG_FUNC_EXIT("%d", res);
2157 YAGL_API EGLBoolean eglUnbindWaylandDisplayWL(EGLDisplay dpy_,
2158 struct wl_display *display)
2160 EGLBoolean res = EGL_FALSE;
2161 struct yagl_display *dpy = NULL;
2163 YAGL_LOG_FUNC_ENTER(eglUnbindWaylandDisplayWL,
2164 "dpy = %u, display = %p",
2165 (yagl_host_handle)dpy_,
2168 if (!yagl_validate_display(dpy_, &dpy)) {
2173 YAGL_SET_ERR(EGL_BAD_PARAMETER);
2177 if (!dpy->native_dpy->WL_bind_wayland_display_supported) {
2178 YAGL_SET_ERR(EGL_BAD_PARAMETER);
2182 res = yagl_native_display_unbind_wl_display(dpy->native_dpy);
2185 YAGL_LOG_FUNC_EXIT("%d", res);
2190 YAGL_API EGLBoolean eglQueryWaylandBufferWL(EGLDisplay dpy_,
2191 struct wl_resource *buffer,
2195 EGLBoolean res = EGL_FALSE;
2196 struct yagl_display *dpy = NULL;
2198 YAGL_LOG_FUNC_ENTER(eglQueryWaylandBufferWL,
2199 "dpy = %u, buffer = %p, attribute = 0x%X",
2200 (yagl_host_handle)dpy_,
2204 if (!yagl_validate_display(dpy_, &dpy)) {
2209 YAGL_SET_ERR(EGL_BAD_PARAMETER);
2213 if (!dpy->native_dpy->WL_bind_wayland_display_supported) {
2214 YAGL_SET_ERR(EGL_BAD_PARAMETER);
2218 res = yagl_native_display_query_wl_buffer(dpy->native_dpy,
2224 YAGL_LOG_FUNC_EXIT("%d", res);
2230 YAGL_API __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char* procname)
2232 __eglMustCastToProperFunctionPointerType ret = NULL;
2234 YAGL_LOG_FUNC_ENTER(eglGetProcAddress, "procname = %s", procname);
2237 if (strncmp(procname, "gl", 2) == 0) {
2239 struct yagl_context *ctx = yagl_get_context();
2242 switch (ctx->client_ctx->client_api) {
2243 case yagl_client_api_gles1:
2244 ret = yagl_get_gles1_sym(procname);
2246 case yagl_client_api_gles2:
2247 case yagl_client_api_gles3:
2248 ret = yagl_get_gles2_sym(procname);
2255 * Workaround for evas, which foolishly calls this without
2256 * context being set.
2258 ret = yagl_get_gles2_sym(procname);
2260 } else if (strncmp(procname, "egl", 3) == 0) {
2261 ret = dlsym(NULL, procname);
2265 YAGL_LOG_FUNC_EXIT("%p", ret);