[WIN32K]
authorJérôme Gardou <jerome.gardou@reactos.org>
Sun, 8 Aug 2010 16:20:24 +0000 (16:20 +0000)
committerJérôme Gardou <jerome.gardou@reactos.org>
Sun, 8 Aug 2010 16:20:24 +0000 (16:20 +0000)
  - 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

subsystems/win32/win32k/dib/alphablend.c
subsystems/win32/win32k/dib/dib24bpp.c
subsystems/win32/win32k/dib/dib32bpp.c

index 8e6298f..be269cf 100644 (file)
@@ -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);
     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) ?
 
       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.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));
 
       DstPixel32.ul = XLATEOBJ_iXlate(&exloRGBSrc.xlo, DstPixel32.ul);
       pfnDibPutPixel(Dest, DstX, DstY, XLATEOBJ_iXlate(ColorTranslation, DstPixel32.ul));
 
index 86c87e5..0642862 100644 (file)
@@ -509,28 +509,22 @@ DIB_24BPP_AlphaBlend(SURFOBJ* Dest, SURFOBJ* Source, RECTL* DestRect,
     SrcX = SourceRect->left;
     while (++Cols <= DestRect->right - DestRect->left)
     {
     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))
       {
       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
       {
       }
       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;
       *Dst++ = DstPixel.col.red;
       *Dst++ = DstPixel.col.green;
       *Dst++ = DstPixel.col.blue;
index 84a0b7d..50c8193 100644 (file)
@@ -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);
     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 = (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;
                         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);
     }
       *Dst++ = DstPixel.ul;
       SrcX = SourceRect->left + (Cols*(SourceRect->right - SourceRect->left))/(DestRect->right - DestRect->left);
     }