[cairo-commit] src/cairo-egl-context.c src/cairo-gl.h

Chris Wilson ickle at kemper.freedesktop.org
Fri Mar 8 03:44:33 PST 2013


 src/cairo-egl-context.c |   33 +++++++++++++++++++++++++++++++++
 src/cairo-gl.h          |    6 ++++++
 2 files changed, 39 insertions(+)

New commits:
commit 524e6fd3e82d952dfa850b832238a1f4f9ccb8bb
Author: Henry Song <henry.song at samsung.com>
Date:   Thu Mar 7 16:33:27 2013 +0000

    gl: Export query for EGLContext and EGLDisplay from device
    
    Similar to glx, add query for the EGLContext and EGLDisplay to egl-based
    cairo devices.

diff --git a/src/cairo-egl-context.c b/src/cairo-egl-context.c
index ba8f60f..c865587 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 cec3173..9fd7608 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


More information about the cairo-commit mailing list