[cairo-bugs] [Bug 11529] Performance of cairo is not good without XRender extension
bugzilla-daemon at freedesktop.org
bugzilla-daemon at freedesktop.org
Mon May 26 08:56:34 PDT 2008
http://bugs.freedesktop.org/show_bug.cgi?id=11529
--- Comment #38 from Behdad Esfahbod <freedesktop at behdad.org> 2008-05-26 08:56:30 PST ---
(From update of attachment 16734)
Looks great. Thanks! Comments below.
>diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
>index ec66c4d..a80a265 100644
>--- a/src/cairo-xlib-surface.c
>+++ b/src/cairo-xlib-surface.c
>@@ -1475,9 +1475,6 @@ _cairo_xlib_surface_composite (cairo_operator_t op,
>
> _cairo_xlib_display_notify (dst->screen_info->display);
>
>- if (!CAIRO_SURFACE_RENDER_HAS_COMPOSITE (dst))
>- return CAIRO_INT_STATUS_UNSUPPORTED;
>-
> operation = _categorize_composite_operation (dst, op, src_pattern,
> mask_pattern != NULL);
> if (operation == DO_UNSUPPORTED)
>@@ -1514,6 +1511,11 @@ _cairo_xlib_surface_composite (cairo_operator_t op,
> switch (operation)
> {
> case DO_RENDER:
>+ if (!CAIRO_SURFACE_RENDER_HAS_COMPOSITE (dst)) {
>+ status = CAIRO_INT_STATUS_UNSUPPORTED;
>+ goto BAIL;
>+ }
You actually don't need this block. Check the bottom of
_recategorize_composite_operation(). It already does that check. So, just
remove the check and we're better.
> status = _cairo_xlib_surface_set_attributes (src, &src_attr);
> if (status)
> goto BAIL;
>@@ -1629,8 +1631,60 @@ _cairo_xlib_surface_fill_rectangles (void *abstract_surface,
>
> _cairo_xlib_display_notify (surface->screen_info->display);
>
>- if (!CAIRO_SURFACE_RENDER_HAS_FILL_RECTANGLE (surface))
>+ if (!CAIRO_SURFACE_RENDER_HAS_FILL_RECTANGLE (surface)) {
>+ if (op == CAIRO_OPERATOR_CLEAR ||
>+ ((op == CAIRO_OPERATOR_SOURCE || op == CAIRO_OPERATOR_OVER) &&
>+ (color->alpha_short >= 0xff00))) {
Use CAIRO_ALPHA_SHORT_IS_OPAQUE here.
>+ XGCValues gcv;
>+ int a_width=0, r_width=0, g_width=0, b_width=0;
>+ int a_shift=0, r_shift=0, g_shift=0, b_shift=0;
>+ int a = color->alpha_short >> 8;
>+ int r = color->red_short >> 8;
>+ int g = color->green_short >> 8;
>+ int b = color->blue_short >> 8;
>+
>+ if (surface->visual->class == TrueColor) {
>+ _characterize_field (surface->a_mask, &a_width, &a_shift);
>+ _characterize_field (surface->r_mask, &r_width, &r_shift);
>+ _characterize_field (surface->g_mask, &g_width, &g_shift);
>+ _characterize_field (surface->b_mask, &b_width, &b_shift);
>+ gcv.foreground = (_field_from_8 (a, a_width, a_shift) |
>+ _field_from_8 (r, r_width, r_shift) |
>+ _field_from_8 (g, g_width, g_shift) |
>+ _field_from_8 (b, b_width, b_shift));
>+ } else {
>+ cairo_xlib_visual_info_t *visual_info;
>+ cairo_int_status_t status;
>+
>+ status = _cairo_xlib_screen_get_visual_info (surface->screen_info,
>+ surface->visual,
>+ &visual_info);
>+ if (status)
>+ return CAIRO_INT_STATUS_UNSUPPORTED;
>+
>+ gcv.foreground =
>+ visual_info->rgb333_to_pseudocolor[_field_from_8 (r, 3, 6) |
>+ _field_from_8 (g, 3, 3) |
>+ _field_from_8 (b, 3, 0)];
>+ }
>+ GC xgc = XCreateGC (surface->dpy, surface->drawable, GCForeground,
>+ &gcv);
>+ if (!xgc)
>+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
>+
>+ for (i = 0; i < num_rects; i++) {
>+ XFillRectangle (surface->dpy, surface->drawable, xgc,
>+ rects[i].x, rects[i].y,
>+ rects[i].width, rects[i].height);
>+ }
>+
>+ XFreeGC(surface->dpy, xgc);
>+ return CAIRO_STATUS_SUCCESS;
>+ }
>+
> return CAIRO_INT_STATUS_UNSUPPORTED;
>+ }
Please add the new code in a new function.
Otherwise looks good. I'll commit it when an updated patch arrives.
--
Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
More information about the cairo-bugs
mailing list