summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cairo-egl-context.c33
-rw-r--r--src/cairo-gl.h6
2 files changed, 39 insertions, 0 deletions
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