[cairo] Bug with paint_with_alpha and perf issueswhencompositing with SOURCE
cairo at antoineazar.com
Tue May 27 12:03:16 PDT 2008
> The cairo operators all have mathematical definitions ..
> we've tried to make them "intuitive", but in the end, the
> mathematical description is what wins, not intuitive
> expectation, or even what is useful in a particular case.
Of course. In the case though where the mathematical definition can't be
translated easily in an intuitive one, I think we should provide the
mathematical one in the doc. The definition of the function is confusing
> Careful - "something similar to" is not the same thing as "exactly".
> Cairo's SOURCE:
> (src IN mask) ADD (dest OUT mask)
> dest_c = (src_c * mask_a) + (dest_c * (1 - mask_a))
> Cairo's OVER:
> (src IN mask) OVER dst
> dest_c = (src_c * mask_a) + (dest_c * (1 - src_a * mask_a))
You're right, I should've been more careful with my wording. I'm not really
arguing that though, I'm just asking which definition is more useful to
(src IN mask) ADD (dest OUT (mask in clip)) as is currently done or
(src IN mask) ADD (dest OUT clip) as I understood initially from the doc and
> Backends can of course already special case things however
> they want- this is all in the "fallback" code already.
> Now, there's maybe a case that the fallback code is a little
> too conservative in assuming pixman/RENDER limitations - you
> could imagine some sort of "flag" for the the backend that
> says "pass me through all operators and I'll implement cairo
> semantics". But I haven't seen any evidence that's a real
> problem here.
I just don't find it very clean to assert on SOURCE and CLEAR in functions
like _cairo_surface_composite and have special cases for them. I guess it's
a design choice to either have Cairo change a given operation into several
more 'atomic' operations and send them to the backends, or ask the backends
to make sure they implement each operator with the definition we give them
(whichever way they want to do it, and if they really can't, just don't
implement it and let Cairo fallback to pixman). The latter would boost
performance quite a bit in the current case.
> Well, in the case where they are exactly the same... when we
> can prove the source has no alpha... there's no reason we
> can't optimize SOURCE to OVER.
> I wouldn't agree that SOURCE "should be faster" ... SOURCE
> should be faster only if we don't have to reference
> destination pixels, but that isn't the case when we have a
> mask. The code we are discussing is specific to the case when
> there is a mask of some type.
OK well it should certainly be faster than what it is right now, and
certainly close to OVER (not 5-10X slower).
More information about the cairo