[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [E-devel] Premultiply or not

> > >   It's definitely a 'plus' for evas to move with working
> > > in premul color space internally (and recall: a,r,g,b is premul
> > > iff a >= r,g,b). There are many reasons for this.. some I've
> > > already stated here
> Just to clarify things, is it a case of "most of the pixel twiddling
> needs to have this multiplication step done anyway, so we might as
> well pre-multiply at the beginning to avoid lots of lengthy
> multiplications happening deep in pixel handling loops, and some
> external sources of pixels already come in premul form anyway"?

	Most of the compositing ops multiply the alpha by the r,g,b
if one can't assume that a >= r,g,b. And if you are dealing with a
dst image which itself has alpha, then not only do you have to mult
the src colors by the alpha (agian, if they are not premul), but you
also should *divide* the result of blending the colors by the result
alpha - *extremely* slow.. which evas and imlib2 got around by using
a 65Kb table that is somewhat faster than dividing, but which does
not generalize well to other ops.
	But even when no ops are done, if the image has alpha, then
one should replace the r,g,b by their alpha multiplied versions for
sending to the display - definitely needed with the xrender engine
for setting data on pictures.
	Internally, it's *much* more efficient to use premul colors,
for dealing with compositing ops and for dealing with the xrender

	If evas works internally with premul data, then when you
set an object's color to (r,g,b,a), if we have evas assume that
this is *not* premul, then evas will have no choice but to replace
this by (r*a/255,g*a/255,b*a/255,a). That's what it *will* use to
color the object by - not the input (r,g,b,a).
	The problem becomes somewhat coplicated when one has the
option of 'doing stuff' with the colors other than just using
them as a simple multiplier (which is what setting an obj's color
will do). Then, lots of ambiguities and limitations come up with
non-premul color inputs.