summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenry Song <henry.song@samsung.com>2013-03-07 16:33:27 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2013-03-08 11:43:39 +0000
commit524e6fd3e82d952dfa850b832238a1f4f9ccb8bb (patch)
tree77eb78581de5524a42ebeebd5979c83f242d6321
parenta8f1b456db744e33a10b2301df03528787e5b1ca (diff)
gl: Export query for EGLContext and EGLDisplay from device
Similar to glx, add query for the EGLContext and EGLDisplay to egl-based cairo devices.
-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