Add generation of 8bpp DIB code

svn path=/trunk/; revision=17441
This commit is contained in:
Gé van Geldorp 2005-08-19 20:56:01 +00:00
parent ceb380247b
commit 927cbf4440
4 changed files with 81 additions and 150 deletions

View file

@ -252,114 +252,17 @@ DIB_8BPP_BitBltSrcCopy(PBLTINFO BltInfo)
return TRUE;
}
BOOLEAN
DIB_8BPP_BitBlt(PBLTINFO BltInfo)
{
ULONG DestX, DestY;
ULONG SourceX, SourceY;
ULONG PatternY = 0;
ULONG Dest, Source = 0, Pattern = 0;
BOOL UsesSource;
BOOL UsesPattern;
PULONG DestBits;
LONG RoundedRight;
UsesSource = ROP4_USES_SOURCE(BltInfo->Rop4);
UsesPattern = ROP4_USES_PATTERN(BltInfo->Rop4);
SourceY = BltInfo->SourcePoint.y;
RoundedRight = BltInfo->DestRect.right -
((BltInfo->DestRect.right - BltInfo->DestRect.left) & 0x7);
if (UsesPattern)
{
if (BltInfo->PatternSurface)
{
PatternY = (BltInfo->DestRect.top + BltInfo->BrushOrigin.y) %
BltInfo->PatternSurface->sizlBitmap.cy;
}
else
{
Pattern = BltInfo->Brush->iSolidColor |
(BltInfo->Brush->iSolidColor << 8) |
(BltInfo->Brush->iSolidColor << 16) |
(BltInfo->Brush->iSolidColor << 24);
}
}
for (DestY = BltInfo->DestRect.top; DestY < BltInfo->DestRect.bottom; DestY++)
{
SourceX = BltInfo->SourcePoint.x;
DestBits = (PULONG)(
(PBYTE)BltInfo->DestSurface->pvScan0 +
BltInfo->DestRect.left +
DestY * BltInfo->DestSurface->lDelta);
for (DestX = BltInfo->DestRect.left; DestX < RoundedRight; DestX += 4, DestBits++)
{
Dest = *DestBits;
if (UsesSource)
{
Source = DIB_GetSource(BltInfo->SourceSurface, SourceX + (DestX - BltInfo->DestRect.left), SourceY, BltInfo->XlateSourceToDest);
Source |= DIB_GetSource(BltInfo->SourceSurface, SourceX + (DestX - BltInfo->DestRect.left) + 1, SourceY, BltInfo->XlateSourceToDest) << 8;
Source |= DIB_GetSource(BltInfo->SourceSurface, SourceX + (DestX - BltInfo->DestRect.left) + 2, SourceY, BltInfo->XlateSourceToDest) << 16;
Source |= DIB_GetSource(BltInfo->SourceSurface, SourceX + (DestX - BltInfo->DestRect.left) + 3, SourceY, BltInfo->XlateSourceToDest) << 24;
}
if (BltInfo->PatternSurface)
{
Pattern = DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest);
Pattern |= DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x + 1) % 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) << 16;
Pattern |= DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x + 3) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest) << 24;
}
*DestBits = DIB_DoRop(BltInfo->Rop4, Dest, Source, Pattern);
}
if (DestX < BltInfo->DestRect.right)
{
for (; DestX < BltInfo->DestRect.right; DestX++)
{
Dest = DIB_8BPP_GetPixel(BltInfo->DestSurface, DestX, DestY);
if (UsesSource)
{
Source = DIB_GetSource(BltInfo->SourceSurface, SourceX + (DestX - BltInfo->DestRect.left), SourceY, BltInfo->XlateSourceToDest);
}
if (BltInfo->PatternSurface)
{
Pattern = DIB_GetSource(BltInfo->PatternSurface, (DestX + BltInfo->BrushOrigin.x) % BltInfo->PatternSurface->sizlBitmap.cx, PatternY, BltInfo->XlatePatternToDest);
}
DIB_8BPP_PutPixel(BltInfo->DestSurface, DestX, DestY, DIB_DoRop(BltInfo->Rop4, Dest, Source, Pattern) & 0xFFFF);
}
}
SourceY++;
if (BltInfo->PatternSurface)
{
PatternY++;
PatternY %= BltInfo->PatternSurface->sizlBitmap.cy;
}
}
return TRUE;
}
/* BitBlt Optimize */
BOOLEAN
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);
}
for (DestY = DestRect->top; DestY< DestRect->bottom; DestY++)
{
DIB_8BPP_HLine(DestSurface, DestRect->left, DestRect->right, DestY, color);
}
return TRUE;
return TRUE;
}
/*
=======================================

View file

@ -14,6 +14,7 @@
<file>dib1bpp.c</file>
<file>dib4bpp.c</file>
<file>dib8bpp.c</file>
<file>dib8gen.c</file>
<file>dib16bpp.c</file>
<file>dib16gen.c</file>
<file>dib24bpp.c</file>

View file

@ -263,11 +263,16 @@ CreateOperation(FILE *Out, unsigned Bpp, PROPINFO RopInfo, unsigned SourceBpp,
Cast = "";
Dest = "*DestPtr";
}
else
else if (16 == Bpp)
{
Cast = "(USHORT) ";
Dest = "*((PUSHORT) DestPtr)";
}
else
{
Cast = "(UCHAR) ";
Dest = "*((PUCHAR) DestPtr)";
}
Output(Out, "%s = ", Dest);
if (ROPCODE_GENERIC == RopInfo->RopCode)
{
@ -448,11 +453,24 @@ CreateCounts(FILE *Out, unsigned Bpp)
MARK(Out);
if (32 != Bpp)
{
Output(Out, "LeftCount = ((ULONG_PTR) DestBase >> 1) & 0x01;\n");
if (8 < Bpp)
{
Output(Out, "LeftCount = ((ULONG_PTR) DestBase >> 1) & 0x01;\n");
}
else
{
Output(Out, "LeftCount = (ULONG_PTR) DestBase & 0x03;\n");
Output(Out, "if (BltInfo->DestRect.right - BltInfo->DestRect.left < "
"LeftCount)\n");
Output(Out, "{\n");
Output(Out, "LeftCount = BltInfo->DestRect.right - "
"BltInfo->DestRect.left;\n");
Output(Out, "}\n");
}
Output(Out, "CenterCount = (BltInfo->DestRect.right - BltInfo->DestRect.left -\n");
Output(Out, " LeftCount) / 2;\n");
Output(Out, " LeftCount) / %u;\n", 32 / Bpp);
Output(Out, "RightCount = (BltInfo->DestRect.right - BltInfo->DestRect.left -\n");
Output(Out, " LeftCount - 2 * CenterCount);\n");
Output(Out, " LeftCount - %u * CenterCount);\n", 32 / Bpp);
}
else
{
@ -460,6 +478,36 @@ CreateCounts(FILE *Out, unsigned Bpp)
}
}
static void
CreateSetSinglePixel(FILE *Out, unsigned Bpp, PROPINFO RopInfo, int Flags,
unsigned SourceBpp)
{
if (RopInfo->UsesSource && 0 == (Flags & FLAG_FORCENOUSESSOURCE))
{
CreateGetSource(Out, Bpp, RopInfo, Flags, SourceBpp, 0);
MARK(Out);
}
if (RopInfo->UsesPattern && 0 != (Flags & FLAG_PATTERNSURFACE))
{
Output(Out, "Pattern = DIB_GetSource(BltInfo->PatternSurface, PatternX, PatternY, BltInfo->XlatePatternToDest);\n");
Output(Out, "if (BltInfo->PatternSurface->sizlBitmap.cx <= ++PatternX)\n");
Output(Out, "{\n");
Output(Out, "PatternX -= BltInfo->PatternSurface->sizlBitmap.cx;\n");
Output(Out, "}\n");
}
if ((RopInfo->UsesSource && 0 == (Flags & FLAG_FORCENOUSESSOURCE) &&
Bpp != SourceBpp) ||
(RopInfo->UsesPattern && 0 != (Flags & FLAG_PATTERNSURFACE)))
{
Output(Out, "\n");
}
CreateOperation(Out, Bpp, RopInfo, SourceBpp, 16);
Output(Out, ";\n");
MARK(Out);
Output(Out, "\n");
Output(Out, "DestPtr = (PULONG)((char *) DestPtr + %u);\n", Bpp / 8);
}
static void
CreateBitCase(FILE *Out, unsigned Bpp, PROPINFO RopInfo, int Flags,
unsigned SourceBpp)
@ -536,33 +584,19 @@ CreateBitCase(FILE *Out, unsigned Bpp, PROPINFO RopInfo, int Flags,
Output(Out, "\n");
if (32 != Bpp)
{
Output(Out, "if (0 != LeftCount)\n");
if (16 == Bpp)
{
Output(Out, "if (0 != LeftCount)\n");
}
else
{
Output(Out, "for (i = 0; i < LeftCount; i++)\n");
}
Output(Out, "{\n");
if (RopInfo->UsesSource && 0 == (Flags & FLAG_FORCENOUSESSOURCE))
{
CreateGetSource(Out, Bpp, RopInfo, Flags | FLAG_FORCERAWSOURCEAVAIL,
SourceBpp, 0);
MARK(Out);
}
if (RopInfo->UsesPattern && 0 != (Flags & FLAG_PATTERNSURFACE))
{
Output(Out, "Pattern = DIB_GetSource(BltInfo->PatternSurface, PatternX, PatternY, BltInfo->XlatePatternToDest);\n");
Output(Out, "if (BltInfo->PatternSurface->sizlBitmap.cx <= ++PatternX)\n");
Output(Out, "{\n");
Output(Out, "PatternX -= BltInfo->PatternSurface->sizlBitmap.cx;\n");
Output(Out, "}\n");
}
if ((RopInfo->UsesSource && 0 == (Flags & FLAG_FORCENOUSESSOURCE) &&
Bpp != SourceBpp) ||
(RopInfo->UsesPattern && 0 != (Flags & FLAG_PATTERNSURFACE)))
{
Output(Out, "\n");
}
CreateOperation(Out, Bpp, RopInfo, SourceBpp, 16);
Output(Out, ";\n");
CreateSetSinglePixel(Out, Bpp, RopInfo,
(16 == Bpp ? Flags | FLAG_FORCERAWSOURCEAVAIL :
Flags), SourceBpp);
MARK(Out);
Output(Out, "\n");
Output(Out, "DestPtr = (PULONG)((char *) DestPtr + 2);\n");
Output(Out, "}\n");
Output(Out, "\n");
}
@ -606,24 +640,16 @@ CreateBitCase(FILE *Out, unsigned Bpp, PROPINFO RopInfo, int Flags,
Output(Out, "\n");
if (32 != Bpp)
{
Output(Out, "if (0 != RightCount)\n");
if (16 == Bpp)
{
Output(Out, "if (0 != RightCount)\n");
}
else
{
Output(Out, "for (i = 0; i < RightCount; i++)\n");
}
Output(Out, "{\n");
if (RopInfo->UsesSource && 0 == (Flags & FLAG_FORCENOUSESSOURCE))
{
CreateGetSource(Out, Bpp, RopInfo, Flags, SourceBpp, 0);
MARK(Out);
}
if (RopInfo->UsesPattern && 0 != (Flags & FLAG_PATTERNSURFACE))
{
Output(Out, "Pattern = DIB_GetSource(BltInfo->PatternSurface, PatternX, PatternY, BltInfo->XlatePatternToDest);\n");
}
if ((RopInfo->UsesSource && 0 == (Flags & FLAG_FORCENOUSESSOURCE)) ||
(RopInfo->UsesPattern && 0 != (Flags & FLAG_PATTERNSURFACE)))
{
Output(Out, "\n");
}
CreateOperation(Out, Bpp, RopInfo, SourceBpp, 16);
Output(Out, ";\n");
CreateSetSinglePixel(Out, Bpp, RopInfo, Flags, SourceBpp);
MARK(Out);
Output(Out, "}\n");
Output(Out, "\n");
@ -998,7 +1024,7 @@ main(int argc, char *argv[])
{
unsigned Index;
static unsigned DestBpp[] =
{ 16, 32 };
{ 8, 16, 32 };
for (Index = 0; Index < sizeof(DestBpp) / sizeof(DestBpp[0]); Index++)
{

View file

@ -44,8 +44,9 @@ clean: gendib_clean
GENDIB_DIB_DIR = subsys$(SEP)win32k$(SEP)dib
GENDIB_DIB_FILES = \
$(GENDIB_DIB_DIR)$(SEP)dib32gen.c \
$(GENDIB_DIB_DIR)$(SEP)dib16gen.c \
$(GENDIB_DIB_DIR)$(SEP)dib32gen.c
$(GENDIB_DIB_DIR)$(SEP)dib8gen.c
$(GENDIB_DIB_FILES): $(GENDIB_TARGET)
$(ECHO_GENDIB)