[cairo] Creating an opaque fade-in effect with Cairo

Maarten Bosmans mkbosmans at gmail.com
Fri Jan 21 03:22:06 PST 2011


2011/1/21 Tristan Schmelcher <tschmelcher at google.com>:
> On 20 January 2011 14:26, Andrea Canciani <ranma42 at gmail.com> wrote:
>> If your destination is always opaque, you can do everything like this:
>>
>> cairo_set_operator (cr, CAIRO_OPERATOR_IN);
>> cairo_set_source (cr, the_fading_surface);
>> cairo_paint_with_alpha (cr, the_fade_parameter);
>>
>> This should be sufficient to completely replace the old content assuming that
>> the destination has a content of type CAIRO_CONTENT_COLOR.
>> It is slightly less flexible than your code, because this will only allow
>> fading from/to black, but I expect it to be faster, because it performs only
>> one compositing operation.
>
> Thanks for the info! My destination is indeed of type
> CAIRO_CONTENT_COLOR, so your suggestion works great, but surprisingly
> it seems to be slightly slower. When I make it render as fast as it
> can, the CLEAR+OVER approach gets an average of 13 fps while the IN
> approach gets an average of 12 fps. Rather strange ... I definitely
> agree with you that it ought to be the faster method.

Why not just use CAIRO_OPERATOR_SOURCE? It is likely faster than
CAIRO_OPERATOR_IN.

Maarten


More information about the cairo mailing list