[cairo-commit] cairo/src cairo-xlib-surface.c, 1.91, 1.92 cairo-xlib.h, 1.18, 1.19

Keith Packard commit at pdx.freedesktop.org
Thu Jul 21 08:46:00 PDT 2005


Committed by: keithp

Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv8187/src

Modified Files:
	cairo-xlib-surface.c cairo-xlib.h 
Log Message:
2005-07-21  Keith Packard  <keithp at keithp.com>

	reviewed by: otaylor, cworth

	* ROADMAP:
	* src/cairo-xlib-surface.c: (cairo_xlib_surface_set_drawable):
	* src/cairo-xlib.h:
	Add cairo_xlib_surface_set_drawable which changes the
	target drawable for an xlib cairo_t to another which
	shares the same format, screen and display.


Index: cairo-xlib-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-xlib-surface.c,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -d -r1.91 -r1.92
--- cairo-xlib-surface.c	21 Jul 2005 13:52:13 -0000	1.91
+++ cairo-xlib-surface.c	21 Jul 2005 15:45:58 -0000	1.92
@@ -1623,6 +1623,50 @@
     xlib_surface->height = height;
 }
 
+/**
+ * cairo_xlib_surface_set_drawable:
+ * @surface: a #cairo_surface_t for the XLib backend
+ * @drawable: the new drawable for the surface
+ * 
+ * Informs cairo of a new X Drawable underlying the
+ * surface. The drawable must match the display, screen
+ * and format of the existing drawable or the application
+ * will get X protocol errors and will probably terminate.
+ * No checks are done by this function to ensure this
+ * compatibility.
+ **/
+void
+cairo_xlib_surface_set_drawable (cairo_surface_t   *abstract_surface,
+				 Drawable	    drawable,
+				 int		    width,
+				 int		    height)
+{
+    cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *)abstract_surface;
+
+    /* XXX: How do we want to handle this error case? */
+    if (! _cairo_surface_is_xlib (abstract_surface))
+	return;
+
+    /* XXX: and what about this case? */
+    if (surface->owns_pixmap)
+	return;
+    
+    if (surface->drawable != drawable) {
+	if (surface->dst_picture)
+	    XRenderFreePicture (surface->dpy, surface->dst_picture);
+	
+	if (surface->src_picture)
+	    XRenderFreePicture (surface->dpy, surface->src_picture);
+    
+	surface->dst_picture = None;
+	surface->src_picture = None;
+    
+	surface->drawable = drawable;
+    }
+    surface->width = width;
+    surface->height = height;
+}
+
 /* RENDER glyphset cache code */
 
 typedef struct glyphset_cache {

Index: cairo-xlib.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-xlib.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- cairo-xlib.h	21 Jul 2005 01:52:31 -0000	1.18
+++ cairo-xlib.h	21 Jul 2005 15:45:58 -0000	1.19
@@ -64,6 +64,12 @@
 			     int              width,
 			     int              height);
 
+void
+cairo_xlib_surface_set_drawable (cairo_surface_t *surface,
+				 Drawable	  drawable,
+				 int              width,
+				 int              height);
+
 CAIRO_END_DECLS
 
 #else  /* CAIRO_HAS_XLIB_SURFACE */




More information about the cairo-commit mailing list