- Fixed algorithm for 4BPP bitblts with ROP != SRCCOPY

- Minor coordinate correction for software mouse pointer emulation

svn path=/trunk/; revision=8087
This commit is contained in:
Filip Navara 2004-02-08 09:27:39 +00:00
parent 2a78934eed
commit 2535445a70
2 changed files with 83 additions and 65 deletions

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: dib4bpp.c,v 1.22 2003/12/08 18:05:30 fireball Exp $ */ /* $Id: dib4bpp.c,v 1.23 2004/02/08 09:27:39 navaraf Exp $ */
#undef WIN32_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <stdlib.h> #include <stdlib.h>
@ -239,14 +239,14 @@ DIB_4BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
PBRUSHOBJ Brush, PPOINTL BrushOrigin, PBRUSHOBJ Brush, PPOINTL BrushOrigin,
XLATEOBJ *ColorTranslation, ULONG Rop4) XLATEOBJ *ColorTranslation, ULONG Rop4)
{ {
LONG i, j, k, sx, sy; LONG i, j, sx, sy;
ULONG Dest, Source, Pattern; ULONG Dest, Source, Pattern;
PULONG DestBits; PULONG DestBits;
BOOL UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000); BOOL UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
BOOL UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000); BOOL UsesPattern = ((Rop4 & 0xF00000) >> 4) != (Rop4 & 0x0F0000);
LONG RoundedRight = DestRect->right - ((DestRect->right - DestRect->left) & 0x7); LONG RoundedRight = DestRect->right - ((DestRect->right - DestRect->left) & 0x7);
static const ULONG ExpandSolidColor[16] = static const ULONG ExpandSolidColor[16] =
{ {
0x00000000 /* 0 */, 0x00000000 /* 0 */,
0x11111111 /* 1 */, 0x11111111 /* 1 */,
0x22222222 /* 2 */, 0x22222222 /* 2 */,
@ -263,61 +263,79 @@ DIB_4BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
0xDDDDDDDD /* 13 */, 0xDDDDDDDD /* 13 */,
0xEEEEEEEE /* 14 */, 0xEEEEEEEE /* 14 */,
0xFFFFFFFF /* 15 */, 0xFFFFFFFF /* 15 */,
}; };
if (Rop4 == SRCCOPY) if (Rop4 == SRCCOPY)
{ {
return(DIB_4BPP_BitBltSrcCopy(DestSurf, SourceSurf, DestGDI, SourceGDI, DestRect, SourcePoint, ColorTranslation)); return(DIB_4BPP_BitBltSrcCopy(DestSurf, SourceSurf, DestGDI, SourceGDI, DestRect, SourcePoint, ColorTranslation));
} }
else else
{ {
sy = SourcePoint->y; sy = SourcePoint->y;
for (j=DestRect->top; j<DestRect->bottom; j++) for (j = DestRect->top; j < DestRect->bottom; j++, sy++)
{ {
sx = SourcePoint->x; DestBits = (PULONG)(DestSurf->pvScan0 + (DestRect->left >> 1) + j * DestSurf->lDelta);
DestBits = (PULONG)(DestSurf->pvScan0 + (DestRect->left>>1) + j * DestSurf->lDelta); sx = SourcePoint->x;
for (i=DestRect->left; i<RoundedRight; i+=8, DestBits++)
{ /* Process all pixels on the left that aren't DWORD aligned */
Dest = *DestBits; for (i = DestRect->left; i & 0x7; i++, sx++)
if (UsesSource) {
{ Dest = DIB_4BPP_GetPixel(DestSurf, i, j);
Source = 0; if (UsesSource)
for (k = 0; k < 8; k += 2) {
{ Source = DIB_GetSource(SourceSurf, SourceGDI, sx, sy, ColorTranslation);
Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left) + k, sy, ColorTranslation) << ((k + 1) * 4)) }
| (DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left) + k + 1, sy, ColorTranslation) << (k * 4)); if (UsesPattern)
} {
} /* FIXME: No support for pattern brushes. */
if (UsesPattern) Pattern = ExpandSolidColor[Brush->iSolidColor & 0xF];
{ }
/* FIXME: No support for pattern brushes. */ DIB_4BPP_PutPixel(DestSurf, i, j, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xF);
Pattern = ExpandSolidColor[Brush->iSolidColor & 0xF]; }
}
*DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern); /* Process all DWORD aligned pixels */
} for (; i < RoundedRight; i += 8, sx += 8, DestBits++)
if (i < DestRect->right) {
{ Dest = *DestBits;
Dest = *DestBits; if (UsesSource)
for (; i < DestRect->right; i++) {
{ Source =
if (UsesSource) (DIB_GetSource(SourceSurf, SourceGDI, sx + 1, sy, ColorTranslation)) |
{ (DIB_GetSource(SourceSurf, SourceGDI, sx + 0, sy, ColorTranslation) << 4) |
Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation); (DIB_GetSource(SourceSurf, SourceGDI, sx + 3, sy, ColorTranslation) << 8) |
} (DIB_GetSource(SourceSurf, SourceGDI, sx + 2, sy, ColorTranslation) << 12) |
if (UsesPattern) (DIB_GetSource(SourceSurf, SourceGDI, sx + 5, sy, ColorTranslation) << 16) |
{ (DIB_GetSource(SourceSurf, SourceGDI, sx + 4, sy, ColorTranslation) << 20) |
/* FIXME: No support for pattern brushes. */ (DIB_GetSource(SourceSurf, SourceGDI, sx + 7, sy, ColorTranslation) << 24) |
Pattern = ExpandSolidColor[Brush->iSolidColor & 0xF]; (DIB_GetSource(SourceSurf, SourceGDI, sx + 6, sy, ColorTranslation) << 28);
} }
DIB_4BPP_PutPixel(DestSurf, i, j, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xF); if (UsesPattern)
Dest >>= 4; {
} /* FIXME: No support for pattern brushes. */
} Pattern = ExpandSolidColor[Brush->iSolidColor & 0xF];
sy++; }
*DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern);
}
/* Process the rest of pixel on the line */
for (; i < DestRect->right; i++, sx++)
{
Dest = DIB_4BPP_GetPixel(DestSurf, i, j);
if (UsesSource)
{
Source = DIB_GetSource(SourceSurf, SourceGDI, sx, sy, ColorTranslation);
}
if (UsesPattern)
{
/* FIXME: No support for pattern brushes. */
Pattern = ExpandSolidColor[Brush->iSolidColor & 0xF];
}
DIB_4BPP_PutPixel(DestSurf, i, j, DIB_DoRop(Rop4, Dest, Source, Pattern) & 0xF);
}
} }
} }
return TRUE; return TRUE;
} }
BOOLEAN DIB_4BPP_StretchBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, BOOLEAN DIB_4BPP_StretchBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: mouse.c,v 1.59 2004/02/06 21:12:55 navaraf Exp $ /* $Id: mouse.c,v 1.60 2004/02/08 09:27:39 navaraf Exp $
* *
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* PURPOSE: Mouse * PURPOSE: Mouse
@ -566,10 +566,10 @@ IntHideMousePointer(GDIDEVICE *ppdev, SURFOBJ *DestSurface)
DestRect.top = max(ppdev->PointerAttributes.Row, 0); DestRect.top = max(ppdev->PointerAttributes.Row, 0);
DestRect.right = min( DestRect.right = min(
ppdev->PointerAttributes.Column + ppdev->PointerAttributes.Width, ppdev->PointerAttributes.Column + ppdev->PointerAttributes.Width,
DestSurface->sizlBitmap.cx - 1); DestSurface->sizlBitmap.cx);
DestRect.bottom = min( DestRect.bottom = min(
ppdev->PointerAttributes.Row + ppdev->PointerAttributes.Height, ppdev->PointerAttributes.Row + ppdev->PointerAttributes.Height,
DestSurface->sizlBitmap.cy - 1); DestSurface->sizlBitmap.cy);
SrcPoint.x = max(-ppdev->PointerAttributes.Column, 0); SrcPoint.x = max(-ppdev->PointerAttributes.Column, 0);
SrcPoint.y = max(-ppdev->PointerAttributes.Row, 0); SrcPoint.y = max(-ppdev->PointerAttributes.Row, 0);
@ -610,10 +610,10 @@ IntShowMousePointer(GDIDEVICE *ppdev, SURFOBJ *DestSurface)
DestRect.top = SrcPoint.y - ppdev->PointerAttributes.Row; DestRect.top = SrcPoint.y - ppdev->PointerAttributes.Row;
DestRect.right = min( DestRect.right = min(
ppdev->PointerAttributes.Width, ppdev->PointerAttributes.Width,
DestSurface->sizlBitmap.cx - ppdev->PointerAttributes.Column - 1); DestSurface->sizlBitmap.cx - ppdev->PointerAttributes.Column);
DestRect.bottom = min( DestRect.bottom = min(
ppdev->PointerAttributes.Height, ppdev->PointerAttributes.Height,
DestSurface->sizlBitmap.cy - ppdev->PointerAttributes.Row - 1); DestSurface->sizlBitmap.cy - ppdev->PointerAttributes.Row);
SaveSurface = EngLockSurface(ppdev->PointerSaveSurface); SaveSurface = EngLockSurface(ppdev->PointerSaveSurface);
EngBitBlt(SaveSurface, DestSurface, NULL, NULL, NULL, EngBitBlt(SaveSurface, DestSurface, NULL, NULL, NULL,
@ -635,10 +635,10 @@ IntShowMousePointer(GDIDEVICE *ppdev, SURFOBJ *DestSurface)
DestRect.top = max(ppdev->PointerAttributes.Row, 0); DestRect.top = max(ppdev->PointerAttributes.Row, 0);
DestRect.right = min( DestRect.right = min(
ppdev->PointerAttributes.Column + ppdev->PointerAttributes.Width, ppdev->PointerAttributes.Column + ppdev->PointerAttributes.Width,
DestSurface->sizlBitmap.cx - 1); DestSurface->sizlBitmap.cx);
DestRect.bottom = min( DestRect.bottom = min(
ppdev->PointerAttributes.Row + ppdev->PointerAttributes.Height, ppdev->PointerAttributes.Row + ppdev->PointerAttributes.Height,
DestSurface->sizlBitmap.cy - 1); DestSurface->sizlBitmap.cy);
SrcPoint.x = max(-ppdev->PointerAttributes.Column, 0); SrcPoint.x = max(-ppdev->PointerAttributes.Column, 0);
SrcPoint.y = max(-ppdev->PointerAttributes.Row, 0); SrcPoint.y = max(-ppdev->PointerAttributes.Row, 0);