From 524e6fd3e82d952dfa850b832238a1f4f9ccb8bb Mon Sep 17 00:00:00 2001 From: Henry Song Date: Thu, 7 Mar 2013 16:33:27 +0000 Subject: gl: Export query for EGLContext and EGLDisplay from device Similar to glx, add query for the EGLContext and EGLDisplay to egl-based cairo devices. --- src/cairo-egl-context.c | 33 +++++++++++++++++++++++++++++++++ src/cairo-gl.h | 6 ++++++ 2 files changed, 39 insertions(+) diff --git a/src/cairo-egl-context.c b/src/cairo-egl-context.c index ba8f60f1..c8655875 100644 --- a/src/cairo-egl-context.c +++ b/src/cairo-egl-context.c @@ -276,3 +276,36 @@ cairo_gl_surface_create_for_egl (cairo_device_t *device, return &surface->base.base; } + +static bool is_egl_device (cairo_device_t *device) +{ + return (device->backend != NULL && + device->backend->type == CAIRO_DEVICE_TYPE_GL); +} + +static cairo_egl_context_t *to_egl_context (cairo_device_t *device) +{ + return (cairo_egl_context_t *) device; +} + +EGLDisplay +cairo_egl_device_get_display (cairo_device_t *device) +{ + if (! is_egl_device (device)) { + _cairo_error_throw (CAIRO_STATUS_DEVICE_TYPE_MISMATCH); + return EGL_NO_DISPLAY; + } + + return to_egl_context (device)->display; +} + +cairo_public EGLContext +cairo_egl_device_get_context (cairo_device_t *device) +{ + if (! is_egl_device (device)) { + _cairo_error_throw (CAIRO_STATUS_DEVICE_TYPE_MISMATCH); + return EGL_NO_CONTEXT; + } + + return to_egl_context (device)->context; +} diff --git a/src/cairo-gl.h b/src/cairo-gl.h index cec31730..9fd7608f 100644 --- a/src/cairo-gl.h +++ b/src/cairo-gl.h @@ -138,6 +138,12 @@ cairo_gl_surface_create_for_egl (cairo_device_t *device, int width, int height); +cairo_public EGLDisplay +cairo_egl_device_get_display (cairo_device_t *device); + +cairo_public EGLSurface +cairo_egl_device_get_context (cairo_device_t *device); + #endif CAIRO_END_DECLS -- cgit v1.2.3