Premultiplied alpha handle for driver
Jonathan Morton
jonathan.morton at movial.com
Tue Jun 1 03:05:56 PDT 2010
On Mon, 2010-05-31 at 10:42 +0800, Huang, FrankR wrote:
> We know the premultiplied alpha will be used sometimes in blend. Is
> that used in the graphics driver?
XRender always expects premultiplied alpha in images. Your previous
example, with ARGB values of (100,255,0,0) is therefore an invalid pixel
vector, since the R channel is greater than the A channel.
> And the picture_1x1[0] is a ARGB picture with an alpha value;
> mask_20x20[0] is a A8 picture with an alpha value. How the
> driver(do_composite) handle this two alpha value?
Each component (A,R,G,B) of the source is multiplied by the mask value
before being applied to the main blend equation, as I explained
previously. Assuming 8 bits per channel, the multiplication occurs as
if 255 == 1.0 and 128 == (128/255), which is usual for graphics.
The general formula is: dst = (src IN mask) OP dst.
With component-alpha turned off, as is usual except for ClearType, src
and dst are expanded to ARGB format (with A set to 255 if not present in
the original format) and mask is cut down to it's alpha channel, before
any evaluation occurs. Any missing channels are cut away from dst when
storing the result.
An example which may help you to understand, is that XRender can handle
un-premultiplied ARGB images by interpreting the same image as an XRGB32
source and an AXXX32 mask (specified as ARGB32) simultaneously. The
result will be in premultiplied format.
--
------
From: Jonathan Morton
jonathan.morton at movial.com
More information about the xorg-devel
mailing list