[cairo] Inefficiency of _cairo_xlib_surface_composite
Jason Dorje Short
jdorje at users.sf.net
Thu Jan 27 14:45:00 PST 2005
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.
-jason
More information about the cairo
mailing list