more optimze of bitblt for dib32

svn path=/trunk/; revision=15812
This commit is contained in:
Magnus Olsen 2005-06-05 18:15:08 +00:00
parent 012786bd8f
commit 3ed044e92e
2 changed files with 238 additions and 64 deletions

View file

@ -120,10 +120,15 @@ BOOLEAN DIB_32BPP_BitBltSrcCopy(PBLTINFO);
BOOLEAN DIB_32BPP_StretchBlt(SURFOBJ*,SURFOBJ*,RECTL*,RECTL*,POINTL*,POINTL,CLIPOBJ*,XLATEOBJ*,ULONG);
BOOLEAN DIB_32BPP_TransparentBlt(SURFOBJ*,SURFOBJ*,RECTL*,POINTL*,XLATEOBJ*,ULONG);
BOOLEAN FASTCALL DIB_32DstInvert(PBLTINFO BltInfo);
BOOLEAN DIB32_Srccopy(PBLTINFO BltInfo);
BOOLEAN DIB32_ColorFill(PBLTINFO BltInfo, ULONG);
BOOLEAN DIB32_SrcPaint(PBLTINFO BltInfo);
BOOLEAN FASTCALL DIB_32DstInvert(PBLTINFO);
BOOLEAN FASTCALL DIB32_Srccopy(PBLTINFO);
BOOLEAN FASTCALL DIB32_ColorFill(PBLTINFO, ULONG);
BOOLEAN FASTCALL DIB32_SrcPaint(PBLTINFO);
BOOLEAN FASTCALL DIB32_NotSrcErase(PBLTINFO);
BOOLEAN FASTCALL DIB32_SrcErase(PBLTINFO);
BOOLEAN FASTCALL DIB_32PatCopy(PBLTINFO);
extern unsigned char notmask[2];
extern unsigned char altnotmask[2];

View file

