- Replace old headers with new ones, programmers added according to svn blame info
- Apply consistent 2pt indentation because of the many indentation levels in this code; getting rid of a tab and 2/3/4pt mixture
- Rename universal StretchBlt file to reflect content
svn path=/trunk/; revision=42339
/*
- * ReactOS W32 Subsystem
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * PROJECT: Win32 subsystem
+ * LICENSE: See COPYING in the top level directory
+ * FILE: subsystems/win32/win32k/dib/dib.c
+ * PURPOSE: ROP handling, function pointer arrays, misc
+ * PROGRAMMERS: Ge van Geldorp
*/
-/* $Id$ */
+
#include <w32k.h>
DIB_FUNCTIONS DibFunctionsForBitmapFormat[] =
{
- /* 0 */
- {
- Dummy_PutPixel, Dummy_GetPixel, Dummy_HLine, Dummy_VLine,
- Dummy_BitBlt, Dummy_BitBlt, Dummy_StretchBlt, Dummy_TransparentBlt,
- Dummy_ColorFill, Dummy_AlphaBlend
- },
- /* BMF_1BPP */
- {
- DIB_1BPP_PutPixel, DIB_1BPP_GetPixel, DIB_1BPP_HLine, DIB_1BPP_VLine,
- DIB_1BPP_BitBlt, DIB_1BPP_BitBltSrcCopy, DIB_XXBPP_StretchBlt,
- DIB_1BPP_TransparentBlt, DIB_1BPP_ColorFill, DIB_1BPP_AlphaBlend
- },
- /* BMF_4BPP */
- {
- DIB_4BPP_PutPixel, DIB_4BPP_GetPixel, DIB_4BPP_HLine, DIB_4BPP_VLine,
- DIB_4BPP_BitBlt, DIB_4BPP_BitBltSrcCopy, DIB_XXBPP_StretchBlt,
- DIB_4BPP_TransparentBlt, DIB_4BPP_ColorFill, DIB_4BPP_AlphaBlend
- },
- /* BMF_8BPP */
- {
- DIB_8BPP_PutPixel, DIB_8BPP_GetPixel, DIB_8BPP_HLine, DIB_8BPP_VLine,
- DIB_8BPP_BitBlt, DIB_8BPP_BitBltSrcCopy, DIB_XXBPP_StretchBlt,
- DIB_8BPP_TransparentBlt, DIB_8BPP_ColorFill, DIB_8BPP_AlphaBlend
- },
- /* BMF_16BPP */
- {
- DIB_16BPP_PutPixel, DIB_16BPP_GetPixel, DIB_16BPP_HLine, DIB_16BPP_VLine,
- DIB_16BPP_BitBlt, DIB_16BPP_BitBltSrcCopy, DIB_XXBPP_StretchBlt,
- DIB_16BPP_TransparentBlt, DIB_16BPP_ColorFill, DIB_16BPP_AlphaBlend
- },
- /* BMF_24BPP */
- {
- DIB_24BPP_PutPixel, DIB_24BPP_GetPixel, DIB_24BPP_HLine, DIB_24BPP_VLine,
- DIB_24BPP_BitBlt, DIB_24BPP_BitBltSrcCopy, DIB_XXBPP_StretchBlt,
- DIB_24BPP_TransparentBlt, DIB_24BPP_ColorFill, DIB_24BPP_AlphaBlend
- },
- /* BMF_32BPP */
- {
- DIB_32BPP_PutPixel, DIB_32BPP_GetPixel, DIB_32BPP_HLine, DIB_32BPP_VLine,
- DIB_32BPP_BitBlt, DIB_32BPP_BitBltSrcCopy, DIB_XXBPP_StretchBlt,
- DIB_32BPP_TransparentBlt, DIB_32BPP_ColorFill, DIB_32BPP_AlphaBlend
- },
- /* BMF_4RLE */
- {
- Dummy_PutPixel, Dummy_GetPixel, Dummy_HLine, Dummy_VLine,
- Dummy_BitBlt, Dummy_BitBlt, Dummy_StretchBlt, Dummy_TransparentBlt,
- Dummy_ColorFill, Dummy_AlphaBlend
- },
- /* BMF_8RLE */
- {
- Dummy_PutPixel, Dummy_GetPixel, Dummy_HLine, Dummy_VLine,
- Dummy_BitBlt, Dummy_BitBlt, Dummy_StretchBlt, Dummy_TransparentBlt,
- Dummy_ColorFill, Dummy_AlphaBlend
- },
- /* BMF_JPEG */
- {
- Dummy_PutPixel, Dummy_GetPixel, Dummy_HLine, Dummy_VLine,
- Dummy_BitBlt, Dummy_BitBlt, Dummy_StretchBlt, Dummy_TransparentBlt,
- Dummy_ColorFill, Dummy_AlphaBlend
- },
- /* BMF_PNG */
- {
- Dummy_PutPixel, Dummy_GetPixel, Dummy_HLine, Dummy_VLine,
- Dummy_BitBlt, Dummy_BitBlt, Dummy_StretchBlt, Dummy_TransparentBlt,
- Dummy_ColorFill, Dummy_AlphaBlend
- }
+ /* 0 */
+ {
+ Dummy_PutPixel, Dummy_GetPixel, Dummy_HLine, Dummy_VLine,
+ Dummy_BitBlt, Dummy_BitBlt, Dummy_StretchBlt, Dummy_TransparentBlt,
+ Dummy_ColorFill, Dummy_AlphaBlend
+ },
+ /* BMF_1BPP */
+ {
+ DIB_1BPP_PutPixel, DIB_1BPP_GetPixel, DIB_1BPP_HLine, DIB_1BPP_VLine,
+ DIB_1BPP_BitBlt, DIB_1BPP_BitBltSrcCopy, DIB_XXBPP_StretchBlt,
+ DIB_1BPP_TransparentBlt, DIB_1BPP_ColorFill, DIB_1BPP_AlphaBlend
+ },
+ /* BMF_4BPP */
+ {
+ DIB_4BPP_PutPixel, DIB_4BPP_GetPixel, DIB_4BPP_HLine, DIB_4BPP_VLine,
+ DIB_4BPP_BitBlt, DIB_4BPP_BitBltSrcCopy, DIB_XXBPP_StretchBlt,
+ DIB_4BPP_TransparentBlt, DIB_4BPP_ColorFill, DIB_4BPP_AlphaBlend
+ },
+ /* BMF_8BPP */
+ {
+ DIB_8BPP_PutPixel, DIB_8BPP_GetPixel, DIB_8BPP_HLine, DIB_8BPP_VLine,
+ DIB_8BPP_BitBlt, DIB_8BPP_BitBltSrcCopy, DIB_XXBPP_StretchBlt,
+ DIB_8BPP_TransparentBlt, DIB_8BPP_ColorFill, DIB_8BPP_AlphaBlend
+ },
+ /* BMF_16BPP */
+ {
+ DIB_16BPP_PutPixel, DIB_16BPP_GetPixel, DIB_16BPP_HLine, DIB_16BPP_VLine,
+ DIB_16BPP_BitBlt, DIB_16BPP_BitBltSrcCopy, DIB_XXBPP_StretchBlt,
+ DIB_16BPP_TransparentBlt, DIB_16BPP_ColorFill, DIB_16BPP_AlphaBlend
+ },
+ /* BMF_24BPP */
+ {
+ DIB_24BPP_PutPixel, DIB_24BPP_GetPixel, DIB_24BPP_HLine, DIB_24BPP_VLine,
+ DIB_24BPP_BitBlt, DIB_24BPP_BitBltSrcCopy, DIB_XXBPP_StretchBlt,
+ DIB_24BPP_TransparentBlt, DIB_24BPP_ColorFill, DIB_24BPP_AlphaBlend
+ },
+ /* BMF_32BPP */
+ {
+ DIB_32BPP_PutPixel, DIB_32BPP_GetPixel, DIB_32BPP_HLine, DIB_32BPP_VLine,
+ DIB_32BPP_BitBlt, DIB_32BPP_BitBltSrcCopy, DIB_XXBPP_StretchBlt,
+ DIB_32BPP_TransparentBlt, DIB_32BPP_ColorFill, DIB_32BPP_AlphaBlend
+ },
+ /* BMF_4RLE */
+ {
+ Dummy_PutPixel, Dummy_GetPixel, Dummy_HLine, Dummy_VLine,
+ Dummy_BitBlt, Dummy_BitBlt, Dummy_StretchBlt, Dummy_TransparentBlt,
+ Dummy_ColorFill, Dummy_AlphaBlend
+ },
+ /* BMF_8RLE */
+ {
+ Dummy_PutPixel, Dummy_GetPixel, Dummy_HLine, Dummy_VLine,
+ Dummy_BitBlt, Dummy_BitBlt, Dummy_StretchBlt, Dummy_TransparentBlt,
+ Dummy_ColorFill, Dummy_AlphaBlend
+ },
+ /* BMF_JPEG */
+ {
+ Dummy_PutPixel, Dummy_GetPixel, Dummy_HLine, Dummy_VLine,
+ Dummy_BitBlt, Dummy_BitBlt, Dummy_StretchBlt, Dummy_TransparentBlt,
+ Dummy_ColorFill, Dummy_AlphaBlend
+ },
+ /* BMF_PNG */
+ {
+ Dummy_PutPixel, Dummy_GetPixel, Dummy_HLine, Dummy_VLine,
+ Dummy_BitBlt, Dummy_BitBlt, Dummy_StretchBlt, Dummy_TransparentBlt,
+ Dummy_ColorFill, Dummy_AlphaBlend
+ }
};
ULONG
ULONG ResultNibble;
ULONG Result;
ULONG i;
- static const ULONG ExpandDest[16] =
+static const ULONG ExpandDest[16] =
{
0x55555555 /* 0000 */,
0x555555AA /* 0001 */,
/* Do the operation on four bits simultaneously. */
Result = 0;
for (i = 0; i < 8; i++)
- {
- ResultNibble = Rop & ExpandDest[Dest & 0xF] & ExpandSource[Source & 0xF] & ExpandPattern[Pattern & 0xF];
- Result |= (((ResultNibble & 0xFF000000) ? 0x8 : 0x0) | ((ResultNibble & 0x00FF0000) ? 0x4 : 0x0) |
- ((ResultNibble & 0x0000FF00) ? 0x2 : 0x0) | ((ResultNibble & 0x000000FF) ? 0x1 : 0x0)) << (i * 4);
- Dest >>= 4;
- Source >>= 4;
- Pattern >>= 4;
- }
+ {
+ ResultNibble = Rop & ExpandDest[Dest & 0xF] & ExpandSource[Source & 0xF] & ExpandPattern[Pattern & 0xF];
+ Result |= (((ResultNibble & 0xFF000000) ? 0x8 : 0x0) | ((ResultNibble & 0x00FF0000) ? 0x4 : 0x0) |
+ ((ResultNibble & 0x0000FF00) ? 0x2 : 0x0) | ((ResultNibble & 0x000000FF) ? 0x1 : 0x0)) << (i * 4);
+ Dest >>= 4;
+ Source >>= 4;
+ Pattern >>= 4;
+ }
return(Result);
}
#define memset4(dest, value, count) asm volatile("rep stosl" : : "D"(dest), "a"(value), "c"(count) : "memory");
#endif
-#define ROP4_BLACKNESS ((((0x00000042) >> 8) & 0xff00) | (((0x00000042) >> 16) & 0x00ff))
+#define ROP4_BLACKNESS ((((0x00000042) >> 8) & 0xff00) | (((0x00000042) >> 16) & 0x00ff))
#define ROP4_NOTSRCERASE ((((0x001100A6) >> 8) & 0xff00) | (((0x001100A6) >> 16) & 0x00ff))
-#define ROP4_NOTSRCCOPY ((((0x00330008) >> 8) & 0xff00) | (((0x00330008) >> 16) & 0x00ff))
-#define ROP4_SRCERASE ((((0x00440328) >> 8) & 0xff00) | (((0x00440328) >> 16) & 0x00ff))
-#define ROP4_DSTINVERT ((((0x00550009) >> 8) & 0xff00) | (((0x00550009) >> 16) & 0x00ff))
-#define ROP4_PATINVERT ((((0x005A0049) >> 8) & 0xff00) | (((0x005A0049) >> 16) & 0x00ff))
-#define ROP4_SRCINVERT ((((0x00660046) >> 8) & 0xff00) | (((0x00660046) >> 16) & 0x00ff))
-#define ROP4_SRCAND ((((0x008800C6) >> 8) & 0xff00) | (((0x008800C6) >> 16) & 0x00ff))
-#define ROP4_MERGEPAINT ((((0x00BB0226) >> 8) & 0xff00) | (((0x00BB0226) >> 16) & 0x00ff))
-#define ROP4_MERGECOPY ((((0x00C000CA) >> 8) & 0xff00) | (((0x00C000CA) >> 16) & 0x00ff))
-#define ROP4_SRCCOPY ((((0x00CC0020) >> 8) & 0xff00) | (((0x00CC0020) >> 16) & 0x00ff))
-#define ROP4_SRCPAINT ((((0x00EE0086) >> 8) & 0xff00) | (((0x00EE0086) >> 16) & 0x00ff))
-#define ROP4_PATCOPY ((((0x00F00021) >> 8) & 0xff00) | (((0x00F00021) >> 16) & 0x00ff))
-#define ROP4_PATPAINT ((((0x00FB0A09) >> 8) & 0xff00) | (((0x00FB0A09) >> 16) & 0x00ff))
-#define ROP4_WHITENESS ((((0x00FF0062) >> 8) & 0xff00) | (((0x00FF0062) >> 16) & 0x00ff))
+#define ROP4_NOTSRCCOPY ((((0x00330008) >> 8) & 0xff00) | (((0x00330008) >> 16) & 0x00ff))
+#define ROP4_SRCERASE ((((0x00440328) >> 8) & 0xff00) | (((0x00440328) >> 16) & 0x00ff))
+#define ROP4_DSTINVERT ((((0x00550009) >> 8) & 0xff00) | (((0x00550009) >> 16) & 0x00ff))
+#define ROP4_PATINVERT ((((0x005A0049) >> 8) & 0xff00) | (((0x005A0049) >> 16) & 0x00ff))
+#define ROP4_SRCINVERT ((((0x00660046) >> 8) & 0xff00) | (((0x00660046) >> 16) & 0x00ff))
+#define ROP4_SRCAND ((((0x008800C6) >> 8) & 0xff00) | (((0x008800C6) >> 16) & 0x00ff))
+#define ROP4_MERGEPAINT ((((0x00BB0226) >> 8) & 0xff00) | (((0x00BB0226) >> 16) & 0x00ff))
+#define ROP4_MERGECOPY ((((0x00C000CA) >> 8) & 0xff00) | (((0x00C000CA) >> 16) & 0x00ff))
+#define ROP4_SRCCOPY ((((0x00CC0020) >> 8) & 0xff00) | (((0x00CC0020) >> 16) & 0x00ff))
+#define ROP4_SRCPAINT ((((0x00EE0086) >> 8) & 0xff00) | (((0x00EE0086) >> 16) & 0x00ff))
+#define ROP4_PATCOPY ((((0x00F00021) >> 8) & 0xff00) | (((0x00F00021) >> 16) & 0x00ff))
+#define ROP4_PATPAINT ((((0x00FB0A09) >> 8) & 0xff00) | (((0x00FB0A09) >> 16) & 0x00ff))
+#define ROP4_WHITENESS ((((0x00FF0062) >> 8) & 0xff00) | (((0x00FF0062) >> 16) & 0x00ff))
typedef struct _BLTINFO
{
- SURFOBJ *DestSurface;
- SURFOBJ *SourceSurface;
- SURFOBJ *PatternSurface;
- XLATEOBJ *XlateSourceToDest;
- XLATEOBJ *XlatePatternToDest;
- RECTL DestRect;
- POINTL SourcePoint;
- BRUSHOBJ *Brush;
- POINTL BrushOrigin;
- ULONG Rop4;
+ SURFOBJ *DestSurface;
+ SURFOBJ *SourceSurface;
+ SURFOBJ *PatternSurface;
+ XLATEOBJ *XlateSourceToDest;
+ XLATEOBJ *XlatePatternToDest;
+ RECTL DestRect;
+ POINTL SourcePoint;
+ BRUSHOBJ *Brush;
+ POINTL BrushOrigin;
+ ULONG Rop4;
} BLTINFO, *PBLTINFO;
typedef VOID (*PFN_DIB_PutPixel)(SURFOBJ*,LONG,LONG,ULONG);
ULONG DIB_DoRop(ULONG Rop, ULONG Dest, ULONG Source, ULONG Pattern);
-#define DIB_GetSource(SourceSurf,sx,sy,ColorTranslation) \
- XLATEOBJ_iXlate(ColorTranslation, \
- DibFunctionsForBitmapFormat[SourceSurf->iBitmapFormat]. \
- DIB_GetPixel(SourceSurf, sx, sy))
+#define DIB_GetSource(SourceSurf,sx,sy,ColorTranslation) \
+ XLATEOBJ_iXlate(ColorTranslation, \
+ DibFunctionsForBitmapFormat[SourceSurf->iBitmapFormat]. \
+ DIB_GetPixel(SourceSurf, sx, sy))
-#define DIB_GetSourceIndex(SourceSurf,sx,sy) \
- DibFunctionsForBitmapFormat[SourceSurf->iBitmapFormat]. \
- DIB_GetPixel(SourceSurf, sx, sy)
+#define DIB_GetSourceIndex(SourceSurf,sx,sy) \
+ DibFunctionsForBitmapFormat[SourceSurf->iBitmapFormat]. \
+ DIB_GetPixel(SourceSurf, sx, sy)
#endif /* _W32K_DIB_DIB_H */
/*
- * ReactOS W32 Subsystem
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * PROJECT: Win32 subsystem
+ * LICENSE: See COPYING in the top level directory
+ * FILE: subsystems/win32/win32k/dib/dib16bpp.c
+ * PURPOSE: Device Independant Bitmap functions, 16bpp
+ * PROGRAMMERS: Jason Filby
+ * Thomas Bluemel
+ * Gregor Anich
*/
#include <w32k.h>
VOID
DIB_16BPP_PutPixel(SURFOBJ *SurfObj, LONG x, LONG y, ULONG c)
{
- PBYTE byteaddr = (PBYTE)SurfObj->pvScan0 + y * SurfObj->lDelta;
- PWORD addr = (PWORD)byteaddr + x;
+ PBYTE byteaddr = (PBYTE)SurfObj->pvScan0 + y * SurfObj->lDelta;
+ PWORD addr = (PWORD)byteaddr + x;
- *addr = (WORD)c;
+ *addr = (WORD)c;
}
ULONG
DIB_16BPP_GetPixel(SURFOBJ *SurfObj, LONG x, LONG y)
{
- PBYTE byteaddr = (PBYTE)SurfObj->pvScan0 + y * SurfObj->lDelta;
- PWORD addr = (PWORD)byteaddr + x;
- return (ULONG)(*addr);
+ PBYTE byteaddr = (PBYTE)SurfObj->pvScan0 + y * SurfObj->lDelta;
+ PWORD addr = (PWORD)byteaddr + x;
+ return (ULONG)(*addr);
}
VOID
DIB_16BPP_HLine(SURFOBJ *SurfObj, LONG x1, LONG x2, LONG y, ULONG c)
{
- PDWORD addr = (PDWORD)((PWORD)((PBYTE)SurfObj->pvScan0 + y * SurfObj->lDelta) + x1);
+ PDWORD addr = (PDWORD)((PWORD)((PBYTE)SurfObj->pvScan0 + y * SurfObj->lDelta) + x1);
#if defined(_M_IX86) && !defined(_MSC_VER)
- /* This is about 10% faster than the generic C code below */
- LONG Count = x2 - x1;
+ /* This is about 10% faster than the generic C code below */
+ LONG Count = x2 - x1;
- __asm__ __volatile__ (
+ __asm__ __volatile__ (
" cld\n"
" mov %0, %%eax\n"
" shl $16, %%eax\n"
" stosw\n"
"1:\n"
: /* no output */
- : "r"(c), "r"(Count), "m"(addr)
+ : "r"(c), "r"(Count), "m"(addr)
: "%eax", "%ecx", "%edi");
#else /* _M_IX86 */
- LONG cx = x1;
- DWORD cc;
-
- if (0 != (cx & 0x01))
- {
- *((PWORD) addr) = c;
- cx++;
- addr = (PDWORD)((PWORD)(addr) + 1);
- }
- cc = ((c & 0xffff) << 16) | (c & 0xffff);
- while(cx + 1 < x2)
- {
- *addr++ = cc;
- cx += 2;
- }
- if (cx < x2)
- {
- *((PWORD) addr) = c;
- }
+ LONG cx = x1;
+ DWORD cc;
+
+ if (0 != (cx & 0x01))
+ {
+ *((PWORD) addr) = c;
+ cx++;
+ addr = (PDWORD)((PWORD)(addr) + 1);
+ }
+ cc = ((c & 0xffff) << 16) | (c & 0xffff);
+ while(cx + 1 < x2)
+ {
+ *addr++ = cc;
+ cx += 2;
+ }
+ if (cx < x2)
+ {
+ *((PWORD) addr) = c;
+ }
#endif /* _M_IX86 */
}
DIB_16BPP_VLine(SURFOBJ *SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
{
#if defined(_M_IX86) && !defined(_MSC_VER)
- asm volatile(
+ asm volatile(
" testl %2, %2" "\n\t"
" jle 2f" "\n\t"
" movl %2, %%ecx" "\n\t"
" jnz 1b" "\n\t"
"2:" "\n\t"
: /* no output */
- : "r"((PBYTE)SurfObj->pvScan0 + (y1 * SurfObj->lDelta) + (x * sizeof (WORD))),
- "r"(SurfObj->lDelta), "r"(y2 - y1), "a"(c)
+ : "r"((PBYTE)SurfObj->pvScan0 + (y1 * SurfObj->lDelta) + (x * sizeof (WORD))),
+ "r"(SurfObj->lDelta), "r"(y2 - y1), "a"(c)
: "cc", "memory", "%ecx");
#else
- PBYTE byteaddr = (PBYTE)(ULONG_PTR)SurfObj->pvScan0 + y1 * SurfObj->lDelta;
- PWORD addr = (PWORD)byteaddr + x;
- LONG lDelta = SurfObj->lDelta;
+ PBYTE byteaddr = (PBYTE)(ULONG_PTR)SurfObj->pvScan0 + y1 * SurfObj->lDelta;
+ PWORD addr = (PWORD)byteaddr + x;
+ LONG lDelta = SurfObj->lDelta;
- byteaddr = (PBYTE)addr;
- while(y1++ < y2)
- {
- *addr = (WORD)c;
+ byteaddr = (PBYTE)addr;
+ while(y1++ < y2)
+ {
+ *addr = (WORD)c;
- byteaddr += lDelta;
- addr = (PWORD)byteaddr;
- }
+ byteaddr += lDelta;
+ addr = (PWORD)byteaddr;
+ }
#endif
}
BOOLEAN
DIB_16BPP_BitBltSrcCopy(PBLTINFO BltInfo)
{
- LONG i, j, sx, sy, xColor, f1;
- PBYTE SourceBits, DestBits, SourceLine, DestLine;
- PBYTE SourceBits_4BPP, SourceLine_4BPP;
- DestBits = (PBYTE)BltInfo->DestSurface->pvScan0 + (BltInfo->DestRect.top * BltInfo->DestSurface->lDelta) + 2 * BltInfo->DestRect.left;
+ LONG i, j, sx, sy, xColor, f1;
+ PBYTE SourceBits, DestBits, SourceLine, DestLine;
+ PBYTE SourceBits_4BPP, SourceLine_4BPP;
+ DestBits = (PBYTE)BltInfo->DestSurface->pvScan0 + (BltInfo->DestRect.top * BltInfo->DestSurface->lDelta) + 2 * BltInfo->DestRect.left;
+
+ switch(BltInfo->SourceSurface->iBitmapFormat)
+ {
+ case BMF_1BPP:
+ sx = BltInfo->SourcePoint.x;
+ sy = BltInfo->SourcePoint.y;
+ for (j=BltInfo->DestRect.top; j<BltInfo->DestRect.bottom; j++)
+ {
+ sx = BltInfo->SourcePoint.x;
+ for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
+ {
+ if(DIB_1BPP_GetPixel(BltInfo->SourceSurface, sx, sy) == 0)
+ {
+ DIB_16BPP_PutPixel(BltInfo->DestSurface, i, j,
+ XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, 0));
+ }
+ else
+ {
+ DIB_16BPP_PutPixel(BltInfo->DestSurface, i, j,
+ XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, 1));
+ }
+ sx++;
+ }
+ sy++;
+ }
+ break;
+
+ case BMF_4BPP:
+ SourceBits_4BPP = (PBYTE)BltInfo->SourceSurface->pvScan0 +
+ (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) +
+ (BltInfo->SourcePoint.x >> 1);
+
+ for (j=BltInfo->DestRect.top; j<BltInfo->DestRect.bottom; j++)
+ {
+ SourceLine_4BPP = SourceBits_4BPP;
+ sx = BltInfo->SourcePoint.x;
+ f1 = sx & 1;
+
+ for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
+ {
+ xColor = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest,
+ (*SourceLine_4BPP & altnotmask[f1]) >> (4 * (1 - f1)));
+ DIB_16BPP_PutPixel(BltInfo->DestSurface, i, j, xColor);
+ if(f1 == 1)
+ {
+ SourceLine_4BPP++;
+ f1 = 0;
+ }
+ else
+ {
+ f1 = 1;
+ }
+ sx++;
+ }
+ SourceBits_4BPP += BltInfo->SourceSurface->lDelta;
+ }
+ break;
+
+ case BMF_8BPP:
+ SourceLine = (PBYTE)BltInfo->SourceSurface->pvScan0 +
+ (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) +
+ BltInfo->SourcePoint.x;
+ DestLine = DestBits;
+
+ for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
+ {
+ SourceBits = SourceLine;
+ DestBits = DestLine;
+
+ for (i = BltInfo->DestRect.left; i < BltInfo->DestRect.right; i++)
+ {
+ *((WORD *)DestBits) = (WORD)XLATEOBJ_iXlate(
+ BltInfo->XlateSourceToDest, *SourceBits);
+ SourceBits += 1;
+ DestBits += 2;
+ }
+
+ SourceLine += BltInfo->SourceSurface->lDelta;
+ DestLine += BltInfo->DestSurface->lDelta;
+ }
+ break;
+
+ case BMF_16BPP:
+ if (NULL == BltInfo->XlateSourceToDest || 0 !=
+ (BltInfo->XlateSourceToDest->flXlate & XO_TRIVIAL))
+ {
+ if (BltInfo->DestRect.top < BltInfo->SourcePoint.y)
+ {
+ SourceBits = (PBYTE)BltInfo->SourceSurface->pvScan0 +
+ (BltInfo->SourcePoint.y *
+ BltInfo->SourceSurface->lDelta) + 2 *
+ BltInfo->SourcePoint.x;
+
+ for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
+ {
+ RtlMoveMemory(DestBits, SourceBits,
+ 2 * (BltInfo->DestRect.right -
+ BltInfo->DestRect.left));
+
+ SourceBits += BltInfo->SourceSurface->lDelta;
+ DestBits += BltInfo->DestSurface->lDelta;
+ }
+ }
+ else
+ {
+ SourceBits = (PBYTE)BltInfo->SourceSurface->pvScan0 +
+ ((BltInfo->SourcePoint.y + BltInfo->DestRect.bottom -
+ BltInfo->DestRect.top - 1) *
+ BltInfo->SourceSurface->lDelta) + 2 *
+ BltInfo->SourcePoint.x;
+
+ DestBits = (PBYTE)BltInfo->DestSurface->pvScan0 +
+ ((BltInfo->DestRect.bottom - 1) *
+ BltInfo->DestSurface->lDelta) + 2 *
+ BltInfo->DestRect.left;
+
+ for (j = BltInfo->DestRect.bottom - 1;
+ BltInfo->DestRect.top <= j; j--)
+ {
+ RtlMoveMemory(DestBits, SourceBits, 2 *
+ (BltInfo->DestRect.right -
+ BltInfo->DestRect.left));
+
+ SourceBits -= BltInfo->SourceSurface->lDelta;
+ DestBits -= BltInfo->DestSurface->lDelta;
+ }
+ }
+ }
+ else
+ {
+ if (BltInfo->DestRect.top < BltInfo->SourcePoint.y)
+ {
+ SourceLine = (PBYTE)BltInfo->SourceSurface->pvScan0 +
+ (BltInfo->SourcePoint.y *
+ BltInfo->SourceSurface->lDelta) + 2 *
+ BltInfo->SourcePoint.x;
+
+ DestLine = DestBits;
+ for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
+ {
+ SourceBits = SourceLine;
+ DestBits = DestLine;
+ for (i = BltInfo->DestRect.left; i <
+ BltInfo->DestRect.right; i++)
+ {
+ *((WORD *)DestBits) = (WORD)XLATEOBJ_iXlate(
+ BltInfo->XlateSourceToDest,
+ *((WORD *)SourceBits));
+ SourceBits += 2;
+ DestBits += 2;
+ }
+ SourceLine += BltInfo->SourceSurface->lDelta;
+ DestLine += BltInfo->DestSurface->lDelta;
+ }
+ }
+ else
+ {
+ SourceLine = (PBYTE)BltInfo->SourceSurface->pvScan0 +
+ ((BltInfo->SourcePoint.y +
+ BltInfo->DestRect.bottom -
+ BltInfo->DestRect.top - 1) *
+ BltInfo->SourceSurface->lDelta) + 2 *
+ BltInfo->SourcePoint.x;
+
+ DestLine = (PBYTE)BltInfo->DestSurface->pvScan0 +
+ ((BltInfo->DestRect.bottom - 1) *
+ BltInfo->DestSurface->lDelta) + 2 *
+ BltInfo->DestRect.left;
+
+ for (j = BltInfo->DestRect.bottom - 1;
+ BltInfo->DestRect.top <= j; j--)
+ {
+ SourceBits = SourceLine;
+ DestBits = DestLine;
+ for (i = BltInfo->DestRect.left; i <
+ BltInfo->DestRect.right; i++)
+ {
+ *((WORD *)DestBits) = (WORD)XLATEOBJ_iXlate(
+ BltInfo->XlateSourceToDest,
+ *((WORD *)SourceBits));
+ SourceBits += 2;
+ DestBits += 2;
+ }
+ SourceLine -= BltInfo->SourceSurface->lDelta;
+ DestLine -= BltInfo->DestSurface->lDelta;
+ }
+ }
+ }
+ break;
+
+ case BMF_24BPP:
+ SourceLine = (PBYTE)BltInfo->SourceSurface->pvScan0 +
+ (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) +
+ 3 * BltInfo->SourcePoint.x;
+
+ DestLine = DestBits;
- switch(BltInfo->SourceSurface->iBitmapFormat)
+ for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
{
- case BMF_1BPP:
- sx = BltInfo->SourcePoint.x;
- sy = BltInfo->SourcePoint.y;
- for (j=BltInfo->DestRect.top; j<BltInfo->DestRect.bottom; j++)
- {
- sx = BltInfo->SourcePoint.x;
- for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
- {
- if(DIB_1BPP_GetPixel(BltInfo->SourceSurface, sx, sy) == 0)
- {
- DIB_16BPP_PutPixel(BltInfo->DestSurface, i, j,
- XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, 0));
- }
- else
- {
- DIB_16BPP_PutPixel(BltInfo->DestSurface, i, j,
- XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, 1));
- }
- sx++;
- }
- sy++;
- }
- break;
-
- case BMF_4BPP:
- SourceBits_4BPP = (PBYTE)BltInfo->SourceSurface->pvScan0 +
- (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) +
- (BltInfo->SourcePoint.x >> 1);
-
- for (j=BltInfo->DestRect.top; j<BltInfo->DestRect.bottom; j++)
- {
- SourceLine_4BPP = SourceBits_4BPP;
- sx = BltInfo->SourcePoint.x;
- f1 = sx & 1;
-
- for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
- {
- xColor = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest,
- (*SourceLine_4BPP & altnotmask[f1]) >> (4 * (1 - f1)));
- DIB_16BPP_PutPixel(BltInfo->DestSurface, i, j, xColor);
- if(f1 == 1)
- {
- SourceLine_4BPP++;
- f1 = 0;
- }
- else
- {
- f1 = 1;
- }
- sx++;
- }
- SourceBits_4BPP += BltInfo->SourceSurface->lDelta;
- }
- break;
-
- case BMF_8BPP:
- SourceLine = (PBYTE)BltInfo->SourceSurface->pvScan0 +
- (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) +
- BltInfo->SourcePoint.x;
- DestLine = DestBits;
-
- for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
- {
- SourceBits = SourceLine;
- DestBits = DestLine;
-
- for (i = BltInfo->DestRect.left; i < BltInfo->DestRect.right; i++)
- {
- *((WORD *)DestBits) = (WORD)XLATEOBJ_iXlate(
- BltInfo->XlateSourceToDest, *SourceBits);
- SourceBits += 1;
- DestBits += 2;
- }
-
- SourceLine += BltInfo->SourceSurface->lDelta;
- DestLine += BltInfo->DestSurface->lDelta;
- }
- break;
-
- case BMF_16BPP:
- if (NULL == BltInfo->XlateSourceToDest || 0 !=
- (BltInfo->XlateSourceToDest->flXlate & XO_TRIVIAL))
- {
- if (BltInfo->DestRect.top < BltInfo->SourcePoint.y)
- {
- SourceBits = (PBYTE)BltInfo->SourceSurface->pvScan0 +
- (BltInfo->SourcePoint.y *
- BltInfo->SourceSurface->lDelta) + 2 *
- BltInfo->SourcePoint.x;
-
- for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
- {
- RtlMoveMemory(DestBits, SourceBits,
- 2 * (BltInfo->DestRect.right -
- BltInfo->DestRect.left));
-
- SourceBits += BltInfo->SourceSurface->lDelta;
- DestBits += BltInfo->DestSurface->lDelta;
- }
- }
- else
- {
- SourceBits = (PBYTE)BltInfo->SourceSurface->pvScan0 +
- ((BltInfo->SourcePoint.y + BltInfo->DestRect.bottom -
- BltInfo->DestRect.top - 1) *
- BltInfo->SourceSurface->lDelta) + 2 *
- BltInfo->SourcePoint.x;
-
- DestBits = (PBYTE)BltInfo->DestSurface->pvScan0 +
- ((BltInfo->DestRect.bottom - 1) *
- BltInfo->DestSurface->lDelta) + 2 *
- BltInfo->DestRect.left;
-
- for (j = BltInfo->DestRect.bottom - 1;
- BltInfo->DestRect.top <= j; j--)
- {
- RtlMoveMemory(DestBits, SourceBits, 2 *
- (BltInfo->DestRect.right -
- BltInfo->DestRect.left));
-
- SourceBits -= BltInfo->SourceSurface->lDelta;
- DestBits -= BltInfo->DestSurface->lDelta;
- }
- }
- }
- else
- {
- if (BltInfo->DestRect.top < BltInfo->SourcePoint.y)
- {
- SourceLine = (PBYTE)BltInfo->SourceSurface->pvScan0 +
- (BltInfo->SourcePoint.y *
- BltInfo->SourceSurface->lDelta) + 2 *
- BltInfo->SourcePoint.x;
-
- DestLine = DestBits;
- for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
- {
- SourceBits = SourceLine;
- DestBits = DestLine;
- for (i = BltInfo->DestRect.left; i <
- BltInfo->DestRect.right; i++)
- {
- *((WORD *)DestBits) = (WORD)XLATEOBJ_iXlate(
- BltInfo->XlateSourceToDest,
- *((WORD *)SourceBits));
- SourceBits += 2;
- DestBits += 2;
- }
- SourceLine += BltInfo->SourceSurface->lDelta;
- DestLine += BltInfo->DestSurface->lDelta;
- }
- }
- else
- {
- SourceLine = (PBYTE)BltInfo->SourceSurface->pvScan0 +
- ((BltInfo->SourcePoint.y +
- BltInfo->DestRect.bottom -
- BltInfo->DestRect.top - 1) *
- BltInfo->SourceSurface->lDelta) + 2 *
- BltInfo->SourcePoint.x;
-
- DestLine = (PBYTE)BltInfo->DestSurface->pvScan0 +
- ((BltInfo->DestRect.bottom - 1) *
- BltInfo->DestSurface->lDelta) + 2 *
- BltInfo->DestRect.left;
-
- for (j = BltInfo->DestRect.bottom - 1;
- BltInfo->DestRect.top <= j; j--)
- {
- SourceBits = SourceLine;
- DestBits = DestLine;
- for (i = BltInfo->DestRect.left; i <
- BltInfo->DestRect.right; i++)
- {
- *((WORD *)DestBits) = (WORD)XLATEOBJ_iXlate(
- BltInfo->XlateSourceToDest,
- *((WORD *)SourceBits));
- SourceBits += 2;
- DestBits += 2;
- }
- SourceLine -= BltInfo->SourceSurface->lDelta;
- DestLine -= BltInfo->DestSurface->lDelta;
- }
- }
- }
- break;
-
- case BMF_24BPP:
- SourceLine = (PBYTE)BltInfo->SourceSurface->pvScan0 +
- (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) +
- 3 * BltInfo->SourcePoint.x;
-
- DestLine = DestBits;
-
- for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
- {
- SourceBits = SourceLine;
- DestBits = DestLine;
-
- for (i = BltInfo->DestRect.left; i < BltInfo->DestRect.right; i++)
- {
- xColor = (*(SourceBits + 2) << 0x10) +
- (*(SourceBits + 1) << 0x08) + (*(SourceBits));
-
- *((WORD *)DestBits) = (WORD)XLATEOBJ_iXlate(
- BltInfo->XlateSourceToDest, xColor);
-
- SourceBits += 3;
- DestBits += 2;
- }
- SourceLine += BltInfo->SourceSurface->lDelta;
- DestLine += BltInfo->DestSurface->lDelta;
- }
- break;
-
- case BMF_32BPP:
- SourceLine = (PBYTE)BltInfo->SourceSurface->pvScan0 +
- (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) +
- 4 * BltInfo->SourcePoint.x;
-
- DestLine = DestBits;
-
- for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
- {
- SourceBits = SourceLine;
- DestBits = DestLine;
-
- for (i = BltInfo->DestRect.left; i < BltInfo->DestRect.right; i++)
- {
- *((WORD *)DestBits) = (WORD)XLATEOBJ_iXlate(
- BltInfo->XlateSourceToDest,
- *((PDWORD) SourceBits));
- SourceBits += 4;
- DestBits += 2;
- }
-
- SourceLine += BltInfo->SourceSurface->lDelta;
- DestLine += BltInfo->DestSurface->lDelta;
- }
- break;
-
- default:
- DPRINT1("DIB_16BPP_Bitblt: Unhandled Source BPP: %u\n",
- BitsPerFormat(BltInfo->SourceSurface->iBitmapFormat));
- return FALSE;
+ SourceBits = SourceLine;
+ DestBits = DestLine;
+
+ for (i = BltInfo->DestRect.left; i < BltInfo->DestRect.right; i++)
+ {
+ xColor = (*(SourceBits + 2) << 0x10) +
+ (*(SourceBits + 1) << 0x08) + (*(SourceBits));
+
+ *((WORD *)DestBits) = (WORD)XLATEOBJ_iXlate(
+ BltInfo->XlateSourceToDest, xColor);
+
+ SourceBits += 3;
+ DestBits += 2;
+ }
+ SourceLine += BltInfo->SourceSurface->lDelta;
+ DestLine += BltInfo->DestSurface->lDelta;
+ }
+ break;
+
+ case BMF_32BPP:
+ SourceLine = (PBYTE)BltInfo->SourceSurface->pvScan0 +
+ (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) +
+ 4 * BltInfo->SourcePoint.x;
+
+ DestLine = DestBits;
+
+ for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
+ {
+ SourceBits = SourceLine;
+ DestBits = DestLine;
+
+ for (i = BltInfo->DestRect.left; i < BltInfo->DestRect.right; i++)
+ {
+ *((WORD *)DestBits) = (WORD)XLATEOBJ_iXlate(
+ BltInfo->XlateSourceToDest,
+ *((PDWORD) SourceBits));
+ SourceBits += 4;
+ DestBits += 2;
+ }
+
+ SourceLine += BltInfo->SourceSurface->lDelta;
+ DestLine += BltInfo->DestSurface->lDelta;
}
+ break;
- return TRUE;
+ default:
+ DPRINT1("DIB_16BPP_Bitblt: Unhandled Source BPP: %u\n",
+ BitsPerFormat(BltInfo->SourceSurface->iBitmapFormat));
+ return FALSE;
+ }
+
+ return TRUE;
}
/* Optimize for bitBlt */
BOOLEAN
DIB_16BPP_ColorFill(SURFOBJ* DestSurface, RECTL* DestRect, ULONG color)
{
- ULONG DestY;
+ ULONG DestY;
#if defined(_M_IX86) && !defined(_MSC_VER)
- /* This is about 10% faster than the generic C code below */
- ULONG delta = DestSurface->lDelta;
- ULONG width = (DestRect->right - DestRect->left) ;
- PULONG pos = (PULONG) ((PBYTE)DestSurface->pvScan0 + DestRect->top * delta + (DestRect->left<<1));
- color = (color&0xffff); /* If the color value is "abcd", put "abcdabcd" into color */
- color += (color<<16);
-
- for (DestY = DestRect->top; DestY< DestRect->bottom; DestY++)
- {
- __asm__ __volatile__ (
- " cld\n"
- " mov %1,%%ebx\n"
- " mov %2,%%edi\n"
- " test $0x03, %%edi\n" /* Align to fullword boundary */
- " jz .FL1\n"
- " stosw\n"
- " dec %%ebx\n"
- " jz .FL2\n"
- ".FL1:\n"
- " mov %%ebx,%%ecx\n" /* Setup count of fullwords to fill */
- " shr $1,%%ecx\n"
- " rep stosl\n" /* The actual fill */
- " test $0x01, %%ebx\n" /* One left to do at the right side? */
- " jz .FL2\n"
- " stosw\n"
- ".FL2:\n"
- :
- : "a" (color), "r" (width), "m" (pos)
- : "%ecx", "%ebx", "%edi");
- pos =(PULONG)((ULONG_PTR)pos + delta);
- }
+ /* This is about 10% faster than the generic C code below */
+ ULONG delta = DestSurface->lDelta;
+ ULONG width = (DestRect->right - DestRect->left) ;
+ PULONG pos = (PULONG) ((PBYTE)DestSurface->pvScan0 + DestRect->top * delta + (DestRect->left<<1));
+ color = (color&0xffff); /* If the color value is "abcd", put "abcdabcd" into color */
+ color += (color<<16);
+
+ for (DestY = DestRect->top; DestY< DestRect->bottom; DestY++)
+ {
+ __asm__ __volatile__ (
+ " cld\n"
+ " mov %1,%%ebx\n"
+ " mov %2,%%edi\n"
+ " test $0x03, %%edi\n" /* Align to fullword boundary */
+ " jz .FL1\n"
+ " stosw\n"
+ " dec %%ebx\n"
+ " jz .FL2\n"
+ ".FL1:\n"
+ " mov %%ebx,%%ecx\n" /* Setup count of fullwords to fill */
+ " shr $1,%%ecx\n"
+ " rep stosl\n" /* The actual fill */
+ " test $0x01, %%ebx\n" /* One left to do at the right side? */
+ " jz .FL2\n"
+ " stosw\n"
+ ".FL2:\n"
+ :
+ : "a" (color), "r" (width), "m" (pos)
+ : "%ecx", "%ebx", "%edi");
+ pos =(PULONG)((ULONG_PTR)pos + delta);
+ }
#else /* _M_IX86 */
- for (DestY = DestRect->top; DestY< DestRect->bottom; DestY++)
- {
- DIB_16BPP_HLine (DestSurface, DestRect->left, DestRect->right, DestY, color);
- }
+ for (DestY = DestRect->top; DestY< DestRect->bottom; DestY++)
+ {
+ DIB_16BPP_HLine (DestSurface, DestRect->left, DestRect->right, DestY, color);
+ }
#endif
- return TRUE;
+ return TRUE;
}
BOOLEAN
RECTL* DestRect, RECTL *SourceRect,
XLATEOBJ *ColorTranslation, ULONG iTransColor)
{
- ULONG RoundedRight, X, Y, SourceX = 0, SourceY = 0, Source, wd, Dest;
- ULONG *DestBits;
-
- LONG DstHeight;
- LONG DstWidth;
- LONG SrcHeight;
- LONG SrcWidth;
-
- DstHeight = DestRect->bottom - DestRect->top;
- DstWidth = DestRect->right - DestRect->left;
- SrcHeight = SourceRect->bottom - SourceRect->top;
- SrcWidth = SourceRect->right - SourceRect->left;
-
- RoundedRight = DestRect->right - ((DestRect->right - DestRect->left) & 0x1);
- DestBits = (ULONG*)((PBYTE)DestSurf->pvScan0 +
- (DestRect->left << 1) +
- DestRect->top * DestSurf->lDelta);
- wd = DestSurf->lDelta - ((DestRect->right - DestRect->left) << 1);
-
- for(Y = DestRect->top; Y < DestRect->bottom; Y++)
+ ULONG RoundedRight, X, Y, SourceX = 0, SourceY = 0, Source, wd, Dest;
+ ULONG *DestBits;
+
+ LONG DstHeight;
+ LONG DstWidth;
+ LONG SrcHeight;
+ LONG SrcWidth;
+
+ DstHeight = DestRect->bottom - DestRect->top;
+ DstWidth = DestRect->right - DestRect->left;
+ SrcHeight = SourceRect->bottom - SourceRect->top;
+ SrcWidth = SourceRect->right - SourceRect->left;
+
+ RoundedRight = DestRect->right - ((DestRect->right - DestRect->left) & 0x1);
+ DestBits = (ULONG*)((PBYTE)DestSurf->pvScan0 +
+ (DestRect->left << 1) +
+ DestRect->top * DestSurf->lDelta);
+ wd = DestSurf->lDelta - ((DestRect->right - DestRect->left) << 1);
+
+ for(Y = DestRect->top; Y < DestRect->bottom; Y++)
+ {
+ SourceY = SourceRect->top+(Y - DestRect->top) * SrcHeight / DstHeight;
+ for(X = DestRect->left; X < RoundedRight; X += 2, DestBits++, SourceX += 2)
{
- SourceY = SourceRect->top+(Y - DestRect->top) * SrcHeight / DstHeight;
- for(X = DestRect->left; X < RoundedRight; X += 2, DestBits++, SourceX += 2)
+ Dest = *DestBits;
+
+ SourceX = SourceRect->left+(X - DestRect->left) * SrcWidth / DstWidth;
+ if (SourceX >= 0 && SourceY >= 0 &&
+ SourceSurf->sizlBitmap.cx > SourceX && SourceSurf->sizlBitmap.cy > SourceY)
+ {
+ Source = DIB_GetSourceIndex(SourceSurf, SourceX, SourceY);
+ if(Source != iTransColor)
+ {
+ Dest &= 0xFFFF0000;
+ Dest |= (XLATEOBJ_iXlate(ColorTranslation, Source) & 0xFFFF);
+ }
+ }
+
+ SourceX = SourceRect->left+(X+1 - DestRect->left) * SrcWidth / DstWidth;
+ if (SourceX >= 0 && SourceY >= 0 &&
+ SourceSurf->sizlBitmap.cx > SourceX && SourceSurf->sizlBitmap.cy > SourceY)
+ {
+ Source = DIB_GetSourceIndex(SourceSurf, SourceX, SourceY);
+ if(Source != iTransColor)
{
- Dest = *DestBits;
-
- SourceX = SourceRect->left+(X - DestRect->left) * SrcWidth / DstWidth;
- if (SourceX >= 0 && SourceY >= 0 &&
- SourceSurf->sizlBitmap.cx > SourceX && SourceSurf->sizlBitmap.cy > SourceY)
- {
- Source = DIB_GetSourceIndex(SourceSurf, SourceX, SourceY);
- if(Source != iTransColor)
- {
- Dest &= 0xFFFF0000;
- Dest |= (XLATEOBJ_iXlate(ColorTranslation, Source) & 0xFFFF);
- }
- }
-
- SourceX = SourceRect->left+(X+1 - DestRect->left) * SrcWidth / DstWidth;
- if (SourceX >= 0 && SourceY >= 0 &&
- SourceSurf->sizlBitmap.cx > SourceX && SourceSurf->sizlBitmap.cy > SourceY)
- {
- Source = DIB_GetSourceIndex(SourceSurf, SourceX, SourceY);
- if(Source != iTransColor)
- {
- Dest &= 0xFFFF;
- Dest |= (XLATEOBJ_iXlate(ColorTranslation, Source) << 16);
- }
- }
-
- *DestBits = Dest;
- }
-
- if(X < DestRect->right)
- {
- SourceX = SourceRect->left+(X - DestRect->left) * SrcWidth / DstWidth;
- if (SourceX >= 0 && SourceY >= 0 &&
- SourceSurf->sizlBitmap.cx > SourceX && SourceSurf->sizlBitmap.cy > SourceY)
- {
- Source = DIB_GetSourceIndex(SourceSurf, SourceX, SourceY);
- if(Source != iTransColor)
- {
- *((USHORT*)DestBits) = (USHORT)XLATEOBJ_iXlate(ColorTranslation,
- Source);
- }
- }
-
- DestBits = (PULONG)((ULONG_PTR)DestBits + 2);
- }
-
- DestBits = (ULONG*)((ULONG_PTR)DestBits + wd);
+ Dest &= 0xFFFF;
+ Dest |= (XLATEOBJ_iXlate(ColorTranslation, Source) << 16);
}
+ }
+
+ *DestBits = Dest;
+ }
- return TRUE;
+ if(X < DestRect->right)
+ {
+ SourceX = SourceRect->left+(X - DestRect->left) * SrcWidth / DstWidth;
+ if (SourceX >= 0 && SourceY >= 0 &&
+ SourceSurf->sizlBitmap.cx > SourceX && SourceSurf->sizlBitmap.cy > SourceY)
+ {
+ Source = DIB_GetSourceIndex(SourceSurf, SourceX, SourceY);
+ if(Source != iTransColor)
+ {
+ *((USHORT*)DestBits) = (USHORT)XLATEOBJ_iXlate(ColorTranslation,
+ Source);
+ }
+ }
+
+ DestBits = (PULONG)((ULONG_PTR)DestBits + 2);
+ }
+
+ DestBits = (ULONG*)((ULONG_PTR)DestBits + wd);
+ }
+
+ return TRUE;
}
typedef union
{
- ULONG ul;
- struct
- {
- UCHAR red;
- UCHAR green;
- UCHAR blue;
- UCHAR alpha;
- } col;
+ ULONG ul;
+ struct
+ {
+ UCHAR red;
+ UCHAR green;
+ UCHAR blue;
+ UCHAR alpha;
+ } col;
} NICEPIXEL32;
typedef union
{
- USHORT us;
- struct
- {
- USHORT red:5,
- green:6,
- blue:5;
- } col;
+ USHORT us;
+ struct
+ {
+ USHORT red:5,
+ green:6,
+ blue:5;
+ } col;
} NICEPIXEL16;
static __inline UCHAR
Clamp5(ULONG val)
{
- return (val > 31) ? 31 : val;
+ return (val > 31) ? 31 : val;
}
static __inline UCHAR
Clamp8(ULONG val)
{
- return (val > 255) ? 255 : val;
+ return (val > 255) ? 255 : val;
}
static __inline UCHAR
Clamp6(ULONG val)
{
- return (val > 63) ? 63 : val;
+ return (val > 63) ? 63 : val;
}
BOOLEAN
RECTL* SourceRect, CLIPOBJ* ClipRegion,
XLATEOBJ* ColorTranslation, BLENDOBJ* BlendObj)
{
- INT Rows, Cols, SrcX, SrcY;
- register PUSHORT Dst;
- ULONG DstDelta;
- BLENDFUNCTION BlendFunc;
- register NICEPIXEL16 SrcPixel16;
- register NICEPIXEL16 DstPixel16;
- register NICEPIXEL32 SrcPixel32;
- register NICEPIXEL32 DstPixel32;
- UCHAR Alpha, SrcBpp;
- XLATEGDI* XlateGDI;
- XLATEOBJ* SrcXlateObj;
-
- DPRINT("DIB_16BPP_AlphaBlend: srcRect: (%d,%d)-(%d,%d), dstRect: (%d,%d)-(%d,%d)\n",
- SourceRect->left, SourceRect->top, SourceRect->right, SourceRect->bottom,
- DestRect->left, DestRect->top, DestRect->right, DestRect->bottom);
-
- ASSERT(DestRect->bottom - DestRect->top == SourceRect->bottom - SourceRect->top &&
- DestRect->right - DestRect->left == SourceRect->right - SourceRect->left);
-
- BlendFunc = BlendObj->BlendFunction;
- if (BlendFunc.BlendOp != AC_SRC_OVER)
- {
- DPRINT1("BlendOp != AC_SRC_OVER\n");
- return FALSE;
- }
- if (BlendFunc.BlendFlags != 0)
- {
- DPRINT1("BlendFlags != 0\n");
- return FALSE;
- }
- if ((BlendFunc.AlphaFormat & ~AC_SRC_ALPHA) != 0)
+ INT Rows, Cols, SrcX, SrcY;
+ register PUSHORT Dst;
+ ULONG DstDelta;
+ BLENDFUNCTION BlendFunc;
+ register NICEPIXEL16 SrcPixel16;
+ register NICEPIXEL16 DstPixel16;
+ register NICEPIXEL32 SrcPixel32;
+ register NICEPIXEL32 DstPixel32;
+ UCHAR Alpha, SrcBpp;
+ XLATEGDI* XlateGDI;
+ XLATEOBJ* SrcXlateObj;
+
+ DPRINT("DIB_16BPP_AlphaBlend: srcRect: (%d,%d)-(%d,%d), dstRect: (%d,%d)-(%d,%d)\n",
+ SourceRect->left, SourceRect->top, SourceRect->right, SourceRect->bottom,
+ DestRect->left, DestRect->top, DestRect->right, DestRect->bottom);
+
+ ASSERT(DestRect->bottom - DestRect->top == SourceRect->bottom - SourceRect->top &&
+ DestRect->right - DestRect->left == SourceRect->right - SourceRect->left);
+
+ BlendFunc = BlendObj->BlendFunction;
+ if (BlendFunc.BlendOp != AC_SRC_OVER)
+ {
+ DPRINT1("BlendOp != AC_SRC_OVER\n");
+ return FALSE;
+ }
+ if (BlendFunc.BlendFlags != 0)
+ {
+ DPRINT1("BlendFlags != 0\n");
+ return FALSE;
+ }
+ if ((BlendFunc.AlphaFormat & ~AC_SRC_ALPHA) != 0)
+ {
+ DPRINT1("Unsupported AlphaFormat (0x%x)\n", BlendFunc.AlphaFormat);
+ return FALSE;
+ }
+ if ((BlendFunc.AlphaFormat & AC_SRC_ALPHA) != 0 &&
+ BitsPerFormat(Source->iBitmapFormat) != 32)
+ {
+ DPRINT1("Source bitmap must be 32bpp when AC_SRC_ALPHA is set\n");
+ return FALSE;
+ }
+
+ if (!ColorTranslation)
+ {
+ DPRINT1("ColorTranslation must not be NULL!\n");
+ return FALSE;
+ }
+
+ XlateGDI = ObjToGDI(ColorTranslation, XLATE);
+ SrcXlateObj = IntEngCreateXlate(0, 0, XlateGDI->SourcePal, XlateGDI->DestPal);
+
+ if (!SrcXlateObj)
+ {
+ DPRINT1("IntEngCreateXlate failed\n");
+ return FALSE;
+ }
+
+ Dst = (PUSHORT)((ULONG_PTR)Dest->pvScan0 + (DestRect->top * Dest->lDelta) +
+ (DestRect->left << 1));
+ DstDelta = Dest->lDelta - ((DestRect->right - DestRect->left) << 1);
+ SrcBpp = BitsPerFormat(Source->iBitmapFormat);
+
+ Rows = DestRect->bottom - DestRect->top;
+ SrcY = SourceRect->top;
+ while (--Rows >= 0)
+ {
+ Cols = DestRect->right - DestRect->left;
+ SrcX = SourceRect->left;
+ while (--Cols >= 0)
{
- DPRINT1("Unsupported AlphaFormat (0x%x)\n", BlendFunc.AlphaFormat);
- return FALSE;
- }
- if ((BlendFunc.AlphaFormat & AC_SRC_ALPHA) != 0 &&
- BitsPerFormat(Source->iBitmapFormat) != 32)
- {
- DPRINT1("Source bitmap must be 32bpp when AC_SRC_ALPHA is set\n");
- return FALSE;
- }
-
- if (!ColorTranslation)
- {
- DPRINT1("ColorTranslation must not be NULL!\n");
- return FALSE;
- }
-
- XlateGDI = ObjToGDI(ColorTranslation, XLATE);
- SrcXlateObj = IntEngCreateXlate(0, 0, XlateGDI->SourcePal, XlateGDI->DestPal);
-
- if (!SrcXlateObj)
- {
- DPRINT1("IntEngCreateXlate failed\n");
- return FALSE;
- }
-
- Dst = (PUSHORT)((ULONG_PTR)Dest->pvScan0 + (DestRect->top * Dest->lDelta) +
- (DestRect->left << 1));
- DstDelta = Dest->lDelta - ((DestRect->right - DestRect->left) << 1);
- SrcBpp = BitsPerFormat(Source->iBitmapFormat);
-
- Rows = DestRect->bottom - DestRect->top;
- SrcY = SourceRect->top;
- while (--Rows >= 0)
- {
- Cols = DestRect->right - DestRect->left;
- SrcX = SourceRect->left;
- while (--Cols >= 0)
- {
- if (SrcBpp <= 16)
- {
- SrcPixel16.us = DIB_GetSource(Source, SrcX++, SrcY, ColorTranslation);
- SrcPixel32.col.red = (SrcPixel16.col.red << 3);
- SrcPixel32.col.green = (SrcPixel16.col.green << 2);
- SrcPixel32.col.blue = (SrcPixel16.col.blue << 3);
-
- 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;
- SrcPixel32.col.alpha = (SrcBpp == 32) ?
- (SrcPixel32.col.alpha * BlendFunc.SourceConstantAlpha / 255) :
- BlendFunc.SourceConstantAlpha;
-
- Alpha = ((BlendFunc.AlphaFormat & AC_SRC_ALPHA) != 0) ?
- SrcPixel32.col.alpha : BlendFunc.SourceConstantAlpha;
-
- DstPixel16.us = *Dst;
- DstPixel16.col.red = Clamp5(DstPixel16.col.red * (255 - Alpha) / 255 +
- (SrcPixel32.col.red >> 3));
-
- DstPixel16.col.green = Clamp6(DstPixel16.col.green * (255 - Alpha) / 255 +
- (SrcPixel32.col.green >> 2));
-
- DstPixel16.col.blue = Clamp5(DstPixel16.col.blue * (255 - Alpha) / 255 +
- (SrcPixel32.col.blue >> 3));
-
- *Dst++ = DstPixel16.us;
- }
- else
- {
- SrcPixel32.ul = DIB_GetSourceIndex(Source, SrcX++, SrcY);
-
- 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;
- SrcPixel32.col.alpha = (SrcBpp == 32) ?
- (SrcPixel32.col.alpha * BlendFunc.SourceConstantAlpha / 255) :
- BlendFunc.SourceConstantAlpha;
-
- Alpha = ((BlendFunc.AlphaFormat & AC_SRC_ALPHA) != 0) ?
- SrcPixel32.col.alpha : BlendFunc.SourceConstantAlpha;
-
- DstPixel32.ul = XLATEOBJ_iXlate(SrcXlateObj, *Dst);
- SrcPixel32.col.red = Clamp8(DstPixel32.col.red * (255 - Alpha) / 255 + SrcPixel32.col.red);
- SrcPixel32.col.green = Clamp8(DstPixel32.col.green * (255 - Alpha) / 255 + SrcPixel32.col.green);
- SrcPixel32.col.blue = Clamp8(DstPixel32.col.blue * (255 - Alpha) / 255 + SrcPixel32.col.blue);
- *Dst++ = XLATEOBJ_iXlate(ColorTranslation, SrcPixel32.ul);
- }
+ if (SrcBpp <= 16)
+ {
+ SrcPixel16.us = DIB_GetSource(Source, SrcX++, SrcY, ColorTranslation);
+ SrcPixel32.col.red = (SrcPixel16.col.red << 3);
+ SrcPixel32.col.green = (SrcPixel16.col.green << 2);
+ SrcPixel32.col.blue = (SrcPixel16.col.blue << 3);
+
+ 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;
+ SrcPixel32.col.alpha = (SrcBpp == 32) ?
+ (SrcPixel32.col.alpha * BlendFunc.SourceConstantAlpha / 255) :
+ BlendFunc.SourceConstantAlpha;
+
+ Alpha = ((BlendFunc.AlphaFormat & AC_SRC_ALPHA) != 0) ?
+ SrcPixel32.col.alpha : BlendFunc.SourceConstantAlpha;
+
+ DstPixel16.us = *Dst;
+ DstPixel16.col.red = Clamp5(DstPixel16.col.red * (255 - Alpha) / 255 +
+ (SrcPixel32.col.red >> 3));
+
+ DstPixel16.col.green = Clamp6(DstPixel16.col.green * (255 - Alpha) / 255 +
+ (SrcPixel32.col.green >> 2));
+
+ DstPixel16.col.blue = Clamp5(DstPixel16.col.blue * (255 - Alpha) / 255 +
+ (SrcPixel32.col.blue >> 3));
+
+ *Dst++ = DstPixel16.us;
+ }
+ else
+ {
+ SrcPixel32.ul = DIB_GetSourceIndex(Source, SrcX++, SrcY);
+
+ 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;
+ SrcPixel32.col.alpha = (SrcBpp == 32) ?
+ (SrcPixel32.col.alpha * BlendFunc.SourceConstantAlpha / 255) :
+ BlendFunc.SourceConstantAlpha;
+
+ Alpha = ((BlendFunc.AlphaFormat & AC_SRC_ALPHA) != 0) ?
+ SrcPixel32.col.alpha : BlendFunc.SourceConstantAlpha;
+
+ DstPixel32.ul = XLATEOBJ_iXlate(SrcXlateObj, *Dst);
+ SrcPixel32.col.red = Clamp8(DstPixel32.col.red * (255 - Alpha) / 255 + SrcPixel32.col.red);
+ SrcPixel32.col.green = Clamp8(DstPixel32.col.green * (255 - Alpha) / 255 + SrcPixel32.col.green);
+ SrcPixel32.col.blue = Clamp8(DstPixel32.col.blue * (255 - Alpha) / 255 + SrcPixel32.col.blue);
+ *Dst++ = XLATEOBJ_iXlate(ColorTranslation, SrcPixel32.ul);
}
-
- Dst = (PUSHORT)((ULONG_PTR)Dst + DstDelta);
- SrcY++;
}
- if (SrcXlateObj) EngDeleteXlate(SrcXlateObj);
+ Dst = (PUSHORT)((ULONG_PTR)Dst + DstDelta);
+ SrcY++;
+ }
+
+ if (SrcXlateObj) EngDeleteXlate(SrcXlateObj);
- return TRUE;
+ return TRUE;
}
/* EOF */
/*
- * ReactOS W32 Subsystem
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * PROJECT: Win32 subsystem
+ * LICENSE: See COPYING in the top level directory
+ * FILE: subsystems/win32/win32k/dib/dib1bpp.c
+ * PURPOSE: Device Independant Bitmap functions, 1bpp
+ * PROGRAMMERS: Jason Filby
*/
-/* $Id$ */
+
#include <w32k.h>
#define NDEBUG
VOID
DIB_1BPP_HLine(SURFOBJ *SurfObj, LONG x1, LONG x2, LONG y, ULONG c)
{
- while(x1 < x2) {
+ while(x1 < x2)
+ {
DIB_1BPP_PutPixel(SurfObj, x1, y, c);
x1++;
}
VOID
DIB_1BPP_VLine(SURFOBJ *SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
{
- while(y1 < y2) {
+ while(y1 < y2)
+ {
DIB_1BPP_PutPixel(SurfObj, x, y1, c);
y1++;
}
static
void
DIB_1BPP_BitBltSrcCopy_From1BPP (
- SURFOBJ* DestSurf,
- SURFOBJ* SourceSurf,
- XLATEOBJ* pxlo,
- PRECTL DestRect,
- POINTL *SourcePoint )
+ SURFOBJ* DestSurf,
+ SURFOBJ* SourceSurf,
+ XLATEOBJ* pxlo,
+ PRECTL DestRect,
+ POINTL *SourcePoint )
{
- // the 'window' in this sense is the x-position that corresponds
- // to the left-edge of the 8-pixel byte we are currently working with.
- // dwx is current x-window, dwx2 is the 'last' window we need to process
- int dwx, dwx2; // destination window x-position
- int swx; // source window y-position
-
- // left and right edges of source and dest rectangles
- int dl = DestRect->left; // dest left
- int dr = DestRect->right-1; // dest right (inclusive)
- int sl = SourcePoint->x; // source left
- int sr = sl + dr - dl; // source right (inclusive)
-
- // which direction are we going?
- int xinc;
- int yinc;
- int ySrcDelta, yDstDelta;
-
- // following 4 variables are used for the y-sweep
- int dy; // dest y
- int dy1; // dest y start
- int dy2; // dest y end
- int sy1; // src y start
-
- int dx;
- int shift;
- BYTE srcmask, dstmask, xormask;
-
- // 'd' and 's' are the dest & src buffer pointers that I use on my x-sweep
- // 'pd' and 'ps' are the dest & src buffer pointers used on the inner y-sweep
- PBYTE d, pd; // dest ptrs
- PBYTE s, ps; // src ptrs
-
- shift = (dl-sl)&7;
-
- xormask = 0xFF * XLATEOBJ_iXlate(pxlo, 0);
-
- if ( DestRect->top <= SourcePoint->y )
- {
- // moving up ( scan top -> bottom )
- dy1 = DestRect->top;
- dy2 = DestRect->bottom - 1;
- sy1 = SourcePoint->y;
- yinc = 1;
- ySrcDelta = SourceSurf->lDelta;
- yDstDelta = DestSurf->lDelta;
- }
- else
- {
- // moving down ( scan bottom -> top )
- dy1 = DestRect->bottom - 1;
- dy2 = DestRect->top;
- sy1 = SourcePoint->y + dy1 - dy2;
- yinc = -1;
- ySrcDelta = -SourceSurf->lDelta;
- yDstDelta = -DestSurf->lDelta;
- }
- if ( DestRect->left <= SourcePoint->x )
- {
- // moving left ( scan left->right )
- dwx = dl&~7;
- swx = (sl-(dl&7))&~7;
- dwx2 = dr&~7;
- xinc = 1;
- }
- else
- {
- // moving right ( scan right->left )
- dwx = dr&~7;
- swx = (sr-(dr&7))&~7; //(sr-7)&~7; // we need the left edge of this block... thus the -7
- dwx2 = dl&~7;
- xinc = -1;
- }
- d = &(((PBYTE)DestSurf->pvScan0)[dy1*DestSurf->lDelta + (dwx>>3)]);
- s = &(((PBYTE)SourceSurf->pvScan0)[sy1*SourceSurf->lDelta + (swx>>3)]);
- for ( ;; )
- {
- dy = dy1;
- pd = d;
- ps = s;
- srcmask = 0xff;
- dx = dwx; /* dest x for this pass */
- if ( dwx < dl )
- {
- int diff = dl-dwx;
- srcmask &= (1<<(8-diff))-1;
- dx = dl;
- }
- if ( dwx+7 > dr )
- {
- int diff = dr-dwx+1;
- srcmask &= ~((1<<(8-diff))-1);
- }
- dstmask = ~srcmask;
-
- // we unfortunately *must* have 5 different versions of the inner
- // loop to be certain we don't try to read from memory that is not
- // needed and may in fact be invalid
- if ( !shift )
- {
- for ( ;; )
- {
- *pd = (BYTE)((*pd & dstmask) | ((ps[0]^xormask) & srcmask));
-
- // this *must* be here, because we could be going up *or* down...
- if ( dy == dy2 )
- break;
- dy += yinc;
- pd += yDstDelta;
- ps += ySrcDelta;
- }
- }
- else if ( !(0xFF00 & (srcmask<<shift) ) ) // check if ps[0] not needed...
- {
- for ( ;; )
- {
- *pd = (BYTE)((*pd & dstmask)
- | ( ( (ps[1]^xormask) >> shift ) & srcmask ));
-
- // this *must* be here, because we could be going up *or* down...
- if ( dy == dy2 )
- break;
- dy += yinc;
- pd += yDstDelta;
- ps += ySrcDelta;
- }
- }
- else if ( !(0xFF & (srcmask<<shift) ) ) // check if ps[1] not needed...
- {
- for ( ;; )
- {
- *pd = (*pd & dstmask)
- | ( ( (ps[0]^xormask) << ( 8 - shift ) ) & srcmask );
-
- // this *must* be here, because we could be going up *or* down...
- if ( dy == dy2 )
- break;
- dy += yinc;
- pd += yDstDelta;
- ps += ySrcDelta;
- }
- }
- else // both ps[0] and ps[1] are needed
- {
- for ( ;; )
- {
- *pd = (*pd & dstmask)
- | ( ( ( ((ps[1]^xormask))|((ps[0]^xormask)<<8) ) >> shift ) & srcmask );
-
- // this *must* be here, because we could be going up *or* down...
- if ( dy == dy2 )
- break;
- dy += yinc;
- pd += yDstDelta;
- ps += ySrcDelta;
- }
- }
-
- // this *must* be here, because we could be going right *or* left...
- if ( dwx == dwx2 )
- break;
- d += xinc;
- s += xinc;
- dwx += xinc<<3;
- swx += xinc<<3;
- }
+ // the 'window' in this sense is the x-position that corresponds
+ // to the left-edge of the 8-pixel byte we are currently working with.
+ // dwx is current x-window, dwx2 is the 'last' window we need to process
+ int dwx, dwx2; // destination window x-position
+ int swx; // source window y-position
+
+ // left and right edges of source and dest rectangles
+ int dl = DestRect->left; // dest left
+ int dr = DestRect->right-1; // dest right (inclusive)
+ int sl = SourcePoint->x; // source left
+ int sr = sl + dr - dl; // source right (inclusive)
+
+ // which direction are we going?
+ int xinc;
+ int yinc;
+ int ySrcDelta, yDstDelta;
+
+ // following 4 variables are used for the y-sweep
+ int dy; // dest y
+ int dy1; // dest y start
+ int dy2; // dest y end
+ int sy1; // src y start
+
+ int dx;
+ int shift;
+ BYTE srcmask, dstmask, xormask;
+
+ // 'd' and 's' are the dest & src buffer pointers that I use on my x-sweep
+ // 'pd' and 'ps' are the dest & src buffer pointers used on the inner y-sweep
+ PBYTE d, pd; // dest ptrs
+ PBYTE s, ps; // src ptrs
+
+ shift = (dl-sl)&7;
+
+ xormask = 0xFF * XLATEOBJ_iXlate(pxlo, 0);
+
+ if ( DestRect->top <= SourcePoint->y )
+ {
+ // moving up ( scan top -> bottom )
+ dy1 = DestRect->top;
+ dy2 = DestRect->bottom - 1;
+ sy1 = SourcePoint->y;
+ yinc = 1;
+ ySrcDelta = SourceSurf->lDelta;
+ yDstDelta = DestSurf->lDelta;
+ }
+ else
+ {
+ // moving down ( scan bottom -> top )
+ dy1 = DestRect->bottom - 1;
+ dy2 = DestRect->top;
+ sy1 = SourcePoint->y + dy1 - dy2;
+ yinc = -1;
+ ySrcDelta = -SourceSurf->lDelta;
+ yDstDelta = -DestSurf->lDelta;
+ }
+ if ( DestRect->left <= SourcePoint->x )
+ {
+ // moving left ( scan left->right )
+ dwx = dl&~7;
+ swx = (sl-(dl&7))&~7;
+ dwx2 = dr&~7;
+ xinc = 1;
+ }
+ else
+ {
+ // moving right ( scan right->left )
+ dwx = dr&~7;
+ swx = (sr-(dr&7))&~7; //(sr-7)&~7; // we need the left edge of this block... thus the -7
+ dwx2 = dl&~7;
+ xinc = -1;
+ }
+ d = &(((PBYTE)DestSurf->pvScan0)[dy1*DestSurf->lDelta + (dwx>>3)]);
+ s = &(((PBYTE)SourceSurf->pvScan0)[sy1*SourceSurf->lDelta + (swx>>3)]);
+ for ( ;; )
+ {
+ dy = dy1;
+ pd = d;
+ ps = s;
+ srcmask = 0xff;
+ dx = dwx; /* dest x for this pass */
+ if ( dwx < dl )
+ {
+ int diff = dl-dwx;
+ srcmask &= (1<<(8-diff))-1;
+ dx = dl;
+ }
+ if ( dwx+7 > dr )
+ {
+ int diff = dr-dwx+1;
+ srcmask &= ~((1<<(8-diff))-1);
+ }
+ dstmask = ~srcmask;
+
+ // we unfortunately *must* have 5 different versions of the inner
+ // loop to be certain we don't try to read from memory that is not
+ // needed and may in fact be invalid
+ if ( !shift )
+ {
+ for ( ;; )
+ {
+ *pd = (BYTE)((*pd & dstmask) | ((ps[0]^xormask) & srcmask));
+
+ // this *must* be here, because we could be going up *or* down...
+ if ( dy == dy2 )
+ break;
+ dy += yinc;
+ pd += yDstDelta;
+ ps += ySrcDelta;
+ }
+ }
+ else if ( !(0xFF00 & (srcmask<<shift) ) ) // check if ps[0] not needed...
+ {
+ for ( ;; )
+ {
+ *pd = (BYTE)((*pd & dstmask)
+ | ( ( (ps[1]^xormask) >> shift ) & srcmask ));
+
+ // this *must* be here, because we could be going up *or* down...
+ if ( dy == dy2 )
+ break;
+ dy += yinc;
+ pd += yDstDelta;
+ ps += ySrcDelta;
+ }
+ }
+ else if ( !(0xFF & (srcmask<<shift) ) ) // check if ps[1] not needed...
+ {
+ for ( ;; )
+ {
+ *pd = (*pd & dstmask)
+ | ( ( (ps[0]^xormask) << ( 8 - shift ) ) & srcmask );
+
+ // this *must* be here, because we could be going up *or* down...
+ if ( dy == dy2 )
+ break;
+ dy += yinc;
+ pd += yDstDelta;
+ ps += ySrcDelta;
+ }
+ }
+ else // both ps[0] and ps[1] are needed
+ {
+ for ( ;; )
+ {
+ *pd = (*pd & dstmask)
+ | ( ( ( ((ps[1]^xormask))|((ps[0]^xormask)<<8) ) >> shift ) & srcmask );
+
+ // this *must* be here, because we could be going up *or* down...
+ if ( dy == dy2 )
+ break;
+ dy += yinc;
+ pd += yDstDelta;
+ ps += ySrcDelta;
+ }
+ }
+
+ // this *must* be here, because we could be going right *or* left...
+ if ( dwx == dwx2 )
+ break;
+ d += xinc;
+ s += xinc;
+ dwx += xinc<<3;
+ swx += xinc<<3;
+ }
}
BOOLEAN
DIB_1BPP_BitBltSrcCopy(PBLTINFO BltInfo)
{
- ULONG Color;
- LONG i, j, sx, sy = BltInfo->SourcePoint.y;
-
- switch ( BltInfo->SourceSurface->iBitmapFormat )
- {
- case BMF_1BPP:
- DIB_1BPP_BitBltSrcCopy_From1BPP ( BltInfo->DestSurface, BltInfo->SourceSurface, BltInfo->XlateSourceToDest, &BltInfo->DestRect, &BltInfo->SourcePoint );
- break;
-
- case BMF_4BPP:
- for (j=BltInfo->DestRect.top; j<BltInfo->DestRect.bottom; j++)
- {
- sx = BltInfo->SourcePoint.x;
- for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
- {
- Color = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, DIB_4BPP_GetPixel(BltInfo->SourceSurface, sx, sy));
- DIB_1BPP_PutPixel(BltInfo->DestSurface, i, j, Color);
- sx++;
- }
- sy++;
- }
- break;
-
- case BMF_8BPP:
- for (j=BltInfo->DestRect.top; j<BltInfo->DestRect.bottom; j++)
- {
- sx = BltInfo->SourcePoint.x;
- for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
- {
- Color = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, DIB_8BPP_GetPixel(BltInfo->SourceSurface, sx, sy));
- DIB_1BPP_PutPixel(BltInfo->DestSurface, i, j, Color);
- sx++;
- }
- sy++;
- }
- break;
-
- case BMF_16BPP:
- for (j=BltInfo->DestRect.top; j<BltInfo->DestRect.bottom; j++)
- {
- sx = BltInfo->SourcePoint.x;
- for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
- {
- Color = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, DIB_16BPP_GetPixel(BltInfo->SourceSurface, sx, sy));
- DIB_1BPP_PutPixel(BltInfo->DestSurface, i, j, Color);
- sx++;
- }
- sy++;
- }
- break;
-
- case BMF_24BPP:
- for (j=BltInfo->DestRect.top; j<BltInfo->DestRect.bottom; j++)
- {
- sx = BltInfo->SourcePoint.x;
- for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
- {
- Color = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, DIB_24BPP_GetPixel(BltInfo->SourceSurface, sx, sy));
- DIB_1BPP_PutPixel(BltInfo->DestSurface, i, j, Color);
- sx++;
- }
- sy++;
- }
- break;
-
- case BMF_32BPP:
- for (j=BltInfo->DestRect.top; j<BltInfo->DestRect.bottom; j++)
- {
- sx = BltInfo->SourcePoint.x;
- for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
- {
- Color = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, DIB_32BPP_GetPixel(BltInfo->SourceSurface, sx, sy));
- DIB_1BPP_PutPixel(BltInfo->DestSurface, i, j, Color);
- sx++;
- }
- sy++;
- }
- break;
-
- default:
- DbgPrint("DIB_1BPP_BitBlt: Unhandled Source BPP: %u\n", BitsPerFormat(BltInfo->SourceSurface->iBitmapFormat));
- return FALSE;
- }
-
- return TRUE;
+ ULONG Color;
+ LONG i, j, sx, sy = BltInfo->SourcePoint.y;
+
+ switch ( BltInfo->SourceSurface->iBitmapFormat )
+ {
+ case BMF_1BPP:
+ DIB_1BPP_BitBltSrcCopy_From1BPP ( BltInfo->DestSurface, BltInfo->SourceSurface, BltInfo->XlateSourceToDest, &BltInfo->DestRect, &BltInfo->SourcePoint );
+ break;
+
+ case BMF_4BPP:
+ for (j=BltInfo->DestRect.top; j<BltInfo->DestRect.bottom; j++)
+ {
+ sx = BltInfo->SourcePoint.x;
+ for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
+ {
+ Color = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, DIB_4BPP_GetPixel(BltInfo->SourceSurface, sx, sy));
+ DIB_1BPP_PutPixel(BltInfo->DestSurface, i, j, Color);
+ sx++;
+ }
+ sy++;
+ }
+ break;
+
+ case BMF_8BPP:
+ for (j=BltInfo->DestRect.top; j<BltInfo->DestRect.bottom; j++)
+ {
+ sx = BltInfo->SourcePoint.x;
+ for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
+ {
+ Color = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, DIB_8BPP_GetPixel(BltInfo->SourceSurface, sx, sy));
+ DIB_1BPP_PutPixel(BltInfo->DestSurface, i, j, Color);
+ sx++;
+ }
+ sy++;
+ }
+ break;
+
+ case BMF_16BPP:
+ for (j=BltInfo->DestRect.top; j<BltInfo->DestRect.bottom; j++)
+ {
+ sx = BltInfo->SourcePoint.x;
+ for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
+ {
+ Color = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, DIB_16BPP_GetPixel(BltInfo->SourceSurface, sx, sy));
+ DIB_1BPP_PutPixel(BltInfo->DestSurface, i, j, Color);
+ sx++;
+ }
+ sy++;
+ }
+ break;
+
+ case BMF_24BPP:
+ for (j=BltInfo->DestRect.top; j<BltInfo->DestRect.bottom; j++)
+ {
+ sx = BltInfo->SourcePoint.x;
+ for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
+ {
+ Color = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, DIB_24BPP_GetPixel(BltInfo->SourceSurface, sx, sy));
+ DIB_1BPP_PutPixel(BltInfo->DestSurface, i, j, Color);
+ sx++;
+ }
+ sy++;
+ }
+ break;
+
+ case BMF_32BPP:
+ for (j=BltInfo->DestRect.top; j<BltInfo->DestRect.bottom; j++)
+ {
+ sx = BltInfo->SourcePoint.x;
+ for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
+ {
+ Color = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, DIB_32BPP_GetPixel(BltInfo->SourceSurface, sx, sy));
+ DIB_1BPP_PutPixel(BltInfo->DestSurface, i, j, Color);
+ sx++;
+ }
+ sy++;
+ }
+ break;
+
+ default:
+ DbgPrint("DIB_1BPP_BitBlt: Unhandled Source BPP: %u\n", BitsPerFormat(BltInfo->SourceSurface->iBitmapFormat));
+ return FALSE;
+ }
+
+ return TRUE;
}
BOOLEAN
DIB_1BPP_BitBlt(PBLTINFO BltInfo)
{
- ULONG DestX, DestY;
- ULONG SourceX, SourceY;
- ULONG PatternY = 0;
- ULONG Dest, Source = 0, Pattern = 0;
- ULONG Index;
- BOOLEAN UsesSource;
- BOOLEAN UsesPattern;
- PULONG DestBits;
- ULONG RoundedRight;
-
- UsesSource = ROP4_USES_SOURCE(BltInfo->Rop4);
- UsesPattern = ROP4_USES_PATTERN(BltInfo->Rop4);
-
- RoundedRight = BltInfo->DestRect.right -
- ((BltInfo->DestRect.right - BltInfo->DestRect.left) & 31);
- SourceY = BltInfo->SourcePoint.y;
-
- if (UsesPattern)
- {
- if (BltInfo->PatternSurface)
+ ULONG DestX, DestY;
+ ULONG SourceX, SourceY;
+ ULONG PatternY = 0;
+ ULONG Dest, Source = 0, Pattern = 0;
+ ULONG Index;
+ BOOLEAN UsesSource;
+ BOOLEAN UsesPattern;
+ PULONG DestBits;
+ ULONG RoundedRight;
+
+ UsesSource = ROP4_USES_SOURCE(BltInfo->Rop4);
+ UsesPattern = ROP4_USES_PATTERN(BltInfo->Rop4);
+
+ RoundedRight = BltInfo->DestRect.right -
+ ((BltInfo->DestRect.right - BltInfo->DestRect.left) & 31);
+ SourceY = BltInfo->SourcePoint.y;
+
+ if (UsesPattern)
+ {
+ if (BltInfo->PatternSurface)
+ {
+ PatternY = (BltInfo->DestRect.top + BltInfo->BrushOrigin.y) %
+ BltInfo->PatternSurface->sizlBitmap.cy;
+ }
+ else
+ {
+ /* FIXME: Shouldn't it be expanded? */
+ if (BltInfo->Brush)
+ Pattern = BltInfo->Brush->iSolidColor;
+ }
+ }
+
+ for (DestY = BltInfo->DestRect.top; DestY < BltInfo->DestRect.bottom; DestY++)
+ {
+ DestX = BltInfo->DestRect.left;
+ SourceX = BltInfo->SourcePoint.x;
+ DestBits = (PULONG)(
+ (PBYTE)BltInfo->DestSurface->pvScan0 +
+ (BltInfo->DestRect.left >> 3) +
+ DestY * BltInfo->DestSurface->lDelta);
+
+ if (DestX & 31)
+ {
+#if 0
+ /* FIXME: This case is completely untested!!! */
+
+ Dest = *((PBYTE)DestBits);
+ NoBits = 31 - (DestX & 31);
+
+ if (UsesSource)
{
- PatternY = (BltInfo->DestRect.top + BltInfo->BrushOrigin.y) %
- BltInfo->PatternSurface->sizlBitmap.cy;
+ Source = 0;
+ /* FIXME: This is incorrect! */
+ for (Index = 31 - NoBits; Index >= 0; Index++)
+ Source |= (DIB_GetSource(SourceSurf, SourceX + Index, SourceY, ColorTranslation) << (31 - Index));
}
- else
+
+ if (BltInfo->PatternSurface)
{
- /* FIXME: Shouldn't it be expanded? */
- if (BltInfo->Brush)
- Pattern = BltInfo->Brush->iSolidColor;
+ Pattern = 0;
+ for (k = 31 - NoBits; k >= 0; k++)
+ Pattern |= (DIB_GetSource(PatternObj, (X + BrushOrigin.x + k) % PatternWidth, PatternY, BltInfo->XlatePatternToDest) << (31 - k));
}
- }
-
- for (DestY = BltInfo->DestRect.top; DestY < BltInfo->DestRect.bottom; DestY++)
- {
- DestX = BltInfo->DestRect.left;
- SourceX = BltInfo->SourcePoint.x;
- DestBits = (PULONG)(
- (PBYTE)BltInfo->DestSurface->pvScan0 +
- (BltInfo->DestRect.left >> 3) +
- DestY * BltInfo->DestSurface->lDelta);
-
- if (DestX & 31)
- {
-#if 0
- /* FIXME: This case is completely untested!!! */
-
- Dest = *((PBYTE)DestBits);
- NoBits = 31 - (DestX & 31);
-
- if (UsesSource)
- {
- Source = 0;
- /* FIXME: This is incorrect! */
- for (Index = 31 - NoBits; Index >= 0; Index++)
- Source |= (DIB_GetSource(SourceSurf, SourceX + Index, SourceY, ColorTranslation) << (31 - Index));
- }
-
- if (BltInfo->PatternSurface)
- {
- Pattern = 0;
- for (k = 31 - NoBits; k >= 0; k++)
- Pattern |= (DIB_GetSource(PatternObj, (X + BrushOrigin.x + k) % PatternWidth, PatternY, BltInfo->XlatePatternToDest) << (31 - k));
- }
-
- Dest = DIB_DoRop(Rop4, Dest, Source, Pattern);
- Dest &= ~((1 << (31 - NoBits)) - 1);
- Dest |= *((PBYTE)DestBits) & ((1 << (31 - NoBits)) - 1);
-
- *DestBits = Dest;
-
- DestX += NoBits;
- SourceX += NoBits;
+
+ Dest = DIB_DoRop(Rop4, Dest, Source, Pattern);
+ Dest &= ~((1 << (31 - NoBits)) - 1);
+ Dest |= *((PBYTE)DestBits) & ((1 << (31 - NoBits)) - 1);
+
+ *DestBits = Dest;
+
+ DestX += NoBits;
+ SourceX += NoBits;
#endif
- }
+ }
+
+ for (; DestX < RoundedRight; DestX += 32, DestBits++, SourceX += 32)
+ {
+ Dest = *DestBits;
- for (; DestX < RoundedRight; DestX += 32, DestBits++, SourceX += 32)
+ if (UsesSource)
{
- Dest = *DestBits;
-
- if (UsesSource)
- {
- Source = 0;
- for (Index = 0; Index < 8; Index++)
- {
- Source |= DIB_GetSource(BltInfo->SourceSurface, SourceX + Index, SourceY, BltInfo->XlateSourceToDest) << (7 - Index);
- Source |= DIB_GetSource(BltInfo->SourceSurface, SourceX + Index + 8, SourceY, BltInfo->XlateSourceToDest) << (8 + (7 - Index));
- Source |= DIB_GetSource(BltInfo->SourceSurface, SourceX + Index + 16, SourceY, BltInfo->XlateSourceToDest) << (16 + (7 - Index));
- Source |= DIB_GetSource(BltInfo->SourceSurface, SourceX + Index + 24, SourceY, BltInfo->XlateSourceToDest) << (24 + (7 - Index));
- }
- }
-
- if (BltInfo->PatternSurface)
- {
- Pattern = 0;
- for (Index = 0; Index < 8; Index++)
- {
- Pattern |= DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x + Index) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest) << (7 - Index);
- Pattern |= DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x + Index + 8) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest) << (8 + (7 - Index));
- Pattern |= DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x + Index + 16) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest) << (16 + (7 - Index));
- Pattern |= DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x + Index + 24) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest) << (24 + (7 - Index));
- }
- }
-
- *DestBits = DIB_DoRop(BltInfo->Rop4, Dest, Source, Pattern);
+ Source = 0;
+ for (Index = 0; Index < 8; Index++)
+ {
+ Source |= DIB_GetSource(BltInfo->SourceSurface, SourceX + Index, SourceY, BltInfo->XlateSourceToDest) << (7 - Index);
+ Source |= DIB_GetSource(BltInfo->SourceSurface, SourceX + Index + 8, SourceY, BltInfo->XlateSourceToDest) << (8 + (7 - Index));
+ Source |= DIB_GetSource(BltInfo->SourceSurface, SourceX + Index + 16, SourceY, BltInfo->XlateSourceToDest) << (16 + (7 - Index));
+ Source |= DIB_GetSource(BltInfo->SourceSurface, SourceX + Index + 24, SourceY, BltInfo->XlateSourceToDest) << (24 + (7 - Index));
+ }
}
- if (DestX < BltInfo->DestRect.right)
+ if (BltInfo->PatternSurface)
{
- for (; DestX < BltInfo->DestRect.right; DestX++, SourceX++)
- {
- Dest = DIB_1BPP_GetPixel(BltInfo->DestSurface, DestX, DestY);
-
- if (UsesSource)
- {
- Source = DIB_GetSource(BltInfo->SourceSurface, SourceX, SourceY, BltInfo->XlateSourceToDest);
- }
-
- if (BltInfo->PatternSurface)
- {
- Pattern = DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest);
- }
-
- DIB_1BPP_PutPixel(BltInfo->DestSurface, DestX, DestY, DIB_DoRop(BltInfo->Rop4, Dest, Source, Pattern) & 0xF);
- }
+ Pattern = 0;
+ for (Index = 0; Index < 8; Index++)
+ {
+ Pattern |= DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x + Index) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest) << (7 - Index);
+ Pattern |= DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x + Index + 8) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest) << (8 + (7 - Index));
+ Pattern |= DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x + Index + 16) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest) << (16 + (7 - Index));
+ Pattern |= DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x + Index + 24) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest) << (24 + (7 - Index));
+ }
}
- SourceY++;
- if (BltInfo->PatternSurface)
+ *DestBits = DIB_DoRop(BltInfo->Rop4, Dest, Source, Pattern);
+ }
+
+ if (DestX < BltInfo->DestRect.right)
+ {
+ for (; DestX < BltInfo->DestRect.right; DestX++, SourceX++)
{
- PatternY++;
- PatternY %= BltInfo->PatternSurface->sizlBitmap.cy;
+ Dest = DIB_1BPP_GetPixel(BltInfo->DestSurface, DestX, DestY);
+
+ if (UsesSource)
+ {
+ Source = DIB_GetSource(BltInfo->SourceSurface, SourceX, SourceY, BltInfo->XlateSourceToDest);
+ }
+
+ if (BltInfo->PatternSurface)
+ {
+ Pattern = DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest);
+ }
+
+ DIB_1BPP_PutPixel(BltInfo->DestSurface, DestX, DestY, DIB_DoRop(BltInfo->Rop4, Dest, Source, Pattern) & 0xF);
}
- }
+ }
+
+ SourceY++;
+ if (BltInfo->PatternSurface)
+ {
+ PatternY++;
+ PatternY %= BltInfo->PatternSurface->sizlBitmap.cy;
+ }
+ }
- return TRUE;
+ return TRUE;
}
/* BitBlt Optimize */
{
ULONG DestY;
- for (DestY = DestRect->top; DestY< DestRect->bottom; DestY++)
- {
- DIB_1BPP_HLine(DestSurface, DestRect->left, DestRect->right, DestY, color);
- }
-
-return TRUE;
+ for (DestY = DestRect->top; DestY< DestRect->bottom; DestY++)
+ {
+ DIB_1BPP_HLine(DestSurface, DestRect->left, DestRect->right, DestY, color);
+ }
+ return TRUE;
}
BOOLEAN
/*
- * ReactOS W32 Subsystem
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * PROJECT: Win32 subsystem
+ * LICENSE: See COPYING in the top level directory
+ * FILE: subsystems/win32/win32k/dib/dib24bpp.c
+ * PURPOSE: Device Independant Bitmap functions, 24bpp
+ * PROGRAMMERS: Jason Filby
+ * Thomas Bluemel
+ * Gregor Anich
*/
-/* $Id$ */
#include <w32k.h>
LONG lDelta = SurfObj->lDelta;
c &= 0xFFFFFF;
- while(y1++ < y2) {
+ while(y1++ < y2)
+ {
*(PUSHORT)(addr) = c & 0xFFFF;
*(addr + 2) = c >> 16;
*DestBits = xColor & 0xff;
*(PWORD)(DestBits + 1) = xColor >> 8;
SourceBits += 1;
- DestBits += 3;
+ DestBits += 3;
}
SourceLine += BltInfo->SourceSurface->lDelta;
case BMF_24BPP:
if (NULL == BltInfo->XlateSourceToDest || 0 != (BltInfo->XlateSourceToDest->flXlate & XO_TRIVIAL))
{
- if (BltInfo->DestRect.top < BltInfo->SourcePoint.y)
- {
- SourceBits = (PBYTE)BltInfo->SourceSurface->pvScan0 + (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) + 3 * BltInfo->SourcePoint.x;
- for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
- {
- RtlMoveMemory(DestBits, SourceBits, 3 * (BltInfo->DestRect.right - BltInfo->DestRect.left));
- SourceBits += BltInfo->SourceSurface->lDelta;
- DestBits += BltInfo->DestSurface->lDelta;
- }
- }
- else
- {
- SourceBits = (PBYTE)BltInfo->SourceSurface->pvScan0 + ((BltInfo->SourcePoint.y + BltInfo->DestRect.bottom - BltInfo->DestRect.top - 1) * BltInfo->SourceSurface->lDelta) + 3 * BltInfo->SourcePoint.x;
- DestBits = (PBYTE)BltInfo->DestSurface->pvScan0 + ((BltInfo->DestRect.bottom - 1) * BltInfo->DestSurface->lDelta) + 3 * BltInfo->DestRect.left;
- for (j = BltInfo->DestRect.bottom - 1; BltInfo->DestRect.top <= j; j--)
- {
- RtlMoveMemory(DestBits, SourceBits, 3 * (BltInfo->DestRect.right - BltInfo->DestRect.left));
- SourceBits -= BltInfo->SourceSurface->lDelta;
- DestBits -= BltInfo->DestSurface->lDelta;
- }
- }
+ if (BltInfo->DestRect.top < BltInfo->SourcePoint.y)
+ {
+ SourceBits = (PBYTE)BltInfo->SourceSurface->pvScan0 + (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) + 3 * BltInfo->SourcePoint.x;
+ for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
+ {
+ RtlMoveMemory(DestBits, SourceBits, 3 * (BltInfo->DestRect.right - BltInfo->DestRect.left));
+ SourceBits += BltInfo->SourceSurface->lDelta;
+ DestBits += BltInfo->DestSurface->lDelta;
+ }
+ }
+ else
+ {
+ SourceBits = (PBYTE)BltInfo->SourceSurface->pvScan0 + ((BltInfo->SourcePoint.y + BltInfo->DestRect.bottom - BltInfo->DestRect.top - 1) * BltInfo->SourceSurface->lDelta) + 3 * BltInfo->SourcePoint.x;
+ DestBits = (PBYTE)BltInfo->DestSurface->pvScan0 + ((BltInfo->DestRect.bottom - 1) * BltInfo->DestSurface->lDelta) + 3 * BltInfo->DestRect.left;
+ for (j = BltInfo->DestRect.bottom - 1; BltInfo->DestRect.top <= j; j--)
+ {
+ RtlMoveMemory(DestBits, SourceBits, 3 * (BltInfo->DestRect.right - BltInfo->DestRect.left));
+ SourceBits -= BltInfo->SourceSurface->lDelta;
+ DestBits -= BltInfo->DestSurface->lDelta;
+ }
+ }
}
else
{
sx = BltInfo->SourcePoint.x;
sy = BltInfo->SourcePoint.y;
- for (j=BltInfo->DestRect.top; j<BltInfo->DestRect.bottom; j++)
- {
- sx = BltInfo->SourcePoint.x;
- for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
+ for (j=BltInfo->DestRect.top; j<BltInfo->DestRect.bottom; j++)
{
- DWORD pixel = DIB_24BPP_GetPixel(BltInfo->SourceSurface, sx, sy);
- DIB_24BPP_PutPixel(BltInfo->DestSurface, i, j, XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, pixel));
- sx++;
+ sx = BltInfo->SourcePoint.x;
+ for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
+ {
+ DWORD pixel = DIB_24BPP_GetPixel(BltInfo->SourceSurface, sx, sy);
+ DIB_24BPP_PutPixel(BltInfo->DestSurface, i, j, XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, pixel));
+ sx++;
+ }
+ sy++;
}
- sy++;
- }
}
break;
*DestBits = xColor & 0xff;
*(PWORD)(DestBits + 1) = xColor >> 8;
SourceBits += 4;
- DestBits += 3;
+ DestBits += 3;
}
SourceLine += BltInfo->SourceSurface->lDelta;
addr += 1;
}
}
- else
+ else
{
/* Align to 4-byte address */
while (0 != ((ULONG_PTR) addr & 0x3))
- {
- *(PUSHORT)(addr) = color;
- addr += 2;
- *(addr) = color >> 16;
- addr += 1;
- Count--;
- }
+ {
+ *(PUSHORT)(addr) = color;
+ addr += 2;
+ *(addr) = color >> 16;
+ addr += 1;
+ Count--;
+ }
/* If the color we need to fill with is 0ABC, then the final mem pattern
* (note little-endianness) would be:
*
: "=m"(addr)
: "m"(color), "m"(Count), "m"(addr)
: "%eax", "%ebx", "%ecx", "%edx", "%edi");
- Count = Count & 0x03;
+ Count = Count & 0x03;
while (0 != Count--)
- {
- *(PUSHORT)(addr) = color;
- addr += 2;
- *(addr) = color >> 16;
- addr += 1;
- }
+ {
+ *(PUSHORT)(addr) = color;
+ addr += 2;
+ *(addr) = color >> 16;
+ addr += 1;
+ }
}
}
#else
for (DestY = DestRect->top; DestY< DestRect->bottom; DestY++)
- {
- DIB_24BPP_HLine(DestSurface, DestRect->left, DestRect->right, DestY, color);
- }
+ {
+ DIB_24BPP_HLine(DestSurface, DestRect->left, DestRect->right, DestY, color);
+ }
#endif
return TRUE;
}
/*
- * ReactOS W32 Subsystem
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * PROJECT: Win32 subsystem
+ * LICENSE: See COPYING in the top level directory
+ * FILE: subsystems/win32/win32k/dib/dib24bppc.c
+ * PURPOSE: C language equivalents of asm optimised 24bpp functions
+ * PROGRAMMERS: Jason Filby
+ * Magnus Olsen
*/
-/* $Id$ */
#include <w32k.h>
PBYTE addr = (PBYTE)SurfObj->pvScan0 + y * SurfObj->lDelta + (x1 << 1) + x1;
ULONG Count = x2 - x1;
-
if (Count < 8)
+ {
+ /* For small fills, don't bother doing anything fancy */
+ while (Count--)
{
- /* For small fills, don't bother doing anything fancy */
- while (Count--)
- {
- *(PUSHORT)(addr) = c;
- addr += 2;
- *(addr) = c >> 16;
- addr += 1;
- }
+ *(PUSHORT)(addr) = c;
+ addr += 2;
+ *(addr) = c >> 16;
+ addr += 1;
}
+ }
else
- {
- ULONG Fill[3];
- ULONG MultiCount;
+ {
+ ULONG Fill[3];
+ ULONG MultiCount;
- /* Align to 4-byte address */
- while (0 != ((ULONG_PTR) addr & 0x3))
- {
- *(PUSHORT)(addr) = c;
- addr += 2;
- *(addr) = c >> 16;
- addr += 1;
- Count--;
- }
- /* If the color we need to fill with is 0ABC, then the final mem pattern
- * (note little-endianness) would be:
- *
- * |C.B.A|C.B.A|C.B.A|C.B.A| <- pixel borders
- * |C.B.A.C|B.A.C.B|A.C.B.A| <- ULONG borders
- *
- * So, taking endianness into account again, we need to fill with these
- * ULONGs: CABC BCAB ABCA */
+ /* Align to 4-byte address */
+ while (0 != ((ULONG_PTR) addr & 0x3))
+ {
+ *(PUSHORT)(addr) = c;
+ addr += 2;
+ *(addr) = c >> 16;
+ addr += 1;
+ Count--;
+ }
+ /* If the color we need to fill with is 0ABC, then the final mem pattern
+ * (note little-endianness) would be:
+ *
+ * |C.B.A|C.B.A|C.B.A|C.B.A| <- pixel borders
+ * |C.B.A.C|B.A.C.B|A.C.B.A| <- ULONG borders
+ *
+ * So, taking endianness into account again, we need to fill with these
+ * ULONGs: CABC BCAB ABCA */
- c = c & 0xffffff; /* 0ABC */
- Fill[0] = c | (c << 24); /* CABC */
- Fill[1] = (c >> 8) | (c << 16); /* BCAB */
- Fill[2] = (c << 8) | (c >> 16); /* ABCA */
- MultiCount = Count / 4;
- do
- {
- *(PULONG)addr = Fill[0];
- addr += 4;
- *(PULONG)addr = Fill[1];
- addr += 4;
- *(PULONG)addr = Fill[2];
- addr += 4;
- }
- while (0 != --MultiCount);
+ c = c & 0xffffff; /* 0ABC */
+ Fill[0] = c | (c << 24); /* CABC */
+ Fill[1] = (c >> 8) | (c << 16); /* BCAB */
+ Fill[2] = (c << 8) | (c >> 16); /* ABCA */
+ MultiCount = Count / 4;
+ do
+ {
+ *(PULONG)addr = Fill[0];
+ addr += 4;
+ *(PULONG)addr = Fill[1];
+ addr += 4;
+ *(PULONG)addr = Fill[2];
+ addr += 4;
+ }
+ while (0 != --MultiCount);
- Count = Count & 0x03;
- while (0 != Count--)
- {
- *(PUSHORT)(addr) = c;
- addr += 2;
- *(addr) = c >> 16;
- addr += 1;
- }
+ Count = Count & 0x03;
+ while (0 != Count--)
+ {
+ *(PUSHORT)(addr) = c;
+ addr += 2;
+ *(addr) = c >> 16;
+ addr += 1;
}
+ }
}
/*
- * ReactOS W32 Subsystem
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * PROJECT: Win32 subsystem
+ * LICENSE: See COPYING in the top level directory
+ * FILE: subsystems/win32/win32k/dib/dib32bpp.c
+ * PURPOSE: Device Independant Bitmap functions, 32bpp
+ * PROGRAMMERS: Jason Filby
+ * Thomas Bluemel
+ * Gregor Anich
*/
-/* $Id$ */
#include <w32k.h>
VOID
DIB_32BPP_PutPixel(SURFOBJ *SurfObj, LONG x, LONG y, ULONG c)
{
- PBYTE byteaddr = (PBYTE)SurfObj->pvScan0 + y * SurfObj->lDelta;
- PDWORD addr = (PDWORD)byteaddr + x;
+ PBYTE byteaddr = (PBYTE)SurfObj->pvScan0 + y * SurfObj->lDelta;
+ PDWORD addr = (PDWORD)byteaddr + x;
- *addr = c;
+ *addr = c;
}
ULONG
DIB_32BPP_GetPixel(SURFOBJ *SurfObj, LONG x, LONG y)
{
- PBYTE byteaddr = (PBYTE)SurfObj->pvScan0 + y * SurfObj->lDelta;
- PDWORD addr = (PDWORD)byteaddr + x;
+ PBYTE byteaddr = (PBYTE)SurfObj->pvScan0 + y * SurfObj->lDelta;
+ PDWORD addr = (PDWORD)byteaddr + x;
- return (ULONG)(*addr);
+ return (ULONG)(*addr);
}
-
VOID
DIB_32BPP_VLine(SURFOBJ *SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
{
-
-
- PBYTE byteaddr = (PBYTE)SurfObj->pvScan0 + y1 * SurfObj->lDelta;
- PDWORD addr = (PDWORD)byteaddr + x;
- LONG lDelta = SurfObj->lDelta >> 2; // >> 2 == / sizeof(DWORD)
-
- byteaddr = (PBYTE)addr;
- while (y1++ < y2)
- {
- *addr = (DWORD)c;
- addr += lDelta;
- }
-
+ PBYTE byteaddr = (PBYTE)SurfObj->pvScan0 + y1 * SurfObj->lDelta;
+ PDWORD addr = (PDWORD)byteaddr + x;
+ LONG lDelta = SurfObj->lDelta >> 2; // >> 2 == / sizeof(DWORD)
+
+ byteaddr = (PBYTE)addr;
+ while (y1++ < y2)
+ {
+ *addr = (DWORD)c;
+ addr += lDelta;
+ }
}
BOOLEAN
DIB_32BPP_BitBltSrcCopy(PBLTINFO BltInfo)
{
- LONG i, j, sx, sy, xColor, f1;
- PBYTE SourceBits, DestBits, SourceLine, DestLine;
- PBYTE SourceBits_4BPP, SourceLine_4BPP;
- PDWORD Source32, Dest32;
+ LONG i, j, sx, sy, xColor, f1;
+ PBYTE SourceBits, DestBits, SourceLine, DestLine;
+ PBYTE SourceBits_4BPP, SourceLine_4BPP;
+ PDWORD Source32, Dest32;
+
+ DestBits = (PBYTE)BltInfo->DestSurface->pvScan0
+ + (BltInfo->DestRect.top * BltInfo->DestSurface->lDelta)
+ + 4 * BltInfo->DestRect.left;
+
+ switch (BltInfo->SourceSurface->iBitmapFormat)
+ {
+ case BMF_1BPP:
- DestBits = (PBYTE)BltInfo->DestSurface->pvScan0
- + (BltInfo->DestRect.top * BltInfo->DestSurface->lDelta)
- + 4 * BltInfo->DestRect.left;
+ sx = BltInfo->SourcePoint.x;
+ sy = BltInfo->SourcePoint.y;
- switch (BltInfo->SourceSurface->iBitmapFormat)
+ for (j=BltInfo->DestRect.top; j<BltInfo->DestRect.bottom; j++)
{
- case BMF_1BPP:
+ sx = BltInfo->SourcePoint.x;
+ for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
+ {
+ if (DIB_1BPP_GetPixel(BltInfo->SourceSurface, sx, sy) == 0)
+ {
+ DIB_32BPP_PutPixel(BltInfo->DestSurface, i, j, XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, 0));
+ } else {
+ DIB_32BPP_PutPixel(BltInfo->DestSurface, i, j, XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, 1));
+ }
+ sx++;
+ }
+ sy++;
+ }
+ break;
- sx = BltInfo->SourcePoint.x;
- sy = BltInfo->SourcePoint.y;
+ case BMF_4BPP:
+ SourceBits_4BPP = (PBYTE)BltInfo->SourceSurface->pvScan0
+ + (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta)
+ + (BltInfo->SourcePoint.x >> 1);
- for (j=BltInfo->DestRect.top; j<BltInfo->DestRect.bottom; j++)
- {
- sx = BltInfo->SourcePoint.x;
- for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
- {
- if (DIB_1BPP_GetPixel(BltInfo->SourceSurface, sx, sy) == 0)
- {
- DIB_32BPP_PutPixel(BltInfo->DestSurface, i, j, XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, 0));
- } else {
- DIB_32BPP_PutPixel(BltInfo->DestSurface, i, j, XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, 1));
- }
- sx++;
- }
- sy++;
- }
- break;
+ for (j=BltInfo->DestRect.top; j<BltInfo->DestRect.bottom; j++)
+ {
+ SourceLine_4BPP = SourceBits_4BPP;
+ sx = BltInfo->SourcePoint.x;
+ f1 = sx & 1;
+
+ for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
+ {
+ xColor = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest,
+ (*SourceLine_4BPP & altnotmask[f1]) >> (4 * (1 - f1)));
+ DIB_32BPP_PutPixel(BltInfo->DestSurface, i, j, xColor);
+ if (f1 == 1) {
+ SourceLine_4BPP++;
+ f1 = 0;
+ } else {
+ f1 = 1;
+ }
+ sx++;
+ }
- case BMF_4BPP:
- SourceBits_4BPP = (PBYTE)BltInfo->SourceSurface->pvScan0
- + (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta)
- + (BltInfo->SourcePoint.x >> 1);
+ SourceBits_4BPP += BltInfo->SourceSurface->lDelta;
+ }
+ break;
- for (j=BltInfo->DestRect.top; j<BltInfo->DestRect.bottom; j++)
- {
- SourceLine_4BPP = SourceBits_4BPP;
- sx = BltInfo->SourcePoint.x;
- f1 = sx & 1;
-
- for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
- {
- xColor = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest,
- (*SourceLine_4BPP & altnotmask[f1]) >> (4 * (1 - f1)));
- DIB_32BPP_PutPixel(BltInfo->DestSurface, i, j, xColor);
- if (f1 == 1) {
- SourceLine_4BPP++;
- f1 = 0;
- } else {
- f1 = 1;
- }
- sx++;
- }
-
- SourceBits_4BPP += BltInfo->SourceSurface->lDelta;
- }
- break;
+ case BMF_8BPP:
+ SourceLine = (PBYTE)BltInfo->SourceSurface->pvScan0 + (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) + BltInfo->SourcePoint.x;
+ DestLine = DestBits;
- case BMF_8BPP:
- SourceLine = (PBYTE)BltInfo->SourceSurface->pvScan0 + (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) + BltInfo->SourcePoint.x;
- DestLine = DestBits;
+ for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
+ {
+ SourceBits = SourceLine;
+ DestBits = DestLine;
+
+ for (i = BltInfo->DestRect.left; i < BltInfo->DestRect.right; i++)
+ {
+ xColor = *SourceBits;
+ *((PDWORD) DestBits) = (DWORD)XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, xColor);
+ SourceBits += 1;
+ DestBits += 4;
+ }
+
+ SourceLine += BltInfo->SourceSurface->lDelta;
+ DestLine += BltInfo->DestSurface->lDelta;
+ }
+ break;
- for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
- {
- SourceBits = SourceLine;
- DestBits = DestLine;
-
- for (i = BltInfo->DestRect.left; i < BltInfo->DestRect.right; i++)
- {
- xColor = *SourceBits;
- *((PDWORD) DestBits) = (DWORD)XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, xColor);
- SourceBits += 1;
- DestBits += 4;
- }
-
- SourceLine += BltInfo->SourceSurface->lDelta;
- DestLine += BltInfo->DestSurface->lDelta;
- }
- break;
+ case BMF_16BPP:
+ SourceLine = (PBYTE)BltInfo->SourceSurface->pvScan0 + (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) + 2 * BltInfo->SourcePoint.x;
+ DestLine = DestBits;
- case BMF_16BPP:
- SourceLine = (PBYTE)BltInfo->SourceSurface->pvScan0 + (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) + 2 * BltInfo->SourcePoint.x;
- DestLine = DestBits;
+ for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
+ {
+ SourceBits = SourceLine;
+ DestBits = DestLine;
+
+ for (i = BltInfo->DestRect.left; i < BltInfo->DestRect.right; i++)
+ {
+ xColor = *((PWORD) SourceBits);
+ *((PDWORD) DestBits) = (DWORD)XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, xColor);
+ SourceBits += 2;
+ DestBits += 4;
+ }
+
+ SourceLine += BltInfo->SourceSurface->lDelta;
+ DestLine += BltInfo->DestSurface->lDelta;
+ }
+ break;
- for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
- {
- SourceBits = SourceLine;
- DestBits = DestLine;
-
- for (i = BltInfo->DestRect.left; i < BltInfo->DestRect.right; i++)
- {
- xColor = *((PWORD) SourceBits);
- *((PDWORD) DestBits) = (DWORD)XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, xColor);
- SourceBits += 2;
- DestBits += 4;
- }
-
- SourceLine += BltInfo->SourceSurface->lDelta;
- DestLine += BltInfo->DestSurface->lDelta;
- }
- break;
+ case BMF_24BPP:
+ SourceLine = (PBYTE)BltInfo->SourceSurface->pvScan0
+ + (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta)
+ + 3 * BltInfo->SourcePoint.x;
+ DestLine = DestBits;
- case BMF_24BPP:
- SourceLine = (PBYTE)BltInfo->SourceSurface->pvScan0
- + (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta)
- + 3 * BltInfo->SourcePoint.x;
- DestLine = DestBits;
+ for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
+ {
+ SourceBits = SourceLine;
+ DestBits = DestLine;
+
+ for (i = BltInfo->DestRect.left; i < BltInfo->DestRect.right; i++)
+ {
+ xColor = (*(SourceBits + 2) << 0x10) +
+ (*(SourceBits + 1) << 0x08) +
+ (*(SourceBits));
+ *((PDWORD)DestBits) = (DWORD)XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, xColor);
+ SourceBits += 3;
+ DestBits += 4;
+ }
+
+ SourceLine += BltInfo->SourceSurface->lDelta;
+ DestLine += BltInfo->DestSurface->lDelta;
+ }
+ break;
- for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
+ case BMF_32BPP:
+ if (NULL == BltInfo->XlateSourceToDest ||
+ 0 != (BltInfo->XlateSourceToDest->flXlate & XO_TRIVIAL))
+ {
+ if (BltInfo->DestRect.top < BltInfo->SourcePoint.y)
+ {
+ SourceBits = (PBYTE)BltInfo->SourceSurface->pvScan0 + (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) + 4 * BltInfo->SourcePoint.x;
+ for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
+ {
+ RtlMoveMemory(DestBits, SourceBits, 4 * (BltInfo->DestRect.right - BltInfo->DestRect.left));
+ SourceBits += BltInfo->SourceSurface->lDelta;
+ DestBits += BltInfo->DestSurface->lDelta;
+ }
+ }
+ else
+ {
+ SourceBits = (PBYTE)BltInfo->SourceSurface->pvScan0
+ + ((BltInfo->SourcePoint.y
+ + BltInfo->DestRect.bottom
+ - BltInfo->DestRect.top - 1) * BltInfo->SourceSurface->lDelta)
+ + 4 * BltInfo->SourcePoint.x;
+ DestBits = (PBYTE)BltInfo->DestSurface->pvScan0 + ((BltInfo->DestRect.bottom - 1) * BltInfo->DestSurface->lDelta) + 4 * BltInfo->DestRect.left;
+ for (j = BltInfo->DestRect.bottom - 1; BltInfo->DestRect.top <= j; j--)
+ {
+ RtlMoveMemory(DestBits, SourceBits, 4 * (BltInfo->DestRect.right - BltInfo->DestRect.left));
+ SourceBits -= BltInfo->SourceSurface->lDelta;
+ DestBits -= BltInfo->DestSurface->lDelta;
+ }
+ }
+ }
+ else
+ {
+ if (BltInfo->DestRect.top < BltInfo->SourcePoint.y)
+ {
+ SourceBits = ((PBYTE)BltInfo->SourceSurface->pvScan0 + (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) + 4 * BltInfo->SourcePoint.x);
+ for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
+ {
+ if (BltInfo->DestRect.left < BltInfo->SourcePoint.x)
+ {
+ Dest32 = (DWORD *) DestBits;
+ Source32 = (DWORD *) SourceBits;
+ for (i = BltInfo->DestRect.left; i < BltInfo->DestRect.right; i++)
{
- SourceBits = SourceLine;
- DestBits = DestLine;
-
- for (i = BltInfo->DestRect.left; i < BltInfo->DestRect.right; i++)
- {
- xColor = (*(SourceBits + 2) << 0x10) +
- (*(SourceBits + 1) << 0x08) +
- (*(SourceBits));
- *((PDWORD)DestBits) = (DWORD)XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, xColor);
- SourceBits += 3;
- DestBits += 4;
- }
-
- SourceLine += BltInfo->SourceSurface->lDelta;
- DestLine += BltInfo->DestSurface->lDelta;
+ *Dest32++ = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, *Source32++);
}
- break;
-
- case BMF_32BPP:
- if (NULL == BltInfo->XlateSourceToDest ||
- 0 != (BltInfo->XlateSourceToDest->flXlate & XO_TRIVIAL))
+ }
+ else
+ {
+ Dest32 = (DWORD *) DestBits + (BltInfo->DestRect.right - BltInfo->DestRect.left - 1);
+ Source32 = (DWORD *) SourceBits + (BltInfo->DestRect.right - BltInfo->DestRect.left - 1);
+ for (i = BltInfo->DestRect.right - 1; BltInfo->DestRect.left <= i; i--)
{
- if (BltInfo->DestRect.top < BltInfo->SourcePoint.y)
- {
- SourceBits = (PBYTE)BltInfo->SourceSurface->pvScan0 + (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) + 4 * BltInfo->SourcePoint.x;
- for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
- {
- RtlMoveMemory(DestBits, SourceBits, 4 * (BltInfo->DestRect.right - BltInfo->DestRect.left));
- SourceBits += BltInfo->SourceSurface->lDelta;
- DestBits += BltInfo->DestSurface->lDelta;
- }
- }
- else
- {
- SourceBits = (PBYTE)BltInfo->SourceSurface->pvScan0
- + ((BltInfo->SourcePoint.y
- + BltInfo->DestRect.bottom
- - BltInfo->DestRect.top - 1) * BltInfo->SourceSurface->lDelta)
- + 4 * BltInfo->SourcePoint.x;
- DestBits = (PBYTE)BltInfo->DestSurface->pvScan0 + ((BltInfo->DestRect.bottom - 1) * BltInfo->DestSurface->lDelta) + 4 * BltInfo->DestRect.left;
- for (j = BltInfo->DestRect.bottom - 1; BltInfo->DestRect.top <= j; j--)
- {
- RtlMoveMemory(DestBits, SourceBits, 4 * (BltInfo->DestRect.right - BltInfo->DestRect.left));
- SourceBits -= BltInfo->SourceSurface->lDelta;
- DestBits -= BltInfo->DestSurface->lDelta;
- }
- }
+ *Dest32-- = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, *Source32--);
}
- else
+ }
+ SourceBits += BltInfo->SourceSurface->lDelta;
+ DestBits += BltInfo->DestSurface->lDelta;
+ }
+ }
+ else
+ {
+ SourceBits = (PBYTE)BltInfo->SourceSurface->pvScan0 + ((BltInfo->SourcePoint.y + BltInfo->DestRect.bottom - BltInfo->DestRect.top - 1) * BltInfo->SourceSurface->lDelta) + 4 * BltInfo->SourcePoint.x;
+ DestBits = (PBYTE)BltInfo->DestSurface->pvScan0 + ((BltInfo->DestRect.bottom - 1) * BltInfo->DestSurface->lDelta) + 4 * BltInfo->DestRect.left;
+ for (j = BltInfo->DestRect.bottom - 1; BltInfo->DestRect.top <= j; j--)
+ {
+ if (BltInfo->DestRect.left < BltInfo->SourcePoint.x)
+ {
+ Dest32 = (DWORD *) DestBits;
+ Source32 = (DWORD *) SourceBits;
+ for (i = BltInfo->DestRect.left; i < BltInfo->DestRect.right; i++)
{
- if (BltInfo->DestRect.top < BltInfo->SourcePoint.y)
- {
- SourceBits = ((PBYTE)BltInfo->SourceSurface->pvScan0 + (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) + 4 * BltInfo->SourcePoint.x);
- for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
- {
- if (BltInfo->DestRect.left < BltInfo->SourcePoint.x)
- {
- Dest32 = (DWORD *) DestBits;
- Source32 = (DWORD *) SourceBits;
- for (i = BltInfo->DestRect.left; i < BltInfo->DestRect.right; i++)
- {
- *Dest32++ = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, *Source32++);
- }
- }
- else
- {
- Dest32 = (DWORD *) DestBits + (BltInfo->DestRect.right - BltInfo->DestRect.left - 1);
- Source32 = (DWORD *) SourceBits + (BltInfo->DestRect.right - BltInfo->DestRect.left - 1);
- for (i = BltInfo->DestRect.right - 1; BltInfo->DestRect.left <= i; i--)
- {
- *Dest32-- = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, *Source32--);
- }
- }
- SourceBits += BltInfo->SourceSurface->lDelta;
- DestBits += BltInfo->DestSurface->lDelta;
- }
- }
- else
- {
- SourceBits = (PBYTE)BltInfo->SourceSurface->pvScan0 + ((BltInfo->SourcePoint.y + BltInfo->DestRect.bottom - BltInfo->DestRect.top - 1) * BltInfo->SourceSurface->lDelta) + 4 * BltInfo->SourcePoint.x;
- DestBits = (PBYTE)BltInfo->DestSurface->pvScan0 + ((BltInfo->DestRect.bottom - 1) * BltInfo->DestSurface->lDelta) + 4 * BltInfo->DestRect.left;
- for (j = BltInfo->DestRect.bottom - 1; BltInfo->DestRect.top <= j; j--)
- {
- if (BltInfo->DestRect.left < BltInfo->SourcePoint.x)
- {
- Dest32 = (DWORD *) DestBits;
- Source32 = (DWORD *) SourceBits;
- for (i = BltInfo->DestRect.left; i < BltInfo->DestRect.right; i++)
- {
- *Dest32++ = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, *Source32++);
- }
- }
- else
- {
- Dest32 = (DWORD *) DestBits + (BltInfo->DestRect.right - BltInfo->DestRect.left - 1);
- Source32 = (DWORD *) SourceBits + (BltInfo->DestRect.right - BltInfo->DestRect.left - 1);
- for (i = BltInfo->DestRect.right - 1; BltInfo->DestRect.left <= i; i--)
- {
- *Dest32-- = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, *Source32--);
- }
- }
- SourceBits -= BltInfo->SourceSurface->lDelta;
- DestBits -= BltInfo->DestSurface->lDelta;
- }
- }
+ *Dest32++ = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, *Source32++);
}
- break;
-
- default:
- DPRINT1("DIB_32BPP_Bitblt: Unhandled Source BPP: %u\n", BitsPerFormat(BltInfo->SourceSurface->iBitmapFormat));
- return FALSE;
+ }
+ else
+ {
+ Dest32 = (DWORD *) DestBits + (BltInfo->DestRect.right - BltInfo->DestRect.left - 1);
+ Source32 = (DWORD *) SourceBits + (BltInfo->DestRect.right - BltInfo->DestRect.left - 1);
+ for (i = BltInfo->DestRect.right - 1; BltInfo->DestRect.left <= i; i--)
+ {
+ *Dest32-- = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, *Source32--);
+ }
+ }
+ SourceBits -= BltInfo->SourceSurface->lDelta;
+ DestBits -= BltInfo->DestSurface->lDelta;
+ }
+ }
}
+ break;
+
+ default:
+ DPRINT1("DIB_32BPP_Bitblt: Unhandled Source BPP: %u\n", BitsPerFormat(BltInfo->SourceSurface->iBitmapFormat));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
BOOLEAN
RECTL* DestRect, RECTL *SourceRect,
XLATEOBJ *ColorTranslation, ULONG iTransColor)
{
- ULONG X, Y, SourceX, SourceY = 0, Source = 0, wd;
- ULONG *DestBits;
-
- LONG DstHeight;
- LONG DstWidth;
- LONG SrcHeight;
- LONG SrcWidth;
-
- DstHeight = DestRect->bottom - DestRect->top;
- DstWidth = DestRect->right - DestRect->left;
- SrcHeight = SourceRect->bottom - SourceRect->top;
- SrcWidth = SourceRect->right - SourceRect->left;
-
- DestBits = (ULONG*)((PBYTE)DestSurf->pvScan0 +
- (DestRect->left << 2) +
- DestRect->top * DestSurf->lDelta);
- wd = DestSurf->lDelta - ((DestRect->right - DestRect->left) << 2);
-
- for (Y = DestRect->top; Y < DestRect->bottom; Y++)
+ ULONG X, Y, SourceX, SourceY = 0, Source = 0, wd;
+ ULONG *DestBits;
+
+ LONG DstHeight;
+ LONG DstWidth;
+ LONG SrcHeight;
+ LONG SrcWidth;
+
+ DstHeight = DestRect->bottom - DestRect->top;
+ DstWidth = DestRect->right - DestRect->left;
+ SrcHeight = SourceRect->bottom - SourceRect->top;
+ SrcWidth = SourceRect->right - SourceRect->left;
+
+ DestBits = (ULONG*)((PBYTE)DestSurf->pvScan0 +
+ (DestRect->left << 2) +
+ DestRect->top * DestSurf->lDelta);
+ wd = DestSurf->lDelta - ((DestRect->right - DestRect->left) << 2);
+
+ for (Y = DestRect->top; Y < DestRect->bottom; Y++)
+ {
+ SourceY = SourceRect->top+(Y - DestRect->top) * SrcHeight / DstHeight;
+ for (X = DestRect->left; X < DestRect->right; X++, DestBits++)
{
- SourceY = SourceRect->top+(Y - DestRect->top) * SrcHeight / DstHeight;
- for (X = DestRect->left; X < DestRect->right; X++, DestBits++)
+ SourceX = SourceRect->left+(X - DestRect->left) * SrcWidth / DstWidth;
+ if (SourceX >= 0 && SourceY >= 0 &&
+ SourceSurf->sizlBitmap.cx > SourceX && SourceSurf->sizlBitmap.cy > SourceY)
+ {
+ Source = DIB_GetSourceIndex(SourceSurf, SourceX, SourceY);
+ if (Source != iTransColor)
{
- SourceX = SourceRect->left+(X - DestRect->left) * SrcWidth / DstWidth;
- if (SourceX >= 0 && SourceY >= 0 &&
- SourceSurf->sizlBitmap.cx > SourceX && SourceSurf->sizlBitmap.cy > SourceY)
- {
- Source = DIB_GetSourceIndex(SourceSurf, SourceX, SourceY);
- if (Source != iTransColor)
- {
- *DestBits = XLATEOBJ_iXlate(ColorTranslation, Source);
- }
- }
+ *DestBits = XLATEOBJ_iXlate(ColorTranslation, Source);
}
-
- DestBits = (ULONG*)((ULONG_PTR)DestBits + wd);
+ }
}
- return TRUE;
+ DestBits = (ULONG*)((ULONG_PTR)DestBits + wd);
+ }
+
+ return TRUE;
}
typedef union {
- ULONG ul;
- struct {
- UCHAR red;
- UCHAR green;
- UCHAR blue;
- UCHAR alpha;
- } col;
+ ULONG ul;
+ struct {
+ UCHAR red;
+ UCHAR green;
+ UCHAR blue;
+ UCHAR alpha;
+ } col;
} NICEPIXEL32;
static __inline UCHAR
Clamp8(ULONG val)
{
- return (val > 255) ? 255 : val;
+ return (val > 255) ? 255 : val;
}
BOOLEAN
RECTL* SourceRect, CLIPOBJ* ClipRegion,
XLATEOBJ* ColorTranslation, BLENDOBJ* BlendObj)
{
- INT Rows, Cols, SrcX, SrcY;
- register PULONG Dst;
- ULONG DstDelta;
- BLENDFUNCTION BlendFunc;
- register NICEPIXEL32 DstPixel, SrcPixel;
- UCHAR Alpha, SrcBpp;
-
- DPRINT("DIB_32BPP_AlphaBlend: srcRect: (%d,%d)-(%d,%d), dstRect: (%d,%d)-(%d,%d)\n",
- SourceRect->left, SourceRect->top, SourceRect->right, SourceRect->bottom,
- DestRect->left, DestRect->top, DestRect->right, DestRect->bottom);
-
- ASSERT(DestRect->bottom - DestRect->top == SourceRect->bottom - SourceRect->top &&
- DestRect->right - DestRect->left == SourceRect->right - SourceRect->left);
-
- BlendFunc = BlendObj->BlendFunction;
- if (BlendFunc.BlendOp != AC_SRC_OVER)
- {
- DPRINT1("BlendOp != AC_SRC_OVER\n");
- return FALSE;
- }
- if (BlendFunc.BlendFlags != 0)
- {
- DPRINT1("BlendFlags != 0\n");
- return FALSE;
- }
- if ((BlendFunc.AlphaFormat & ~AC_SRC_ALPHA) != 0)
+ INT Rows, Cols, SrcX, SrcY;
+ register PULONG Dst;
+ ULONG DstDelta;
+ BLENDFUNCTION BlendFunc;
+ register NICEPIXEL32 DstPixel, SrcPixel;
+ UCHAR Alpha, SrcBpp;
+
+ DPRINT("DIB_32BPP_AlphaBlend: srcRect: (%d,%d)-(%d,%d), dstRect: (%d,%d)-(%d,%d)\n",
+ SourceRect->left, SourceRect->top, SourceRect->right, SourceRect->bottom,
+ DestRect->left, DestRect->top, DestRect->right, DestRect->bottom);
+
+ ASSERT(DestRect->bottom - DestRect->top == SourceRect->bottom - SourceRect->top &&
+ DestRect->right - DestRect->left == SourceRect->right - SourceRect->left);
+
+ BlendFunc = BlendObj->BlendFunction;
+ if (BlendFunc.BlendOp != AC_SRC_OVER)
+ {
+ DPRINT1("BlendOp != AC_SRC_OVER\n");
+ return FALSE;
+ }
+ if (BlendFunc.BlendFlags != 0)
+ {
+ DPRINT1("BlendFlags != 0\n");
+ return FALSE;
+ }
+ if ((BlendFunc.AlphaFormat & ~AC_SRC_ALPHA) != 0)
+ {
+ DPRINT1("Unsupported AlphaFormat (0x%x)\n", BlendFunc.AlphaFormat);
+ return FALSE;
+ }
+ if ((BlendFunc.AlphaFormat & AC_SRC_ALPHA) != 0 &&
+ BitsPerFormat(Source->iBitmapFormat) != 32)
+ {
+ DPRINT1("Source bitmap must be 32bpp when AC_SRC_ALPHA is set\n");
+ return FALSE;
+ }
+
+ Dst = (PULONG)((ULONG_PTR)Dest->pvScan0 + (DestRect->top * Dest->lDelta) +
+ (DestRect->left << 2));
+ DstDelta = Dest->lDelta - ((DestRect->right - DestRect->left) << 2);
+ SrcBpp = BitsPerFormat(Source->iBitmapFormat);
+
+ Rows = DestRect->bottom - DestRect->top;
+ SrcY = SourceRect->top;
+ while (--Rows >= 0)
+ {
+ Cols = DestRect->right - DestRect->left;
+ SrcX = SourceRect->left;
+ while (--Cols >= 0)
{
- DPRINT1("Unsupported AlphaFormat (0x%x)\n", BlendFunc.AlphaFormat);
- return FALSE;
- }
- if ((BlendFunc.AlphaFormat & AC_SRC_ALPHA) != 0 &&
- BitsPerFormat(Source->iBitmapFormat) != 32)
- {
- DPRINT1("Source bitmap must be 32bpp when AC_SRC_ALPHA is set\n");
- return FALSE;
- }
-
- Dst = (PULONG)((ULONG_PTR)Dest->pvScan0 + (DestRect->top * Dest->lDelta) +
- (DestRect->left << 2));
- DstDelta = Dest->lDelta - ((DestRect->right - DestRect->left) << 2);
- SrcBpp = BitsPerFormat(Source->iBitmapFormat);
-
- Rows = DestRect->bottom - DestRect->top;
- SrcY = SourceRect->top;
- while (--Rows >= 0)
- {
- Cols = DestRect->right - DestRect->left;
- SrcX = SourceRect->left;
- while (--Cols >= 0)
- {
- 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;
- SrcPixel.col.alpha = (SrcBpp == 32) ? (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);
- *Dst++ = DstPixel.ul;
- }
- Dst = (PULONG)((ULONG_PTR)Dst + DstDelta);
- SrcY++;
+ 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;
+ SrcPixel.col.alpha = (SrcBpp == 32) ? (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);
+ *Dst++ = DstPixel.ul;
}
+ Dst = (PULONG)((ULONG_PTR)Dst + DstDelta);
+ SrcY++;
+ }
- return TRUE;
+ return TRUE;
}
/* EOF */
/*
- * ReactOS W32 Subsystem
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 2004, 2005, 2006 ReactOS Team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * PROJECT: Win32 subsystem
+ * LICENSE: See COPYING in the top level directory
+ * FILE: subsystems/win32/win32k/dib/dib32bppc.c
+ * PURPOSE: C language equivalents of asm optimised 32bpp functions
+ * PROGRAMMERS: Jason Filby
+ * Magnus Olsen
*/
-/* $Id: */
#include <w32k.h>
VOID
DIB_32BPP_HLine(SURFOBJ *SurfObj, LONG x1, LONG x2, LONG y, ULONG c)
{
- PBYTE byteaddr = (PBYTE)((ULONG_PTR)SurfObj->pvScan0 + y * SurfObj->lDelta);
- PDWORD addr = (PDWORD)byteaddr + x1;
- LONG cx = x1;
+ PBYTE byteaddr = (PBYTE)((ULONG_PTR)SurfObj->pvScan0 + y * SurfObj->lDelta);
+ PDWORD addr = (PDWORD)byteaddr + x1;
+ LONG cx = x1;
- while(cx < x2)
- {
- *addr = (DWORD)c;
- ++addr;
- ++cx;
- }
+ while(cx < x2)
+ {
+ *addr = (DWORD)c;
+ ++addr;
+ ++cx;
+ }
}
BOOLEAN
DIB_32BPP_ColorFill(SURFOBJ* DestSurface, RECTL* DestRect, ULONG color)
{
- ULONG DestY;
+ ULONG DestY;
- for (DestY = DestRect->top; DestY< DestRect->bottom; DestY++)
- {
- DIB_32BPP_HLine (DestSurface, DestRect->left, DestRect->right, DestY, color);
- }
+ for (DestY = DestRect->top; DestY< DestRect->bottom; DestY++)
+ {
+ DIB_32BPP_HLine (DestSurface, DestRect->left, DestRect->right, DestY, color);
+ }
- return TRUE;
+ return TRUE;
}
/*
- * ReactOS W32 Subsystem
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * PROJECT: Win32 subsystem
+ * LICENSE: See COPYING in the top level directory
+ * FILE: subsystems/win32/win32k/dib/dib4bpp.c
+ * PURPOSE: Device Independant Bitmap functions, 4bpp
+ * PROGRAMMERS: Jason Filby
*/
-/* $Id$ */
+
#include <w32k.h>
PBYTE addr = (PBYTE)SurfObj->pvScan0 + (x1>>1) + y * SurfObj->lDelta;
LONG cx = x1;
- while(cx < x2) {
+ while(cx < x2)
+ {
*addr = (*addr & notmask[x1&1]) | (c << ((1-(x1&1))<<2));
if((++x1 & 1) == 0)
++addr;
int lDelta = SurfObj->lDelta;
addr += (x>>1) + y1 * lDelta;
- while(y1++ < y2) {
+ while(y1++ < y2)
+ {
*addr = (*addr & notmask[x&1]) | (c << ((1-(x&1))<<2));
addr += lDelta;
}
if(DIB_1BPP_GetPixel(BltInfo->SourceSurface, sx, sy) == 0)
{
DIB_4BPP_PutPixel(BltInfo->DestSurface, i, j, XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, 0));
- } else {
+ }
+ else
+ {
DIB_4BPP_PutPixel(BltInfo->DestSurface, i, j, XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, 1));
}
sx++;
for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
{
- if (NULL != BltInfo->XlateSourceToDest)
- {
- DIB_4BPP_PutPixel(BltInfo->DestSurface, i, j, XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, DIB_4BPP_GetPixel(BltInfo->SourceSurface, sx, sy)));
- }
- else
- {
- DIB_4BPP_PutPixel(BltInfo->DestSurface, i, j, DIB_4BPP_GetPixel(BltInfo->SourceSurface, sx, sy));
- }
+ if (NULL != BltInfo->XlateSourceToDest)
+ {
+ DIB_4BPP_PutPixel(BltInfo->DestSurface, i, j, XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, DIB_4BPP_GetPixel(BltInfo->SourceSurface, sx, sy)));
+ }
+ else
+ {
+ DIB_4BPP_PutPixel(BltInfo->DestSurface, i, j, DIB_4BPP_GetPixel(BltInfo->SourceSurface, sx, sy));
+ }
sx++;
}
sy++;
BOOLEAN
DIB_4BPP_BitBlt(PBLTINFO BltInfo)
{
- ULONG DestX, DestY;
- ULONG SourceX, SourceY;
- ULONG PatternY = 0;
- ULONG Dest, Source = 0, Pattern = 0;
- BOOLEAN UsesSource;
- BOOLEAN UsesPattern;
- PULONG DestBits;
- LONG RoundedRight;
- static const ULONG ExpandSolidColor[16] =
- {
- 0x00000000 /* 0 */,
- 0x11111111 /* 1 */,
- 0x22222222 /* 2 */,
- 0x33333333 /* 3 */,
- 0x44444444 /* 4 */,
- 0x55555555 /* 5 */,
- 0x66666666 /* 6 */,
- 0x77777777 /* 7 */,
- 0x88888888 /* 8 */,
- 0x99999999 /* 9 */,
- 0xAAAAAAAA /* 10 */,
- 0xBBBBBBBB /* 11 */,
- 0xCCCCCCCC /* 12 */,
- 0xDDDDDDDD /* 13 */,
- 0xEEEEEEEE /* 14 */,
- 0xFFFFFFFF /* 15 */,
- };
-
- UsesSource = ROP4_USES_SOURCE(BltInfo->Rop4);
- UsesPattern = ROP4_USES_PATTERN(BltInfo->Rop4);
-
- SourceY = BltInfo->SourcePoint.y;
- RoundedRight = BltInfo->DestRect.right -
- ((BltInfo->DestRect.right - BltInfo->DestRect.left) & 0x7);
-
- if (UsesPattern)
- {
- if (BltInfo->PatternSurface)
+ ULONG DestX, DestY;
+ ULONG SourceX, SourceY;
+ ULONG PatternY = 0;
+ ULONG Dest, Source = 0, Pattern = 0;
+ BOOLEAN UsesSource;
+ BOOLEAN UsesPattern;
+ PULONG DestBits;
+ LONG RoundedRight;
+ static const ULONG ExpandSolidColor[16] =
+ {
+ 0x00000000 /* 0 */,
+ 0x11111111 /* 1 */,
+ 0x22222222 /* 2 */,
+ 0x33333333 /* 3 */,
+ 0x44444444 /* 4 */,
+ 0x55555555 /* 5 */,
+ 0x66666666 /* 6 */,
+ 0x77777777 /* 7 */,
+ 0x88888888 /* 8 */,
+ 0x99999999 /* 9 */,
+ 0xAAAAAAAA /* 10 */,
+ 0xBBBBBBBB /* 11 */,
+ 0xCCCCCCCC /* 12 */,
+ 0xDDDDDDDD /* 13 */,
+ 0xEEEEEEEE /* 14 */,
+ 0xFFFFFFFF /* 15 */,
+ };
+
+ UsesSource = ROP4_USES_SOURCE(BltInfo->Rop4);
+ UsesPattern = ROP4_USES_PATTERN(BltInfo->Rop4);
+
+ SourceY = BltInfo->SourcePoint.y;
+ RoundedRight = BltInfo->DestRect.right -
+ ((BltInfo->DestRect.right - BltInfo->DestRect.left) & 0x7);
+
+ if (UsesPattern)
+ {
+ if (BltInfo->PatternSurface)
+ {
+ PatternY = (BltInfo->DestRect.top + BltInfo->BrushOrigin.y) %
+ BltInfo->PatternSurface->sizlBitmap.cy;
+ }
+ else
+ {
+ if (BltInfo->Brush)
+ Pattern = ExpandSolidColor[BltInfo->Brush->iSolidColor];
+ }
+ }
+
+ for (DestY = BltInfo->DestRect.top; DestY < BltInfo->DestRect.bottom; DestY++)
+ {
+ DestBits = (PULONG)(
+ (PBYTE)BltInfo->DestSurface->pvScan0 +
+ (BltInfo->DestRect.left >> 1) +
+ DestY * BltInfo->DestSurface->lDelta);
+ SourceX = BltInfo->SourcePoint.x;
+ DestX = BltInfo->DestRect.left;
+
+ if (DestX & 0x1)
+ {
+ Dest = DIB_4BPP_GetPixel(BltInfo->DestSurface, DestX, DestY);
+
+ if (UsesSource)
{
- PatternY = (BltInfo->DestRect.top + BltInfo->BrushOrigin.y) %
- BltInfo->PatternSurface->sizlBitmap.cy;
+ Source = DIB_GetSource(BltInfo->SourceSurface, SourceX, SourceY, BltInfo->XlateSourceToDest);
}
- else
+
+ if (BltInfo->PatternSurface)
{
- if (BltInfo->Brush)
- Pattern = ExpandSolidColor[BltInfo->Brush->iSolidColor];
+ Pattern = DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest);
}
- }
-
- for (DestY = BltInfo->DestRect.top; DestY < BltInfo->DestRect.bottom; DestY++)
- {
- DestBits = (PULONG)(
- (PBYTE)BltInfo->DestSurface->pvScan0 +
- (BltInfo->DestRect.left >> 1) +
- DestY * BltInfo->DestSurface->lDelta);
- SourceX = BltInfo->SourcePoint.x;
- DestX = BltInfo->DestRect.left;
-
- if (DestX & 0x1)
- {
- Dest = DIB_4BPP_GetPixel(BltInfo->DestSurface, DestX, DestY);
-
- if (UsesSource)
- {
- Source = DIB_GetSource(BltInfo->SourceSurface, SourceX, SourceY, BltInfo->XlateSourceToDest);
- }
- if (BltInfo->PatternSurface)
- {
- Pattern = DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest);
- }
+ DIB_4BPP_PutPixel(BltInfo->DestSurface, DestX, DestY, DIB_DoRop(BltInfo->Rop4, Dest, Source, Pattern) & 0xF);
- DIB_4BPP_PutPixel(BltInfo->DestSurface, DestX, DestY, DIB_DoRop(BltInfo->Rop4, Dest, Source, Pattern) & 0xF);
+ DestX++;
+ SourceX++;
+ DestBits = (PULONG)((ULONG_PTR)DestBits + 1);
+ }
- DestX++;
- SourceX++;
- DestBits = (PULONG)((ULONG_PTR)DestBits + 1);
+ for (; DestX < RoundedRight; DestX += 8, SourceX += 8, DestBits++)
+ {
+ Dest = *DestBits;
+ if (UsesSource)
+ {
+ Source =
+ (DIB_GetSource(BltInfo->SourceSurface, SourceX + 1, SourceY, BltInfo->XlateSourceToDest)) |
+ (DIB_GetSource(BltInfo->SourceSurface, SourceX + 0, SourceY, BltInfo->XlateSourceToDest) << 4) |
+ (DIB_GetSource(BltInfo->SourceSurface, SourceX + 3, SourceY, BltInfo->XlateSourceToDest) << 8) |
+ (DIB_GetSource(BltInfo->SourceSurface, SourceX + 2, SourceY, BltInfo->XlateSourceToDest) << 12) |
+ (DIB_GetSource(BltInfo->SourceSurface, SourceX + 5, SourceY, BltInfo->XlateSourceToDest) << 16) |
+ (DIB_GetSource(BltInfo->SourceSurface, SourceX + 4, SourceY, BltInfo->XlateSourceToDest) << 20) |
+ (DIB_GetSource(BltInfo->SourceSurface, SourceX + 7, SourceY, BltInfo->XlateSourceToDest) << 24) |
+ (DIB_GetSource(BltInfo->SourceSurface, SourceX + 6, SourceY, BltInfo->XlateSourceToDest) << 28);
}
-
- for (; DestX < RoundedRight; DestX += 8, SourceX += 8, DestBits++)
+ if (BltInfo->PatternSurface)
{
- Dest = *DestBits;
- if (UsesSource)
- {
- Source =
- (DIB_GetSource(BltInfo->SourceSurface, SourceX + 1, SourceY, BltInfo->XlateSourceToDest)) |
- (DIB_GetSource(BltInfo->SourceSurface, SourceX + 0, SourceY, BltInfo->XlateSourceToDest) << 4) |
- (DIB_GetSource(BltInfo->SourceSurface, SourceX + 3, SourceY, BltInfo->XlateSourceToDest) << 8) |
- (DIB_GetSource(BltInfo->SourceSurface, SourceX + 2, SourceY, BltInfo->XlateSourceToDest) << 12) |
- (DIB_GetSource(BltInfo->SourceSurface, SourceX + 5, SourceY, BltInfo->XlateSourceToDest) << 16) |
- (DIB_GetSource(BltInfo->SourceSurface, SourceX + 4, SourceY, BltInfo->XlateSourceToDest) << 20) |
- (DIB_GetSource(BltInfo->SourceSurface, SourceX + 7, SourceY, BltInfo->XlateSourceToDest) << 24) |
- (DIB_GetSource(BltInfo->SourceSurface, SourceX + 6, SourceY, BltInfo->XlateSourceToDest) << 28);
- }
- if (BltInfo->PatternSurface)
- {
- Pattern = DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x + 1) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest);
- Pattern |= DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x + 0) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest) << 4;
- Pattern |= DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x + 3) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest) << 8;
- Pattern |= DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x + 2) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest) << 12;
- Pattern |= DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x + 5) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest) << 16;
- Pattern |= DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x + 4) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest) << 20;
- Pattern |= DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x + 7) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest) << 24;
- Pattern |= DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x + 6) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest) << 28;
- }
- *DestBits = DIB_DoRop(BltInfo->Rop4, Dest, Source, Pattern);
+ Pattern = DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x + 1) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest);
+ Pattern |= DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x + 0) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest) << 4;
+ Pattern |= DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x + 3) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest) << 8;
+ Pattern |= DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x + 2) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest) << 12;
+ Pattern |= DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x + 5) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest) << 16;
+ Pattern |= DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x + 4) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest) << 20;
+ Pattern |= DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x + 7) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest) << 24;
+ Pattern |= DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x + 6) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest) << 28;
}
-
- /* Process the rest of pixel on the line */
- for (; DestX < BltInfo->DestRect.right; DestX++, SourceX++)
+ *DestBits = DIB_DoRop(BltInfo->Rop4, Dest, Source, Pattern);
+ }
+
+ /* Process the rest of pixel on the line */
+ for (; DestX < BltInfo->DestRect.right; DestX++, SourceX++)
+ {
+ Dest = DIB_4BPP_GetPixel(BltInfo->DestSurface, DestX, DestY);
+ if (UsesSource)
{
- Dest = DIB_4BPP_GetPixel(BltInfo->DestSurface, DestX, DestY);
- if (UsesSource)
- {
- Source = DIB_GetSource(BltInfo->SourceSurface, SourceX, SourceY, BltInfo->XlateSourceToDest);
- }
- if (BltInfo->PatternSurface)
- {
- Pattern = DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest);
- }
- DIB_4BPP_PutPixel(BltInfo->DestSurface, DestX, DestY, DIB_DoRop(BltInfo->Rop4, Dest, Source, Pattern) & 0xF);
+ Source = DIB_GetSource(BltInfo->SourceSurface, SourceX, SourceY, BltInfo->XlateSourceToDest);
}
-
- SourceY++;
if (BltInfo->PatternSurface)
{
- PatternY++;
- PatternY %= BltInfo->PatternSurface->sizlBitmap.cy;
+ Pattern = DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest);
}
- }
+ DIB_4BPP_PutPixel(BltInfo->DestSurface, DestX, DestY, DIB_DoRop(BltInfo->Rop4, Dest, Source, Pattern) & 0xF);
+ }
+
+ SourceY++;
+ if (BltInfo->PatternSurface)
+ {
+ PatternY++;
+ PatternY %= BltInfo->PatternSurface->sizlBitmap.cy;
+ }
+ }
- return TRUE;
+ return TRUE;
}
/* BitBlt Optimize */
{
ULONG DestY;
- for (DestY = DestRect->top; DestY< DestRect->bottom; DestY++)
- {
- DIB_4BPP_HLine(DestSurface, DestRect->left, DestRect->right, DestY, color);
- }
-
-return TRUE;
+ for (DestY = DestRect->top; DestY < DestRect->bottom; DestY++)
+ {
+ DIB_4BPP_HLine(DestSurface, DestRect->left, DestRect->right, DestY, color);
+ }
+ return TRUE;
}
BOOLEAN
/*
- * ReactOS W32 Subsystem
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * PROJECT: Win32 subsystem
+ * LICENSE: See COPYING in the top level directory
+ * FILE: subsystems/win32/win32k/dib/dib8bpp.c
+ * PURPOSE: Device Independant Bitmap functions, 8bpp
+ * PROGRAMMERS: Jason Filby
+ * Thomas Bluemel
+ * Gregor Anich
*/
-/* $Id$ */
#include <w32k.h>
LONG lDelta = SurfObj->lDelta;
byteaddr = addr;
- while(y1++ < y2) {
+ while(y1++ < y2)
+ {
*addr = c;
addr += lDelta;
if(DIB_1BPP_GetPixel(BltInfo->SourceSurface, sx, sy) == 0)
{
DIB_8BPP_PutPixel(BltInfo->DestSurface, i, j, XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, 0));
- } else {
+ }
+ else
+ {
DIB_8BPP_PutPixel(BltInfo->DestSurface, i, j, XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, 1));
}
sx++;
case BMF_8BPP:
if (NULL == BltInfo->XlateSourceToDest || 0 != (BltInfo->XlateSourceToDest->flXlate & XO_TRIVIAL))
{
- if (BltInfo->DestRect.top < BltInfo->SourcePoint.y)
- {
- SourceBits = (PBYTE)BltInfo->SourceSurface->pvScan0 + (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) + BltInfo->SourcePoint.x;
- for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
- {
- RtlMoveMemory(DestBits, SourceBits, BltInfo->DestRect.right - BltInfo->DestRect.left);
- SourceBits += BltInfo->SourceSurface->lDelta;
- DestBits += BltInfo->DestSurface->lDelta;
- }
- }
- else
- {
- SourceBits = (PBYTE)BltInfo->SourceSurface->pvScan0 + ((BltInfo->SourcePoint.y + BltInfo->DestRect.bottom - BltInfo->DestRect.top - 1) * BltInfo->SourceSurface->lDelta) + BltInfo->SourcePoint.x;
- DestBits = (PBYTE)BltInfo->DestSurface->pvScan0 + ((BltInfo->DestRect.bottom - 1) * BltInfo->DestSurface->lDelta) + BltInfo->DestRect.left;
- for (j = BltInfo->DestRect.bottom - 1; BltInfo->DestRect.top <= j; j--)
- {
- RtlMoveMemory(DestBits, SourceBits, BltInfo->DestRect.right - BltInfo->DestRect.left);
- SourceBits -= BltInfo->SourceSurface->lDelta;
- DestBits -= BltInfo->DestSurface->lDelta;
- }
- }
+ if (BltInfo->DestRect.top < BltInfo->SourcePoint.y)
+ {
+ SourceBits = (PBYTE)BltInfo->SourceSurface->pvScan0 + (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) + BltInfo->SourcePoint.x;
+ for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
+ {
+ RtlMoveMemory(DestBits, SourceBits, BltInfo->DestRect.right - BltInfo->DestRect.left);
+ SourceBits += BltInfo->SourceSurface->lDelta;
+ DestBits += BltInfo->DestSurface->lDelta;
+ }
+ }
+ else
+ {
+ SourceBits = (PBYTE)BltInfo->SourceSurface->pvScan0 + ((BltInfo->SourcePoint.y + BltInfo->DestRect.bottom - BltInfo->DestRect.top - 1) * BltInfo->SourceSurface->lDelta) + BltInfo->SourcePoint.x;
+ DestBits = (PBYTE)BltInfo->DestSurface->pvScan0 + ((BltInfo->DestRect.bottom - 1) * BltInfo->DestSurface->lDelta) + BltInfo->DestRect.left;
+ for (j = BltInfo->DestRect.bottom - 1; BltInfo->DestRect.top <= j; j--)
+ {
+ RtlMoveMemory(DestBits, SourceBits, BltInfo->DestRect.right - BltInfo->DestRect.left);
+ SourceBits -= BltInfo->SourceSurface->lDelta;
+ DestBits -= BltInfo->DestSurface->lDelta;
+ }
+ }
}
else
{
- if (BltInfo->DestRect.top < BltInfo->SourcePoint.y)
- {
- SourceLine = (PBYTE)BltInfo->SourceSurface->pvScan0 + (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) + BltInfo->SourcePoint.x;
- DestLine = DestBits;
- for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
- {
- SourceBits = SourceLine;
- DestBits = DestLine;
- for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
- {
- *DestBits++ = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, *SourceBits++);
- }
- SourceLine += BltInfo->SourceSurface->lDelta;
- DestLine += BltInfo->DestSurface->lDelta;
- }
- }
- else
- {
- SourceLine = (PBYTE)BltInfo->SourceSurface->pvScan0 + ((BltInfo->SourcePoint.y + BltInfo->DestRect.bottom - BltInfo->DestRect.top - 1) * BltInfo->SourceSurface->lDelta) + BltInfo->SourcePoint.x;
- DestLine = (PBYTE)BltInfo->DestSurface->pvScan0 + ((BltInfo->DestRect.bottom - 1) * BltInfo->DestSurface->lDelta) + BltInfo->DestRect.left;
- for (j = BltInfo->DestRect.bottom - 1; BltInfo->DestRect.top <= j; j--)
- {
- SourceBits = SourceLine;
- DestBits = DestLine;
- for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
- {
- *DestBits++ = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, *SourceBits++);
- }
- SourceLine -= BltInfo->SourceSurface->lDelta;
- DestLine -= BltInfo->DestSurface->lDelta;
- }
- }
+ if (BltInfo->DestRect.top < BltInfo->SourcePoint.y)
+ {
+ SourceLine = (PBYTE)BltInfo->SourceSurface->pvScan0 + (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) + BltInfo->SourcePoint.x;
+ DestLine = DestBits;
+ for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
+ {
+ SourceBits = SourceLine;
+ DestBits = DestLine;
+ for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
+ {
+ *DestBits++ = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, *SourceBits++);
+ }
+ SourceLine += BltInfo->SourceSurface->lDelta;
+ DestLine += BltInfo->DestSurface->lDelta;
+ }
+ }
+ else
+ {
+ SourceLine = (PBYTE)BltInfo->SourceSurface->pvScan0 + ((BltInfo->SourcePoint.y + BltInfo->DestRect.bottom - BltInfo->DestRect.top - 1) * BltInfo->SourceSurface->lDelta) + BltInfo->SourcePoint.x;
+ DestLine = (PBYTE)BltInfo->DestSurface->pvScan0 + ((BltInfo->DestRect.bottom - 1) * BltInfo->DestSurface->lDelta) + BltInfo->DestRect.left;
+ for (j = BltInfo->DestRect.bottom - 1; BltInfo->DestRect.top <= j; j--)
+ {
+ SourceBits = SourceLine;
+ DestBits = DestLine;
+ for (i=BltInfo->DestRect.left; i<BltInfo->DestRect.right; i++)
+ {
+ *DestBits++ = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, *SourceBits++);
+ }
+ SourceLine -= BltInfo->SourceSurface->lDelta;
+ DestLine -= BltInfo->DestSurface->lDelta;
+ }
+ }
}
break;
xColor = *((PWORD) SourceBits);
*DestBits = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, xColor);
SourceBits += 2;
- DestBits += 1;
+ DestBits += 1;
}
SourceLine += BltInfo->SourceSurface->lDelta;
(*(SourceBits));
*DestBits = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, xColor);
SourceBits += 3;
- DestBits += 1;
+ DestBits += 1;
}
SourceLine += BltInfo->SourceSurface->lDelta;
xColor = *((PDWORD) SourceBits);
*DestBits = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, xColor);
SourceBits += 4;
- DestBits += 1;
+ DestBits += 1;
}
SourceLine += BltInfo->SourceSurface->lDelta;
{
ULONG DestY;
for (DestY = DestRect->top; DestY< DestRect->bottom; DestY++)
- {
- DIB_8BPP_HLine(DestSurface, DestRect->left, DestRect->right, DestY, color);
- }
-
+ {
+ DIB_8BPP_HLine(DestSurface, DestRect->left, DestRect->right, DestY, color);
+ }
return TRUE;
}
}
typedef union {
- ULONG ul;
- struct {
- UCHAR red;
- UCHAR green;
- UCHAR blue;
- UCHAR alpha;
- } col;
+ ULONG ul;
+ struct {
+ UCHAR red;
+ UCHAR green;
+ UCHAR blue;
+ UCHAR alpha;
+ } col;
} NICEPIXEL32;
typedef union {
- USHORT us;
- struct {
- USHORT red:5,
- green:6,
- blue:5;
- } col;
+ USHORT us;
+ struct {
+ USHORT red:5,
+ green:6,
+ blue:5;
+ } col;
} NICEPIXEL16;
static __inline UCHAR
Clamp8(ULONG val)
{
- return (val > 255) ? 255 : val;
+ return (val > 255) ? 255 : val;
}
BOOLEAN
RECTL* SourceRect, CLIPOBJ* ClipRegion,
XLATEOBJ* ColorTranslation, BLENDOBJ* BlendObj)
{
- INT Rows, Cols, SrcX, SrcY;
- register PUCHAR Dst;
- ULONG DstDelta;
- BLENDFUNCTION BlendFunc;
- register NICEPIXEL32 DstPixel32;
- register NICEPIXEL32 SrcPixel32;
- register NICEPIXEL16 SrcPixel16;
- UCHAR Alpha, SrcBpp;
- XLATEGDI* XlateGDI;
- XLATEOBJ* SrcXlateObj;
-
- DPRINT("DIB_8BPP_AlphaBlend: srcRect: (%d,%d)-(%d,%d), dstRect: (%d,%d)-(%d,%d)\n",
- SourceRect->left, SourceRect->top, SourceRect->right, SourceRect->bottom,
- DestRect->left, DestRect->top, DestRect->right, DestRect->bottom);
-
- ASSERT(DestRect->bottom - DestRect->top == SourceRect->bottom - SourceRect->top &&
- DestRect->right - DestRect->left == SourceRect->right - SourceRect->left);
-
- BlendFunc = BlendObj->BlendFunction;
- if (BlendFunc.BlendOp != AC_SRC_OVER)
- {
- DPRINT1("BlendOp != AC_SRC_OVER\n");
- return FALSE;
- }
- if (BlendFunc.BlendFlags != 0)
- {
- DPRINT1("BlendFlags != 0\n");
- return FALSE;
- }
- if ((BlendFunc.AlphaFormat & ~AC_SRC_ALPHA) != 0)
- {
- DPRINT1("Unsupported AlphaFormat (0x%x)\n", BlendFunc.AlphaFormat);
- return FALSE;
- }
- if ((BlendFunc.AlphaFormat & AC_SRC_ALPHA) != 0 &&
- BitsPerFormat(Source->iBitmapFormat) != 32)
- {
- DPRINT1("Source bitmap must be 32bpp when AC_SRC_ALPHA is set\n");
- return FALSE;
- }
- if (!ColorTranslation)
- {
- DPRINT1("ColorTranslation must not be NULL!\n");
- return FALSE;
- }
+ INT Rows, Cols, SrcX, SrcY;
+ register PUCHAR Dst;
+ ULONG DstDelta;
+ BLENDFUNCTION BlendFunc;
+ register NICEPIXEL32 DstPixel32;
+ register NICEPIXEL32 SrcPixel32;
+ register NICEPIXEL16 SrcPixel16;
+ UCHAR Alpha, SrcBpp;
+ XLATEGDI* XlateGDI;
+ XLATEOBJ* SrcXlateObj;
+
+ DPRINT("DIB_8BPP_AlphaBlend: srcRect: (%d,%d)-(%d,%d), dstRect: (%d,%d)-(%d,%d)\n",
+ SourceRect->left, SourceRect->top, SourceRect->right, SourceRect->bottom,
+ DestRect->left, DestRect->top, DestRect->right, DestRect->bottom);
+
+ ASSERT(DestRect->bottom - DestRect->top == SourceRect->bottom - SourceRect->top &&
+ DestRect->right - DestRect->left == SourceRect->right - SourceRect->left);
+
+ BlendFunc = BlendObj->BlendFunction;
+ if (BlendFunc.BlendOp != AC_SRC_OVER)
+ {
+ DPRINT1("BlendOp != AC_SRC_OVER\n");
+ return FALSE;
+ }
+ if (BlendFunc.BlendFlags != 0)
+ {
+ DPRINT1("BlendFlags != 0\n");
+ return FALSE;
+ }
+ if ((BlendFunc.AlphaFormat & ~AC_SRC_ALPHA) != 0)
+ {
+ DPRINT1("Unsupported AlphaFormat (0x%x)\n", BlendFunc.AlphaFormat);
+ return FALSE;
+ }
+ if ((BlendFunc.AlphaFormat & AC_SRC_ALPHA) != 0 &&
+ BitsPerFormat(Source->iBitmapFormat) != 32)
+ {
+ DPRINT1("Source bitmap must be 32bpp when AC_SRC_ALPHA is set\n");
+ return FALSE;
+ }
+ if (!ColorTranslation)
+ {
+ DPRINT1("ColorTranslation must not be NULL!\n");
+ return FALSE;
+ }
- XlateGDI = ObjToGDI(ColorTranslation, XLATE);
- SrcXlateObj = IntEngCreateXlate(0, 0, XlateGDI->SourcePal, XlateGDI->DestPal);
+ XlateGDI = ObjToGDI(ColorTranslation, XLATE);
+ SrcXlateObj = IntEngCreateXlate(0, 0, XlateGDI->SourcePal, XlateGDI->DestPal);
- if (!SrcXlateObj)
- {
- DPRINT1("IntEngCreateXlate failed\n");
- return FALSE;
- }
-
- Dst = (PUCHAR)((ULONG_PTR)Dest->pvScan0 + (DestRect->top * Dest->lDelta) +
- DestRect->left);
- DstDelta = Dest->lDelta - (DestRect->right - DestRect->left);
- SrcBpp = BitsPerFormat(Source->iBitmapFormat);
-
- Rows = DestRect->bottom - DestRect->top;
- SrcY = SourceRect->top;
- while (--Rows >= 0)
- {
- Cols = DestRect->right - DestRect->left;
- SrcX = SourceRect->left;
- while (--Cols >= 0)
+ if (!SrcXlateObj)
+ {
+ DPRINT1("IntEngCreateXlate failed\n");
+ return FALSE;
+ }
+
+ Dst = (PUCHAR)((ULONG_PTR)Dest->pvScan0 + (DestRect->top * Dest->lDelta) +
+ DestRect->left);
+ DstDelta = Dest->lDelta - (DestRect->right - DestRect->left);
+ SrcBpp = BitsPerFormat(Source->iBitmapFormat);
+
+ Rows = DestRect->bottom - DestRect->top;
+ SrcY = SourceRect->top;
+ while (--Rows >= 0)
+ {
+ Cols = DestRect->right - DestRect->left;
+ SrcX = SourceRect->left;
+ while (--Cols >= 0)
+ {
+ if (SrcBpp <= 16)
{
- if (SrcBpp <= 16)
- {
- SrcPixel16.us = DIB_GetSource(Source, SrcX++, SrcY, ColorTranslation);
- SrcPixel32.col.red = (SrcPixel16.col.red << 3) | (SrcPixel16.col.red >> 2);
- SrcPixel32.col.green = (SrcPixel16.col.green << 2) | (SrcPixel16.col.green >> 4);
- SrcPixel32.col.blue = (SrcPixel16.col.blue << 3) | (SrcPixel16.col.blue >> 2);
- }
- else
- {
- SrcPixel32.ul = DIB_GetSourceIndex(Source, SrcX++, SrcY);
- }
- 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;
- SrcPixel32.col.alpha = (SrcBpp == 32) ? (SrcPixel32.col.alpha * BlendFunc.SourceConstantAlpha / 255) : BlendFunc.SourceConstantAlpha;
-
- Alpha = ((BlendFunc.AlphaFormat & AC_SRC_ALPHA) != 0) ?
- SrcPixel32.col.alpha : BlendFunc.SourceConstantAlpha;
-
- DstPixel32.ul = XLATEOBJ_iXlate(SrcXlateObj, *Dst);
- SrcPixel32.col.red = Clamp8(DstPixel32.col.red * (255 - Alpha) / 255 + SrcPixel32.col.red);
- SrcPixel32.col.green = Clamp8(DstPixel32.col.green * (255 - Alpha) / 255 + SrcPixel32.col.green);
- SrcPixel32.col.blue = Clamp8(DstPixel32.col.blue * (255 - Alpha) / 255 + SrcPixel32.col.blue);
- *Dst++ = XLATEOBJ_iXlate(ColorTranslation, SrcPixel32.ul);
+ SrcPixel16.us = DIB_GetSource(Source, SrcX++, SrcY, ColorTranslation);
+ SrcPixel32.col.red = (SrcPixel16.col.red << 3) | (SrcPixel16.col.red >> 2);
+ SrcPixel32.col.green = (SrcPixel16.col.green << 2) | (SrcPixel16.col.green >> 4);
+ SrcPixel32.col.blue = (SrcPixel16.col.blue << 3) | (SrcPixel16.col.blue >> 2);
}
- Dst = (PUCHAR)((ULONG_PTR)Dst + DstDelta);
- SrcY++;
- }
+ else
+ {
+ SrcPixel32.ul = DIB_GetSourceIndex(Source, SrcX++, SrcY);
+ }
+ 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;
+ SrcPixel32.col.alpha = (SrcBpp == 32) ? (SrcPixel32.col.alpha * BlendFunc.SourceConstantAlpha / 255) : BlendFunc.SourceConstantAlpha;
+
+ Alpha = ((BlendFunc.AlphaFormat & AC_SRC_ALPHA) != 0) ?
+ SrcPixel32.col.alpha : BlendFunc.SourceConstantAlpha;
+
+ DstPixel32.ul = XLATEOBJ_iXlate(SrcXlateObj, *Dst);
+ SrcPixel32.col.red = Clamp8(DstPixel32.col.red * (255 - Alpha) / 255 + SrcPixel32.col.red);
+ SrcPixel32.col.green = Clamp8(DstPixel32.col.green * (255 - Alpha) / 255 + SrcPixel32.col.green);
+ SrcPixel32.col.blue = Clamp8(DstPixel32.col.blue * (255 - Alpha) / 255 + SrcPixel32.col.blue);
+ *Dst++ = XLATEOBJ_iXlate(ColorTranslation, SrcPixel32.ul);
+ }
+ Dst = (PUCHAR)((ULONG_PTR)Dst + DstDelta);
+ SrcY++;
+ }
- if (SrcXlateObj)
- EngDeleteXlate(SrcXlateObj);
+ if (SrcXlateObj)
+ EngDeleteXlate(SrcXlateObj);
- return TRUE;
+ return TRUE;
}
/* EOF */
+++ /dev/null
-/*
- * ReactOS W32 Subsystem
- * Copyright (C) 2009 ReactOS Team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <w32k.h>
-
-#define NDEBUG
-#include <debug.h>
-
-BOOLEAN DIB_XXBPP_StretchBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, SURFOBJ *MaskSurf,
- SURFOBJ *PatternSurface,
- RECTL *DestRect, RECTL *SourceRect,
- POINTL *MaskOrigin, BRUSHOBJ *Brush,
- POINTL *BrushOrigin, XLATEOBJ *ColorTranslation,
- XLATEOBJ *XlatePatternToDest, ROP4 ROP)
-{
- LONG sx = 0;
- LONG sy = 0;
- LONG DesX;
- LONG DesY;
-
- LONG DstHeight;
- LONG DstWidth;
- LONG SrcHeight;
- LONG SrcWidth;
-
- ULONG Color;
- ULONG Dest, Source = 0, Pattern = 0;
- ULONG xxBPPMask;
- BOOLEAN CanDraw;
-
- PFN_DIB_GetPixel fnSource_GetPixel = NULL;
- PFN_DIB_GetPixel fnDest_GetPixel = NULL;
- PFN_DIB_PutPixel fnDest_PutPixel = NULL;
- PFN_DIB_GetPixel fnPattern_GetPixel = NULL;
- PFN_DIB_GetPixel fnMask_GetPixel = NULL;
-
- LONG PatternX = 0, PatternY = 0;
-
- BOOL UsesSource = ROP4_USES_SOURCE(ROP);
- BOOL UsesPattern = ROP4_USES_PATTERN(ROP);
-
- fnDest_GetPixel = DibFunctionsForBitmapFormat[DestSurf->iBitmapFormat].DIB_GetPixel;
- fnDest_PutPixel = DibFunctionsForBitmapFormat[DestSurf->iBitmapFormat].DIB_PutPixel;
-
- DPRINT("Dest BPP: %u, dstRect: (%d,%d)-(%d,%d)\n",
- BitsPerFormat(DestSurf->iBitmapFormat), DestRect->left, DestRect->top, DestRect->right, DestRect->bottom);
-
- if (UsesSource)
- {
- fnSource_GetPixel = DibFunctionsForBitmapFormat[SourceSurf->iBitmapFormat].DIB_GetPixel;
- DPRINT("Source BPP: %u, srcRect: (%d,%d)-(%d,%d)\n",
- BitsPerFormat(SourceSurf->iBitmapFormat), SourceRect->left, SourceRect->top, SourceRect->right, SourceRect->bottom);
- }
-
- if (MaskSurf)
- {
- fnMask_GetPixel = DibFunctionsForBitmapFormat[MaskSurf->iBitmapFormat].DIB_GetPixel;
- }
-
- DstHeight = DestRect->bottom - DestRect->top;
- DstWidth = DestRect->right - DestRect->left;
- SrcHeight = SourceRect->bottom - SourceRect->top;
- SrcWidth = SourceRect->right - SourceRect->left;
-
- /* FIXME : MaskOrigin? */
-
- switch(DestSurf->iBitmapFormat)
- {
- case BMF_1BPP: xxBPPMask = 0x1; break;
- case BMF_4BPP: xxBPPMask = 0xF; break;
- case BMF_8BPP: xxBPPMask = 0xFF; break;
- case BMF_16BPP: xxBPPMask = 0xFFFF; break;
- case BMF_24BPP: xxBPPMask = 0xFFFFFF; break;
- default:
- xxBPPMask = 0xFFFFFFFF;
- }
-
- if (UsesPattern)
- {
- if (PatternSurface)
- {
- PatternY = (DestRect->top - BrushOrigin->y) % PatternSurface->sizlBitmap.cy;
- if (PatternY < 0)
- {
- PatternY += PatternSurface->sizlBitmap.cy;
- }
- fnPattern_GetPixel = DibFunctionsForBitmapFormat[PatternSurface->iBitmapFormat].DIB_GetPixel;
- }
- else
- {
- if (Brush)
- Pattern = Brush->iSolidColor;
- }
- }
-
-
- for (DesY = DestRect->top; DesY < DestRect->bottom; DesY++)
- {
- if (PatternSurface)
- {
- PatternX = (DestRect->left - BrushOrigin->x) % PatternSurface->sizlBitmap.cx;
- if (PatternX < 0)
- {
- PatternX += PatternSurface->sizlBitmap.cx;
- }
- }
- if (UsesSource)
- sy = SourceRect->top+(DesY - DestRect->top) * SrcHeight / DstHeight;
-
- for (DesX = DestRect->left; DesX < DestRect->right; DesX++)
- {
- CanDraw = TRUE;
-
- if (fnMask_GetPixel)
- {
- sx = SourceRect->left+(DesX - DestRect->left) * SrcWidth / DstWidth;
- if (sx < 0 || sy < 0 ||
- MaskSurf->sizlBitmap.cx < sx || MaskSurf->sizlBitmap.cy < sy ||
- fnMask_GetPixel(MaskSurf, sx, sy) != 0)
- {
- CanDraw = FALSE;
- }
- }
-
- if (UsesSource && CanDraw)
- {
- sx = SourceRect->left+(DesX - DestRect->left) * SrcWidth / DstWidth;
- if (sx >= 0 && sy >= 0 &&
- SourceSurf->sizlBitmap.cx > sx && SourceSurf->sizlBitmap.cy > sy)
- {
- Source = XLATEOBJ_iXlate(ColorTranslation, fnSource_GetPixel(SourceSurf, sx, sy));
- }
- else
- {
- Source = 0;
- CanDraw = (ROP3_TO_ROP4(SRCCOPY) != ROP);
- }
- }
-
- if (CanDraw)
- {
- if (PatternSurface)
- {
- Pattern = XLATEOBJ_iXlate(XlatePatternToDest, fnPattern_GetPixel(PatternSurface, PatternX, PatternY));
- PatternX++;
- PatternX %= PatternSurface->sizlBitmap.cx;
- }
-
- Dest = fnDest_GetPixel(DestSurf, DesX, DesY);
- Color = DIB_DoRop(ROP, Dest, Source, Pattern) & xxBPPMask;
-
- fnDest_PutPixel(DestSurf, DesX, DesY, Color);
- }
- }
-
- if (PatternSurface)
- {
- PatternY++;
- PatternY %= PatternSurface->sizlBitmap.cy;
- }
- }
-
- return TRUE;
-}
-
-/* EOF */
/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS win32 subsystem
- * PURPOSE: Flood filling support
- * FILE: subsystems/win32/win32k/dib/floodfill.c
- * PROGRAMMER: Gregor Schneider, <grschneider AT gmail DOT com>
- */
+* COPYRIGHT: See COPYING in the top level directory
+* PROJECT: ReactOS win32 subsystem
+* PURPOSE: Flood filling support
+* FILE: subsystems/win32/win32k/dib/floodfill.c
+* PROGRAMMER: Gregor Schneider, <grschneider AT gmail DOT com>
+*/
#include <w32k.h>
/* Floodfil helper structures and functions */
typedef struct _floodItem
{
- ULONG x;
- ULONG y;
+ ULONG x;
+ ULONG y;
} FLOODITEM;
typedef struct _floodInfo
{
- ULONG floodLen;
- FLOODITEM *floodStart;
- FLOODITEM *floodData;
+ ULONG floodLen;
+ FLOODITEM *floodStart;
+ FLOODITEM *floodData;
} FLOODINFO;
static __inline BOOL initFlood(FLOODINFO *info, RECTL *DstRect)
{
- ULONG width = DstRect->right - DstRect->left;
- ULONG height = DstRect->bottom - DstRect->top;
- info->floodData = ExAllocatePoolWithTag(NonPagedPool, width * height * sizeof(FLOODITEM), TAG_DIB);
- if (info->floodData == NULL)
- {
- return FALSE;
- }
- info->floodStart = info->floodData + (width * height);
- DPRINT("Allocated flood stack from %p to %p\n", info->floodData, info->floodStart);
- return TRUE;
+ ULONG width = DstRect->right - DstRect->left;
+ ULONG height = DstRect->bottom - DstRect->top;
+ info->floodData = ExAllocatePoolWithTag(NonPagedPool, width * height * sizeof(FLOODITEM), TAG_DIB);
+ if (info->floodData == NULL)
+ {
+ return FALSE;
+ }
+ info->floodStart = info->floodData + (width * height);
+ DPRINT("Allocated flood stack from %p to %p\n", info->floodData, info->floodStart);
+ return TRUE;
}
static __inline VOID finalizeFlood(FLOODINFO *info)
{
- ExFreePoolWithTag(info->floodData, TAG_DIB);
+ ExFreePoolWithTag(info->floodData, TAG_DIB);
}
static __inline VOID addItemFlood(FLOODINFO *info,
ULONG x,
ULONG Color,
BOOL isSurf)
{
- if (x >= DstRect->left && x <= DstRect->right &&
- y >= DstRect->top && y <= DstRect->bottom)
+ if (x >= DstRect->left && x <= DstRect->right &&
+ y >= DstRect->top && y <= DstRect->bottom)
+ {
+ if (isSurf == TRUE &&
+ DibFunctionsForBitmapFormat[DstSurf->iBitmapFormat].DIB_GetPixel(DstSurf, x, y) != Color)
{
- if (isSurf == TRUE &&
- DibFunctionsForBitmapFormat[DstSurf->iBitmapFormat].DIB_GetPixel(DstSurf, x, y) != Color)
- {
- return;
- }
- else if (isSurf == FALSE &&
- DibFunctionsForBitmapFormat[DstSurf->iBitmapFormat].DIB_GetPixel(DstSurf, x, y) == Color)
- {
- return;
- }
- info->floodStart--;
- info->floodStart->x = x;
- info->floodStart->y = y;
- info->floodLen++;
+ return;
}
+ else if (isSurf == FALSE &&
+ DibFunctionsForBitmapFormat[DstSurf->iBitmapFormat].DIB_GetPixel(DstSurf, x, y) == Color)
+ {
+ return;
+ }
+ info->floodStart--;
+ info->floodStart->x = x;
+ info->floodStart->y = y;
+ info->floodLen++;
+ }
}
static __inline VOID removeItemFlood(FLOODINFO *info)
{
- info->floodStart++;
- info->floodLen--;
+ info->floodStart++;
+ info->floodLen--;
}
BOOLEAN DIB_XXBPP_FloodFillSolid(SURFOBJ *DstSurf,
ULONG ConvColor,
UINT FillType)
{
- ULONG x, y;
- ULONG BrushColor;
- FLOODINFO flood = {0, NULL, NULL};
+ ULONG x, y;
+ ULONG BrushColor;
+ FLOODINFO flood = {0, NULL, NULL};
- BrushColor = Brush->iSolidColor;
- x = Origin->x;
- y = Origin->y;
+ BrushColor = Brush->iSolidColor;
+ x = Origin->x;
+ y = Origin->y;
- if (FillType == FLOODFILLBORDER)
+ if (FillType == FLOODFILLBORDER)
+ {
+ /* Check if the start pixel has the border color */
+ if (DibFunctionsForBitmapFormat[DstSurf->iBitmapFormat].DIB_GetPixel(DstSurf, x, y) == ConvColor)
{
- /* Check if the start pixel has the border color */
- if (DibFunctionsForBitmapFormat[DstSurf->iBitmapFormat].DIB_GetPixel(DstSurf, x, y) == ConvColor)
- {
- return FALSE;
- }
+ return FALSE;
+ }
- if (initFlood(&flood, DstRect) == FALSE)
- {
- return FALSE;
- }
- addItemFlood(&flood, x, y, DstSurf, DstRect, ConvColor, FALSE);
- while (flood.floodLen != 0)
- {
- x = flood.floodStart->x;
- y = flood.floodStart->y;
- removeItemFlood(&flood);
+ if (initFlood(&flood, DstRect) == FALSE)
+ {
+ return FALSE;
+ }
+ addItemFlood(&flood, x, y, DstSurf, DstRect, ConvColor, FALSE);
+ while (flood.floodLen != 0)
+ {
+ x = flood.floodStart->x;
+ y = flood.floodStart->y;
+ removeItemFlood(&flood);
- DibFunctionsForBitmapFormat[DstSurf->iBitmapFormat].DIB_PutPixel(DstSurf, x, y, BrushColor);
- if (flood.floodStart - 4 < flood.floodData)
- {
- DPRINT1("Can't finish flooding!\n");
- finalizeFlood(&flood);
- return FALSE;
- }
- addItemFlood(&flood, x, y + 1, DstSurf, DstRect, ConvColor, FALSE);
- addItemFlood(&flood, x, y - 1, DstSurf, DstRect, ConvColor, FALSE);
- addItemFlood(&flood, x + 1, y, DstSurf, DstRect, ConvColor, FALSE);
- addItemFlood(&flood, x - 1, y, DstSurf, DstRect, ConvColor, FALSE);
- }
+ DibFunctionsForBitmapFormat[DstSurf->iBitmapFormat].DIB_PutPixel(DstSurf, x, y, BrushColor);
+ if (flood.floodStart - 4 < flood.floodData)
+ {
+ DPRINT1("Can't finish flooding!\n");
finalizeFlood(&flood);
+ return FALSE;
+ }
+ addItemFlood(&flood, x, y + 1, DstSurf, DstRect, ConvColor, FALSE);
+ addItemFlood(&flood, x, y - 1, DstSurf, DstRect, ConvColor, FALSE);
+ addItemFlood(&flood, x + 1, y, DstSurf, DstRect, ConvColor, FALSE);
+ addItemFlood(&flood, x - 1, y, DstSurf, DstRect, ConvColor, FALSE);
}
- else if (FillType == FLOODFILLSURFACE)
+ finalizeFlood(&flood);
+ }
+ else if (FillType == FLOODFILLSURFACE)
+ {
+ /* Check if the start pixel has the surface color */
+ if (DibFunctionsForBitmapFormat[DstSurf->iBitmapFormat].DIB_GetPixel(DstSurf, x, y) != ConvColor)
{
- /* Check if the start pixel has the surface color */
- if (DibFunctionsForBitmapFormat[DstSurf->iBitmapFormat].DIB_GetPixel(DstSurf, x, y) != ConvColor)
- {
- return FALSE;
- }
-
- if (initFlood(&flood, DstRect) == FALSE)
- {
- return FALSE;
- }
- addItemFlood(&flood, x, y, DstSurf, DstRect, ConvColor, TRUE);
- while (flood.floodLen != 0)
- {
- x = flood.floodStart->x;
- y = flood.floodStart->y;
- removeItemFlood(&flood);
+ return FALSE;
+ }
- DibFunctionsForBitmapFormat[DstSurf->iBitmapFormat].DIB_PutPixel(DstSurf, x, y, BrushColor);
- if (flood.floodStart - 4 < flood.floodData)
- {
- DPRINT1("Can't finish flooding!\n");
- finalizeFlood(&flood);
- return FALSE;
- }
- addItemFlood(&flood, x, y + 1, DstSurf, DstRect, ConvColor, TRUE);
- addItemFlood(&flood, x, y - 1, DstSurf, DstRect, ConvColor, TRUE);
- addItemFlood(&flood, x + 1, y, DstSurf, DstRect, ConvColor, TRUE);
- addItemFlood(&flood, x - 1, y, DstSurf, DstRect, ConvColor, TRUE);
- }
- finalizeFlood(&flood);
+ if (initFlood(&flood, DstRect) == FALSE)
+ {
+ return FALSE;
}
- else
+ addItemFlood(&flood, x, y, DstSurf, DstRect, ConvColor, TRUE);
+ while (flood.floodLen != 0)
{
- DPRINT1("Unsupported FloodFill type!\n");
+ x = flood.floodStart->x;
+ y = flood.floodStart->y;
+ removeItemFlood(&flood);
+
+ DibFunctionsForBitmapFormat[DstSurf->iBitmapFormat].DIB_PutPixel(DstSurf, x, y, BrushColor);
+ if (flood.floodStart - 4 < flood.floodData)
+ {
+ DPRINT1("Can't finish flooding!\n");
+ finalizeFlood(&flood);
return FALSE;
+ }
+ addItemFlood(&flood, x, y + 1, DstSurf, DstRect, ConvColor, TRUE);
+ addItemFlood(&flood, x, y - 1, DstSurf, DstRect, ConvColor, TRUE);
+ addItemFlood(&flood, x + 1, y, DstSurf, DstRect, ConvColor, TRUE);
+ addItemFlood(&flood, x - 1, y, DstSurf, DstRect, ConvColor, TRUE);
}
- return TRUE;
+ finalizeFlood(&flood);
+ }
+ else
+ {
+ DPRINT1("Unsupported FloodFill type!\n");
+ return FALSE;
+ }
+ return TRUE;
}
-/*
- * ReactOS W32 Subsystem
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 2004, 2005, 2006 ReactOS Team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+/*
+ * PROJECT: Win32 subsystem
+ * LICENSE: See COPYING in the top level directory
+ * FILE: subsystems/win32/win32k/dib/i386/dib24bpp_hline.c
+ * PURPOSE: ASM optimised 24bpp HLine
+ * PROGRAMMERS: Magnus Olsen
*/
-/* $Id: */
.globl _DIB_24BPP_HLine
.intel_syntax noprefix
mov esi, edx
mov [esp+4], eax
ja Align4byte
- lea eax, [edx-1]
+ lea eax, [edx-1]
mov [esp], eax
inc eax
jnz small_fill
pop esi
pop edi
ret
-
+
/* For small fills, don't bother doing anything fancy */
small_fill:
movzx ecx, word ptr [esp+58]
pop esi
pop edi
ret
-
+
Align4byte:
/* Align to 4-byte address */
test al, 3
jz loop1
lea esi, [esi+0]
lea edi, [edi+0]
-
+
loopasmversion:
/* This is about 30% faster than the generic C code below */
movzx edx, word ptr [esp+58]
-
-/*
- * ReactOS W32 Subsystem
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 2004, 2005, 2006 ReactOS Team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+/*
+ * PROJECT: Win32 subsystem
+ * LICENSE: See COPYING in the top level directory
+ * FILE: subsystems/win32/win32k/dib/i386/dib32bpp_colorfill.c
+ * PURPOSE: ASM optimised 32bpp ColorFill
+ * PROGRAMMERS: Magnus Olsen
*/
-/* $Id: */
+
.globl _DIB_32BPP_ColorFill
.intel_syntax noprefix
sub eax, edi
mov [esp], eax
lea esi, [esi+0]
-
+
for_loop:
mov eax, ebp
cld
add [esp+4], edx
dec dword ptr [esp]
jnz for_loop
- end:
+ end:
mov ebx, [esp+8]
mov eax, 1
mov esi, [esp+12]
mov edi, [esp+16]
mov ebp, [esp+20]
add esp, 24
- ret
-
+ ret
+
algin_draw:
stosd
dec ebx
add [esp+4], edx
dec dword ptr [esp]
jnz for_loop
-
+
mov ebx, [esp+8]
mov eax, 1
mov esi, [esp+12]
-/*
- * ReactOS W32 Subsystem
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 2004, 2005, 2006 ReactOS Team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+/*
+ * PROJECT: Win32 subsystem
+ * LICENSE: See COPYING in the top level directory
+ * FILE: subsystems/win32/win32k/dib/i386/dib32bpp_hline.c
+ * PURPOSE: ASM optimised 32bpp HLine
+ * PROGRAMMERS: Magnus Olsen
*/
-/* $Id: */
.globl _DIB_32BPP_HLine
.intel_syntax noprefix
_DIB_32BPP_HLine:
sub esp, 12 // rember the base is not hex it is dec
mov ecx, [esp+16]
- mov [esp+4], ebx
+ mov [esp+4], ebx
mov edx, [esp+20] // edx = LONG x1
- mov [esp+8], edi
+ mov [esp+8], edi
mov edi, [esp+28]
mov eax, [ecx+36]
mov ebx, [esp+24] // ebx = LONG x2
mov edi, [ecx+32]
sub ebx, edx // cx = (x2 - x1) ;
add eax, edi
- lea edx, [eax+edx*4]
+ lea edx, [eax+edx*4]
mov [esp], edx
cld
- mov eax, [esp+32]
+ mov eax, [esp+32]
mov edi, [esp]
test edi, 3 // Align to fullword boundary
jnz short _save_rest
mov ecx, ebx // Setup count of fullwords to fill
rep stosd
-
+
mov ebx, [esp+4]
mov edi, [esp+8]
add esp, 12
--- /dev/null
+/*
+ * PROJECT: Win32 subsystem
+ * LICENSE: See COPYING in the top level directory
+ * FILE: subsystems/win32/win32k/dib/stretchblt.c
+ * PURPOSE: StretchBlt implementation suitable for all bit depths
+ * PROGRAMMERS: Magnus Olsen
+ * Evgeniy Boltik
+ * Gregor Schneider
+ */
+
+#include <w32k.h>
+
+#define NDEBUG
+#include <debug.h>
+
+BOOLEAN DIB_XXBPP_StretchBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, SURFOBJ *MaskSurf,
+ SURFOBJ *PatternSurface,
+ RECTL *DestRect, RECTL *SourceRect,
+ POINTL *MaskOrigin, BRUSHOBJ *Brush,
+ POINTL *BrushOrigin, XLATEOBJ *ColorTranslation,
+ XLATEOBJ *XlatePatternToDest, ROP4 ROP)
+{
+ LONG sx = 0;
+ LONG sy = 0;
+ LONG DesX;
+ LONG DesY;
+
+ LONG DstHeight;
+ LONG DstWidth;
+ LONG SrcHeight;
+ LONG SrcWidth;
+
+ ULONG Color;
+ ULONG Dest, Source = 0, Pattern = 0;
+ ULONG xxBPPMask;
+ BOOLEAN CanDraw;
+
+ PFN_DIB_GetPixel fnSource_GetPixel = NULL;
+ PFN_DIB_GetPixel fnDest_GetPixel = NULL;
+ PFN_DIB_PutPixel fnDest_PutPixel = NULL;
+ PFN_DIB_GetPixel fnPattern_GetPixel = NULL;
+ PFN_DIB_GetPixel fnMask_GetPixel = NULL;
+
+ LONG PatternX = 0, PatternY = 0;
+
+ BOOL UsesSource = ROP4_USES_SOURCE(ROP);
+ BOOL UsesPattern = ROP4_USES_PATTERN(ROP);
+
+ fnDest_GetPixel = DibFunctionsForBitmapFormat[DestSurf->iBitmapFormat].DIB_GetPixel;
+ fnDest_PutPixel = DibFunctionsForBitmapFormat[DestSurf->iBitmapFormat].DIB_PutPixel;
+
+ DPRINT("Dest BPP: %u, dstRect: (%d,%d)-(%d,%d)\n",
+ BitsPerFormat(DestSurf->iBitmapFormat), DestRect->left, DestRect->top, DestRect->right, DestRect->bottom);
+
+ if (UsesSource)
+ {
+ fnSource_GetPixel = DibFunctionsForBitmapFormat[SourceSurf->iBitmapFormat].DIB_GetPixel;
+ DPRINT("Source BPP: %u, srcRect: (%d,%d)-(%d,%d)\n",
+ BitsPerFormat(SourceSurf->iBitmapFormat), SourceRect->left, SourceRect->top, SourceRect->right, SourceRect->bottom);
+ }
+
+ if (MaskSurf)
+ {
+ fnMask_GetPixel = DibFunctionsForBitmapFormat[MaskSurf->iBitmapFormat].DIB_GetPixel;
+ }
+
+ DstHeight = DestRect->bottom - DestRect->top;
+ DstWidth = DestRect->right - DestRect->left;
+ SrcHeight = SourceRect->bottom - SourceRect->top;
+ SrcWidth = SourceRect->right - SourceRect->left;
+
+ /* FIXME : MaskOrigin? */
+
+ switch(DestSurf->iBitmapFormat)
+ {
+ case BMF_1BPP: xxBPPMask = 0x1; break;
+ case BMF_4BPP: xxBPPMask = 0xF; break;
+ case BMF_8BPP: xxBPPMask = 0xFF; break;
+ case BMF_16BPP: xxBPPMask = 0xFFFF; break;
+ case BMF_24BPP: xxBPPMask = 0xFFFFFF; break;
+ default:
+ xxBPPMask = 0xFFFFFFFF;
+ }
+
+ if (UsesPattern)
+ {
+ if (PatternSurface)
+ {
+ PatternY = (DestRect->top - BrushOrigin->y) % PatternSurface->sizlBitmap.cy;
+ if (PatternY < 0)
+ {
+ PatternY += PatternSurface->sizlBitmap.cy;
+ }
+ fnPattern_GetPixel = DibFunctionsForBitmapFormat[PatternSurface->iBitmapFormat].DIB_GetPixel;
+ }
+ else
+ {
+ if (Brush)
+ Pattern = Brush->iSolidColor;
+ }
+ }
+
+
+ for (DesY = DestRect->top; DesY < DestRect->bottom; DesY++)
+ {
+ if (PatternSurface)
+ {
+ PatternX = (DestRect->left - BrushOrigin->x) % PatternSurface->sizlBitmap.cx;
+ if (PatternX < 0)
+ {
+ PatternX += PatternSurface->sizlBitmap.cx;
+ }
+ }
+ if (UsesSource)
+ sy = SourceRect->top+(DesY - DestRect->top) * SrcHeight / DstHeight;
+
+ for (DesX = DestRect->left; DesX < DestRect->right; DesX++)
+ {
+ CanDraw = TRUE;
+
+ if (fnMask_GetPixel)
+ {
+ sx = SourceRect->left+(DesX - DestRect->left) * SrcWidth / DstWidth;
+ if (sx < 0 || sy < 0 ||
+ MaskSurf->sizlBitmap.cx < sx || MaskSurf->sizlBitmap.cy < sy ||
+ fnMask_GetPixel(MaskSurf, sx, sy) != 0)
+ {
+ CanDraw = FALSE;
+ }
+ }
+
+ if (UsesSource && CanDraw)
+ {
+ sx = SourceRect->left+(DesX - DestRect->left) * SrcWidth / DstWidth;
+ if (sx >= 0 && sy >= 0 &&
+ SourceSurf->sizlBitmap.cx > sx && SourceSurf->sizlBitmap.cy > sy)
+ {
+ Source = XLATEOBJ_iXlate(ColorTranslation, fnSource_GetPixel(SourceSurf, sx, sy));
+ }
+ else
+ {
+ Source = 0;
+ CanDraw = (ROP3_TO_ROP4(SRCCOPY) != ROP);
+ }
+ }
+
+ if (CanDraw)
+ {
+ if (PatternSurface)
+ {
+ Pattern = XLATEOBJ_iXlate(XlatePatternToDest, fnPattern_GetPixel(PatternSurface, PatternX, PatternY));
+ PatternX++;
+ PatternX %= PatternSurface->sizlBitmap.cx;
+ }
+
+ Dest = fnDest_GetPixel(DestSurf, DesX, DesY);
+ Color = DIB_DoRop(ROP, Dest, Source, Pattern) & xxBPPMask;
+
+ fnDest_PutPixel(DestSurf, DesX, DesY, Color);
+ }
+ }
+
+ if (PatternSurface)
+ {
+ PatternY++;
+ PatternY %= PatternSurface->sizlBitmap.cy;
+ }
+ }
+
+ return TRUE;
+}
+
+/* EOF */
<file>dib16bpp.c</file>
<file>dib24bpp.c</file>
<file>dib32bpp.c</file>
- <file>dibXXbpp.c</file>
<file>dib.c</file>
<file>floodfill.c</file>
+ <file>stretchblt.c</file>
<if property="ARCH" value="i386">
<directory name="i386">