[cairo] [PATCH] cairo_x_surface_t

Ian Osgood iano at quirkster.com
Sun Oct 15 16:30:30 PDT 2006


From 8d7eb6a32166a329fbf06de4aeb86e4bd2853571 Mon Sep 17 00:00:00 2001
From: Ian Osgood <iano at quirkster.com>
Date: Sun, 15 Oct 2006 16:29:20 -0700
Subject: [PATCH] cairo_x_surface_t for stuff common to XCB and Xlib

---
 src/cairo-x-private.h    |   42 ++++++++++
 src/cairo-xcb-surface.c  |  142 +++++++++++++----------------------
 src/cairo-xlib-surface.c |  187 +++++++++++++++++++---------------------------
 3 files changed, 172 insertions(+), 199 deletions(-)

diff --git a/src/cairo-x-private.h b/src/cairo-x-private.h
index 34f8f57..c82d5eb 100644
--- a/src/cairo-x-private.h
+++ b/src/cairo-x-private.h
@@ -35,9 +35,47 @@ #define CAIRO_X_PRIVATE_H
 
 #include "cairoint.h"
 
+typedef struct cairo_x_surface_t {
+    cairo_surface_t base;
+
+    cairo_bool_t owns_pixmap;
+
+    int use_pixmap;
+
+    int render_major;
+    int render_minor;
+
+    /* TRUE if the server has a bug with repeating pictures
+     *
+     *  https://bugs.freedesktop.org/show_bug.cgi?id=3566
+     *
+     * We can't test for this because it depends on whether the
+     * picture is in video memory or not.
+     *
+     * We also use this variable as a guard against a second
+     * independent bug with transformed repeating pictures:
+     *
+     * http://lists.freedesktop.org/archives/cairo/2004-September/001839.html
+     *
+     * Both are fixed in xorg >= 6.9 and hopefully in > 6.8.2, so
+     * we can reuse the test for now.
+     */
+    cairo_bool_t buggy_repeat;
+
+    int width;
+    int height;
+    int depth;
+
+    cairo_bool_t have_clip_rects;
+    void *clip_rects;			/* X rectangle array */
+    int num_clip_rects;
+
+} cairo_x_surface_t;
+
 #define CAIRO_SURFACE_RENDER_AT_LEAST(surface, major, minor)	\
-	(((surface)->render_major > major) ||			\
-	 (((surface)->render_major == major) && ((surface)->render_minor >= minor)))
+	((((cairo_x_surface_t *)surface)->render_major > major) || \
+	 ((((cairo_x_surface_t *)surface)->render_major == major) && \
+	 (((cairo_x_surface_t *)surface)->render_minor >= minor)))
 
 #define CAIRO_SURFACE_RENDER_HAS_CREATE_PICTURE(surface)		CAIRO_SURFACE_RENDER_AT_LEAST((surface), 0, 0)
 #define CAIRO_SURFACE_RENDER_HAS_COMPOSITE(surface)		CAIRO_SURFACE_RENDER_AT_LEAST((surface), 0, 0)
diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c
index 86879c4..678471f 100644
--- a/src/cairo-xcb-surface.c
+++ b/src/cairo-xcb-surface.c
@@ -77,54 +77,20 @@ _xcb_render_format_to_content (xcb_rende
 #define CAIRO_ASSUME_PIXMAP	20
 
 typedef struct cairo_xcb_surface {
-    cairo_surface_t base;
+    cairo_x_surface_t x;
 
     xcb_connection_t *dpy;
     xcb_screen_t *screen;
 
     xcb_gcontext_t gc;
     xcb_drawable_t drawable;
-    int owns_pixmap;
     xcb_visualtype_t *visual;
 
-    int use_pixmap;
-
-    int render_major;
-    int render_minor;
-
-    int width;
-    int height;
-    int depth;
-
-    xcb_rectangle_t *clip_rects;
-    int num_clip_rects;
-
     xcb_render_picture_t picture;
     xcb_render_pictforminfo_t format;
     int has_format;
 } cairo_xcb_surface_t;
 
-#define CAIRO_SURFACE_RENDER_AT_LEAST(surface, major, minor)	\
-	(((surface)->render_major > major) ||			\
-	 (((surface)->render_major == major) && ((surface)->render_minor >= minor)))
-
-#define CAIRO_SURFACE_RENDER_HAS_CREATE_PICTURE(surface)		CAIRO_SURFACE_RENDER_AT_LEAST((surface), 0, 0)
-#define CAIRO_SURFACE_RENDER_HAS_COMPOSITE(surface)		CAIRO_SURFACE_RENDER_AT_LEAST((surface), 0, 0)
-
-#define CAIRO_SURFACE_RENDER_HAS_FILL_RECTANGLE(surface)		CAIRO_SURFACE_RENDER_AT_LEAST((surface), 0, 1)
-#define CAIRO_SURFACE_RENDER_HAS_FILL_RECTANGLES(surface)		CAIRO_SURFACE_RENDER_AT_LEAST((surface), 0, 1)
-
-#define CAIRO_SURFACE_RENDER_HAS_DISJOINT(surface)			CAIRO_SURFACE_RENDER_AT_LEAST((surface), 0, 2)
-#define CAIRO_SURFACE_RENDER_HAS_CONJOINT(surface)			CAIRO_SURFACE_RENDER_AT_LEAST((surface), 0, 2)
-
-#define CAIRO_SURFACE_RENDER_HAS_TRAPEZOIDS(surface)		CAIRO_SURFACE_RENDER_AT_LEAST((surface), 0, 4)
-#define CAIRO_SURFACE_RENDER_HAS_TRIANGLES(surface)		CAIRO_SURFACE_RENDER_AT_LEAST((surface), 0, 4)
-#define CAIRO_SURFACE_RENDER_HAS_TRISTRIP(surface)			CAIRO_SURFACE_RENDER_AT_LEAST((surface), 0, 4)
-#define CAIRO_SURFACE_RENDER_HAS_TRIFAN(surface)			CAIRO_SURFACE_RENDER_AT_LEAST((surface), 0, 4)
-
-#define CAIRO_SURFACE_RENDER_HAS_PICTURE_TRANSFORM(surface)	CAIRO_SURFACE_RENDER_AT_LEAST((surface), 0, 6)
-#define CAIRO_SURFACE_RENDER_HAS_FILTERS(surface)	CAIRO_SURFACE_RENDER_AT_LEAST((surface), 0, 6)
-
 static void
 _cairo_xcb_surface_ensure_gc (cairo_xcb_surface_t *surface);
 
@@ -137,7 +103,7 @@ _cairo_xcb_surface_create_similar (void	
     cairo_xcb_surface_t *src = abstract_src;
     xcb_connection_t *dpy = src->dpy;
     xcb_pixmap_t pixmap;
-    cairo_xcb_surface_t *surface;
+    cairo_x_surface_t *surface;
     cairo_format_t format = _cairo_format_from_content (content);
     xcb_render_pictforminfo_t *xrender_format;
 
@@ -156,7 +122,7 @@ _cairo_xcb_surface_create_similar (void	
 
     xrender_format = xcb_render_util_find_standard_format (xcb_render_util_query_formats (dpy), format);
     /* XXX: what to do if xrender_format is null? */
-    surface = (cairo_xcb_surface_t *)
+    surface = (cairo_x_surface_t *)
 	cairo_xcb_surface_create_with_xrender_format (dpy, pixmap, src->screen,
 						      xrender_format,
 						      width, height);
@@ -177,13 +143,13 @@ _cairo_xcb_surface_finish (void *abstrac
     if (surface->picture)
 	xcb_render_free_picture (surface->dpy, surface->picture);
 
-    if (surface->owns_pixmap)
+    if (surface->x.owns_pixmap)
 	xcb_free_pixmap (surface->dpy, surface->drawable);
 
     if (surface->gc)
 	xcb_free_gc (surface->dpy, surface->gc);
 
-    free (surface->clip_rects);
+    free (surface->x.clip_rects);
 
     surface->dpy = NULL;
 
@@ -232,8 +198,8 @@ _get_image_surface (cairo_xcb_surface_t 
 
     x1 = 0;
     y1 = 0;
-    x2 = surface->width;
-    y2 = surface->height;
+    x2 = surface->x.width;
+    y2 = surface->x.height;
 
     if (interest_rect) {
 	cairo_rectangle_int16_t rect;
@@ -267,7 +233,7 @@ _get_image_surface (cairo_xcb_surface_t 
 
     /* XXX: This should try to use the XShm extension if available */
 
-    if (surface->use_pixmap == 0)
+    if (surface->x.use_pixmap == 0)
     {
 	xcb_generic_error_t *error;
 	imagerep = xcb_get_image_reply(surface->dpy,
@@ -281,11 +247,11 @@ _get_image_surface (cairo_xcb_surface_t 
 	 * so retry with the safe code path.
 	 */
 	if (error)
-	    surface->use_pixmap = CAIRO_ASSUME_PIXMAP;
+	    surface->x.use_pixmap = CAIRO_ASSUME_PIXMAP;
     }
     else
     {
-	surface->use_pixmap--;
+	surface->x.use_pixmap--;
 	imagerep = NULL;
     }
 
@@ -300,7 +266,7 @@ _get_image_surface (cairo_xcb_surface_t 
 	xcb_pixmap_t pixmap;
 	pixmap = xcb_generate_id (surface->dpy);
 	xcb_create_pixmap (surface->dpy,
-			 surface->depth,
+			 surface->x.depth,
 			 pixmap,
 			 surface->drawable,
 			 x2 - x1, y2 - y1);
@@ -322,15 +288,15 @@ _get_image_surface (cairo_xcb_surface_t 
 	return CAIRO_STATUS_NO_MEMORY;
 
     bpp = _bits_per_pixel(surface->dpy, imagerep->depth);
-    bytes_per_line = _bytes_per_line(surface->dpy, surface->width, bpp);
+    bytes_per_line = _bytes_per_line(surface->dpy, surface->x.width, bpp);
 
-    data = malloc (bytes_per_line * surface->height);
+    data = malloc (bytes_per_line * surface->x.height);
     if (data == NULL) {
 	free (imagerep);
 	return CAIRO_STATUS_NO_MEMORY;
     }
 
-    memcpy (data, xcb_get_image_data (imagerep), bytes_per_line * surface->height);
+    memcpy (data, xcb_get_image_data (imagerep), bytes_per_line * surface->x.height);
     free (imagerep);
 
     /*
@@ -356,8 +322,8 @@ _get_image_surface (cairo_xcb_surface_t 
 	masks.red_mask = 0;
 	masks.green_mask = 0;
 	masks.blue_mask = 0;
-	if (surface->depth < 32)
-	    masks.alpha_mask = (1 << surface->depth) - 1;
+	if (surface->x.depth < 32)
+	    masks.alpha_mask = (1 << surface->x.depth) - 1;
 	else
 	    masks.alpha_mask = 0xffffffff;
     }
@@ -406,21 +372,21 @@ _get_image_surface (cairo_xcb_surface_t 
 static void
 _cairo_xcb_surface_set_picture_clip_rects (cairo_xcb_surface_t *surface)
 {
-    if (surface->num_clip_rects)
+    if (surface->x.num_clip_rects)
 	xcb_render_set_picture_clip_rectangles (surface->dpy, surface->picture,
 					   0, 0,
-					   surface->num_clip_rects,
-					   surface->clip_rects);
+					   surface->x.num_clip_rects,
+					   surface->x.clip_rects);
 }
 
 static void
 _cairo_xcb_surface_set_gc_clip_rects (cairo_xcb_surface_t *surface)
 {
-    if (surface->num_clip_rects)
+    if (surface->x.num_clip_rects)
 	xcb_set_clip_rectangles(surface->dpy, XCB_CLIP_ORDERING_YX_SORTED, surface->gc,
 			     0, 0,
-			     surface->num_clip_rects,
-			     surface->clip_rects );
+			     surface->x.num_clip_rects,
+			     surface->x.clip_rects );
 }
 
 static void
@@ -538,7 +504,7 @@ _cairo_xcb_surface_clone_similar (void		
     cairo_xcb_surface_t *surface = abstract_surface;
     cairo_xcb_surface_t *clone;
 
-    if (src->backend == surface->base.backend ) {
+    if (src->backend == surface->x.base.backend ) {
 	cairo_xcb_surface_t *xcb_src = (cairo_xcb_surface_t *)src;
 
 	if (_cairo_xcb_surface_same_screen(surface, xcb_src)) {
@@ -550,18 +516,18 @@ _cairo_xcb_surface_clone_similar (void		
 	cairo_image_surface_t *image_src = (cairo_image_surface_t *)src;
 	cairo_content_t content = _cairo_content_from_format (image_src->format);
 
-	if (surface->base.status)
-	    return surface->base.status;
+	if (surface->x.base.status)
+	    return surface->x.base.status;
 
 	clone = (cairo_xcb_surface_t *)
 	    _cairo_xcb_surface_create_similar (surface, content,
 					       image_src->width, image_src->height);
-	if (clone->base.status)
+	if (clone->x.base.status)
 	    return CAIRO_STATUS_NO_MEMORY;
 
 	_draw_image_surface (clone, image_src, 0, 0);
 
-	*clone_out = &clone->base;
+	*clone_out = &clone->x.base;
 
 	return CAIRO_STATUS_SUCCESS;
     }
@@ -759,7 +725,7 @@ _cairo_xcb_surface_composite (cairo_oper
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
     status = _cairo_pattern_acquire_surfaces (src_pattern, mask_pattern,
-					      &dst->base,
+					      &dst->x.base,
 					      src_x, src_y,
 					      mask_x, mask_y,
 					      width, height,
@@ -806,9 +772,9 @@ _cairo_xcb_surface_composite (cairo_oper
     }
 
     if (mask)
-	_cairo_pattern_release_surface (mask_pattern, &mask->base, &mask_attr);
+	_cairo_pattern_release_surface (mask_pattern, &mask->x.base, &mask_attr);
 
-    _cairo_pattern_release_surface (src_pattern, &src->base, &src_attr);
+    _cairo_pattern_release_surface (src_pattern, &src->x.base, &src_attr);
 
     return status;
 }
@@ -866,7 +832,7 @@ _cairo_xcb_surface_composite_trapezoids 
     if (!CAIRO_SURFACE_RENDER_HAS_TRAPEZOIDS (dst))
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
-    status = _cairo_pattern_acquire_surface (pattern, &dst->base,
+    status = _cairo_pattern_acquire_surface (pattern, &dst->x.base,
 					     src_x, src_y, width, height,
 					     (cairo_surface_t **) &src,
 					     &attributes);
@@ -909,7 +875,7 @@ _cairo_xcb_surface_composite_trapezoids 
 			     render_src_y + attributes.y_offset,
 			     num_traps, (xcb_render_trapezoid_t *) traps);
 
-    _cairo_pattern_release_surface (pattern, &src->base, &attributes);
+    _cairo_pattern_release_surface (pattern, &src->x.base, &attributes);
 
     return status;
 }
@@ -920,12 +886,12 @@ _cairo_xcb_surface_set_clip_region (void
 {
     cairo_xcb_surface_t *surface = abstract_surface;
 
-    if (surface->clip_rects) {
-	free (surface->clip_rects);
-	surface->clip_rects = NULL;
+    if (surface->x.clip_rects) {
+	free (surface->x.clip_rects);
+	surface->x.clip_rects = NULL;
     }
 
-    surface->num_clip_rects = 0;
+    surface->x.num_clip_rects = 0;
 
     if (region == NULL) {
 	if (surface->gc) {
@@ -964,8 +930,8 @@ _cairo_xcb_surface_set_clip_region (void
 	    rects[i].height = boxes[i].y2 - boxes[i].y1;
 	}
 
-	surface->clip_rects = rects;
-	surface->num_clip_rects = n_boxes;
+	surface->x.clip_rects = rects;
+	surface->x.num_clip_rects = n_boxes;
 
 	if (surface->gc)
 	    _cairo_xcb_surface_set_gc_clip_rects (surface);
@@ -981,7 +947,7 @@ static cairo_int_status_t
 _cairo_xcb_surface_get_extents (void		        *abstract_surface,
 				cairo_rectangle_int16_t *rectangle)
 {
-    cairo_xcb_surface_t *surface = abstract_surface;
+    cairo_x_surface_t *surface = abstract_surface;
 
     rectangle->x = 0;
     rectangle->y = 0;
@@ -1050,7 +1016,7 @@ _cairo_xcb_surface_create_internal (xcb_
 	return (cairo_surface_t*) &_cairo_surface_nil;
     }
 
-    _cairo_surface_init (&surface->base, &cairo_xcb_surface_backend,
+    _cairo_surface_init (&surface->x.base, &cairo_xcb_surface_backend,
 			 _xcb_render_format_to_content (format));
 
     surface->dpy = dpy;
@@ -1058,7 +1024,7 @@ _cairo_xcb_surface_create_internal (xcb_
 
     surface->gc = XCB_NONE;
     surface->drawable = drawable;
-    surface->owns_pixmap = FALSE;
+    surface->x.owns_pixmap = FALSE;
     surface->visual = visual;
     if (format) {
 	surface->format = *format;
@@ -1067,16 +1033,16 @@ _cairo_xcb_surface_create_internal (xcb_
 	surface->format.id = XCB_NONE;
 	surface->has_format = 0;
     }
-    surface->use_pixmap = 0;
-    surface->width = width;
-    surface->height = height;
-    surface->depth = depth;
+    surface->x.use_pixmap = 0;
+    surface->x.width = width;
+    surface->x.height = height;
+    surface->x.depth = depth;
 
-    surface->clip_rects = NULL;
-    surface->num_clip_rects = 0;
+    surface->x.clip_rects = NULL;
+    surface->x.num_clip_rects = 0;
 
     if (format) {
-	surface->depth = format->depth;
+	surface->x.depth = format->depth;
     } else if (visual) {
 	xcb_depth_iterator_t depths;
 	xcb_visualtype_iterator_t visuals;
@@ -1092,7 +1058,7 @@ _cairo_xcb_surface_create_internal (xcb_
 	    {
 		if(visuals.data->visual_id == visual->visual_id)
 		{
-		    surface->depth = depths.data->depth;
+		    surface->x.depth = depths.data->depth;
 		    goto found;
 		}
 	    }
@@ -1101,13 +1067,13 @@ _cairo_xcb_surface_create_internal (xcb_
 	;
     }
 
-    surface->render_major = -1;
-    surface->render_minor = -1;
+    surface->x.render_major = -1;
+    surface->x.render_minor = -1;
 
     r = xcb_render_util_query_version(dpy);
     if (r) {
-	surface->render_major = r->major_version;
-	surface->render_minor = r->minor_version;
+	surface->x.render_major = r->major_version;
+	surface->x.render_minor = r->minor_version;
     }
 
     surface->picture = XCB_NONE;
@@ -1282,7 +1248,7 @@ cairo_xcb_surface_set_size (cairo_surfac
 			    int              width,
 			    int              height)
 {
-    cairo_xcb_surface_t *xcb_surface = (cairo_xcb_surface_t *)surface;
+    cairo_x_surface_t *xcb_surface = (cairo_x_surface_t *)surface;
 
     if (! _cairo_surface_is_xcb (surface)) {
 	_cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index bc7e1f1..969447b 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -83,7 +83,7 @@ _cairo_xlib_surface_show_glyphs (void   
 #define CAIRO_ASSUME_PIXMAP	20
 
 struct _cairo_xlib_surface {
-    cairo_surface_t base;
+    cairo_x_surface_t x;
 
     Display *dpy;
     cairo_xlib_screen_info_t *screen_info;
@@ -91,41 +91,10 @@ struct _cairo_xlib_surface {
     GC gc;
     Drawable drawable;
     Screen *screen;
-    cairo_bool_t owns_pixmap;
     Visual *visual;
 
-    int use_pixmap;
-
-    int render_major;
-    int render_minor;
-
-    /* TRUE if the server has a bug with repeating pictures
-     *
-     *  https://bugs.freedesktop.org/show_bug.cgi?id=3566
-     *
-     * We can't test for this because it depends on whether the
-     * picture is in video memory or not.
-     *
-     * We also use this variable as a guard against a second
-     * independent bug with transformed repeating pictures:
-     *
-     * http://lists.freedesktop.org/archives/cairo/2004-September/001839.html
-     *
-     * Both are fixed in xorg >= 6.9 and hopefully in > 6.8.2, so
-     * we can reuse the test for now.
-     */
-    cairo_bool_t buggy_repeat;
-
-    int width;
-    int height;
-    int depth;
-
     Picture dst_picture, src_picture;
 
-    cairo_bool_t have_clip_rects;
-    XRectangle *clip_rects;
-    int num_clip_rects;
-
     XRenderPictFormat *xrender_format;
 };
 
@@ -175,7 +144,7 @@ _cairo_xlib_surface_create_similar_with_
     cairo_xlib_surface_t *src = abstract_src;
     Display *dpy = src->dpy;
     Pixmap pix;
-    cairo_xlib_surface_t *surface;
+    cairo_x_surface_t *surface;
     int depth = _CAIRO_FORMAT_DEPTH (format);
     XRenderPictFormat *xrender_format = _CAIRO_FORMAT_TO_XRENDER_FORMAT (dpy,
 									 format);
@@ -193,7 +162,7 @@ _cairo_xlib_surface_create_similar_with_
 			 width <= 0 ? 1 : width, height <= 0 ? 1 : height,
 			 depth);
 
-    surface = (cairo_xlib_surface_t *)
+    surface = (cairo_x_surface_t *)
 	cairo_xlib_surface_create_with_xrender_format (dpy, pix, src->screen,
 						       xrender_format,
 						       width, height);
@@ -240,7 +209,7 @@ _cairo_xlib_surface_create_similar (void
 {
     cairo_xlib_surface_t *src = abstract_src;
     XRenderPictFormat *xrender_format = src->xrender_format;
-    cairo_xlib_surface_t *surface;
+    cairo_x_surface_t *surface;
     Pixmap pix;
 
     /* Start by examining the surface's XRenderFormat, or if it
@@ -269,7 +238,7 @@ _cairo_xlib_surface_create_similar (void
 			 width <= 0 ? 1 : width, height <= 0 ? 1 : height,
 			 xrender_format->depth);
 
-    surface = (cairo_xlib_surface_t *)
+    surface = (cairo_x_surface_t *)
 	cairo_xlib_surface_create_with_xrender_format (src->dpy, pix,
 						       src->screen,
 						       xrender_format,
@@ -294,14 +263,14 @@ _cairo_xlib_surface_finish (void *abstra
     if (surface->src_picture != None)
 	XRenderFreePicture (surface->dpy, surface->src_picture);
 
-    if (surface->owns_pixmap)
+    if (surface->x.owns_pixmap)
 	XFreePixmap (surface->dpy, surface->drawable);
 
     if (surface->gc != NULL)
 	XFreeGC (surface->dpy, surface->gc);
 
-    if (surface->clip_rects != NULL)
-	free (surface->clip_rects);
+    if (surface->x.clip_rects != NULL)
+	free (surface->x.clip_rects);
 
     surface->dpy = NULL;
 
@@ -439,8 +408,8 @@ _get_image_surface (cairo_xlib_surface_t
 
     x1 = 0;
     y1 = 0;
-    x2 = surface->width;
-    y2 = surface->height;
+    x2 = surface->x.width;
+    y2 = surface->x.height;
 
     if (interest_rect) {
 	cairo_rectangle_int16_t rect;
@@ -474,7 +443,7 @@ _get_image_surface (cairo_xlib_surface_t
 
     /* XXX: This should try to use the XShm extension if available */
 
-    if (surface->use_pixmap == 0)
+    if (surface->x.use_pixmap == 0)
     {
 	cairo_xlib_error_func_t old_handler;
 
@@ -492,11 +461,11 @@ _get_image_surface (cairo_xlib_surface_t
 	 * so retry with the safe code path.
 	 */
 	if (!ximage)
-	    surface->use_pixmap = CAIRO_ASSUME_PIXMAP;
+	    surface->x.use_pixmap = CAIRO_ASSUME_PIXMAP;
     }
     else
     {
-	surface->use_pixmap--;
+	surface->x.use_pixmap--;
 	ximage = NULL;
     }
 
@@ -512,7 +481,7 @@ _get_image_surface (cairo_xlib_surface_t
 	Pixmap pixmap = XCreatePixmap (surface->dpy,
 				       surface->drawable,
 				       x2 - x1, y2 - y1,
-				       surface->depth);
+				       surface->x.depth);
 	_cairo_xlib_surface_ensure_gc (surface);
 
 	XCopyArea (surface->dpy, surface->drawable, pixmap, surface->gc,
@@ -555,8 +524,8 @@ _get_image_surface (cairo_xlib_surface_t
 	masks.red_mask = 0;
 	masks.green_mask = 0;
 	masks.blue_mask = 0;
-	if (surface->depth < 32)
-	    masks.alpha_mask = (1 << surface->depth) - 1;
+	if (surface->x.depth < 32)
+	    masks.alpha_mask = (1 << surface->x.depth) - 1;
 	else
 	    masks.alpha_mask = 0xffffffff;
     }
@@ -620,21 +589,21 @@ _cairo_xlib_surface_ensure_src_picture (
 static void
 _cairo_xlib_surface_set_picture_clip_rects (cairo_xlib_surface_t *surface)
 {
-    if (surface->have_clip_rects)
+    if (surface->x.have_clip_rects)
 	XRenderSetPictureClipRectangles (surface->dpy, surface->dst_picture,
 					 0, 0,
-					 surface->clip_rects,
-					 surface->num_clip_rects);
+					 surface->x.clip_rects,
+					 surface->x.num_clip_rects);
 }
 
 static void
 _cairo_xlib_surface_set_gc_clip_rects (cairo_xlib_surface_t *surface)
 {
-    if (surface->have_clip_rects)
+    if (surface->x.have_clip_rects)
 	XSetClipRectangles(surface->dpy, surface->gc,
 			   0, 0,
-			   surface->clip_rects,
-			   surface->num_clip_rects, YXSorted);
+			   surface->x.clip_rects,
+			   surface->x.num_clip_rects, YXSorted);
 }
 
 static void
@@ -787,7 +756,7 @@ _cairo_xlib_surface_clone_similar (void	
     cairo_xlib_surface_t *surface = abstract_surface;
     cairo_xlib_surface_t *clone;
 
-    if (src->backend == surface->base.backend ) {
+    if (src->backend == surface->x.base.backend ) {
 	cairo_xlib_surface_t *xlib_src = (cairo_xlib_surface_t *)src;
 
 	if (_cairo_xlib_surface_same_screen (surface, xlib_src)) {
@@ -804,12 +773,12 @@ _cairo_xlib_surface_clone_similar (void	
 	clone = (cairo_xlib_surface_t *)
 	    _cairo_xlib_surface_create_similar_with_format (surface, image_src->format,
 						image_src->width, image_src->height);
-	if (clone->base.status)
+	if (clone->x.base.status)
 	    return CAIRO_STATUS_NO_MEMORY;
 
 	_draw_image_surface (clone, image_src, 0, 0);
 
-	*clone_out = &clone->base;
+	*clone_out = &clone->x.base;
 
 	return CAIRO_STATUS_SUCCESS;
     }
@@ -968,7 +937,7 @@ _surfaces_compatible (cairo_xlib_surface
 	return FALSE;
 
     /* same depth (for core) */
-    if (src->depth != dst->depth)
+    if (src->x.depth != dst->x.depth)
 	return FALSE;
 
     /* if Render is supported, match picture formats */
@@ -1051,7 +1020,7 @@ _categorize_composite_operation (cairo_x
 				 cairo_bool_t	       have_mask)
 
 {
-    if (!dst->buggy_repeat)
+    if (!dst->x.buggy_repeat)
 	return DO_RENDER;
 
     if (src_pattern->type == CAIRO_PATTERN_TYPE_SURFACE)
@@ -1125,12 +1094,12 @@ _recategorize_composite_operation (cairo
 	return DO_XCOPYAREA;
     }
 
-    if (!dst->buggy_repeat)
+    if (!dst->x.buggy_repeat)
 	return DO_RENDER;
 
     if (is_integer_translation &&
 	src_attr->extend == CAIRO_EXTEND_REPEAT &&
-	(src->width != 1 || src->height != 1))
+	(src->x.width != 1 || src->x.height != 1))
     {
 	if (!have_mask &&
 	    !needs_alpha_composite &&
@@ -1216,7 +1185,7 @@ _cairo_xlib_surface_composite (cairo_ope
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
     status = _cairo_pattern_acquire_surfaces (src_pattern, mask_pattern,
-					      &dst->base,
+					      &dst->x.base,
 					      src_x, src_y,
 					      mask_x, mask_y,
 					      width, height,
@@ -1311,20 +1280,20 @@ _cairo_xlib_surface_composite (cairo_ope
     }
 
     if (!_cairo_operator_bounded_by_source (op))
-      status = _cairo_surface_composite_fixup_unbounded (&dst->base,
-							 &src_attr, src->width, src->height,
+      status = _cairo_surface_composite_fixup_unbounded (&dst->x.base,
+							 &src_attr, src->x.width, src->x.height,
 							 mask ? &mask_attr : NULL,
-							 mask ? mask->width : 0,
-							 mask ? mask->height : 0,
+							 mask ? mask->x.width : 0,
+							 mask ? mask->x.height : 0,
 							 src_x, src_y,
 							 mask_x, mask_y,
 							 dst_x, dst_y, width, height);
 
  BAIL:
     if (mask)
-	_cairo_pattern_release_surface (mask_pattern, &mask->base, &mask_attr);
+	_cairo_pattern_release_surface (mask_pattern, &mask->x.base, &mask_attr);
 
-    _cairo_pattern_release_surface (src_pattern, &src->base, &src_attr);
+    _cairo_pattern_release_surface (src_pattern, &src->x.base, &src_attr);
 
     return status;
 }
@@ -1478,7 +1447,7 @@ _cairo_xlib_surface_composite_trapezoids
     if (operation == DO_UNSUPPORTED)
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
-    status = _cairo_pattern_acquire_surface (pattern, &dst->base,
+    status = _cairo_pattern_acquire_surface (pattern, &dst->x.base,
 					     src_x, src_y, width, height,
 					     (cairo_surface_t **) &src,
 					     &attributes);
@@ -1550,8 +1519,8 @@ _cairo_xlib_surface_composite_trapezoids
 
 	XRenderFreePicture (dst->dpy, mask_picture);
 
-	status = _cairo_surface_composite_shape_fixup_unbounded (&dst->base,
-								 &attributes, src->width, src->height,
+	status = _cairo_surface_composite_shape_fixup_unbounded (&dst->x.base,
+								 &attributes, src->x.width, src->x.height,
 								 width, height,
 								 src_x, src_y,
 								 0, 0,
@@ -1569,7 +1538,7 @@ _cairo_xlib_surface_composite_trapezoids
     }
 
  BAIL:
-    _cairo_pattern_release_surface (pattern, &src->base, &attributes);
+    _cairo_pattern_release_surface (pattern, &src->x.base, &attributes);
 
     return status;
 }
@@ -1580,13 +1549,13 @@ _cairo_xlib_surface_set_clip_region (voi
 {
     cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *) abstract_surface;
 
-    if (surface->clip_rects) {
-	free (surface->clip_rects);
-	surface->clip_rects = NULL;
+    if (surface->x.clip_rects) {
+	free (surface->x.clip_rects);
+	surface->x.clip_rects = NULL;
     }
 
-    surface->have_clip_rects = FALSE;
-    surface->num_clip_rects = 0;
+    surface->x.have_clip_rects = FALSE;
+    surface->x.num_clip_rects = 0;
 
     if (region == NULL) {
 	if (surface->gc)
@@ -1621,9 +1590,9 @@ _cairo_xlib_surface_set_clip_region (voi
 	    rects[i].height = boxes[i].y2 - boxes[i].y1;
 	}
 
-	surface->have_clip_rects = TRUE;
-	surface->clip_rects = rects;
-	surface->num_clip_rects = n_boxes;
+	surface->x.have_clip_rects = TRUE;
+	surface->x.clip_rects = rects;
+	surface->x.num_clip_rects = n_boxes;
 
 	if (surface->gc)
 	    _cairo_xlib_surface_set_gc_clip_rects (surface);
@@ -1639,7 +1608,7 @@ static cairo_int_status_t
 _cairo_xlib_surface_get_extents (void		         *abstract_surface,
 				 cairo_rectangle_int16_t *rectangle)
 {
-    cairo_xlib_surface_t *surface = abstract_surface;
+    cairo_x_surface_t *surface = abstract_surface;
 
     rectangle->x = 0;
     rectangle->y = 0;
@@ -1759,9 +1728,9 @@ _cairo_xlib_surface_create_internal (Dis
     }
 
     if (cairo_xlib_render_disabled ||
-	! XRenderQueryVersion (dpy, &surface->render_major, &surface->render_minor)) {
-	surface->render_major = -1;
-	surface->render_minor = -1;
+	! XRenderQueryVersion (dpy, &surface->x.render_major, &surface->x.render_minor)) {
+	surface->x.render_major = -1;
+	surface->x.render_minor = -1;
     }
 
     if (CAIRO_SURFACE_RENDER_HAS_CREATE_PICTURE (surface)) {
@@ -1775,7 +1744,7 @@ _cairo_xlib_surface_create_internal (Dis
 	xrender_format = NULL;
     }
 
-    _cairo_surface_init (&surface->base, &cairo_xlib_surface_backend,
+    _cairo_surface_init (&surface->x.base, &cairo_xlib_surface_backend,
 			 _xrender_format_to_content (xrender_format));
 
     surface->dpy = dpy;
@@ -1784,21 +1753,21 @@ _cairo_xlib_surface_create_internal (Dis
     surface->gc = NULL;
     surface->drawable = drawable;
     surface->screen = screen;
-    surface->owns_pixmap = FALSE;
-    surface->use_pixmap = 0;
-    surface->width = width;
-    surface->height = height;
+    surface->x.owns_pixmap = FALSE;
+    surface->x.use_pixmap = 0;
+    surface->x.width = width;
+    surface->x.height = height;
 
-    surface->buggy_repeat = FALSE;
+    surface->x.buggy_repeat = FALSE;
     if (strstr (ServerVendor (dpy), "X.Org") != NULL) {
 	if (VendorRelease (dpy) <= 60802000)
-	    surface->buggy_repeat = TRUE;
+	    surface->x.buggy_repeat = TRUE;
     } else if (strstr (ServerVendor (dpy), "XFree86") != NULL) {
 	if (VendorRelease (dpy) <= 40500000)
-	    surface->buggy_repeat = TRUE;
+	    surface->x.buggy_repeat = TRUE;
     } else if (strstr (ServerVendor (dpy), "Sun Microsystems, Inc.") != NULL) {
 	if (VendorRelease (dpy) <= 60900000)
-	    surface->buggy_repeat = TRUE;
+	    surface->x.buggy_repeat = TRUE;
     }
 
     surface->dst_picture = None;
@@ -1806,11 +1775,11 @@ _cairo_xlib_surface_create_internal (Dis
 
     surface->visual = visual;
     surface->xrender_format = xrender_format;
-    surface->depth = depth;
+    surface->x.depth = depth;
 
-    surface->have_clip_rects = FALSE;
-    surface->clip_rects = NULL;
-    surface->num_clip_rects = 0;
+    surface->x.have_clip_rects = FALSE;
+    surface->x.clip_rects = NULL;
+    surface->x.num_clip_rects = 0;
 
     return (cairo_surface_t *) surface;
 }
@@ -1954,7 +1923,7 @@ cairo_xlib_surface_set_size (cairo_surfa
 			     int              width,
 			     int              height)
 {
-    cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *) abstract_surface;
+    cairo_x_surface_t *surface = (cairo_x_surface_t *) abstract_surface;
 
     if (! _cairo_surface_is_xlib (abstract_surface)) {
 	_cairo_surface_set_error (abstract_surface,
@@ -1993,7 +1962,7 @@ cairo_xlib_surface_set_drawable (cairo_s
     }
 
     /* XXX: and what about this case? */
-    if (surface->owns_pixmap)
+    if (surface->x.owns_pixmap)
 	return;
 
     if (surface->drawable != drawable) {
@@ -2008,8 +1977,8 @@ cairo_xlib_surface_set_drawable (cairo_s
 
 	surface->drawable = drawable;
     }
-    surface->width = width;
-    surface->height = height;
+    surface->x.width = width;
+    surface->x.height = height;
 }
 
 /**
@@ -2117,7 +2086,7 @@ cairo_xlib_surface_get_visual (cairo_sur
 int
 cairo_xlib_surface_get_depth (cairo_surface_t *abstract_surface)
 {
-    cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *) abstract_surface;
+    cairo_x_surface_t *surface = (cairo_x_surface_t *) abstract_surface;
 
     if (! _cairo_surface_is_xlib (abstract_surface)) {
 	_cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
@@ -2140,7 +2109,7 @@ cairo_xlib_surface_get_depth (cairo_surf
 int
 cairo_xlib_surface_get_width (cairo_surface_t *abstract_surface)
 {
-    cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *) abstract_surface;
+    cairo_x_surface_t *surface = (cairo_x_surface_t *) abstract_surface;
 
     if (! _cairo_surface_is_xlib (abstract_surface)) {
 	_cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
@@ -2163,7 +2132,7 @@ cairo_xlib_surface_get_width (cairo_surf
 int
 cairo_xlib_surface_get_height (cairo_surface_t *abstract_surface)
 {
-    cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *) abstract_surface;
+    cairo_x_surface_t *surface = (cairo_x_surface_t *) abstract_surface;
 
     if (! _cairo_surface_is_xlib (abstract_surface)) {
 	_cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
@@ -2648,9 +2617,9 @@ _cairo_xlib_surface_show_glyphs (void   
      * fallback clip masking, we have to go through the full
      * fallback path.
      */
-    if (dst->base.clip &&
-        (dst->base.clip->mode != CAIRO_CLIP_MODE_REGION ||
-         dst->base.clip->surface != NULL))
+    if (dst->x.base.clip &&
+        (dst->x.base.clip->mode != CAIRO_CLIP_MODE_REGION ||
+         dst->x.base.clip->surface != NULL))
         return CAIRO_INT_STATUS_UNSUPPORTED;
 
     operation = _categorize_composite_operation (dst, op, src_pattern, TRUE);
@@ -2693,7 +2662,7 @@ _cairo_xlib_surface_show_glyphs (void   
     }
 
     if (src_pattern->type == CAIRO_PATTERN_TYPE_SOLID) {
-        status = _cairo_pattern_acquire_surface (src_pattern, &dst->base,
+        status = _cairo_pattern_acquire_surface (src_pattern, &dst->x.base,
                                                  0, 0, 1, 1,
                                                  (cairo_surface_t **) &src,
                                                  &attributes);
@@ -2707,7 +2676,7 @@ _cairo_xlib_surface_show_glyphs (void   
         if (status)
 	    goto BAIL;
 
-        status = _cairo_pattern_acquire_surface (src_pattern, &dst->base,
+        status = _cairo_pattern_acquire_surface (src_pattern, &dst->x.base,
                                                  glyph_extents.x, glyph_extents.y,
                                                  glyph_extents.width, glyph_extents.height,
                                                  (cairo_surface_t **) &src,
@@ -2783,7 +2752,7 @@ _cairo_xlib_surface_show_glyphs (void   
     free (output_glyphs);
 
     if (src)
-        _cairo_pattern_release_surface (src_pattern, &src->base, &attributes);
+        _cairo_pattern_release_surface (src_pattern, &src->x.base, &attributes);
     if (src_pattern == &solid_pattern.base)
 	_cairo_pattern_fini (&solid_pattern.base);
 
-- 
1.4.2.3



More information about the cairo mailing list