Cleanup in win32k/dib:

- 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
This commit is contained in:
Gregor Schneider 2009-08-02 15:49:17 +00:00
parent 54817d5b14
commit 3283ffdef8
17 changed files with 2137 additions and 2274 deletions

View file

@ -1,22 +1,11 @@
/*
* 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>
@ -30,72 +19,72 @@ unsigned char altnotmask[2] = { 0xf0, 0x0f };
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
@ -104,7 +93,7 @@ DIB_DoRop(ULONG Rop, ULONG Dest, ULONG Source, ULONG Pattern)
ULONG ResultNibble;
ULONG Result;
ULONG i;
static const ULONG ExpandDest[16] =
static const ULONG ExpandDest[16] =
{
0x55555555 /* 0000 */,
0x555555AA /* 0001 */,
@ -187,14 +176,14 @@ DIB_DoRop(ULONG Rop, ULONG Dest, ULONG Source, ULONG Pattern)
/* 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);
}

View file

@ -5,35 +5,35 @@
#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);
@ -141,14 +141,14 @@ extern unsigned char altnotmask[2];
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 */

File diff suppressed because it is too large Load diff

View file

@ -1,22 +1,11 @@
/*
* 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
@ -44,7 +33,8 @@ DIB_1BPP_GetPixel(SURFOBJ *SurfObj, LONG x, LONG y)
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++;
}
@ -53,7 +43,8 @@ DIB_1BPP_HLine(SURFOBJ *SurfObj, LONG x1, LONG x2, LONG y, ULONG c)
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++;
}
@ -62,407 +53,407 @@ DIB_1BPP_VLine(SURFOBJ *SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
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
// 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)
// 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;
// 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
// 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;
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
// '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;
shift = (dl-sl)&7;
xormask = 0xFF * XLATEOBJ_iXlate(pxlo, 0);
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;
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));
// 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 ( !(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 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;
}
}
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 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;
}
// 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;
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;
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_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_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_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_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;
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;
}
default:
DbgPrint("DIB_1BPP_BitBlt: Unhandled Source BPP: %u\n", BitsPerFormat(BltInfo->SourceSurface->iBitmapFormat));
return FALSE;
}
return TRUE;
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;
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);
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;
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;
}
}
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);
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 (DestX & 31)
{
#if 0
/* FIXME: This case is completely untested!!! */
/* FIXME: This case is completely untested!!! */
Dest = *((PBYTE)DestBits);
NoBits = 31 - (DestX & 31);
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;
#endif
}
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;
/* FIXME: This is incorrect! */
for (Index = 31 - NoBits; Index >= 0; Index++)
Source |= (DIB_GetSource(SourceSurf, SourceX + Index, SourceY, ColorTranslation) << (31 - Index));
}
if (DestX < BltInfo->DestRect.right)
{
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);
}
}
SourceY++;
if (BltInfo->PatternSurface)
{
PatternY++;
PatternY %= BltInfo->PatternSurface->sizlBitmap.cy;
Pattern = 0;
for (k = 31 - NoBits; k >= 0; k++)
Pattern |= (DIB_GetSource(PatternObj, (X + BrushOrigin.x + k) % PatternWidth, PatternY, BltInfo->XlatePatternToDest) << (31 - k));
}
}
return TRUE;
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;
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);
}
if (DestX < BltInfo->DestRect.right)
{
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);
}
}
SourceY++;
if (BltInfo->PatternSurface)
{
PatternY++;
PatternY %= BltInfo->PatternSurface->sizlBitmap.cy;
}
}
return TRUE;
}
/* BitBlt Optimize */
@ -471,12 +462,11 @@ DIB_1BPP_ColorFill(SURFOBJ* DestSurface, RECTL* DestRect, ULONG color)
{
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

View file

@ -1,22 +1,12 @@
/*
* 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>
@ -47,7 +37,8 @@ DIB_24BPP_VLine(SURFOBJ *SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
LONG lDelta = SurfObj->lDelta;
c &= 0xFFFFFF;
while(y1++ < y2) {
while(y1++ < y2)
{
*(PUSHORT)(addr) = c & 0xFFFF;
*(addr + 2) = c >> 16;
@ -129,7 +120,7 @@ DIB_24BPP_BitBltSrcCopy(PBLTINFO BltInfo)
*DestBits = xColor & 0xff;
*(PWORD)(DestBits + 1) = xColor >> 8;
SourceBits += 1;
DestBits += 3;
DestBits += 3;
}
SourceLine += BltInfo->SourceSurface->lDelta;
@ -162,44 +153,44 @@ DIB_24BPP_BitBltSrcCopy(PBLTINFO BltInfo)
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;
@ -218,7 +209,7 @@ DIB_24BPP_BitBltSrcCopy(PBLTINFO BltInfo)
*DestBits = xColor & 0xff;
*(PWORD)(DestBits + 1) = xColor >> 8;
SourceBits += 4;
DestBits += 3;
DestBits += 3;
}
SourceLine += BltInfo->SourceSurface->lDelta;
@ -333,17 +324,17 @@ DIB_24BPP_ColorFill(SURFOBJ* DestSurface, RECTL* DestRect, ULONG color)
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:
*
@ -384,22 +375,22 @@ DIB_24BPP_ColorFill(SURFOBJ* DestSurface, RECTL* DestRect, ULONG color)
: "=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;
}

View file

@ -1,22 +1,11 @@
/*
* 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>
@ -29,64 +18,63 @@ DIB_24BPP_HLine(SURFOBJ *SurfObj, LONG x1, LONG x2, LONG y, ULONG c)
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;
/* Align to 4-byte address */
while (0 != ((ULONG_PTR) addr & 0x3))
{
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 */
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;
}
*(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);
Count = Count & 0x03;
while (0 != Count--)
{
*(PUSHORT)(addr) = c;
addr += 2;
*(addr) = c >> 16;
addr += 1;
}
}
}

