[PATCH] Add new API cairo_xlib_surface_get_render_format

Carl Worth cworth at cworth.org
Sun Jan 27 12:13:13 PST 2008


---
 src/cairo-xlib-surface.c |   27 +++++++++++++++++++++++++++
 src/cairo-xlib-xrender.h |    3 +++
 2 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index be5aa09..96d4d73 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -2160,6 +2160,33 @@ cairo_xlib_surface_create_with_xrender_format (Display		    *dpy,
 						NULL, format, width, height, 0);
 }
 slim_hidden_def (cairo_xlib_surface_create_with_xrender_format);
+
+/**
+ * cairo_xlib_surface_get_xrender_format
+ * @surface: an xlib surface created by
+ * cairo_xlib_surface_create_with_render_format
+ *
+ * Return value: the XRenderPictFormat* with which the surface was
+ * originally created, (or NULL if the surface is not an xlib surface
+ * or if the Render extension is not available).
+ */
+XRenderPictFormat *
+cairo_xlib_surface_get_xrender_format (cairo_surface_t *surface)
+{
+    cairo_xlib_surface_t *xlib_surface = (cairo_xlib_surface_t *) surface;
+
+    /* Throw an error for a non-xlib surface */
+    if (! _cairo_surface_is_xlib (surface)) {
+	_cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+	return NULL;
+    }
+
+    /* And also for an xlib surface that is not an xlib-xrender surface */
+    if (xlib_surface->xrender_format == NULL)
+	_cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+
+    return xlib_surface->xrender_format;
+}
 #endif

 /**
diff --git a/src/cairo-xlib-xrender.h b/src/cairo-xlib-xrender.h
index 572049d..6dd584f 100644
--- a/src/cairo-xlib-xrender.h
+++ b/src/cairo-xlib-xrender.h
@@ -54,6 +54,9 @@ cairo_xlib_surface_create_with_xrender_format (Display		 *dpy,
                                                int		  width,
                                                int		  height);

+cairo_public XRenderPictFormat *
+cairo_xlib_surface_get_xrender_format (cairo_surface_t *surface);
+
 CAIRO_END_DECLS

 #else  /* CAIRO_HAS_XLIB_XRENDER_SURFACE */
--
1.5.3.2


--Multipart_Sun_Jan_27_22:34:59_2008-1
Content-Type: application/octet-stream; type=patch
Content-Disposition: attachment; filename="0002-Add-get-xrender-format-test-to-test-cairo_xlib_surfa.patch"
Content-Transfer-Encoding: 7bit



More information about the cairo mailing list