renderer-native: Always use MetaEgl when interacting with EGL

Partly for consistency, partly for error handling functionality.

https://bugzilla.gnome.org/show_bug.cgi?id=785381
This commit is contained in:
Jonas Ådahl 2017-07-24 16:19:55 +08:00
parent 18eb66de06
commit b0e42d3f6e
3 changed files with 89 additions and 11 deletions

View File

@ -290,6 +290,27 @@ meta_egl_choose_config (MetaEgl *egl,
return TRUE;
}
EGLSurface
meta_egl_create_window_surface (MetaEgl *egl,
EGLDisplay display,
EGLConfig config,
EGLNativeWindowType native_window_type,
const EGLint *attrib_list,
GError **error)
{
EGLSurface surface;
surface = eglCreateWindowSurface (display, config,
native_window_type, attrib_list);
if (surface == EGL_NO_SURFACE)
{
set_egl_error (error);
return EGL_NO_SURFACE;
}
return surface;
}
EGLSurface
meta_egl_create_pbuffer_surface (MetaEgl *egl,
EGLDisplay display,
@ -309,6 +330,21 @@ meta_egl_create_pbuffer_surface (MetaEgl *egl,
return surface;
}
gboolean
meta_egl_destroy_surface (MetaEgl *egl,
EGLDisplay display,
EGLSurface surface,
GError **error)
{
if (!eglDestroySurface (display, surface))
{
set_egl_error (error);
return FALSE;
}
return TRUE;
}
static gboolean
is_egl_proc_valid_real (void *proc,
const char *proc_name,
@ -353,6 +389,20 @@ meta_egl_get_platform_display (MetaEgl *egl,
return display;
}
gboolean
meta_egl_terminate (MetaEgl *egl,
EGLDisplay display,
GError **error)
{
if (!eglTerminate (display))
{
set_egl_error (error);
return FALSE;
}
return TRUE;
}
EGLImageKHR
meta_egl_create_image (MetaEgl *egl,
EGLDisplay display,

View File

@ -71,18 +71,34 @@ gboolean meta_egl_destroy_image (MetaEgl *egl,
EGLImageKHR image,
GError **error);
EGLSurface meta_egl_create_window_surface (MetaEgl *egl,
EGLDisplay display,
EGLConfig config,
EGLNativeWindowType native_window_type,
const EGLint *attrib_list,
GError **error);
EGLSurface meta_egl_create_pbuffer_surface (MetaEgl *egl,
EGLDisplay display,
EGLConfig config,
const EGLint *attrib_list,
GError **error);
gboolean meta_egl_destroy_surface (MetaEgl *egl,
EGLDisplay display,
EGLSurface surface,
GError **error);
EGLDisplay meta_egl_get_platform_display (MetaEgl *egl,
EGLenum platform,
void *native_display,
const EGLint *attrib_list,
GError **error);
gboolean meta_egl_terminate (MetaEgl *egl,
EGLDisplay display,
GError **error);
gboolean meta_egl_query_wayland_buffer (MetaEgl *egl,
EGLDisplay display,
struct wl_resource *buffer,

View File

@ -242,9 +242,11 @@ static void
meta_renderer_native_disconnect (CoglRenderer *cogl_renderer)
{
CoglRendererEGL *cogl_renderer_egl = cogl_renderer->winsys;
MetaRendererNative *renderer_native = cogl_renderer_egl->platform;
MetaEgl *egl = meta_renderer_native_get_egl (renderer_native);
if (cogl_renderer_egl->edpy != EGL_NO_DISPLAY)
eglTerminate (cogl_renderer_egl->edpy);
meta_egl_terminate (egl, cogl_renderer_egl->edpy, NULL);
g_slice_free (CoglRendererEGL, cogl_renderer_egl);
}
@ -516,10 +518,15 @@ meta_renderer_native_egl_cleanup_context (CoglDisplay *cogl_display)
CoglDisplayEGL *cogl_display_egl = cogl_display->winsys;
CoglRenderer *cogl_renderer = cogl_display->renderer;
CoglRendererEGL *cogl_renderer_egl = cogl_renderer->winsys;
MetaRendererNative *renderer_native = cogl_renderer_egl->platform;
MetaEgl *egl = meta_renderer_native_get_egl (renderer_native);
if (cogl_display_egl->dummy_surface != EGL_NO_SURFACE)
{
eglDestroySurface (cogl_renderer_egl->edpy, cogl_display_egl->dummy_surface);
meta_egl_destroy_surface (egl,
cogl_renderer_egl->edpy,
cogl_display_egl->dummy_surface,
NULL);
cogl_display_egl->dummy_surface = EGL_NO_SURFACE;
}
}
@ -1062,6 +1069,7 @@ meta_renderer_native_create_surface_gbm (MetaOnscreenNative *onscreen_native,
CoglDisplayEGL *cogl_display_egl = cogl_display->winsys;
CoglRendererEGL *cogl_renderer_egl = cogl_display->renderer->winsys;
MetaRendererNative *renderer_native = cogl_renderer_egl->platform;
MetaEgl *egl = meta_renderer_native_get_egl (renderer_native);
MetaRendererNativeGpuData *renderer_gpu_data;
struct gbm_surface *new_gbm_surface;
EGLNativeWindowType egl_native_window;
@ -1085,16 +1093,16 @@ meta_renderer_native_create_surface_gbm (MetaOnscreenNative *onscreen_native,
}
egl_native_window = (EGLNativeWindowType) new_gbm_surface;
new_egl_surface = eglCreateWindowSurface (cogl_renderer_egl->edpy,
new_egl_surface =
meta_egl_create_window_surface (egl,
cogl_renderer_egl->edpy,
cogl_display_egl->egl_config,
egl_native_window,
NULL);
NULL,
error);
if (new_egl_surface == EGL_NO_SURFACE)
{
gbm_surface_destroy (new_gbm_surface);
g_set_error (error, COGL_WINSYS_ERROR,
COGL_WINSYS_ERROR_CREATE_ONSCREEN,
"Failed to allocate surface");
return FALSE;
}
@ -1458,8 +1466,9 @@ meta_renderer_native_release_onscreen (CoglOnscreen *onscreen)
CoglContext *cogl_context = framebuffer->context;
CoglRenderer *cogl_renderer = cogl_context->display->renderer;
CoglRendererEGL *cogl_renderer_egl = cogl_renderer->winsys;
CoglOnscreenEGL *onscreen_egl = onscreen->winsys;
MetaRendererNative *renderer_native = cogl_renderer_egl->platform;
MetaEgl *egl = meta_renderer_native_get_egl (renderer_native);
CoglOnscreenEGL *onscreen_egl = onscreen->winsys;
MetaOnscreenNative *onscreen_native;
MetaRendererNativeGpuData *renderer_gpu_data;
@ -1471,7 +1480,10 @@ meta_renderer_native_release_onscreen (CoglOnscreen *onscreen)
if (onscreen_egl->egl_surface != EGL_NO_SURFACE)
{
eglDestroySurface (cogl_renderer_egl->edpy, onscreen_egl->egl_surface);
meta_egl_destroy_surface (egl,
cogl_renderer_egl->edpy,
onscreen_egl->egl_surface,
NULL);
onscreen_egl->egl_surface = EGL_NO_SURFACE;
}