View file

@ -1,22 +1,12 @@
/*
* 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>
@ -26,271 +16,267 @@
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)
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;
}
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;
DestBits = (PBYTE)BltInfo->DestSurface->pvScan0
+ (BltInfo->DestRect.top * BltInfo->DestSurface->lDelta)
+ 4 * BltInfo->DestRect.left;
switch (BltInfo->SourceSurface->iBitmapFormat)
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++)
{
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_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;
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_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;
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;
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;
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;
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++)
{
*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;
}
}
}
break;
default:
DPRINT1("DIB_32BPP_Bitblt: Unhandled Source BPP: %u\n", BitsPerFormat(BltInfo->SourceSurface->iBitmapFormat));
return FALSE;
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;
return TRUE;
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_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;
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;
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;
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;
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++)
{
*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;
}
}
}
break;
default:
DPRINT1("DIB_32BPP_Bitblt: Unhandled Source BPP: %u\n", BitsPerFormat(BltInfo->SourceSurface->iBitmapFormat));
return FALSE;
}
return TRUE;
}
BOOLEAN
@ -298,61 +284,61 @@ DIB_32BPP_TransparentBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
RECTL* DestRect, RECTL *SourceRect,
XLATEOBJ *ColorTranslation, ULONG iTransColor)
{
ULONG X, Y, SourceX, SourceY = 0, Source = 0, wd;
ULONG *DestBits;
ULONG X, Y, SourceX, SourceY = 0, Source = 0, wd;
ULONG *DestBits;
LONG DstHeight;
LONG DstWidth;
LONG SrcHeight;
LONG SrcWidth;
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;
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);
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++)
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
@ -360,77 +346,77 @@ DIB_32BPP_AlphaBlend(SURFOBJ* Dest, SURFOBJ* Source, RECTL* DestRect,
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;
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);
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);
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)
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("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;
}
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;
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);
Alpha = ((BlendFunc.AlphaFormat & AC_SRC_ALPHA) != 0) ?
SrcPixel.col.alpha : BlendFunc.SourceConstantAlpha;
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++;
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 */

View file

