[Pixman] [PATCH 1/3] Add pixman_composite_trapezoids().

Soeren Sandmann sandmann at cs.au.dk
Thu Jan 13 10:05:05 PST 2011


Adam Jackson <ajax at nwnk.net> writes:

> On Wed, 2011-01-12 at 08:49 -0500, Søren Sandmann Pedersen wrote:
> > This function is an implementation of the X server request
> > Trapezoids. That request is what the X backend of cairo is using all
> > the time; by moving it into pixman we can hopefully make it faster.
> 
> This looks like it loses the "solid alpha add" optimization from
> miTrapezoids.  Am I missing something, or is that just coming later?

No, you are right, it does lose that optimization. However, nothing
actually hits it. Cairo's solid images are invariably 1x1R with a
format of x8r8g8b8, which means this:

    if (PICT_FORMAT_TYPE (pSrc->format) != PICT_TYPE_A)
        return FALSE;

is hit and the optimization is never triggered. 

What cairo actually does from time to time, is ADDing a solid white
image onto an a8 destination, and that would benefit from this
optimization. Adding it to pixman is actually pretty straightforward:

+    if (op == PIXMAN_OP_ADD &&
+       (src->common.flags & FAST_PATH_IS_OPAQUE) &&
+       (dst->common.extended_format_code == PIXMAN_a8))
+    {
+       for (i = 0; i < n_traps; ++i)
+       {
+           pixman_trapezoid_t *trap = &(traps[i]);
+           
+           if (!pixman_trapezoid_valid (trap))
+               continue;
+           
+           pixman_rasterize_trapezoid (dst, trap, 0, 0);
+       }
+    }
+    else

though I'd like to get it covered by tests before adding it.

A similar optimization for adding solid black images would be
possible, but would require detecting an additional
FAST_PATH_SOLID_BLACK flag in compute_image_info(). It doesn't look
like anything would actually benefit from it though.


Soren


More information about the xorg-devel mailing list