Re: Thin Client Benchmark Testing



Federico Mena Quintero (federico ximian com):

> I don't know yet why that happens.  Interestingly enough, running
> sysprof shows that *all* the time (94%) goes to the X server.  I
> wonder why that happens, since, well, aren't we falling back to doing
> everything client-side?
> 
> Your best bet is to see what GTK+ does in the fallback code that makes
> it so slow.

  Federico rocks.  On IRC he very quickly found the most likely cause of
the performance regression in the cairo code.

  Attached is a patch to cairo which should make it much more usable,
and maybe gets close to solving the performance regression.  There is a
missing optimization in cairo for non-RENDER X servers where it should
be using XFillRectangle() instead of a more involved fallback.

  Dave, is there any way you could try this patch out?  It was made
against cairo CVS HEAD but I have verified that it applies to the 1.0
branch.

  The patch can still be improved, it currently allocates a colour
through X where it could calculate the pixel value itself for TrueColor
or DirectColor visuals.

  -Billy

Index: src/cairo-xlib-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-xlib-surface.c,v
retrieving revision 1.126
diff -p -u -r1.126 cairo-xlib-surface.c
--- src/cairo-xlib-surface.c	2 Nov 2005 00:40:37 -0000	1.126
+++ src/cairo-xlib-surface.c	2 Nov 2005 04:19:50 -0000
@@ -1332,8 +1332,32 @@ _cairo_xlib_surface_fill_rectangles (voi
     cairo_xlib_surface_t *surface = abstract_surface;
     XRenderColor render_color;
 
-    if (!CAIRO_SURFACE_RENDER_HAS_FILL_RECTANGLE (surface))
-	return CAIRO_INT_STATUS_UNSUPPORTED;
+    if (!CAIRO_SURFACE_RENDER_HAS_FILL_RECTANGLE (surface)) {
+	Colormap colormap;
+	XColor xcolor;
+	int i;
+
+	if (color->alpha_short != 0xffff /* && operator != CAIRO_SOURCE*/)
+	    return CAIRO_INT_STATUS_UNSUPPORTED;
+
+	_cairo_xlib_surface_ensure_gc (surface);
+
+	memset (&xcolor, 0, sizeof (XColor));
+	xcolor.red = color->red_short;
+	xcolor.green = color->green_short;
+	xcolor.blue = color->blue_short;
+	colormap = DefaultColormap (surface->dpy, XScreenNumberOfScreen (surface->screen));
+	XAllocColor (surface->dpy, colormap, &xcolor);
+
+	XSetForeground (surface->dpy, surface->gc, xcolor.pixel);
+
+	for (i = 0; i < num_rects; i++)
+	    XFillRectangle (surface->dpy, surface->drawable, surface->gc,
+			    rects[i].x, rects[i].y, rects[i].width, rects[i].height);
+
+	XFreeColors (surface->dpy, colormap, &xcolor.pixel, 1, 0);
+	return CAIRO_STATUS_SUCCESS;
+    }
 
     render_color.red   = color->red_short;
     render_color.green = color->green_short;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]