@ -1,22 +1,11 @@
/*
* 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>
@ -26,27 +15,27 @@
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;
}

View file

@ -1,22 +1,11 @@
/*
* 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>
@ -43,7 +32,8 @@ DIB_4BPP_HLine(SURFOBJ *SurfObj, LONG x1, LONG x2, LONG y, ULONG c)
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;
@ -58,7 +48,8 @@ DIB_4BPP_VLine(SURFOBJ *SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
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;
}
@ -90,7 +81,9 @@ DIB_4BPP_BitBltSrcCopy(PBLTINFO BltInfo)
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++;
@ -108,14 +101,14 @@ DIB_4BPP_BitBltSrcCopy(PBLTINFO BltInfo)
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++;
@ -227,138 +220,138 @@ DIB_4BPP_BitBltSrcCopy(PBLTINFO BltInfo)
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 */,
};
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);
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);
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)
{
Source = DIB_GetSource(BltInfo->SourceSurface, SourceX, SourceY, BltInfo->XlateSourceToDest);
}
if (UsesPattern)
{
if (BltInfo->PatternSurface)
{
PatternY = (BltInfo->DestRect.top + BltInfo->BrushOrigin.y) %
BltInfo->PatternSurface->sizlBitmap.cy;
Pattern = DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest);
}
else
DIB_4BPP_PutPixel(BltInfo->DestSurface, DestX, DestY, DIB_DoRop(BltInfo->Rop4, Dest, Source, Pattern) & 0xF);
DestX++;
SourceX++;
DestBits = (PULONG)((ULONG_PTR)DestBits + 1);
}
for (; DestX < RoundedRight; DestX += 8, SourceX += 8, DestBits++)
{
Dest = *DestBits;
if (UsesSource)
{
if (BltInfo->Brush)
Pattern = ExpandSolidColor[BltInfo->Brush->iSolidColor];
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 (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);
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);
}
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);
}
/* 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)
{
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);
}
SourceY++;
if (BltInfo->PatternSurface)
{
PatternY++;
PatternY %= BltInfo->PatternSurface->sizlBitmap.cy;
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);
}
return TRUE;
/* 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)
{
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);
}
SourceY++;
if (BltInfo->PatternSurface)
{
PatternY++;
PatternY %= BltInfo->PatternSurface->sizlBitmap.cy;
}
}
return TRUE;
}
/* BitBlt Optimize */
@ -367,12 +360,11 @@ DIB_4BPP_ColorFill(SURFOBJ* DestSurface, RECTL* DestRect, ULONG color)
{
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

View file

@ -1,22 +1,12 @@
/*
* 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>
@ -53,7 +43,8 @@ DIB_8BPP_VLine(SURFOBJ *SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
LONG lDelta = SurfObj->lDelta;
byteaddr = addr;
while(y1++ < y2) {
while(y1++ < y2)
{
*addr = c;
addr += lDelta;
@ -83,7 +74,9 @@ DIB_8BPP_BitBltSrcCopy(PBLTINFO BltInfo)
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++;
@ -117,62 +110,62 @@ DIB_8BPP_BitBltSrcCopy(PBLTINFO BltInfo)
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;
@ -190,7 +183,7 @@ DIB_8BPP_BitBltSrcCopy(PBLTINFO BltInfo)
xColor = *((PWORD) SourceBits);
*DestBits = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, xColor);
SourceBits += 2;
DestBits += 1;
DestBits += 1;
}
SourceLine += BltInfo->SourceSurface->lDelta;
@ -214,7 +207,7 @@ DIB_8BPP_BitBltSrcCopy(PBLTINFO BltInfo)
(*(SourceBits));
*DestBits = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, xColor);
SourceBits += 3;
DestBits += 1;
DestBits += 1;
}
SourceLine += BltInfo->SourceSurface->lDelta;
@ -236,7 +229,7 @@ DIB_8BPP_BitBltSrcCopy(PBLTINFO BltInfo)
xColor = *((PDWORD) SourceBits);
*DestBits = XLATEOBJ_iXlate(BltInfo->XlateSourceToDest, xColor);
SourceBits += 4;
DestBits += 1;
DestBits += 1;
}
SourceLine += BltInfo->SourceSurface->lDelta;
@ -258,10 +251,9 @@ DIB_8BPP_ColorFill(SURFOBJ* DestSurface, RECTL* DestRect, ULONG color)
{
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;
}
@ -372,28 +364,28 @@ DIB_8BPP_TransparentBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
}
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
@ -401,107 +393,107 @@ DIB_8BPP_AlphaBlend(SURFOBJ* Dest, SURFOBJ* Source, RECTL* DestRect,
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;
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);
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);
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;
}
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;
}
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);
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)
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;
if (SrcXlateObj)
EngDeleteXlate(SrcXlateObj);
Alpha = ((BlendFunc.AlphaFormat & AC_SRC_ALPHA) != 0) ?
SrcPixel32.col.alpha : BlendFunc.SourceConstantAlpha;
return TRUE;
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);
return TRUE;
}
/* EOF */

View file

@ -1,182 +0,0 @@
/*
* 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 */

View file

@ -1,10 +1,10 @@
/*
* 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>
@ -23,33 +23,33 @@
/* 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,
@ -59,29 +59,29 @@ static __inline VOID addItemFlood(FLOODINFO *info,
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,
@ -91,84 +91,84 @@ 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;
}
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);
}
finalizeFlood(&flood);
return FALSE;
}
else if (FillType == FLOODFILLSURFACE)
if (initFlood(&flood, DstRect) == FALSE)
{
/* 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);
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);
return FALSE;
}
else
addItemFlood(&flood, x, y, DstSurf, DstRect, ConvColor, FALSE);
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, 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);
}
return TRUE;
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)
{
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);
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);
}
else
{
DPRINT1("Unsupported FloodFill type!\n");
return FALSE;
}
return TRUE;
}

View file

@ -1,22 +1,10 @@
/*
* 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
@ -46,7 +34,7 @@
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
@ -55,7 +43,7 @@
pop esi
pop edi
ret
/* For small fills, don't bother doing anything fancy */
small_fill:
movzx ecx, word ptr [esp+58]
@ -76,7 +64,7 @@
pop esi
pop edi
ret
Align4byte:
/* Align to 4-byte address */
test al, 3
@ -84,7 +72,7 @@
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]

View file

@ -1,23 +1,11 @@
/*
* 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
@ -52,7 +40,7 @@
sub eax, edi
mov [esp], eax
lea esi, [esi+0]
for_loop:
mov eax, ebp
cld
@ -65,15 +53,15 @@
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
@ -83,7 +71,7 @@
add [esp+4], edx
dec dword ptr [esp]
jnz for_loop
mov ebx, [esp+8]
mov eax, 1
mov esi, [esp+12]

View file

@ -1,22 +1,10 @@
/*
* 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
@ -29,9 +17,9 @@
_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
@ -39,16 +27,16 @@ _DIB_32BPP_HLine:
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

View file

@ -0,0 +1,173 @@
/*
* 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 */

View file

@ -29,9 +29,9 @@
<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">