@ -45,20 +45,33 @@ DIB_32BPP_GetPixel(SURFOBJ *SurfObj, LONG x, LONG y)
VOID
DIB_32BPP_HLine(SURFOBJ *SurfObj, LONG x1, LONG x2, LONG y, ULONG c)
{
LONG cx = (x2 - x1) ;
if (cx>0)
{
PBYTE byteaddr = SurfObj->pvScan0 + y * SurfObj->lDelta;
PDWORD addr = (PDWORD)byteaddr + x1;
LONG cx = x2 - x1;
if (cx>0) memset4(addr, c, cx);
memset4(addr, c, cx);
}
else if (cx<0)
{
PBYTE byteaddr = SurfObj->pvScan0 + y * SurfObj->lDelta;
PDWORD addr = (PDWORD)byteaddr + x2;
cx = (x1 - x2) ;
memset4(addr, c, cx);
}
}
#else
VOID
DIB_32BPP_HLine(SURFOBJ *SurfObj, LONG x1, LONG x2, LONG y, ULONG c)
{
PBYTE byteaddr = SurfObj->pvScan0 + y * SurfObj->lDelta;
PDWORD addr = (PDWORD)byteaddr + x1;
LONG cx = x1;
while(cx < x2) {
while(cx < x2)
{
*addr = (DWORD)c;
++addr;
++cx;
@ -74,11 +87,12 @@ DIB_32BPP_VLine(SURFOBJ *SurfObj, LONG x, LONG y1, LONG y2, ULONG c)
LONG lDelta = SurfObj->lDelta >> 2; /* >> 2 == / sizeof(DWORD) */
byteaddr = (PBYTE)addr;
while(y1++ < y2) {
while(y1++ < y2)
{
*addr = (DWORD)c;
addr += lDelta;
}
}
BOOLEAN
@ -337,6 +351,18 @@ DIB_32BPP_BitBlt(PBLTINFO BltInfo)
return DIB32_SrcPaint(BltInfo);
break;
case ROP4_NOTSRCERASE:
return DIB32_NotSrcErase(BltInfo);
break;
case ROP4_SRCERASE:
return DIB32_SrcErase(BltInfo);
break;
case ROP4_PATCOPY:
// return(Pattern);
return DIB_32PatCopy(BltInfo);
break;
default:
break;
}
@ -400,47 +426,183 @@ DIB_32BPP_BitBlt(PBLTINFO BltInfo)
}
/* optimze functions for bitblt */
BOOLEAN
FASTCALL
DIB_32PatCopy(PBLTINFO BltInfo)
{
ULONG delta;
ULONG DestX, DestY, PatternY;
PULONG DestBits;
if (!BltInfo->PatternSurface)
{
return DIB32_ColorFill(BltInfo, XLATEOBJ_iXlate(BltInfo->XlatePatternToDest, BltInfo->Brush->iSolidColor));
}
DestBits = (PULONG)(BltInfo->DestSurface->pvScan0 + (BltInfo->DestRect.left << 2) +
BltInfo->DestRect.top * BltInfo->DestSurface->lDelta);
delta = BltInfo->DestSurface->lDelta - ((BltInfo->DestRect.right - BltInfo->DestRect.left) <<2);
PatternY = (BltInfo->DestRect.top + BltInfo->BrushOrigin.y) % BltInfo->PatternSurface->sizlBitmap.cy;
for (DestY = BltInfo->DestRect.top; DestY < BltInfo->DestRect.bottom; DestY++)
{
for (DestX = BltInfo->DestRect.left; DestX < BltInfo->DestRect.right; DestX++, DestBits++)
{
*DestBits = DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest);
}
PatternY++;
PatternY %= BltInfo->PatternSurface->sizlBitmap.cy;
DestBits = (PULONG)((ULONG_PTR)DestBits + delta);
}
return TRUE;
}
BOOLEAN
FASTCALL
DIB_32DstInvert(PBLTINFO BltInfo)
{
ULONG DestX, DestY;
PULONG DestBits;
ULONG top = BltInfo->DestRect.top;
ULONG left = BltInfo->DestRect.left;
ULONG DestX = BltInfo->DestRect.right - left;
ULONG DestY = BltInfo->DestRect.bottom - top;
ULONG delta = BltInfo->DestSurface->lDelta - (DestX << 2);
/* Calculate the Initial Destination */
DestBits = (PULONG)(BltInfo->DestSurface->pvScan0 + (left << 2) +
top * BltInfo->DestSurface->lDelta);
ULONG bottom = BltInfo->DestRect.bottom;
ULONG right = BltInfo->DestRect.right;
ULONG delta = BltInfo->DestSurface->lDelta - ((BltInfo->DestRect.right - BltInfo->DestRect.left) <<2) ;
while (DestY > 0)
DestBits = (PULONG)(BltInfo->DestSurface->pvScan0 +
(BltInfo->DestRect.left << 2) +
BltInfo->DestRect.top * BltInfo->DestSurface->lDelta);
for (DestY = BltInfo->DestRect.top; DestY < bottom; DestY++)
{
while (DestX > 0)
for (DestX = BltInfo->DestRect.left; DestX < right; DestX++, DestBits++)
{
/* Invert bits */
*DestBits =~ *DestBits;
/* Update Position */
DestBits++;
/* Decrease distance to do */
DestX--;
*DestBits = ~*DestBits ;
}
/* Update position */
DestBits = (PULONG)((ULONG_PTR)DestBits + delta);
/* Decrease distance to do */
DestY--;
}
/* Return TRUE */
return TRUE;
}
BOOLEAN
FASTCALL
DIB32_SrcErase(PBLTINFO BltInfo)
{
BOOLEAN status = FALSE;
switch (BltInfo->SourceSurface->iBitmapFormat)
{
case BMF_1BPP:
case BMF_4BPP:
case BMF_16BPP:
case BMF_24BPP:
case BMF_32BPP:
{
ULONG DestX, DestY;
ULONG SourceX, SourceY;
PULONG DestBits;
ULONG bottom = BltInfo->DestRect.bottom;
ULONG right = BltInfo->DestRect.right;
ULONG delta = BltInfo->DestSurface->lDelta - ((BltInfo->DestRect.right - BltInfo->DestRect.left) <<2) ;
DestBits = (PULONG)(BltInfo->DestSurface->pvScan0 + (BltInfo->DestRect.left << 2) +
BltInfo->DestRect.top * BltInfo->DestSurface->lDelta);
SourceY = BltInfo->SourcePoint.y;
for (DestY = BltInfo->DestRect.top; DestY < bottom; DestY++)
{
SourceX = BltInfo->SourcePoint.x;
for (DestX = BltInfo->DestRect.left; DestX < right; DestX++, DestBits++, SourceX++)
{
*DestBits = ~(*DestBits & DIB_GetSource(BltInfo->SourceSurface, SourceX,
SourceY, BltInfo->XlateSourceToDest));
}
DestBits = (PULONG)((ULONG_PTR)DestBits + delta);
SourceY++;
}
}
status = TRUE;
break;
default:
break;
}
return status;
}
BOOLEAN
FASTCALL
DIB32_NotSrcErase(PBLTINFO BltInfo)
{
BOOLEAN status = FALSE;
switch (BltInfo->SourceSurface->iBitmapFormat)
{
case BMF_1BPP:
case BMF_4BPP:
case BMF_16BPP:
case BMF_24BPP:
case BMF_32BPP:
{
ULONG DestX, DestY;
ULONG SourceX, SourceY;
PULONG DestBits;
ULONG bottom = BltInfo->DestRect.bottom;
ULONG right = BltInfo->DestRect.right;
ULONG delta = BltInfo->DestSurface->lDelta - ((BltInfo->DestRect.right - BltInfo->DestRect.left) <<2) ;
DestBits = (PULONG)(BltInfo->DestSurface->pvScan0 + (BltInfo->DestRect.left << 2) +
BltInfo->DestRect.top * BltInfo->DestSurface->lDelta);
SourceY = BltInfo->SourcePoint.y;
for (DestY = BltInfo->DestRect.top; DestY < bottom; DestY++)
{
SourceX = BltInfo->SourcePoint.x;
for (DestX = BltInfo->DestRect.left; DestX < right; DestX++, DestBits++, SourceX++)
{
*DestBits = ~(*DestBits | DIB_GetSource(BltInfo->SourceSurface, SourceX,
SourceY, BltInfo->XlateSourceToDest));
}
DestBits = (PULONG)((ULONG_PTR)DestBits + delta);
SourceY++;
}
}
status = TRUE;
break;
default:
break;
}
return status;
}
BOOLEAN
FASTCALL
DIB32_SrcPaint(PBLTINFO BltInfo)
{
BOOLEAN status = FALSE;
@ -461,7 +623,8 @@ DIB32_SrcPaint(PBLTINFO BltInfo)
ULONG right = BltInfo->DestRect.right;
ULONG delta = BltInfo->DestSurface->lDelta - ((BltInfo->DestRect.right - BltInfo->DestRect.left) <<2) ;
DestBits = (PULONG)(BltInfo->DestSurface->pvScan0 + (BltInfo->DestRect.left << 2) +
DestBits = (PULONG)(BltInfo->DestSurface->pvScan0 +
(BltInfo->DestRect.left << 2) +
BltInfo->DestRect.top * BltInfo->DestSurface->lDelta);
SourceY = BltInfo->SourcePoint.y;
@ -494,7 +657,8 @@ DIB32_SrcPaint(PBLTINFO BltInfo)
ULONG right = BltInfo->DestRect.right;
ULONG delta = BltInfo->DestSurface->lDelta - ((BltInfo->DestRect.right - BltInfo->DestRect.left) <<2) ;
DestBits = (PULONG)(BltInfo->DestSurface->pvScan0 + (BltInfo->DestRect.left << 2) +
DestBits = (PULONG)(BltInfo->DestSurface->pvScan0 +
(BltInfo->DestRect.left << 2) +
BltInfo->DestRect.top * BltInfo->DestSurface->lDelta);
SourceY = BltInfo->SourcePoint.y;
@ -522,7 +686,9 @@ DIB32_SrcPaint(PBLTINFO BltInfo)
return status;
}
BOOLEAN
FASTCALL
DIB32_Srccopy(PBLTINFO BltInfo)
{
BOOLEAN status = FALSE;
@ -543,7 +709,8 @@ DIB32_Srccopy(PBLTINFO BltInfo)
ULONG right = BltInfo->DestRect.right;
ULONG delta = ((BltInfo->DestRect.right - BltInfo->DestRect.left) <<2) + BltInfo->DestSurface->lDelta;
DestBits = (PULONG)(BltInfo->DestSurface->pvScan0 + (BltInfo->DestRect.left << 2) +
DestBits = (PULONG)(BltInfo->DestSurface->pvScan0 +
(BltInfo->DestRect.left << 2) +
BltInfo->DestRect.top * BltInfo->DestSurface->lDelta);
SourceY = BltInfo->SourcePoint.y;
@ -588,8 +755,8 @@ DIB32_Srccopy(PBLTINFO BltInfo)
Destdelta = BltInfo->DestSurface->lDelta;
Sourcedelta = BltInfo->SourceSurface->lDelta;
Destaddr = BltInfo->DestSurface->pvScan0 + BltInfo->DestRect.top * Destdelta + BltInfo->DestRect.left;
Srcaddr = BltInfo->SourceSurface->pvScan0 + BltInfo->SourcePoint.y * Sourcedelta + BltInfo->SourcePoint.x;
Destaddr = BltInfo->DestSurface->pvScan0 + BltInfo->DestRect.top * Destdelta + (BltInfo->DestRect.left<<2);
Srcaddr = BltInfo->SourceSurface->pvScan0 + BltInfo->SourcePoint.y * Sourcedelta + (BltInfo->SourcePoint.x<<2);
DesmaxX *= 4;
if (DesmaxY > 0)
@ -605,6 +772,7 @@ DIB32_Srccopy(PBLTINFO BltInfo)
status = TRUE;
break;
}
default:
break;
}
@ -613,6 +781,7 @@ return status;
}
BOOLEAN
FASTCALL
DIB32_ColorFill(PBLTINFO BltInfo, ULONG color)
{
ULONG DestY;