[cairo] Inefficiency of _cairo_xlib_surface_composite

David Reveman davidr at novell.com
Thu Jan 27 15:50:13 PST 2005


On Thu, 2005-01-27 at 17:45 -0500, Jason Dorje Short wrote:
> Cairo should use the fast method where possible, and the slow method
> where it's not possible.
> 
> In _cairo_xlib_surface_composite, XCopyArea is used if it is deemed
> possible, and XRenderComposite is used otherwise.  On my system
> XRenderComposite is about 5x slower so this check should really try hard
> to see if XCopyArea can be used!
> 
> Currently if there is any scaling, XRenderComposite is used (correct).
> XRenderComposite is also used if there is a non-integer translation (I'm
> not sure if this actually gives any benefit versus just rounding off the
> translation, and for very large translations I think there will be
> rounding errors in the check).
> 
> Also XCopyArea is only used if the operation is SRC and there's no mask.
>   Here is where the greatest improvement can be done.  I'm not sure what
> the exact check should be but consider:
> 
> - If the operation is OVER (the default) and there's no mask, then the
> result is the same as SRC.  So XCopyArea should be used.
> 
> - If the operation is OVER or SRC and there is a mask, but the mask is
> only 1-bit (all alpha values either 255 or 0), then XCopyArea can be
> used with a monochrome bitmap as a mask.
> 
> I think both of these changes are needed so that typical xlib operations
> won't be made much slower by Cairo (and there may be other possible
> optimizations as well).  The ability to support alpha is nice but when
> there is no alpha present the fast fallback should be used.
> 
> It's also possible (even desirable) to optimize this in XRender as well.


The current use of CopyArea in cairo's xlib backend is broken, it
doesn't check that the depth and the root window of the source matches
the depth and the root window of the destination.

Honestly, I'd really like to see this CopyArea fast-path go away
completely. I'd rather see effort being put into making the X server
pick up these special cases than doing all these ugly tricks in cairo.
On new X servers CopyArea might not be any faster (e.g. in Xgl
Composite(op=SRC) is just as fast as CopyArea) and all this extra work
done in cairo will just be a waste. Yes, I know, it will make a huge
difference on older X servers but I think that's just too bad.

-David




More information about the cairo mailing list