* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id$ */
+
#include <w32k.h>
+#define NDEBUG
+#include <debug.h>
+
VOID
DIB_16BPP_PutPixel(SURFOBJ *SurfObj, LONG x, LONG y, ULONG c)
{
- PBYTE byteaddr = SurfObj->pvScan0 + y * SurfObj->lDelta;
+ PBYTE byteaddr = (PBYTE)SurfObj->pvScan0 + y * SurfObj->lDelta;
PWORD addr = (PWORD)byteaddr + x;
*addr = (WORD)c;
ULONG
DIB_16BPP_GetPixel(SURFOBJ *SurfObj, LONG x, LONG y)
{
- PBYTE byteaddr = SurfObj->pvScan0 + y * SurfObj->lDelta;
+ PBYTE byteaddr = (PBYTE)SurfObj->pvScan0 + y * SurfObj->lDelta;
PWORD addr = (PWORD)byteaddr + x;
return (ULONG)(*addr);
VOID
DIB_16BPP_HLine(SURFOBJ *SurfObj, LONG x1, LONG x2, LONG y, ULONG c)
{
- PDWORD addr = (PDWORD)((PWORD)(SurfObj->pvScan0 + y * SurfObj->lDelta) + x1);
+ PDWORD addr = (PDWORD)((PWORD)((PBYTE)SurfObj->pvScan0 + y * SurfObj->lDelta) + x1);
#ifdef _M_IX86
" shl $16, %%eax\n"
" andl $0xffff, %0\n" /* If the pixel value is "abcd", put "abcdabcd" in %eax */
" or %0, %%eax\n"
+" mov %2, %%edi\n"
" test $0x03, %%edi\n" /* Align to fullword boundary */
-" jz .L1\n"
+" jz 0f\n"
" stosw\n"
" dec %1\n"
-" jz .L2\n"
-".L1:\n"
+" jz 1f\n"
+"0:\n"
" mov %1,%%ecx\n" /* Setup count of fullwords to fill */
" shr $1,%%ecx\n"
" rep stosl\n" /* The actual fill */
" test $0x01, %1\n" /* One left to do at the right side? */
-" jz .L2\n"
+" jz 1f\n"
" stosw\n"
-".L2:\n"
+"1:\n"
: /* no output */
- : "r"(c), "r"(Count), "D"(addr)
- : "%eax", "%ecx");
+ : "r"(c), "r"(Count), "m"(addr)
+ : "%eax", "%ecx", "%edi");
#else /* _M_IX86 */
LONG cx = x1;
DWORD cc;
" jnz 1b" "\n\t"
"2:" "\n\t"
: /* no output */
- : "r"(SurfObj->pvScan0 + (y1 * SurfObj->lDelta) + (x * sizeof (WORD))),
+ : "r"((PBYTE)SurfObj->pvScan0 + (y1 * SurfObj->lDelta) + (x * sizeof (WORD))),
"r"(SurfObj->lDelta), "r"(y2 - y1), "a"(c)
: "cc", "memory", "%ecx");
#else
LONG i, j, sx, sy, xColor, f1;
PBYTE SourceBits, DestBits, SourceLine, DestLine;
PBYTE SourceBits_4BPP, SourceLine_4BPP;
- DestBits = BltInfo->DestSurface->pvScan0 + (BltInfo->DestRect.top * BltInfo->DestSurface->lDelta) + 2 * BltInfo->DestRect.left;
+ DestBits = (PBYTE)BltInfo->DestSurface->pvScan0 + (BltInfo->DestRect.top * BltInfo->DestSurface->lDelta) + 2 * BltInfo->DestRect.left;
switch(BltInfo->SourceSurface->iBitmapFormat)
{
break;
case BMF_4BPP:
- SourceBits_4BPP = BltInfo->SourceSurface->pvScan0 + (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) + (BltInfo->SourcePoint.x >> 1);
+ 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++)
{
break;
case BMF_8BPP:
- SourceLine = BltInfo->SourceSurface->pvScan0 + (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) + BltInfo->SourcePoint.x;
+ 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++)
{
if (BltInfo->DestRect.top < BltInfo->SourcePoint.y)
{
- SourceBits = BltInfo->SourceSurface->pvScan0 + (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) + 2 * BltInfo->SourcePoint.x;
+ SourceBits = (PBYTE)BltInfo->SourceSurface->pvScan0 + (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) + 2 * BltInfo->SourcePoint.x;
for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
{
RtlMoveMemory(DestBits, SourceBits, 2 * (BltInfo->DestRect.right - BltInfo->DestRect.left));
}
else
{
- SourceBits = BltInfo->SourceSurface->pvScan0 + ((BltInfo->SourcePoint.y + BltInfo->DestRect.bottom - BltInfo->DestRect.top - 1) * BltInfo->SourceSurface->lDelta) + 2 * BltInfo->SourcePoint.x;
- DestBits = BltInfo->DestSurface->pvScan0 + ((BltInfo->DestRect.bottom - 1) * BltInfo->DestSurface->lDelta) + 2 * BltInfo->DestRect.left;
+ SourceBits = (PBYTE)BltInfo->SourceSurface->pvScan0 + ((BltInfo->SourcePoint.y + BltInfo->DestRect.bottom - BltInfo->DestRect.top - 1) * BltInfo->SourceSurface->lDelta) + 2 * BltInfo->SourcePoint.x;
+ DestBits = (PBYTE)BltInfo->DestSurface->pvScan0 + ((BltInfo->DestRect.bottom - 1) * BltInfo->DestSurface->lDelta) + 2 * BltInfo->DestRect.left;
for (j = BltInfo->DestRect.bottom - 1; BltInfo->DestRect.top <= j; j--)
{
RtlMoveMemory(DestBits, SourceBits, 2 * (BltInfo->DestRect.right - BltInfo->DestRect.left));
{
if (BltInfo->DestRect.top < BltInfo->SourcePoint.y)
{
- SourceLine = BltInfo->SourceSurface->pvScan0 + (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) + 2 * BltInfo->SourcePoint.x;
+ 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++)
{
}
else
{
- SourceLine = BltInfo->SourceSurface->pvScan0 + ((BltInfo->SourcePoint.y + BltInfo->DestRect.bottom - BltInfo->DestRect.top - 1) * BltInfo->SourceSurface->lDelta) + 2 * BltInfo->SourcePoint.x;
- DestLine = BltInfo->DestSurface->pvScan0 + ((BltInfo->DestRect.bottom - 1) * BltInfo->DestSurface->lDelta) + 2 * BltInfo->DestRect.left;
+ SourceLine = (PBYTE)BltInfo->SourceSurface->pvScan0 + ((BltInfo->SourcePoint.y + BltInfo->DestRect.bottom - BltInfo->DestRect.top - 1) * BltInfo->SourceSurface->lDelta) + 2 * BltInfo->SourcePoint.x;
+ DestLine = (PBYTE)BltInfo->DestSurface->pvScan0 + ((BltInfo->DestRect.bottom - 1) * BltInfo->DestSurface->lDelta) + 2 * BltInfo->DestRect.left;
for (j = BltInfo->DestRect.bottom - 1; BltInfo->DestRect.top <= j; j--)
{
SourceBits = SourceLine;
break;
case BMF_24BPP:
- SourceLine = BltInfo->SourceSurface->pvScan0 + (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) + 3 * BltInfo->SourcePoint.x;
+ 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++)
break;
case BMF_32BPP:
- SourceLine = BltInfo->SourceSurface->pvScan0 + (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) + 4 * BltInfo->SourcePoint.x;
+ SourceLine = (PBYTE)BltInfo->SourceSurface->pvScan0 + (BltInfo->SourcePoint.y * BltInfo->SourceSurface->lDelta) + 4 * BltInfo->SourcePoint.x;
DestLine = DestBits;
for (j = BltInfo->DestRect.top; j < BltInfo->DestRect.bottom; j++)
return TRUE;
}
-BOOLEAN
-DIB_16BPP_BitBlt(PBLTINFO BltInfo)
-{
- ULONG DestX, DestY;
- ULONG SourceX, SourceY;
- ULONG PatternY = 0;
- ULONG Dest, Source = 0, Pattern = 0;
- BOOL UsesSource;
- BOOL UsesPattern;
- PULONG DestBits;
- ULONG RoundedRight;
-
- UsesSource = ROP4_USES_SOURCE(BltInfo->Rop4);
- UsesPattern = ROP4_USES_PATTERN(BltInfo->Rop4);
-
- RoundedRight = BltInfo->DestRect.right -
- ((BltInfo->DestRect.right - BltInfo->DestRect.left) & 0x1);
- SourceY = BltInfo->SourcePoint.y;
- DestBits = (PULONG)(
- BltInfo->DestSurface->pvScan0 +
- (BltInfo->DestRect.left << 1) +
- BltInfo->DestRect.top * BltInfo->DestSurface->lDelta);
-
- if (UsesPattern)
- {
- if (BltInfo->PatternSurface)
- {
- PatternY = (BltInfo->DestRect.top + BltInfo->BrushOrigin.y) %
- BltInfo->PatternSurface->sizlBitmap.cy;
- }
- else
- {
- Pattern = BltInfo->Brush->iSolidColor |
- (BltInfo->Brush->iSolidColor << 16);
- }
- }
-
- for (DestY = BltInfo->DestRect.top; DestY < BltInfo->DestRect.bottom; DestY++)
- {
- SourceX = BltInfo->SourcePoint.x;
-
- for (DestX = BltInfo->DestRect.left; DestX < RoundedRight; DestX += 2, DestBits++, SourceX += 2)
- {
- Dest = *DestBits;
-
- if (UsesSource)
- {
- Source = DIB_GetSource(BltInfo->SourceSurface, SourceX, SourceY, BltInfo->XlateSourceToDest);
- Source |= DIB_GetSource(BltInfo->SourceSurface, SourceX + 1, SourceY, BltInfo->XlateSourceToDest) << 16;
- }
-
- 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) << 16;
- }
-
- *DestBits = DIB_DoRop(BltInfo->Rop4, Dest, Source, Pattern);
- }
-
- if (DestX < BltInfo->DestRect.right)
- {
- Dest = *((PUSHORT)DestBits);
-
- 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_16BPP_PutPixel(BltInfo->DestSurface, DestX, DestY, DIB_DoRop(BltInfo->Rop4, Dest, Source, Pattern) & 0xFFFF);
- DestBits = (PULONG)((ULONG_PTR)DestBits + 2);
- }
-
- SourceY++;
- if (BltInfo->PatternSurface)
- {
- PatternY++;
- PatternY %= BltInfo->PatternSurface->sizlBitmap.cy;
- }
- DestBits = (PULONG)(
- (ULONG_PTR)DestBits -
- ((BltInfo->DestRect.right - BltInfo->DestRect.left) << 1) +
- BltInfo->DestSurface->lDelta);
- }
-
- return TRUE;
-}
-
/* Optimize for bitBlt */
BOOLEAN
DIB_16BPP_ColorFill(SURFOBJ* DestSurface, RECTL* DestRect, ULONG color)
/* This is about 10% faster than the generic C code below */
ULONG delta = DestSurface->lDelta;
ULONG width = (DestRect->right - DestRect->left) ;
- PULONG pos = (PULONG) (DestSurface->pvScan0 + DestRect->top * delta + (DestRect->left<<1));
+ PULONG pos = (PULONG) ((PBYTE)DestSurface->pvScan0 + DestRect->top * delta + (DestRect->left<<1));
color = (color&0xffff); /* If the color value is "abcd", put "abcdabcd" into color */
color += (color<<16);
{
__asm__ __volatile__ (
" cld\n"
- " mov %0,%%eax\n"
" mov %1,%%ebx\n"
+ " mov %2,%%edi\n"
" test $0x03, %%edi\n" /* Align to fullword boundary */
" jz .FL1\n"
" stosw\n"
" jz .FL2\n"
" stosw\n"
".FL2:\n"
- :
- : "r" (color), "r" (width), "D" (pos)
- : "%eax", "%ecx","%ebx");
+ :
+ : "a" (color), "r" (width), "m" (pos)
+ : "%ecx", "%ebx", "%edi");
pos =(PULONG)((ULONG_PTR)pos + delta);
}
typedef unsigned short PIXEL;
/* 16-bit HiColor (565 format) */
-inline PIXEL average16(PIXEL a, PIXEL b)
+__inline PIXEL average16(PIXEL a, PIXEL b)
{
// This one doesn't work
/*
PIXEL *ScanLine, *ScanLineAhead;
PIXEL *PrevSource = NULL;
PIXEL *PrevSourceAhead = NULL;
- PIXEL *Target = (PIXEL *) (DestSurf->pvScan0 + (DestRect->top * DestSurf->lDelta) + 2 * DestRect->left);
- PIXEL *Source = (PIXEL *) (SourceSurf->pvScan0 + (SourceRect->top * SourceSurf->lDelta) + 2 * SourceRect->left);
+ PIXEL *Target = (PIXEL *) ((PBYTE)DestSurf->pvScan0 + (DestRect->top * DestSurf->lDelta) + 2 * DestRect->left);
+ PIXEL *Source = (PIXEL *) ((PBYTE)SourceSurf->pvScan0 + (SourceRect->top * SourceSurf->lDelta) + 2 * SourceRect->left);
PSPAN ClipSpans;
UINT ClipSpansCount;
UINT SpanIndex;
return TRUE;
}
+/* check clib region */
+BOOLEAN CheckClipRegion(CLIPOBJ *ClipRegion, RECTL* DestRect, int DesX, int DesY)
+{
+ BOOLEAN status = FALSE;
+ PSPAN ClipSpans;
+ UINT ClipSpansCount;
+ UINT SpanIndex = 0;
+
+ if (! ClipobjToSpans(&ClipSpans, &ClipSpansCount, ClipRegion, DestRect))
+ {
+ return FALSE;
+ }
+
+ if (0 == ClipSpansCount)
+ {
+ /* No clip spans == empty clipping region, everything clipped away */
+ ASSERT(NULL == ClipSpans);
+ return FALSE;
+ }
+
+ for (SpanIndex=0; SpanIndex<ClipSpansCount;SpanIndex++)
+ {
+ if (ClipSpans[SpanIndex].Y < DesY)
+ status = FALSE;
+
+ if (ClipSpans[SpanIndex].Y+ClipSpans[SpanIndex].Height > DesY)
+ status = FALSE;
+
+ if (ClipSpans[SpanIndex].X > DesX)
+ status = FALSE;
+
+ if (ClipSpans[SpanIndex].X+ClipSpans[SpanIndex].Width > DesX)
+ status = FALSE;
+ }
+
+ return status;
+}
+
+
//NOTE: If you change something here, please do the same in other dibXXbpp.c files!
BOOLEAN DIB_16BPP_StretchBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
RECTL* DestRect, RECTL *SourceRect,
int DesX;
int DesY;
int color;
- int zoomX;
- int zoomY;
- int count;
- int saveX;
- int saveY;
- BOOLEAN DesIsBiggerY=FALSE;
+ PULONG DestBits;
+
DPRINT("DIB_16BPP_StretchBlt: Source BPP: %u, srcRect: (%d,%d)-(%d,%d), dstRect: (%d,%d)-(%d,%d)\n",
BitsPerFormat(SourceSurf->iBitmapFormat), SourceRect->left, SourceRect->top, SourceRect->right, SourceRect->bottom,
DestRect->left, DestRect->top, DestRect->right, DestRect->bottom);
- SrcSizeY = SourceRect->bottom;
- SrcSizeX = SourceRect->right;
+ SrcSizeY = SourceRect->bottom - SourceRect->top;
+ SrcSizeX = SourceRect->right - SourceRect->left;
- DesSizeY = DestRect->bottom;
- DesSizeX = DestRect->right;
-
- zoomX = DesSizeX / SrcSizeX;
- if (zoomX==0) zoomX=1;
-
- zoomY = DesSizeY / SrcSizeY;
- if (zoomY==0) zoomY=1;
-
- if (DesSizeY>SrcSizeY)
- DesIsBiggerY = TRUE;
-
+ DesSizeY = DestRect->bottom - DestRect->top;
+ DesSizeX = DestRect->right - DestRect->left;
-
switch(SourceSurf->iBitmapFormat)
{
-
case BMF_1BPP:
- /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
- /* This is a reference implementation, it hasn't been optimized for speed */
- if (zoomX>1)
- {
- /* Draw one Hline on X - Led to the Des Zoom In*/
- if (DesSizeX>SrcSizeX)
- {
- for (DesY=DestRect->bottom-zoomY; DesY>=0; DesY-=zoomY)
- {
- if (DesIsBiggerY)
- sy = (int) ((ULONG) SrcSizeY * (ULONG) DesY) / ((ULONG) DesSizeY);
- else
- sy = (int) ((ULONG) DesSizeY * (ULONG) DesY) / ((ULONG) SrcSizeY);
-
- if (sy > SourceRect->bottom) break;
-
- saveY = DesY+zoomY;
-
- for (DesX=DestRect->right-zoomX; DesX>=0; DesX-=zoomX)
- {
- sx = (int) ((ULONG) SrcSizeX * (ULONG) DesX) / ((ULONG) DesSizeX);
-
- if (sx > SourceRect->right) break;
-
- saveX = DesX + zoomX;
-
- if (DIB_1BPP_GetPixel(SourceSurf, sx, sy) == 0)
- for (count=DesY;count<saveY;count++)
- DIB_16BPP_HLine(DestSurf, DesX, saveX, count, 0);
- else
- for (count=DesY;count<saveY;count++)
- DIB_16BPP_HLine(DestSurf, DesX, saveX, count, 1);
-
- }
- }
- }
- else
- {
- /* Draw one Hline on X - Led to the Des Zoom Out*/
-
- for (DesY=DestRect->bottom-zoomY; DesY>=0; DesY-=zoomY)
- {
- if (DesIsBiggerY)
- sy = (int) ((ULONG) SrcSizeY * (ULONG) DesY) / ((ULONG) DesSizeY);
- else
- sy = (int) ((ULONG) DesSizeY * (ULONG) DesY) / ((ULONG) SrcSizeY);
-
- if (sy > SourceRect->bottom) break;
-
- saveY = DesY+zoomY;
-
- for (DesX=DestRect->right-zoomX; DesX>=0; DesX-=zoomX)
- {
- sx = (int) ((ULONG) DesSizeX * (ULONG) DesX) / ((ULONG) SrcSizeX);
-
- if (sx > SourceRect->right) break;
-
- saveX = DesX + zoomX;
-
- if (DIB_1BPP_GetPixel(SourceSurf, sx, sy) == 0)
- for (count=DesY;count<saveY;count++)
- DIB_16BPP_HLine(DestSurf, DesX, saveX, count, 0);
- else
- for (count=DesY;count<saveY;count++)
- DIB_16BPP_HLine(DestSurf, DesX, saveX, count, 1);
-
- }
- }
- }
- }
- else
- {
-
- if (DesSizeX>SrcSizeX)
- {
- /* Draw one pixel on X - Led to the Des Zoom In*/
- for (DesY=DestRect->bottom-zoomY; DesY>=0; DesY-=zoomY)
- {
- if (DesIsBiggerY)
- sy = (int) ((ULONG) SrcSizeY * (ULONG) DesY) / ((ULONG) DesSizeY);
- else
- sy = (int) ((ULONG) DesSizeY * (ULONG) DesY) / ((ULONG) SrcSizeY);
-
- if (sy > SourceRect->bottom) break;
-
- saveY = DesY+zoomY;
-
- for (DesX=DestRect->right-zoomX; DesX>=0; DesX-=zoomX)
- {
- sx = (int) ((ULONG) SrcSizeX * (ULONG) DesX) / ((ULONG) DesSizeX);
-
- if (sx > SourceRect->right) break;
-
- if (DIB_1BPP_GetPixel(SourceSurf, sx, sy) == 0)
- for (count=DesY;count<saveY;count++)
- DIB_16BPP_PutPixel(DestSurf, DesX, count, 0);
- else
- for (count=DesY;count<saveY;count++)
- DIB_16BPP_PutPixel(DestSurf, DesX, count, 1);
-
-
- }
- }
- }
- else
- {
- /* Draw one pixel on X - Led to the Des Zoom Out*/
- for (DesY=DestRect->bottom-zoomY; DesY>=0; DesY-=zoomY)
- {
- if (DesIsBiggerY)
- sy = (int) ((ULONG) SrcSizeY * (ULONG) DesY) / ((ULONG) DesSizeY);
- else
- sy = (int) ((ULONG) DesSizeY * (ULONG) DesY) / ((ULONG) SrcSizeY);
-
- if (sy > SourceRect->bottom) break;
-
- saveY = DesY+zoomY;
-
- for (DesX=DestRect->right-zoomX; DesX>=0; DesX-=zoomX)
- {
- sx = (int) ((ULONG) DesSizeX * (ULONG) DesX) / ((ULONG) SrcSizeX);
-
- if (sx > SourceRect->right) break;
-
- if (DIB_1BPP_GetPixel(SourceSurf, sx, sy) == 0)
- for (count=DesY;count<saveY;count++)
- DIB_16BPP_PutPixel(DestSurf, DesX, count, 0);
- else
- for (count=DesY;count<saveY;count++)
- DIB_16BPP_PutPixel(DestSurf, DesX, count, 1);
-
- }
- }
- }
- }
- break;
+ /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
+ /* This is a reference implementation, it hasn't been optimized for speed */
+
+ DestBits = (PULONG)((PBYTE)DestSurf->pvScan0 + (DestRect->left << 1) +
+ DestRect->top * DestSurf->lDelta);
+
+ for (DesY=0; DesY<DesSizeY; DesY++)
+ {
+ sy = ((DesY * SrcSizeY) / DesSizeY) + SourceRect->top;
+
+ for (DesX=0; DesX<DesSizeX; DesX++)
+ {
+
+ sx = ((DesX * SrcSizeX) / DesSizeX) + SourceRect->left;
+
+ if(DIB_1BPP_GetPixel(SourceSurf, sx, sy) == 0)
+ {
+ *DestBits = XLATEOBJ_iXlate(ColorTranslation, 0);
+ DestBits = (PULONG)((ULONG_PTR)DestBits + 2);
+ }
+ else
+ {
+ *DestBits = XLATEOBJ_iXlate(ColorTranslation, 1);
+ DestBits = (PULONG)((ULONG_PTR)DestBits + 2);
+ }
+ }
+ DestBits = (PULONG)((ULONG_PTR)DestBits - (DesSizeX << 1) + DestSurf->lDelta);
+ }
+ break;
case BMF_4BPP:
- /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
- /* This is a reference implementation, it hasn't been optimized for speed */
- if (zoomX>1)
- {
- /* Draw one Hline on X - Led to the Des Zoom In*/
- if (DesSizeX>SrcSizeX)
- {
- for (DesY=DestRect->bottom-zoomY; DesY>=0; DesY-=zoomY)
- {
- if (DesIsBiggerY)
- sy = (int) ((ULONG) SrcSizeY * (ULONG) DesY) / ((ULONG) DesSizeY);
- else
- sy = (int) ((ULONG) DesSizeY * (ULONG) DesY) / ((ULONG) SrcSizeY);
-
- if (sy > SourceRect->bottom) break;
-
- saveY = DesY+zoomY;
-
- for (DesX=DestRect->right-zoomX; DesX>=0; DesX-=zoomX)
- {
- sx = (int) ((ULONG) SrcSizeX * (ULONG) DesX) / ((ULONG) DesSizeX);
-
- if (sx > SourceRect->right) break;
-
- color = XLATEOBJ_iXlate(ColorTranslation, DIB_4BPP_GetPixel(SourceSurf, sx, sy));
-
- saveX = DesX + zoomX;
- for (count=DesY;count<saveY;count++)
- DIB_16BPP_HLine(DestSurf, DesX, saveX, count, color);
- }
- }
- }
- else
- {
- /* Draw one Hline on X - Led to the Des Zoom Out*/
-
- for (DesY=DestRect->bottom-zoomY; DesY>=0; DesY-=zoomY)
- {
- if (DesIsBiggerY)
- sy = (int) ((ULONG) SrcSizeY * (ULONG) DesY) / ((ULONG) DesSizeY);
- else
- sy = (int) ((ULONG) DesSizeY * (ULONG) DesY) / ((ULONG) SrcSizeY);
-
- if (sy > SourceRect->bottom) break;
-
- saveY = DesY+zoomY;
-
- for (DesX=DestRect->right-zoomX; DesX>=0; DesX-=zoomX)
- {
- sx = (int) ((ULONG) DesSizeX * (ULONG) DesX) / ((ULONG) SrcSizeX);
-
- if (sx > SourceRect->right) break;
-
- color = XLATEOBJ_iXlate(ColorTranslation, DIB_4BPP_GetPixel(SourceSurf, sx, sy));
-
- saveX = DesX + zoomX;
- for (count=DesY;count<saveY;count++)
- DIB_16BPP_HLine(DestSurf, DesX, saveX, count, color);
- }
- }
- }
- }
-
- else
- {
-
- if (DesSizeX>SrcSizeX)
- {
- /* Draw one pixel on X - Led to the Des Zoom In*/
- for (DesY=DestRect->bottom-zoomY; DesY>=0; DesY-=zoomY)
- {
- if (DesIsBiggerY)
- sy = (int) ((ULONG) SrcSizeY * (ULONG) DesY) / ((ULONG) DesSizeY);
- else
- sy = (int) ((ULONG) DesSizeY * (ULONG) DesY) / ((ULONG) SrcSizeY);
-
- if (sy > SourceRect->bottom) break;
-
- saveY = DesY+zoomY;
-
- for (DesX=DestRect->right-zoomX; DesX>=0; DesX-=zoomX)
- {
- sx = (int) ((ULONG) SrcSizeX * (ULONG) DesX) / ((ULONG) DesSizeX);
-
- if (sx > SourceRect->right) break;
-
- color = XLATEOBJ_iXlate(ColorTranslation, DIB_4BPP_GetPixel(SourceSurf, sx, sy));
-
- for (count=DesY;count<saveY;count++)
- DIB_16BPP_PutPixel(DestSurf, DesX, count, color);
- }
- }
- }
- else
- {
- /* Draw one pixel on X - Led to the Des Zoom Out*/
- for (DesY=DestRect->bottom-zoomY; DesY>=0; DesY-=zoomY)
- {
- if (DesIsBiggerY)
- sy = (int) ((ULONG) SrcSizeY * (ULONG) DesY) / ((ULONG) DesSizeY);
- else
- sy = (int) ((ULONG) DesSizeY * (ULONG) DesY) / ((ULONG) SrcSizeY);
-
- if (sy > SourceRect->bottom) break;
-
- saveY = DesY+zoomY;
-
- for (DesX=DestRect->right-zoomX; DesX>=0; DesX-=zoomX)
- {
- sx = (int) ((ULONG) DesSizeX * (ULONG) DesX) / ((ULONG) SrcSizeX);
-
- if (sx > SourceRect->right) break;
-
- color = XLATEOBJ_iXlate(ColorTranslation, DIB_4BPP_GetPixel(SourceSurf, sx, sy));
-
- for (count=DesY;count<saveY;count++)
- DIB_16BPP_PutPixel(DestSurf, DesX, count, color);
- }
- }
- }
- }
- break;
-
+ /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
+ /* This is a reference implementation, it hasn't been optimized for speed */
+
+ DestBits = (PULONG)((PBYTE)DestSurf->pvScan0 + (DestRect->left << 1) +
+ DestRect->top * DestSurf->lDelta);
+
+ for (DesY=0; DesY<DesSizeY; DesY++)
+ {
+ sy = ((DesY * SrcSizeY) / DesSizeY) + SourceRect->top;
+
+ for (DesX=0; DesX<DesSizeX; DesX++)
+ {
+
+ sx = ((DesX * SrcSizeX) / DesSizeX) + SourceRect->left;
+ color = DIB_4BPP_GetPixel(SourceSurf, sx, sy);
+
+ *DestBits = XLATEOBJ_iXlate(ColorTranslation, color);
+ DestBits = (PULONG)((ULONG_PTR)DestBits + 2);
+ }
+ DestBits = (PULONG)((ULONG_PTR)DestBits - (DesSizeX << 1) + DestSurf->lDelta);
+ }
+ break;
+
case BMF_8BPP:
- /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
- /* This is a reference implementation, it hasn't been optimized for speed */
- if (zoomX>1)
- {
- /* Draw one Hline on X - Led to the Des Zoom In*/
- if (DesSizeX>SrcSizeX)
- {
- for (DesY=DestRect->bottom-zoomY; DesY>=0; DesY-=zoomY)
- {
- if (DesIsBiggerY)
- sy = (int) ((ULONG) SrcSizeY * (ULONG) DesY) / ((ULONG) DesSizeY);
- else
- sy = (int) ((ULONG) DesSizeY * (ULONG) DesY) / ((ULONG) SrcSizeY);
-
- if (sy > SourceRect->bottom) break;
-
- saveY = DesY+zoomY;
-
- for (DesX=DestRect->right-zoomX; DesX>=0; DesX-=zoomX)
- {
- sx = (int) ((ULONG) SrcSizeX * (ULONG) DesX) / ((ULONG) DesSizeX);
-
- if (sx > SourceRect->right) break;
-
- color = XLATEOBJ_iXlate(ColorTranslation, DIB_8BPP_GetPixel(SourceSurf, sx, sy));
-
- saveX = DesX + zoomX;
- for (count=DesY;count<saveY;count++)
- DIB_16BPP_HLine(DestSurf, DesX, saveX, count, color);
- }
- }
- }
- else
- {
- /* Draw one Hline on X - Led to the Des Zoom Out*/
-
- for (DesY=DestRect->bottom-zoomY; DesY>=0; DesY-=zoomY)
- {
- if (DesIsBiggerY)
- sy = (int) ((ULONG) SrcSizeY * (ULONG) DesY) / ((ULONG) DesSizeY);
- else
- sy = (int) ((ULONG) DesSizeY * (ULONG) DesY) / ((ULONG) SrcSizeY);
-
- if (sy > SourceRect->bottom) break;
-
- saveY = DesY+zoomY;
-
- for (DesX=DestRect->right-zoomX; DesX>=0; DesX-=zoomX)
- {
- sx = (int) ((ULONG) DesSizeX * (ULONG) DesX) / ((ULONG) SrcSizeX);
-
- if (sx > SourceRect->right) break;
-
- color = XLATEOBJ_iXlate(ColorTranslation, DIB_8BPP_GetPixel(SourceSurf, sx, sy));
-
- saveX = DesX + zoomX;
- for (count=DesY;count<saveY;count++)
- DIB_16BPP_HLine(DestSurf, DesX, saveX, count, color);
- }
- }
- }
- }
-
- else
- {
-
- if (DesSizeX>SrcSizeX)
- {
- /* Draw one pixel on X - Led to the Des Zoom In*/
- for (DesY=DestRect->bottom-zoomY; DesY>=0; DesY-=zoomY)
- {
- if (DesIsBiggerY)
- sy = (int) ((ULONG) SrcSizeY * (ULONG) DesY) / ((ULONG) DesSizeY);
- else
- sy = (int) ((ULONG) DesSizeY * (ULONG) DesY) / ((ULONG) SrcSizeY);
-
- if (sy > SourceRect->bottom) break;
-
- saveY = DesY+zoomY;
-
- for (DesX=DestRect->right-zoomX; DesX>=0; DesX-=zoomX)
- {
- sx = (int) ((ULONG) SrcSizeX * (ULONG) DesX) / ((ULONG) DesSizeX);
-
- if (sx > SourceRect->right) break;
-
- color = XLATEOBJ_iXlate(ColorTranslation, DIB_8BPP_GetPixel(SourceSurf, sx, sy));
-
- for (count=DesY;count<saveY;count++)
- DIB_16BPP_PutPixel(DestSurf, DesX, count, color);
- }
- }
- }
- else
- {
- /* Draw one pixel on X - Led to the Des Zoom Out*/
- for (DesY=DestRect->bottom-zoomY; DesY>=0; DesY-=zoomY)
- {
- if (DesIsBiggerY)
- sy = (int) ((ULONG) SrcSizeY * (ULONG) DesY) / ((ULONG) DesSizeY);
- else
- sy = (int) ((ULONG) DesSizeY * (ULONG) DesY) / ((ULONG) SrcSizeY);
-
- if (sy > SourceRect->bottom) break;
-
- saveY = DesY+zoomY;
-
- for (DesX=DestRect->right-zoomX; DesX>=0; DesX-=zoomX)
- {
- sx = (int) ((ULONG) DesSizeX * (ULONG) DesX) / ((ULONG) SrcSizeX);
-
- if (sx > SourceRect->right) break;
-
- color = XLATEOBJ_iXlate(ColorTranslation, DIB_8BPP_GetPixel(SourceSurf, sx, sy));
-
- for (count=DesY;count<saveY;count++)
- DIB_16BPP_PutPixel(DestSurf, DesX, count, color);
- }
- }
- }
- }
- break;
-
- case BMF_16BPP:
- return ScaleRectAvg16(DestSurf, SourceSurf, DestRect, SourceRect, MaskOrigin, BrushOrigin,
- ClipRegion, ColorTranslation, Mode);
- break;
+ /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
+ /* This is a reference implementation, it hasn't been optimized for speed */
+
+ DestBits = (PULONG)((PBYTE)DestSurf->pvScan0 + (DestRect->left << 1) +
+ DestRect->top * DestSurf->lDelta);
+
+ for (DesY=0; DesY<DesSizeY; DesY++)
+ {
+ sy = ((DesY * SrcSizeY) / DesSizeY) + SourceRect->top;
+
+ for (DesX=0; DesX<DesSizeX; DesX++)
+ {
+
+ sx = ((DesX * SrcSizeX) / DesSizeX) + SourceRect->left;
+ color = DIB_8BPP_GetPixel(SourceSurf, sx, sy);
+
+ *DestBits = XLATEOBJ_iXlate(ColorTranslation, color);
+ DestBits = (PULONG)((ULONG_PTR)DestBits + 2);
+ }
+ DestBits = (PULONG)((ULONG_PTR)DestBits - (DesSizeX << 1) + DestSurf->lDelta);
+ }
+ break;
+
case BMF_24BPP:
- /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
- /* This is a reference implementation, it hasn't been optimized for speed */
- if (zoomX>1)
- {
- /* Draw one Hline on X - Led to the Des Zoom In*/
- if (DesSizeX>SrcSizeX)
- {
- for (DesY=DestRect->bottom-zoomY; DesY>=0; DesY-=zoomY)
- {
- if (DesIsBiggerY)
- sy = (int) ((ULONG) SrcSizeY * (ULONG) DesY) / ((ULONG) DesSizeY);
- else
- sy = (int) ((ULONG) DesSizeY * (ULONG) DesY) / ((ULONG) SrcSizeY);
-
- if (sy > SourceRect->bottom) break;
-
- saveY = DesY+zoomY;
-
- for (DesX=DestRect->right-zoomX; DesX>=0; DesX-=zoomX)
- {
- sx = (int) ((ULONG) SrcSizeX * (ULONG) DesX) / ((ULONG) DesSizeX);
-
- if (sx > SourceRect->right) break;
-
- color = XLATEOBJ_iXlate(ColorTranslation, DIB_24BPP_GetPixel(SourceSurf, sx, sy));
-
- saveX = DesX + zoomX;
- for (count=DesY;count<saveY;count++)
- DIB_16BPP_HLine(DestSurf, DesX, saveX, count, color);
- }
- }
- }
- else
- {
- /* Draw one Hline on X - Led to the Des Zoom Out*/
-
- for (DesY=DestRect->bottom-zoomY; DesY>=0; DesY-=zoomY)
- {
- if (DesIsBiggerY)
- sy = (int) ((ULONG) SrcSizeY * (ULONG) DesY) / ((ULONG) DesSizeY);
- else
- sy = (int) ((ULONG) DesSizeY * (ULONG) DesY) / ((ULONG) SrcSizeY);
-
- if (sy > SourceRect->bottom) break;
-
- saveY = DesY+zoomY;
-
- for (DesX=DestRect->right-zoomX; DesX>=0; DesX-=zoomX)
- {
- sx = (int) ((ULONG) DesSizeX * (ULONG) DesX) / ((ULONG) SrcSizeX);
-
- if (sx > SourceRect->right) break;
-
- color = XLATEOBJ_iXlate(ColorTranslation, DIB_24BPP_GetPixel(SourceSurf, sx, sy));
-
- saveX = DesX + zoomX;
- for (count=DesY;count<saveY;count++)
- DIB_16BPP_HLine(DestSurf, DesX, saveX, count, color);
- }
- }
- }
- }
-
- else
- {
-
- if (DesSizeX>SrcSizeX)
- {
- /* Draw one pixel on X - Led to the Des Zoom In*/
- for (DesY=DestRect->bottom-zoomY; DesY>=0; DesY-=zoomY)
- {
- if (DesIsBiggerY)
- sy = (int) ((ULONG) SrcSizeY * (ULONG) DesY) / ((ULONG) DesSizeY);
- else
- sy = (int) ((ULONG) DesSizeY * (ULONG) DesY) / ((ULONG) SrcSizeY);
-
- if (sy > SourceRect->bottom) break;
-
- saveY = DesY+zoomY;
-
- for (DesX=DestRect->right-zoomX; DesX>=0; DesX-=zoomX)
- {
- sx = (int) ((ULONG) SrcSizeX * (ULONG) DesX) / ((ULONG) DesSizeX);
-
- if (sx > SourceRect->right) break;
-
- color = XLATEOBJ_iXlate(ColorTranslation, DIB_24BPP_GetPixel(SourceSurf, sx, sy));
-
- for (count=DesY;count<saveY;count++)
- DIB_16BPP_PutPixel(DestSurf, DesX, count, color);
- }
- }
- }
- else
- {
- /* Draw one pixel on X - Led to the Des Zoom Out*/
- for (DesY=DestRect->bottom-zoomY; DesY>=0; DesY-=zoomY)
- {
- if (DesIsBiggerY)
- sy = (int) ((ULONG) SrcSizeY * (ULONG) DesY) / ((ULONG) DesSizeY);
- else
- sy = (int) ((ULONG) DesSizeY * (ULONG) DesY) / ((ULONG) SrcSizeY);
-
- if (sy > SourceRect->bottom) break;
-
- saveY = DesY+zoomY;
-
- for (DesX=DestRect->right-zoomX; DesX>=0; DesX-=zoomX)
- {
- sx = (int) ((ULONG) DesSizeX * (ULONG) DesX) / ((ULONG) SrcSizeX);
-
- if (sx > SourceRect->right) break;
-
- color = XLATEOBJ_iXlate(ColorTranslation, DIB_24BPP_GetPixel(SourceSurf, sx, sy));
-
- for (count=DesY;count<saveY;count++)
- DIB_16BPP_PutPixel(DestSurf, DesX, count, color);
- }
- }
- }
- }
- break;
+ /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
+ /* This is a reference implementation, it hasn't been optimized for speed */
+
+ DestBits = (PULONG)((PBYTE)DestSurf->pvScan0 + (DestRect->left << 1) +
+ DestRect->top * DestSurf->lDelta);
+
+ for (DesY=0; DesY<DesSizeY; DesY++)
+ {
+ sy = ((DesY * SrcSizeY) / DesSizeY) + SourceRect->top;
+
+ for (DesX=0; DesX<DesSizeX; DesX++)
+ {
+
+ sx = ((DesX * SrcSizeX) / DesSizeX) + SourceRect->left;
+ color = DIB_24BPP_GetPixel(SourceSurf, sx, sy);
+
+ *DestBits = XLATEOBJ_iXlate(ColorTranslation, color);
+ DestBits = (PULONG)((ULONG_PTR)DestBits + 2);
+ }
+ DestBits = (PULONG)((ULONG_PTR)DestBits - (DesSizeX << 1) + DestSurf->lDelta);
+ } break;
case BMF_32BPP:
- /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
- /* This is a reference implementation, it hasn't been optimized for speed */
- if (zoomX>1)
- {
- /* Draw one Hline on X - Led to the Des Zoom In*/
- if (DesSizeX>SrcSizeX)
- {
- for (DesY=DestRect->bottom-zoomY; DesY>=0; DesY-=zoomY)
- {
- if (DesIsBiggerY)
- sy = (int) ((ULONG) SrcSizeY * (ULONG) DesY) / ((ULONG) DesSizeY);
- else
- sy = (int) ((ULONG) DesSizeY * (ULONG) DesY) / ((ULONG) SrcSizeY);
-
- if (sy > SourceRect->bottom) break;
-
- saveY = DesY+zoomY;
-
- for (DesX=DestRect->right-zoomX; DesX>=0; DesX-=zoomX)
- {
- sx = (int) ((ULONG) SrcSizeX * (ULONG) DesX) / ((ULONG) DesSizeX);
-
- if (sx > SourceRect->right) break;
-
- color = XLATEOBJ_iXlate(ColorTranslation, DIB_32BPP_GetPixel(SourceSurf, sx, sy));
-
- saveX = DesX + zoomX;
- for (count=DesY;count<saveY;count++)
- DIB_16BPP_HLine(DestSurf, DesX, saveX, count, color);
- }
- }
- }
- else
- {
- /* Draw one Hline on X - Led to the Des Zoom Out*/
-
- for (DesY=DestRect->bottom-zoomY; DesY>=0; DesY-=zoomY)
- {
- if (DesIsBiggerY)
- sy = (int) ((ULONG) SrcSizeY * (ULONG) DesY) / ((ULONG) DesSizeY);
- else
- sy = (int) ((ULONG) DesSizeY * (ULONG) DesY) / ((ULONG) SrcSizeY);
-
- if (sy > SourceRect->bottom) break;
-
- saveY = DesY+zoomY;
-
- for (DesX=DestRect->right-zoomX; DesX>=0; DesX-=zoomX)
- {
- sx = (int) ((ULONG) DesSizeX * (ULONG) DesX) / ((ULONG) SrcSizeX);
-
- if (sx > SourceRect->right) break;
-
- color = XLATEOBJ_iXlate(ColorTranslation, DIB_32BPP_GetPixel(SourceSurf, sx, sy));
-
- saveX = DesX + zoomX;
- for (count=DesY;count<saveY;count++)
- DIB_16BPP_HLine(DestSurf, DesX, saveX, count, color);
- }
- }
- }
- }
-
- else
- {
-
- if (DesSizeX>SrcSizeX)
- {
- /* Draw one pixel on X - Led to the Des Zoom In*/
- for (DesY=DestRect->bottom-zoomY; DesY>=0; DesY-=zoomY)
- {
- if (DesIsBiggerY)
- sy = (int) ((ULONG) SrcSizeY * (ULONG) DesY) / ((ULONG) DesSizeY);
- else
- sy = (int) ((ULONG) DesSizeY * (ULONG) DesY) / ((ULONG) SrcSizeY);
-
- if (sy > SourceRect->bottom) break;
-
- saveY = DesY+zoomY;
-
- for (DesX=DestRect->right-zoomX; DesX>=0; DesX-=zoomX)
- {
- sx = (int) ((ULONG) SrcSizeX * (ULONG) DesX) / ((ULONG) DesSizeX);
-
- if (sx > SourceRect->right) break;
-
- color = XLATEOBJ_iXlate(ColorTranslation, DIB_32BPP_GetPixel(SourceSurf, sx, sy));
-
- for (count=DesY;count<saveY;count++)
- DIB_16BPP_PutPixel(DestSurf, DesX, count, color);
- }
- }
- }
- else
- {
- /* Draw one pixel on X - Led to the Des Zoom Out*/
- for (DesY=DestRect->bottom-zoomY; DesY>=0; DesY-=zoomY)
- {
- if (DesIsBiggerY)
- sy = (int) ((ULONG) SrcSizeY * (ULONG) DesY) / ((ULONG) DesSizeY);
- else
- sy = (int) ((ULONG) DesSizeY * (ULONG) DesY) / ((ULONG) SrcSizeY);
-
- if (sy > SourceRect->bottom) break;
-
- saveY = DesY+zoomY;
-
- for (DesX=DestRect->right-zoomX; DesX>=0; DesX-=zoomX)
- {
- sx = (int) ((ULONG) DesSizeX * (ULONG) DesX) / ((ULONG) SrcSizeX);
-
- if (sx > SourceRect->right) break;
-
- color = XLATEOBJ_iXlate(ColorTranslation, DIB_32BPP_GetPixel(SourceSurf, sx, sy));
-
- for (count=DesY;count<saveY;count++)
- DIB_16BPP_PutPixel(DestSurf, DesX, count, color);
- }
- }
- }
- }
- break;
+ /* FIXME : MaskOrigin, BrushOrigin, ClipRegion, Mode ? */
+ /* This is a reference implementation, it hasn't been optimized for speed */
+
+ DestBits = (PULONG)((PBYTE)DestSurf->pvScan0 + (DestRect->left << 1) +
+ DestRect->top * DestSurf->lDelta);
+
+ for (DesY=0; DesY<DesSizeY; DesY++)
+ {
+ sy = ((DesY * SrcSizeY) / DesSizeY) + SourceRect->top;
+
+ for (DesX=0; DesX<DesSizeX; DesX++)
+ {
+
+ sx = ((DesX * SrcSizeX) / DesSizeX) + SourceRect->left;
+ color = DIB_32BPP_GetPixel(SourceSurf, sx, sy);
+
+ *DestBits = XLATEOBJ_iXlate(ColorTranslation, color);
+ DestBits = (PULONG)((ULONG_PTR)DestBits + 2);
+ }
+ DestBits = (PULONG)((ULONG_PTR)DestBits - (DesSizeX << 1) + DestSurf->lDelta);
+ }
+ break;
+ case BMF_16BPP:
+ return ScaleRectAvg16(DestSurf, SourceSurf, DestRect, SourceRect, MaskOrigin, BrushOrigin,
+ ClipRegion, ColorTranslation, Mode);
break;
default:
RoundedRight = DestRect->right - ((DestRect->right - DestRect->left) & 0x1);
SourceY = SourcePoint->y;
- DestBits = (ULONG*)(DestSurf->pvScan0 +
+ DestBits = (ULONG*)((PBYTE)DestSurf->pvScan0 +
(DestRect->left << 1) +
DestRect->top * DestSurf->lDelta);
wd = DestSurf->lDelta - ((DestRect->right - DestRect->left) << 1);
return TRUE;
}
+typedef union {
+ 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;
+} NICEPIXEL16;
+
+STATIC inline UCHAR
+Clamp5(ULONG val)
+{
+ return (val > 31) ? 31 : val;
+}
+
+STATIC inline UCHAR
+Clamp6(ULONG val)
+{
+ return (val > 63) ? 63 : val;
+}
+
+BOOLEAN
+DIB_16BPP_AlphaBlend(SURFOBJ* Dest, SURFOBJ* Source, RECTL* DestRect,
+ RECTL* SourceRect, CLIPOBJ* ClipRegion,
+ XLATEOBJ* ColorTranslation, BLENDOBJ* BlendObj)
+{
+ INT Rows, Cols, SrcX, SrcY;
+ register PUSHORT Dst;
+ ULONG DstDelta;
+ BLENDFUNCTION BlendFunc;
+ register NICEPIXEL16 DstPixel;
+ register NICEPIXEL32 SrcPixel;
+ UCHAR Alpha, SrcBpp;
+
+ DPRINT("DIB_16BPP_AlphaBlend: srcRect: (%d,%d)-(%d,%d), dstRect: (%d,%d)-(%d,%d)\n",
+ SourceRect->left, SourceRect->top, SourceRect->right, SourceRect->bottom,
+ DestRect->left, DestRect->top, DestRect->right, DestRect->bottom);
+
+ ASSERT(DestRect->bottom - DestRect->top == SourceRect->bottom - SourceRect->top &&
+ DestRect->right - DestRect->left == SourceRect->right - SourceRect->left);
+
+ BlendFunc = BlendObj->BlendFunction;
+ if (BlendFunc.BlendOp != AC_SRC_OVER)
+ {
+ DPRINT1("BlendOp != AC_SRC_OVER\n");
+ return FALSE;
+ }
+ if (BlendFunc.BlendFlags != 0)
+ {
+ DPRINT1("BlendFlags != 0\n");
+ return FALSE;
+ }
+ if ((BlendFunc.AlphaFormat & ~AC_SRC_ALPHA) != 0)
+ {
+ DPRINT1("Unsupported AlphaFormat (0x%x)\n", BlendFunc.AlphaFormat);
+ return FALSE;
+ }
+ if ((BlendFunc.AlphaFormat & AC_SRC_ALPHA) != 0 &&
+ BitsPerFormat(Source->iBitmapFormat) != 32)
+ {
+ DPRINT1("Source bitmap must be 32bpp when AC_SRC_ALPHA is set\n");
+ return FALSE;
+ }
+
+ Dst = (PUSHORT)((ULONG_PTR)Dest->pvScan0 + (DestRect->top * Dest->lDelta) +
+ (DestRect->left << 1));
+ DstDelta = Dest->lDelta - ((DestRect->right - DestRect->left) << 1);
+ SrcBpp = BitsPerFormat(Source->iBitmapFormat);
+
+ Rows = DestRect->bottom - DestRect->top;
+ SrcY = SourceRect->top;
+ while (--Rows >= 0)
+ {
+ Cols = DestRect->right - DestRect->left;
+ SrcX = SourceRect->left;
+ while (--Cols >= 0)
+ {
+ if (SrcBpp <= 16)
+ {
+ DstPixel.us = DIB_GetSource(Source, SrcX++, SrcY, ColorTranslation);
+ SrcPixel.col.red = (DstPixel.col.red << 3) | (DstPixel.col.red >> 2);
+ SrcPixel.col.green = (DstPixel.col.green << 2) | (DstPixel.col.green >> 4);
+ SrcPixel.col.blue = (DstPixel.col.blue << 3) | (DstPixel.col.blue >> 2);
+ }
+ else
+ {
+ SrcPixel.ul = DIB_GetSourceIndex(Source, SrcX++, SrcY);
+ }
+ 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.us = *Dst;
+ DstPixel.col.red = Clamp5(DstPixel.col.red * (255 - Alpha) / 255 + (SrcPixel.col.red >> 3));
+ DstPixel.col.green = Clamp6(DstPixel.col.green * (255 - Alpha) / 255 + (SrcPixel.col.green >> 2));
+ DstPixel.col.blue = Clamp5(DstPixel.col.blue * (255 - Alpha) / 255 + (SrcPixel.col.blue >> 3));
+ *Dst++ = DstPixel.us;
+ }
+ Dst = (PUSHORT)((ULONG_PTR)Dst + DstDelta);
+ SrcY++;
+ }
+
+ return TRUE;
+}
+
/* EOF */