From: Jérôme Gardou Date: Sun, 8 Aug 2010 16:20:24 +0000 (+0000) Subject: [WIN32K] X-Git-Tag: backups/reactos-yarotows@57446~28 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=d4933ee771a930736e6d821b5bd25d903651b4ef [WIN32K] - I watch and I learn : / has precedence over *=. - Also make sure that we divide what we want to divide with the appropriate parentheses. - Do not take care of alpha in other depths than 32 bpp. svn path=/branches/reactos-yarotows/; revision=48488 --- diff --git a/subsystems/win32/win32k/dib/alphablend.c b/subsystems/win32/win32k/dib/alphablend.c index 8e6298f6fe8..be269cf5c37 100644 --- a/subsystems/win32/win32k/dib/alphablend.c +++ b/subsystems/win32/win32k/dib/alphablend.c @@ -90,21 +90,18 @@ DIB_XXBPP_AlphaBlend(SURFOBJ* Dest, SURFOBJ* Source, RECTL* DestRect, while(DstX < DestRect->right) { SrcPixel32.ul = DIB_GetSource(Source, SrcX, SrcY, &exloSrcRGB.xlo); - SrcPixel32.col.red *= BlendFunc.SourceConstantAlpha / 255; - SrcPixel32.col.green *= BlendFunc.SourceConstantAlpha / 255; - SrcPixel32.col.blue *= BlendFunc.SourceConstantAlpha / 255; - SrcPixel32.col.alpha = (32 == SrcBpp) ? - SrcPixel32.col.alpha * BlendFunc.SourceConstantAlpha / 255 : - BlendFunc.SourceConstantAlpha ; + SrcPixel32.col.red = (SrcPixel32.col.red * BlendFunc.SourceConstantAlpha) / 255; + SrcPixel32.col.green = (SrcPixel32.col.green * BlendFunc.SourceConstantAlpha) / 255; + SrcPixel32.col.blue = (SrcPixel32.col.blue * BlendFunc.SourceConstantAlpha) / 255; Alpha = ((BlendFunc.AlphaFormat & AC_SRC_ALPHA) != 0) ? - SrcPixel32.col.alpha : BlendFunc.SourceConstantAlpha ; + (SrcPixel32.col.alpha * BlendFunc.SourceConstantAlpha) / 255 : + BlendFunc.SourceConstantAlpha ; DstPixel32.ul = DIB_GetSource(Dest, DstX, DstY, &exloDstRGB.xlo); - DstPixel32.col.red = Clamp8(DstPixel32.col.red * (255 - Alpha) / 255 + SrcPixel32.col.red) ; - DstPixel32.col.green = Clamp8(DstPixel32.col.green * (255 - Alpha) / 255 + SrcPixel32.col.green) ; - DstPixel32.col.blue = Clamp8(DstPixel32.col.blue * (255 - Alpha) / 255 + SrcPixel32.col.blue) ; - DstPixel32.col.alpha = Clamp8(DstPixel32.col.alpha * (255 - Alpha) / 255 + SrcPixel32.col.alpha) ; + DstPixel32.col.red = Clamp8((DstPixel32.col.red * (255 - Alpha)) / 255 + SrcPixel32.col.red) ; + DstPixel32.col.green = Clamp8((DstPixel32.col.green * (255 - Alpha)) / 255 + SrcPixel32.col.green) ; + DstPixel32.col.blue = Clamp8((DstPixel32.col.blue * (255 - Alpha)) / 255 + SrcPixel32.col.blue) ; DstPixel32.ul = XLATEOBJ_iXlate(&exloRGBSrc.xlo, DstPixel32.ul); pfnDibPutPixel(Dest, DstX, DstY, XLATEOBJ_iXlate(ColorTranslation, DstPixel32.ul)); diff --git a/subsystems/win32/win32k/dib/dib24bpp.c b/subsystems/win32/win32k/dib/dib24bpp.c index 86c87e5da73..0642862b0b1 100644 --- a/subsystems/win32/win32k/dib/dib24bpp.c +++ b/subsystems/win32/win32k/dib/dib24bpp.c @@ -509,28 +509,22 @@ DIB_24BPP_AlphaBlend(SURFOBJ* Dest, SURFOBJ* Source, RECTL* DestRect, SrcX = SourceRect->left; while (++Cols <= DestRect->right - DestRect->left) { + SrcPixel.ul = DIB_GetSource(Source, SrcX, SrcY, ColorTranslation); + SrcPixel.col.red = (SrcPixel.col.red * BlendFunc.SourceConstantAlpha) / 255; + SrcPixel.col.green = (SrcPixel.col.green * BlendFunc.SourceConstantAlpha) / 255; + SrcPixel.col.blue = (SrcPixel.col.blue * BlendFunc.SourceConstantAlpha) / 255; if (!(BlendFunc.AlphaFormat & AC_SRC_ALPHA)) { - SrcPixel.ul = DIB_GetSource(Source, SrcX, SrcY, ColorTranslation); - SrcPixel.col.red *= BlendFunc.SourceConstantAlpha / 255; - SrcPixel.col.green *= BlendFunc.SourceConstantAlpha / 255; - SrcPixel.col.blue *= BlendFunc.SourceConstantAlpha / 255; - Alpha = BlendFunc.SourceConstantAlpha ; + Alpha = BlendFunc.SourceConstantAlpha ; } else { - SrcPixel.ul = DIB_GetSourceIndex(Source, SrcX, SrcY); - SrcPixel.col.red *= BlendFunc.SourceConstantAlpha / 255; - SrcPixel.col.green *= BlendFunc.SourceConstantAlpha / 255; - SrcPixel.col.blue *= BlendFunc.SourceConstantAlpha / 255; - SrcPixel.col.alpha *= BlendFunc.SourceConstantAlpha / 255; - - Alpha = SrcPixel.col.alpha; + Alpha = (SrcPixel.col.alpha * BlendFunc.SourceConstantAlpha) / 255; } - DstPixel.col.red = (*Dst) * (255 - Alpha) / 255 + SrcPixel.col.red ; - DstPixel.col.green = *(Dst+1) * (255 - Alpha) / 255 + SrcPixel.col.green ; - DstPixel.col.blue = *(Dst+2) * (255 - Alpha) / 255 + SrcPixel.col.blue ; + DstPixel.col.red = Clamp8((*Dst * (255 - Alpha)) / 255 + SrcPixel.col.red) ; + DstPixel.col.green = Clamp8((*(Dst+1) * (255 - Alpha) / 255 + SrcPixel.col.green)) ; + DstPixel.col.blue = Clamp8((*(Dst+2) * (255 - Alpha)) / 255 + SrcPixel.col.blue) ; *Dst++ = DstPixel.col.red; *Dst++ = DstPixel.col.green; *Dst++ = DstPixel.col.blue; diff --git a/subsystems/win32/win32k/dib/dib32bpp.c b/subsystems/win32/win32k/dib/dib32bpp.c index 84a0b7d0bb4..50c819380ce 100644 --- a/subsystems/win32/win32k/dib/dib32bpp.c +++ b/subsystems/win32/win32k/dib/dib32bpp.c @@ -392,21 +392,21 @@ DIB_32BPP_AlphaBlend(SURFOBJ* Dest, SURFOBJ* Source, RECTL* DestRect, while (++Cols <= DestRect->right - DestRect->left) { SrcPixel.ul = DIB_GetSource(Source, SrcX, SrcY, ColorTranslation); - SrcPixel.col.red *= BlendFunc.SourceConstantAlpha / 255; - SrcPixel.col.green *= BlendFunc.SourceConstantAlpha / 255; - SrcPixel.col.blue *= BlendFunc.SourceConstantAlpha / 255; + SrcPixel.col.red = (SrcPixel.col.red * BlendFunc.SourceConstantAlpha) / 255; + SrcPixel.col.green = (SrcPixel.col.green * BlendFunc.SourceConstantAlpha) / 255; + SrcPixel.col.blue = (SrcPixel.col.blue * BlendFunc.SourceConstantAlpha) / 255; SrcPixel.col.alpha = (32 == SrcBpp) ? - SrcPixel.col.alpha * BlendFunc.SourceConstantAlpha / 255 : + (SrcPixel.col.alpha * BlendFunc.SourceConstantAlpha) / 255 : BlendFunc.SourceConstantAlpha ; Alpha = ((BlendFunc.AlphaFormat & AC_SRC_ALPHA) != 0) ? SrcPixel.col.alpha : BlendFunc.SourceConstantAlpha ; DstPixel.ul = *Dst; - DstPixel.col.red = Clamp8(DstPixel.col.red * (255 - Alpha) / 255 + SrcPixel.col.red) ; - DstPixel.col.green = Clamp8(DstPixel.col.green * (255 - Alpha) / 255 + SrcPixel.col.green) ; - DstPixel.col.blue = Clamp8(DstPixel.col.blue * (255 - Alpha) / 255 + SrcPixel.col.blue) ; - DstPixel.col.alpha = Clamp8(DstPixel.col.alpha * (255 - Alpha) / 255 + SrcPixel.col.alpha) ; + DstPixel.col.red = Clamp8((DstPixel.col.red * (255 - Alpha)) / 255 + SrcPixel.col.red) ; + DstPixel.col.green = Clamp8((DstPixel.col.green * (255 - Alpha)) / 255 + SrcPixel.col.green) ; + DstPixel.col.blue = Clamp8((DstPixel.col.blue * (255 - Alpha)) / 255 + SrcPixel.col.blue) ; + DstPixel.col.alpha = Clamp8((DstPixel.col.alpha * (255 - Alpha)) / 255 + SrcPixel.col.alpha) ; *Dst++ = DstPixel.ul; SrcX = SourceRect->left + (Cols*(SourceRect->right - SourceRect->left))/(DestRect->right - DestRect->left); }