diff --git a/ChangeLog b/ChangeLog index 73d850880..3efc8d1bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2005-07-21 Keith Packard + + 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. + 2005-07-21 Carl Worth * ROADMAP: Note that cairo_font_options_t is done now. diff --git a/ROADMAP b/ROADMAP index 9283ab619..90dea5bd4 100644 --- a/ROADMAP +++ b/ROADMAP @@ -65,7 +65,7 @@ API additions (more detail in TODO file) based on it Status: cworth has sent API proposal to list - A12. cairo_xlib_surface_set_drawable +✓A12. cairo_xlib_surface_set_drawable Difficulty: Easy Status: Keith has a patch sitting ready on the list. diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c index 1d579955d..9e93289ff 100644 --- a/src/cairo-xlib-surface.c +++ b/src/cairo-xlib-surface.c @@ -1623,6 +1623,50 @@ cairo_xlib_surface_set_size (cairo_surface_t *surface, 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 { diff --git a/src/cairo-xlib.h b/src/cairo-xlib.h index dbe0e15fb..5cdf1378b 100644 --- a/src/cairo-xlib.h +++ b/src/cairo-xlib.h @@ -64,6 +64,12 @@ cairo_xlib_surface_set_size (cairo_surface_t *surface, 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 */