From 2f151896eb21fef7e3c387c2b355ba6c25490aa2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 20 Nov 2015 13:43:05 +0100 Subject: [PATCH] use egl_create_surface everywhere --- gfx/common/egl_common.c | 4 +++- gfx/drivers_context/androidegl_ctx.c | 8 +------- gfx/drivers_context/bbqnx_ctx.c | 12 +----------- gfx/drivers_context/emscriptenegl_ctx.c | 8 +------- gfx/drivers_context/mali_fbdev_ctx.c | 11 +---------- gfx/drivers_context/vivante_fbdev_ctx.c | 12 +----------- gfx/drivers_context/wayland_ctx.c | 9 +-------- gfx/drivers_context/xegl_ctx.c | 8 +------- 8 files changed, 10 insertions(+), 62 deletions(-) diff --git a/gfx/common/egl_common.c b/gfx/common/egl_common.c index 087115ecfd..acf953587f 100644 --- a/gfx/common/egl_common.c +++ b/gfx/common/egl_common.c @@ -232,12 +232,14 @@ bool egl_create_context(EGLint *egl_attribs) bool egl_create_surface(NativeWindowType native_window) { g_egl_surf = eglCreateWindowSurface(g_egl_dpy, g_egl_config, native_window, NULL); - if (!g_egl_surf) + if (!g_egl_surf || g_egl_surf == EGL_NO_SURFACE) return false; /* Connect the context to the surface. */ if (!eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx)) return false; + RARCH_LOG("[EGL]: Current context: %p.\n", (void*)eglGetCurrentContext()); + return true; } diff --git a/gfx/drivers_context/androidegl_ctx.c b/gfx/drivers_context/androidegl_ctx.c index 9ff113f45e..af66bb8a19 100644 --- a/gfx/drivers_context/androidegl_ctx.c +++ b/gfx/drivers_context/androidegl_ctx.c @@ -82,13 +82,7 @@ static bool android_gfx_ctx_init(void *data) goto error; } - g_egl_surf = eglCreateWindowSurface(g_egl_dpy, - g_egl_config, android_app->window, 0); - if (!g_egl_surf) - goto error; - - if (!eglMakeCurrent(g_egl_dpy, g_egl_surf, - g_egl_surf, g_egl_ctx)) + if (!egl_create_surface(android_app->window)) goto error; return true; diff --git a/gfx/drivers_context/bbqnx_ctx.c b/gfx/drivers_context/bbqnx_ctx.c index 36e1c12b6c..109df60d66 100644 --- a/gfx/drivers_context/bbqnx_ctx.c +++ b/gfx/drivers_context/bbqnx_ctx.c @@ -214,18 +214,8 @@ static bool gfx_ctx_qnx_init(void *data) goto error; } - if (!(g_egl_surf = eglCreateWindowSurface(g_egl_dpy, g_egl_config, screen_win, 0))) - { - RARCH_ERR("eglCreateWindowSurface failed.\n"); + if (!egl_create_surface(screen_win)) goto error; - } - - - if (!eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx)) - { - RARCH_ERR("eglMakeCurrent failed.\n"); - goto error; - } return true; diff --git a/gfx/drivers_context/emscriptenegl_ctx.c b/gfx/drivers_context/emscriptenegl_ctx.c index cae433189c..da882da09b 100644 --- a/gfx/drivers_context/emscriptenegl_ctx.c +++ b/gfx/drivers_context/emscriptenegl_ctx.c @@ -141,13 +141,7 @@ static bool gfx_ctx_emscripten_init(void *data) goto error; } - /* create an EGL window surface. */ - g_egl_surf = eglCreateWindowSurface(g_egl_dpy, g_egl_config, 0, NULL); - if (!g_egl_surf) - goto error; - - /* Connect the context to the surface. */ - if (!eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx)) + if (!egl_create_surface(0)) goto error; eglQuerySurface(g_egl_dpy, g_egl_surf, EGL_WIDTH, &width); diff --git a/gfx/drivers_context/mali_fbdev_ctx.c b/gfx/drivers_context/mali_fbdev_ctx.c index 94a3a55a3a..0f52f2c60f 100644 --- a/gfx/drivers_context/mali_fbdev_ctx.c +++ b/gfx/drivers_context/mali_fbdev_ctx.c @@ -172,17 +172,8 @@ static bool gfx_ctx_mali_fbdev_set_video_mode(void *data, goto error; } - if ((g_egl_surf = eglCreateWindowSurface(g_egl_dpy, g_egl_config, &native_window, 0)) == EGL_NO_SURFACE) - { - RARCH_ERR("eglCreateWindowSurface failed.\n"); + if (!egl_create_surface(&native_window)) goto error; - } - - if (!eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx)) - { - RARCH_ERR("eglMakeCurrent failed.\n"); - goto error; - } return true; diff --git a/gfx/drivers_context/vivante_fbdev_ctx.c b/gfx/drivers_context/vivante_fbdev_ctx.c index a2c776bd48..b4bb7c583c 100644 --- a/gfx/drivers_context/vivante_fbdev_ctx.c +++ b/gfx/drivers_context/vivante_fbdev_ctx.c @@ -135,19 +135,9 @@ static bool gfx_ctx_vivante_set_video_mode(void *data, } window = fbCreateWindow(fbGetDisplayByIndex(0), 0, 0, 0, 0); - g_egl_surf = eglCreateWindowSurface(g_egl_dpy, g_egl_config, window, 0); - if (g_egl_surf == EGL_NO_SURFACE) - { - RARCH_ERR("eglCreateWindowSurface failed.\n"); + if (!egl_create_surface(window)) goto error; - } - - if (!eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx)) - { - RARCH_ERR("eglMakeCurrent failed.\n"); - goto error; - } return true; diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index f6773e3559..81d4311525 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -504,16 +504,9 @@ static bool gfx_ctx_wl_set_video_mode(void *data, goto error; } - g_egl_surf = eglCreateWindowSurface(g_egl_dpy, g_egl_config, - (EGLNativeWindowType)wl->g_win, NULL); - if (!g_egl_surf) + if (!egl_create_surface((EGLNativeWindowType)wl->g_win)) goto error; - if (!eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx)) - goto error; - - RARCH_LOG("[Wayland/EGL]: Current context: %p.\n", (void*)eglGetCurrentContext()); - egl_set_swap_interval(data, g_interval); if (fullscreen) diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index 03bb6b7a86..31021262ac 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -295,15 +295,9 @@ static bool gfx_ctx_xegl_set_video_mode(void *data, goto error; } - g_egl_surf = eglCreateWindowSurface(g_egl_dpy, g_egl_config, (EGLNativeWindowType)g_x11_win, NULL); - if (!g_egl_surf) + if (!egl_create_surface((EGLNativeWindowType)g_x11_win)) goto error; - if (!eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx)) - goto error; - - RARCH_LOG("[X/EGL]: Current context: %p.\n", (void*)eglGetCurrentContext()); - x11_set_window_attr(g_x11_dpy, g_x11_win); if (fullscreen)