Premultiplied alpha handle for driver
Huang, FrankR
FrankR.Huang at amd.com
Tue Jun 1 05:02:34 PDT 2010
Absoluely correct formula.
I have use my application to do the calculation according to your code and do an SRC operation on the final display on geode. Its result is same as the OVER operation on X12000.
Tomorrow I will correct our geode driver and let you know my update:).
Thanks a lot for you, Morton.
Frank
-----Original Message-----
From: Jonathan Morton [mailto:jonathan.morton at movial.com]
Sent: 2010年6月1日 19:31
To: Huang, FrankR
Cc: xorg-devel at lists.x.org
Subject: RE: Premultiplied alpha handle for driver
On Tue, 2010-06-01 at 18:55 +0800, Huang, FrankR wrote:
> So I just want to know if picture_1x1 has the alpha value and mask has
> the alpha value. How the driver handle this? If I know the answer, I
> can fix this bug. Hope your reply soon:)
Here's a couple of code fragments from a reference library I wrote a
while ago. These would be called as follows:
if(msk) {
PixelsDoMask(src, msk, tmp, count);
PixelsDoOpOver(tmp, dst, count);
} else {
PixelsDoOpOver(src, dst, count);
}
void PixelsDoMask (
PixelsColour * src,
const u8 * const msk,
PixelsColour * tmp,
const u32 count )
{
for(u32 c=0; c < count; c++) {
u32 mask = msk[c];
if(!mask) {
tmp[c] = nil;
} else if(mask == 255) {
tmp[c] = src[c];
} else {
tmp[c].a = divBy255(src[c].a * mask);
tmp[c].r = divBy255(src[c].r * mask);
tmp[c].g = divBy255(src[c].g * mask);
tmp[c].b = divBy255(src[c].b * mask);
}
}
}
void PixelsDoOpOver (
const PixelsColour * const src,
PixelsColour * dst,
const u32 count )
{
for(u32 c=0; c < count; c++) {
u32 a = 255 - src[c].a;
if(!a) {
dst[c] = src[c];
} else if(a != 255) {
dst[c].a = sat255(divBy255(dst[c].a * a) + src[c].a);
dst[c].r = sat255(divBy255(dst[c].r * a) + src[c].r);
dst[c].g = sat255(divBy255(dst[c].g * a) + src[c].g);
dst[c].b = sat255(divBy255(dst[c].b * a) + src[c].b);
}
}
}
--
------
From: Jonathan Morton
jonathan.morton at movial.com
More information about the xorg-devel
mailing list