egl: Add more API used when rendering

Eventually, we'll render buffers without using Cogl, and for this we
need to be able to do things like creating, destroying and changing the
context, as well as swapping buffers.

https://bugzilla.gnome.org/show_bug.cgi?id=785381
This commit is contained in:
Jonas Ådahl 2017-07-24 17:17:25 +08:00
parent 802f7dcd30
commit 2d8827cb0c
2 changed files with 91 additions and 0 deletions

View File

@ -422,6 +422,41 @@ meta_egl_terminate (MetaEgl *egl,
return TRUE; return TRUE;
} }
EGLContext
meta_egl_create_context (MetaEgl *egl,
EGLDisplay display,
EGLConfig config,
EGLContext share_context,
const EGLint *attrib_list,
GError **error)
{
EGLContext context;
context = eglCreateContext (display, config, share_context, attrib_list);
if (context == EGL_NO_CONTEXT)
{
set_egl_error (error);
return EGL_NO_CONTEXT;
}
return context;
}
gboolean
meta_egl_destroy_context (MetaEgl *egl,
EGLDisplay display,
EGLContext context,
GError **error)
{
if (!eglDestroyContext (display, context))
{
set_egl_error (error);
return FALSE;
}
return TRUE;
}
EGLImageKHR EGLImageKHR
meta_egl_create_image (MetaEgl *egl, meta_egl_create_image (MetaEgl *egl,
EGLDisplay display, EGLDisplay display,
@ -465,6 +500,38 @@ meta_egl_destroy_image (MetaEgl *egl,
return TRUE; return TRUE;
} }
gboolean
meta_egl_make_current (MetaEgl *egl,
EGLDisplay display,
EGLSurface draw,
EGLSurface read,
EGLContext context,
GError **error)
{
if (!eglMakeCurrent (display, draw, read, context))
{
set_egl_error (error);
return FALSE;
}
return TRUE;
}
gboolean
meta_egl_swap_buffers (MetaEgl *egl,
EGLDisplay display,
EGLSurface surface,
GError **error)
{
if (!eglSwapBuffers (display, surface))
{
set_egl_error (error);
return FALSE;
}
return TRUE;
}
gboolean gboolean
meta_egl_query_wayland_buffer (MetaEgl *egl, meta_egl_query_wayland_buffer (MetaEgl *egl,
EGLDisplay display, EGLDisplay display,

View File

@ -62,6 +62,18 @@ gboolean meta_egl_choose_config (MetaEgl *egl,
EGLConfig *chosen_config, EGLConfig *chosen_config,
GError **error); GError **error);
EGLContext meta_egl_create_context (MetaEgl *egl,
EGLDisplay display,
EGLConfig config,
EGLContext share_context,
const EGLint *attrib_list,
GError **error);
gboolean meta_egl_destroy_context (MetaEgl *egl,
EGLDisplay display,
EGLContext context,
GError **error);
EGLImageKHR meta_egl_create_image (MetaEgl *egl, EGLImageKHR meta_egl_create_image (MetaEgl *egl,
EGLDisplay display, EGLDisplay display,
EGLContext context, EGLContext context,
@ -103,6 +115,18 @@ gboolean meta_egl_terminate (MetaEgl *egl,
EGLDisplay display, EGLDisplay display,
GError **error); GError **error);
gboolean meta_egl_make_current (MetaEgl *egl,
EGLDisplay display,
EGLSurface draw,
EGLSurface read,
EGLContext context,
GError **error);
gboolean meta_egl_swap_buffers (MetaEgl *egl,
EGLDisplay display,
EGLSurface surface,
GError **error);
gboolean meta_egl_query_wayland_buffer (MetaEgl *egl, gboolean meta_egl_query_wayland_buffer (MetaEgl *egl,
EGLDisplay display, EGLDisplay display,
struct wl_resource *buffer, struct wl_resource *buffer,