[cairo] Inefficiency of _cairo_xlib_surface_composite

Carl Worth cworth at cworth.org
Thu Jan 27 14:55:44 PST 2005


On Thu, 27 Jan 2005 17:45:00 -0500, Jason Dorje Short wrote:
> Cairo should use the fast method where possible, and the slow method
> where it's not possible.

Sure.

> Currently if there is any scaling, XRenderComposite is used
> (correct).

Yes.

> 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).

Respecting non-integer translation allows effects such as an image
sliding very smoothly, (advancing at less the one pixel/frame).

> - 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.

This is the case only if the source image has alpha==1 everywhere. So
this could work for images of CAIRO_FORMAT_RGB24.

> - 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.

To be able to do this, cairo should be provided with an A1 mask. There
was a recent patch proposed to allow the user to specify the format of
the internally-constructed masks. So that may help here.

The other missing piece, (as also recently discussed), is that the
user should be able to directly specify a surface for masking the
current pattern. When this API is added, the user could supply an A1
mask here as well.

I can't imagine that it would make sense for cairo to examine an A8 or
ARGB32 image looking for constant, extreme alpha, (except perhaps in
the 1x1 repeating mask case if it shows up again).

> 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.

Sure. Patches for any of the above would be gladly accepted.

-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050127/9b597f7d/attachment.pgp


More information about the cairo mailing list