[PATCH 1/5] xlib, xcb: Hand off EXTEND_PAD/EXTEND_REFLECT to Render

Thomas Jaeger ThJaeger at gmail.com
Thu Feb 19 09:02:41 PST 2009


Most drivers and the X server used to have incorrect RepeatPad/RepeatReflect
implementations, forcing cairo to fall back to client-side software rendering,
which is painfully slow due to pixmaps being transfered over the wire.  These
issues are mostly fixed in the drivers (with the exception of radeonhd, whose
developers didn't respond) and the RepeatPad software fallback is implemented
correctly as of pixman-0.15.0, so this patch will hand off composite operations
with EXTEND_PAD/EXTEND_REFLECT source patterns to XRender.

There is no way to detect whether the X server or the drivers use a
broken Render implementation, we make a guess based on the server
version:  It's probably safe to assume that 1.7 X servers will use
fixed drivers and a recent enough version of pixman.
---
 src/cairo-xcb-surface.c          |   15 +++++++++++++--
 src/cairo-xlib-display.c         |   15 +++++++++++----
 src/cairo-xlib-private.h         |    1 +
 src/cairo-xlib-surface-private.h |    1 +
 src/cairo-xlib-surface.c         |    9 +++++++++
 5 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c
index c21e600..b85bc30 100644
--- a/src/cairo-xcb-surface.c
+++ b/src/cairo-xcb-surface.c
@@ -101,6 +101,8 @@ typedef struct cairo_xcb_surface {
 
 #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)
+#define CAIRO_SURFACE_RENDER_HAS_REPEAT_PAD(surface)	CAIRO_SURFACE_RENDER_AT_LEAST((surface), 0, 10)
+#define CAIRO_SURFACE_RENDER_HAS_REPEAT_REFLECT(surface)	CAIRO_SURFACE_RENDER_AT_LEAST((surface), 0, 10)
 
 static void
 _cairo_xcb_surface_ensure_gc (cairo_xcb_surface_t *surface);
@@ -840,13 +842,22 @@ _cairo_xcb_surface_set_attributes (cairo_xcb_surface_t	      *surface,
 
     switch (attributes->extend) {
     case CAIRO_EXTEND_NONE:
-	_cairo_xcb_surface_set_repeat (surface, 0);
+	_cairo_xcb_surface_set_repeat (surface, XCB_RENDER_REPEAT_NONE);
 	break;
     case CAIRO_EXTEND_REPEAT:
-	_cairo_xcb_surface_set_repeat (surface, 1);
+	_cairo_xcb_surface_set_repeat (surface, XCB_RENDER_REPEAT_NORMAL);
 	break;
     case CAIRO_EXTEND_REFLECT:
+	if (!CAIRO_SURFACE_RENDER_HAS_REPEAT_REFLECT(surface))
+	    return CAIRO_INT_STATUS_UNSUPPORTED;
+	_cairo_xcb_surface_set_repeat (surface, XCB_RENDER_REPEAT_REFLECT);
+	break;
     case CAIRO_EXTEND_PAD:
+	if (!CAIRO_SURFACE_RENDER_HAS_REPEAT_PAD(surface))
+	    return CAIRO_INT_STATUS_UNSUPPORTED;
+	_cairo_xcb_surface_set_repeat (surface, XCB_RENDER_REPEAT_PAD);
+	break;
+    default:
 	return CAIRO_INT_STATUS_UNSUPPORTED;
     }
 
diff --git a/src/cairo-xlib-display.c b/src/cairo-xlib-display.c
index af244ab..65df2b7 100644
--- a/src/cairo-xlib-display.c
+++ b/src/cairo-xlib-display.c
@@ -285,6 +285,7 @@ _cairo_xlib_display_get (Display *dpy,
 	    sizeof (display->cached_xrender_formats));
 
     display->buggy_repeat = FALSE;
+    display->buggy_pad_reflect = TRUE;
 
     /* This buggy_repeat condition is very complicated because there
      * are multiple X server code bases (with multiple versioning
@@ -331,13 +332,19 @@ _cairo_xlib_display_get (Display *dpy,
      *    (just using VendorRelase < 70000000), as buggy_repeat=TRUE.
      */
     if (strstr (ServerVendor (dpy), "X.Org") != NULL) {
-	if (VendorRelease (dpy) >= 60700000 && VendorRelease (dpy) < 70000000)
-	    display->buggy_repeat = TRUE;
-	if (VendorRelease (dpy) < 10400000)
-	    display->buggy_repeat = TRUE;
+	if (VendorRelease (dpy) >= 60700000) {
+	    if (VendorRelease (dpy) < 70000000)
+		display->buggy_repeat = TRUE;
+	} else {
+	    if (VendorRelease (dpy) < 10400000)
+		display->buggy_repeat = TRUE;
+	    if (VendorRelease (dpy) >= 10699000)
+		display->buggy_pad_reflect = FALSE;
+	}
     } else if (strstr (ServerVendor (dpy), "XFree86") != NULL) {
 	if (VendorRelease (dpy) <= 40500000)
 	    display->buggy_repeat = TRUE;
+
     }
 
     display->next = _cairo_xlib_display_list;
diff --git a/src/cairo-xlib-private.h b/src/cairo-xlib-private.h
index b9c84b8..4995bc6 100644
--- a/src/cairo-xlib-private.h
+++ b/src/cairo-xlib-private.h
@@ -73,6 +73,7 @@ struct _cairo_xlib_display {
 
     cairo_xlib_hook_t *close_display_hooks;
     unsigned int buggy_repeat :1;
+    unsigned int buggy_pad_reflect :1;
     unsigned int closed :1;
 };
 
diff --git a/src/cairo-xlib-surface-private.h b/src/cairo-xlib-surface-private.h
index fe37e5f..164fe15 100644
--- a/src/cairo-xlib-surface-private.h
+++ b/src/cairo-xlib-surface-private.h
@@ -76,6 +76,7 @@ struct _cairo_xlib_surface {
      * we can reuse the test for now.
      */
     cairo_bool_t buggy_repeat;
+    cairo_bool_t buggy_pad_reflect;
 
     int width;
     int height;
diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index e456691..d58971b 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -1450,7 +1450,15 @@ _cairo_xlib_surface_set_attributes (cairo_xlib_surface_t	    *surface,
 	_cairo_xlib_surface_set_repeat (surface, RepeatNormal);
 	break;
     case CAIRO_EXTEND_REFLECT:
+	if (surface->buggy_pad_reflect)
+	    return CAIRO_INT_STATUS_UNSUPPORTED;
+	_cairo_xlib_surface_set_repeat (surface, RepeatReflect);
+	break;
     case CAIRO_EXTEND_PAD:
+	if (surface->buggy_pad_reflect)
+	    return CAIRO_INT_STATUS_UNSUPPORTED;
+	_cairo_xlib_surface_set_repeat (surface, RepeatPad);
+	break;
     default:
 	return CAIRO_INT_STATUS_UNSUPPORTED;
     }
@@ -2665,6 +2673,7 @@ _cairo_xlib_surface_create_internal (Display		       *dpy,
 	/* so we can use the XTile fallback */
 	surface->buggy_repeat = TRUE;
     }
+    surface->buggy_pad_reflect = screen_info->display->buggy_pad_reflect;
 
     surface->dst_picture = None;
     surface->src_picture = None;
-- 
1.6.3.1


--------------060006090906060701020708
Content-Type: text/x-patch;
 name="0002-pattern-Use-pixman-for-EXTEND_PAD.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="0002-pattern-Use-pixman-for-EXTEND_PAD.patch"



More information about the cairo mailing list