[cairo] newbie clipping question

Owen Taylor otaylor at redhat.com
Mon Oct 16 04:29:46 PDT 2006


On Mon, 2006-10-16 at 07:54 +0200, Emmanuel Pacaud wrote:
> Le dimanche 15 octobre 2006 à 20:52 -0400, Owen Taylor a écrit :
> > Hmm, what sort of X server are you using? If it's older than a year
> > or two, then the X server may be creating temporary mask the size
> > of the primitive that you are drawing.
> 
> It happens on a quite recent x server (xorg 7.1.1 here).
> It looks like most of the time is spent in the x server. On each render
> of long line, it tries to allocate a big temporary chunk of memory.

If you are interested in doing some code experiments, in 
_cairo_xlib_surface_composite_trapezoids there is:

    if (!_cairo_operator_bounded_by_mask (op)) {
        /* XRenderCompositeTrapezoids() creates a mask only large enough for the
         * trapezoids themselves, but if the operator is unbounded, then we need
         * to actually composite all the way out to the bounds, so we create
         * the mask and composite ourselves. There actually would
         * be benefit to doing this in all cases, since RENDER implementations
         * will frequently create a too temporary big mask, ignoring destination
         * bounds and clip. (XRenderAddTraps() could be used to make creating
         * the mask somewhat cheaper.)
         */
        Picture mask_picture = _create_trapezoid_mask (dst, traps, num_traps,
                                                       dst_x, dst_y, width, height,
                                                       pict_format);

You could try taking that comment's suggestion and turning that to 'if (TRUE)'

There is also a comment in _create_trapezoid_mask():

    /* This would be considerably simpler using XRenderAddTraps(), but since
     * we are only using this in the unbounded-operator case, we stick with
     * XRenderCompositeTrapezoids, which is available on older versions
     * of RENDER rather than conditionalizing. We should still hit an
     * optimization that avoids creating another intermediate surface on
     * the servers that have XRenderAddTraps().
     */

If the optimization referred to there works, then the simple if (true) {} should 
be good enough, but if it isn't working for one reason or the other, then
switching to XRenderAddTraps() would be necessary; that's not a lot of work -
the main effort is just checking the Composite version.

						- Owen 




More information about the cairo mailing list