2007-10-21 18:35:19 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS VGA display driver
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
2015-11-05 18:07:00 +00:00
|
|
|
* FILE: win32ss/drivers/displays/vga/objects/bitblt.c
|
2021-09-13 01:33:14 +00:00
|
|
|
* PURPOSE:
|
|
|
|
* PROGRAMMERS:
|
2007-10-21 18:35:19 +00:00
|
|
|
*/
|
|
|
|
|
2007-10-31 09:45:15 +00:00
|
|
|
#include <vgaddi.h>
|
2005-11-29 00:33:22 +00:00
|
|
|
|
2014-01-04 10:31:27 +00:00
|
|
|
#include "bitblt.h"
|
|
|
|
|
2004-01-10 14:39:21 +00:00
|
|
|
typedef BOOL (*PFN_VGABlt)(SURFOBJ*, SURFOBJ*, XLATEOBJ*, RECTL*, POINTL*);
|
2007-10-21 11:50:55 +00:00
|
|
|
typedef BOOL (APIENTRY *PBLTRECTFUNC)(SURFOBJ* OutputObj,
|
|
|
|
SURFOBJ* InputObj,
|
|
|
|
SURFOBJ* Mask,
|
|
|
|
XLATEOBJ* ColorTranslation,
|
|
|
|
RECTL* OutputRect,
|
|
|
|
POINTL* InputPoint,
|
|
|
|
POINTL* MaskOrigin,
|
|
|
|
BRUSHOBJ* Brush,
|
|
|
|
POINTL* BrushOrigin,
|
|
|
|
ROP4 Rop4);
|
2004-01-10 14:39:21 +00:00
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
static BOOL FASTCALL VGADDI_IntersectRect(
|
|
|
|
OUT RECTL* prcDst,
|
|
|
|
IN RECTL* prcSrc1,
|
|
|
|
IN RECTL* prcSrc2)
|
2004-01-10 14:39:21 +00:00
|
|
|
{
|
2007-10-21 18:35:19 +00:00
|
|
|
static const RECTL rclEmpty = { 0, 0, 0, 0 };
|
2004-01-10 14:39:21 +00:00
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
prcDst->left = max(prcSrc1->left, prcSrc2->left);
|
|
|
|
prcDst->right = min(prcSrc1->right, prcSrc2->right);
|
2004-01-10 14:39:21 +00:00
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
if (prcDst->left < prcDst->right)
|
|
|
|
{
|
|
|
|
prcDst->top = max(prcSrc1->top, prcSrc2->top);
|
|
|
|
prcDst->bottom = min(prcSrc1->bottom, prcSrc2->bottom);
|
2004-01-10 14:39:21 +00:00
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
if (prcDst->top < prcDst->bottom) return(TRUE);
|
|
|
|
}
|
2004-01-10 14:39:21 +00:00
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
*prcDst = rclEmpty;
|
2004-01-10 14:39:21 +00:00
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
return FALSE;
|
2004-01-10 14:39:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DIB_BltToVGA_Fixed(int x, int y, int w, int h, void *b, int Source_lDelta, int mod);
|
|
|
|
|
|
|
|
BOOL
|
2007-10-21 18:35:19 +00:00
|
|
|
DIBtoVGA(
|
|
|
|
IN SURFOBJ *Dest,
|
|
|
|
IN SURFOBJ *Source,
|
|
|
|
IN XLATEOBJ *ColorTranslation,
|
|
|
|
IN RECTL *DestRect,
|
|
|
|
IN POINTL *SourcePoint)
|
2004-01-10 14:39:21 +00:00
|
|
|
{
|
2007-10-21 18:35:19 +00:00
|
|
|
LONG dx, dy;
|
2004-01-10 14:39:21 +00:00
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
dx = DestRect->right - DestRect->left;
|
|
|
|
dy = DestRect->bottom - DestRect->top;
|
2004-01-10 14:39:21 +00:00
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
if (NULL == ColorTranslation || 0 != (ColorTranslation->flXlate & XO_TRIVIAL))
|
2004-01-10 14:39:21 +00:00
|
|
|
{
|
2007-10-21 18:35:19 +00:00
|
|
|
DIB_BltToVGA(DestRect->left, DestRect->top, dx, dy,
|
|
|
|
(PVOID)((ULONG_PTR)Source->pvScan0 + SourcePoint->y * Source->lDelta + (SourcePoint->x >> 1)),
|
|
|
|
Source->lDelta, SourcePoint->x % 2);
|
2004-01-10 14:39:21 +00:00
|
|
|
}
|
2007-10-21 18:35:19 +00:00
|
|
|
else
|
2004-01-10 14:39:21 +00:00
|
|
|
{
|
2007-10-21 18:35:19 +00:00
|
|
|
/* Perform color translation */
|
|
|
|
DIB_BltToVGAWithXlate(DestRect->left, DestRect->top, dx, dy,
|
|
|
|
(PVOID)((ULONG_PTR)Source->pvScan0 + SourcePoint->y * Source->lDelta + (SourcePoint->x >> 1)),
|
|
|
|
Source->lDelta, ColorTranslation);
|
2004-01-10 14:39:21 +00:00
|
|
|
}
|
2007-10-21 18:35:19 +00:00
|
|
|
return FALSE;
|
2004-01-10 14:39:21 +00:00
|
|
|
}
|
|
|
|
|
2005-05-08 02:16:32 +00:00
|
|
|
BOOL
|
2007-10-21 18:35:19 +00:00
|
|
|
VGAtoDIB(
|
|
|
|
IN SURFOBJ *Dest,
|
|
|
|
IN SURFOBJ *Source,
|
|
|
|
IN XLATEOBJ *ColorTranslation,
|
|
|
|
IN RECTL *DestRect,
|
|
|
|
IN POINTL *SourcePoint)
|
2004-01-10 14:39:21 +00:00
|
|
|
{
|
2007-10-21 18:35:19 +00:00
|
|
|
LONG i, j, dx, dy;
|
|
|
|
UCHAR *GDIpos, *initial;
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
/* Used by the temporary DFB */
|
2011-09-11 00:40:20 +00:00
|
|
|
//DEVSURF DestDevSurf;
|
2004-01-10 14:39:21 +00:00
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
/* FIXME: Optimize to retrieve entire bytes at a time (see ../vgavideo/vgavideo.c:vgaGetByte) */
|
2004-01-10 14:39:21 +00:00
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
GDIpos = Dest->pvScan0 /* + (DestRect->top * Dest->lDelta) + (DestRect->left >> 1) */ ;
|
|
|
|
dx = DestRect->right - DestRect->left;
|
|
|
|
dy = DestRect->bottom - DestRect->top;
|
2004-01-10 14:39:21 +00:00
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
if (ColorTranslation == NULL)
|
|
|
|
{
|
|
|
|
/* Prepare a Dest Dev Target and copy from the DFB to the DIB */
|
2011-09-11 00:40:20 +00:00
|
|
|
//DestDevSurf.NextScan = Dest->lDelta;
|
|
|
|
//DestDevSurf.StartBmp = Dest->pvScan0;
|
2004-01-10 14:39:21 +00:00
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
DIB_BltFromVGA(SourcePoint->x, SourcePoint->y, dx, dy, Dest->pvScan0, Dest->lDelta);
|
|
|
|
}
|
|
|
|
else
|
2004-01-10 14:39:21 +00:00
|
|
|
{
|
2007-10-21 18:35:19 +00:00
|
|
|
/* Color translation */
|
|
|
|
for (j = SourcePoint->y; j < SourcePoint->y + dy; j++)
|
|
|
|
{
|
|
|
|
initial = GDIpos;
|
|
|
|
for (i = SourcePoint->x; i < SourcePoint->x + dx; i++)
|
|
|
|
{
|
|
|
|
*GDIpos = XLATEOBJ_iXlate(ColorTranslation, vgaGetPixel(i, j));
|
|
|
|
GDIpos++;
|
|
|
|
}
|
|
|
|
GDIpos = initial + Dest->lDelta;
|
|
|
|
}
|
2004-01-10 14:39:21 +00:00
|
|
|
}
|
2007-10-21 18:35:19 +00:00
|
|
|
return FALSE;
|
2004-01-10 14:39:21 +00:00
|
|
|
}
|
|
|
|
|
2005-05-08 02:16:32 +00:00
|
|
|
BOOL
|
2007-10-21 18:35:19 +00:00
|
|
|
DFBtoVGA(
|
|
|
|
IN SURFOBJ *Dest,
|
|
|
|
IN SURFOBJ *Source,
|
|
|
|
IN XLATEOBJ *ColorTranslation,
|
|
|
|
IN RECTL *DestRect,
|
|
|
|
IN POINTL *SourcePoint)
|
2004-01-10 14:39:21 +00:00
|
|
|
{
|
2007-10-21 18:35:19 +00:00
|
|
|
/* Do DFBs need color translation?? */
|
|
|
|
return FALSE;
|
2004-01-10 14:39:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL
|
2007-10-21 18:35:19 +00:00
|
|
|
VGAtoDFB(
|
|
|
|
IN SURFOBJ *Dest,
|
|
|
|
IN SURFOBJ *Source,
|
|
|
|
IN XLATEOBJ *ColorTranslation,
|
|
|
|
IN RECTL *DestRect,
|
|
|
|
IN POINTL *SourcePoint)
|
2004-01-10 14:39:21 +00:00
|
|
|
{
|
2007-10-21 18:35:19 +00:00
|
|
|
/* Do DFBs need color translation?? */
|
|
|
|
return FALSE;
|
2004-01-10 14:39:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL
|
2007-10-21 18:35:19 +00:00
|
|
|
VGAtoVGA(
|
|
|
|
IN SURFOBJ *Dest,
|
|
|
|
IN SURFOBJ *Source,
|
|
|
|
IN XLATEOBJ *ColorTranslation,
|
|
|
|
IN RECTL *DestRect,
|
|
|
|
IN POINTL *SourcePoint)
|
2004-01-10 14:39:21 +00:00
|
|
|
{
|
2007-10-21 18:35:19 +00:00
|
|
|
LONG i, i2, j, dx, dy, alterx, altery;
|
|
|
|
static char buf[SCREEN_X];
|
2004-01-10 14:39:21 +00:00
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
/* Calculate deltas */
|
|
|
|
dx = DestRect->right - DestRect->left;
|
|
|
|
dy = DestRect->bottom - DestRect->top;
|
|
|
|
|
|
|
|
alterx = DestRect->left - SourcePoint->x;
|
|
|
|
altery = DestRect->top - SourcePoint->y;
|
|
|
|
|
|
|
|
i = SourcePoint->x;
|
|
|
|
i2 = i + alterx;
|
|
|
|
|
|
|
|
if (SourcePoint->y >= DestRect->top)
|
|
|
|
{
|
|
|
|
for (j = SourcePoint->y; j < SourcePoint->y + dy; j++)
|
|
|
|
{
|
|
|
|
LONG j2 = j + altery;
|
|
|
|
vgaReadScan ( i, j, dx, buf );
|
|
|
|
vgaWriteScan ( i2, j2, dx, buf );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2004-01-10 14:39:21 +00:00
|
|
|
{
|
2007-10-21 18:35:19 +00:00
|
|
|
for(j = (SourcePoint->y + dy - 1); j >= SourcePoint->y; j--)
|
|
|
|
{
|
|
|
|
LONG j2 = j + altery;
|
|
|
|
vgaReadScan ( i, j, dx, buf );
|
|
|
|
vgaWriteScan ( i2, j2, dx, buf );
|
|
|
|
}
|
2004-01-10 14:39:21 +00:00
|
|
|
}
|
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL APIENTRY
|
|
|
|
VGADDI_BltBrush(
|
|
|
|
IN SURFOBJ* Dest,
|
|
|
|
IN SURFOBJ* Source,
|
|
|
|
IN SURFOBJ* MaskSurf,
|
|
|
|
IN XLATEOBJ* ColorTranslation,
|
|
|
|
IN RECTL* DestRect,
|
|
|
|
IN POINTL* SourcePoint,
|
|
|
|
IN POINTL* MaskPoint,
|
|
|
|
IN BRUSHOBJ* Brush,
|
|
|
|
IN POINTL* BrushPoint,
|
|
|
|
IN ROP4 Rop4)
|
|
|
|
{
|
|
|
|
UCHAR SolidColor = 0;
|
|
|
|
LONG Left;
|
|
|
|
LONG Length;
|
|
|
|
PUCHAR Video;
|
|
|
|
UCHAR Mask;
|
|
|
|
INT i, j;
|
|
|
|
ULONG RasterOp = VGA_NORMAL;
|
|
|
|
|
|
|
|
/* Punt brush blts to non-device surfaces. */
|
|
|
|
if (Dest->iType != STYPE_DEVICE)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* Punt pattern fills. */
|
|
|
|
if ((GET_OPINDEX_FROM_ROP4(Rop4) == GET_OPINDEX_FROM_ROP3(PATCOPY)
|
|
|
|
|| GET_OPINDEX_FROM_ROP4(Rop4) == GET_OPINDEX_FROM_ROP3(PATINVERT)) &&
|
|
|
|
Brush->iSolidColor == 0xFFFFFFFF)
|
2004-01-10 14:39:21 +00:00
|
|
|
{
|
2007-10-21 18:35:19 +00:00
|
|
|
return FALSE;
|
2004-01-10 14:39:21 +00:00
|
|
|
}
|
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
/* Get the brush colour. */
|
|
|
|
switch (GET_OPINDEX_FROM_ROP4(Rop4))
|
2004-01-10 14:39:21 +00:00
|
|
|
{
|
2007-10-21 18:35:19 +00:00
|
|
|
case GET_OPINDEX_FROM_ROP3(PATCOPY): SolidColor = Brush->iSolidColor; break;
|
|
|
|
case GET_OPINDEX_FROM_ROP3(PATINVERT): SolidColor = Brush->iSolidColor; RasterOp = VGA_XOR; break;
|
|
|
|
case GET_OPINDEX_FROM_ROP3(WHITENESS): SolidColor = 0xF; break;
|
|
|
|
case GET_OPINDEX_FROM_ROP3(BLACKNESS): SolidColor = 0x0; break;
|
|
|
|
case GET_OPINDEX_FROM_ROP3(DSTINVERT): SolidColor = 0xF; RasterOp = VGA_XOR; break;
|
2004-01-10 14:39:21 +00:00
|
|
|
}
|
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
/* Select write mode 3. */
|
|
|
|
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x05);
|
|
|
|
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0x03);
|
2004-01-10 14:39:21 +00:00
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
/* Setup set/reset register. */
|
|
|
|
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x00);
|
|
|
|
WRITE_PORT_UCHAR((PUCHAR)GRA_D, (UCHAR)SolidColor);
|
2004-01-10 14:39:21 +00:00
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
/* Enable writes to all pixels. */
|
|
|
|
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x08);
|
|
|
|
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0xFF);
|
2004-01-10 14:39:21 +00:00
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
/* Set up data rotate. */
|
|
|
|
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x03);
|
|
|
|
WRITE_PORT_UCHAR((PUCHAR)GRA_D, RasterOp);
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
/* Fill any pixels on the left which don't fall into a full row of eight. */
|
|
|
|
if ((DestRect->left % 8) != 0)
|
2004-01-10 14:39:21 +00:00
|
|
|
{
|
2007-10-21 18:35:19 +00:00
|
|
|
/* Disable writes to pixels outside of the destination rectangle. */
|
|
|
|
Mask = (1 << (8 - (DestRect->left % 8))) - 1;
|
|
|
|
if ((DestRect->right - DestRect->left) < (8 - (DestRect->left % 8)))
|
|
|
|
Mask &= ~((1 << (8 - (DestRect->right % 8))) - 1);
|
|
|
|
|
|
|
|
/* Write the same color to each pixel. */
|
|
|
|
Video = (PUCHAR)vidmem + DestRect->top * 80 + (DestRect->left >> 3);
|
|
|
|
for (i = DestRect->top; i < DestRect->bottom; i++, Video += 80)
|
|
|
|
{
|
|
|
|
(VOID)READ_REGISTER_UCHAR(Video);
|
|
|
|
WRITE_REGISTER_UCHAR(Video, Mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Have we finished. */
|
|
|
|
if ((DestRect->right - DestRect->left) < (8 - (DestRect->left % 8)))
|
|
|
|
{
|
|
|
|
/* Restore write mode 2. */
|
|
|
|
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x05);
|
|
|
|
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0x02);
|
|
|
|
|
|
|
|
/* Set up data rotate. */
|
|
|
|
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x03);
|
|
|
|
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0x00);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2005-05-08 02:16:32 +00:00
|
|
|
}
|
2004-01-10 14:39:21 +00:00
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
/* Fill any whole rows of eight pixels. */
|
|
|
|
Left = (DestRect->left + 7) & ~0x7;
|
|
|
|
Length = (DestRect->right >> 3) - (Left >> 3);
|
|
|
|
for (i = DestRect->top; i < DestRect->bottom; i++)
|
2004-01-10 14:39:21 +00:00
|
|
|
{
|
2007-10-21 18:35:19 +00:00
|
|
|
Video = (PUCHAR)vidmem + i * 80 + (Left >> 3);
|
|
|
|
for (j = 0; j < Length; j++, Video++)
|
|
|
|
{
|
2004-04-08 15:45:18 +00:00
|
|
|
#if 0
|
2007-10-21 18:35:19 +00:00
|
|
|
(VOID)READ_REGISTER_UCHAR(Video);
|
|
|
|
WRITE_REGISTER_UCHAR(Video, 0xFF);
|
2004-04-08 15:45:18 +00:00
|
|
|
#else
|
2007-10-21 18:35:19 +00:00
|
|
|
char volatile Temp = *Video;
|
|
|
|
Temp |= 0;
|
|
|
|
*Video = 0xFF;
|
2004-04-08 15:45:18 +00:00
|
|
|
#endif
|
2007-10-21 18:35:19 +00:00
|
|
|
}
|
2004-01-10 14:39:21 +00:00
|
|
|
}
|
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
/* Fill any pixels on the right which don't fall into a complete row. */
|
|
|
|
if ((DestRect->right % 8) != 0)
|
2004-01-10 14:39:21 +00:00
|
|
|
{
|
2007-10-21 18:35:19 +00:00
|
|
|
/* Disable writes to pixels outside the destination rectangle. */
|
|
|
|
Mask = ~((1 << (8 - (DestRect->right % 8))) - 1);
|
|
|
|
|
|
|
|
Video = (PUCHAR)vidmem + DestRect->top * 80 + (DestRect->right >> 3);
|
|
|
|
for (i = DestRect->top; i < DestRect->bottom; i++, Video += 80)
|
|
|
|
{
|
|
|
|
(VOID)READ_REGISTER_UCHAR(Video);
|
|
|
|
WRITE_REGISTER_UCHAR(Video, Mask);
|
|
|
|
}
|
2004-01-10 14:39:21 +00:00
|
|
|
}
|
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
/* Restore write mode 2. */
|
|
|
|
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x05);
|
|
|
|
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0x02);
|
2004-01-10 14:39:21 +00:00
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
/* Set up data rotate. */
|
|
|
|
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x03);
|
|
|
|
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0x00);
|
2004-01-10 14:39:21 +00:00
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
return TRUE;
|
2004-01-10 14:39:21 +00:00
|
|
|
}
|
|
|
|
|
2007-10-21 11:50:55 +00:00
|
|
|
BOOL APIENTRY
|
2007-10-21 18:35:19 +00:00
|
|
|
VGADDI_BltSrc(
|
|
|
|
IN SURFOBJ* Dest,
|
|
|
|
IN SURFOBJ* Source,
|
|
|
|
IN SURFOBJ* Mask,
|
|
|
|
IN XLATEOBJ* ColorTranslation,
|
|
|
|
IN RECTL* DestRect,
|
|
|
|
IN POINTL* SourcePoint,
|
|
|
|
IN POINTL* MaskOrigin,
|
|
|
|
IN BRUSHOBJ* Brush,
|
|
|
|
IN POINTL* BrushOrigin,
|
|
|
|
IN ROP4 Rop4)
|
2004-01-10 14:39:21 +00:00
|
|
|
{
|
2007-10-21 18:35:19 +00:00
|
|
|
PFN_VGABlt BltOperation;
|
|
|
|
ULONG SourceType;
|
|
|
|
|
|
|
|
SourceType = Source->iType;
|
|
|
|
|
|
|
|
if (SourceType == STYPE_BITMAP && Dest->iType == STYPE_DEVICE)
|
|
|
|
BltOperation = DIBtoVGA;
|
|
|
|
else if (SourceType == STYPE_DEVICE && Dest->iType == STYPE_BITMAP)
|
|
|
|
BltOperation = VGAtoDIB;
|
|
|
|
else if (SourceType == STYPE_DEVICE && Dest->iType == STYPE_DEVICE)
|
|
|
|
BltOperation = VGAtoVGA;
|
|
|
|
else if (SourceType == STYPE_DEVBITMAP && Dest->iType == STYPE_DEVICE)
|
|
|
|
BltOperation = DFBtoVGA;
|
|
|
|
else if (SourceType == STYPE_DEVICE && Dest->iType == STYPE_DEVBITMAP)
|
|
|
|
BltOperation = VGAtoDFB;
|
|
|
|
else
|
2004-01-10 14:39:21 +00:00
|
|
|
{
|
2007-10-21 18:35:19 +00:00
|
|
|
/* Punt blts not involving a device or a device-bitmap. */
|
|
|
|
return FALSE;
|
2005-05-08 02:16:32 +00:00
|
|
|
}
|
2004-01-10 14:39:21 +00:00
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
BltOperation(Dest, Source, ColorTranslation, DestRect, SourcePoint);
|
|
|
|
return TRUE;
|
2004-01-10 14:39:21 +00:00
|
|
|
}
|
|
|
|
|
2007-10-21 11:50:55 +00:00
|
|
|
BOOL APIENTRY
|
2007-10-21 18:35:19 +00:00
|
|
|
VGADDI_BltMask(
|
|
|
|
IN SURFOBJ* Dest,
|
|
|
|
IN SURFOBJ* Source,
|
|
|
|
IN SURFOBJ* Mask,
|
|
|
|
IN XLATEOBJ* ColorTranslation,
|
|
|
|
IN RECTL* DestRect,
|
|
|
|
IN POINTL* SourcePoint,
|
|
|
|
IN POINTL* MaskPoint,
|
|
|
|
IN BRUSHOBJ* Brush,
|
|
|
|
IN POINTL* BrushPoint,
|
|
|
|
IN ROP4 Rop4)
|
2004-01-10 14:39:21 +00:00
|
|
|
{
|
2007-10-21 18:35:19 +00:00
|
|
|
LONG i, j, dx, dy, c8;
|
|
|
|
BYTE *tMask, *lMask;
|
2004-01-10 14:39:21 +00:00
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
dx = DestRect->right - DestRect->left;
|
|
|
|
dy = DestRect->bottom - DestRect->top;
|
2004-01-10 14:39:21 +00:00
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
if (ColorTranslation == NULL)
|
2004-01-10 14:39:21 +00:00
|
|
|
{
|
2007-10-21 18:35:19 +00:00
|
|
|
if (Mask != NULL)
|
|
|
|
{
|
|
|
|
tMask = Mask->pvScan0;
|
|
|
|
for (j = 0; j < dy; j++)
|
|
|
|
{
|
|
|
|
lMask = tMask;
|
|
|
|
c8 = 0;
|
|
|
|
for (i = 0; i < dx; i++)
|
|
|
|
{
|
|
|
|
if((*lMask & maskbit[c8]) != 0)
|
|
|
|
vgaPutPixel(DestRect->left + i, DestRect->top + j, Brush->iSolidColor);
|
|
|
|
c8++;
|
|
|
|
if(c8 == 8)
|
|
|
|
{
|
|
|
|
lMask++;
|
|
|
|
c8=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tMask += Mask->lDelta;
|
|
|
|
}
|
|
|
|
}
|
2004-01-10 14:39:21 +00:00
|
|
|
}
|
2007-10-21 18:35:19 +00:00
|
|
|
return TRUE;
|
2004-01-10 14:39:21 +00:00
|
|
|
}
|
|
|
|
|
2007-10-21 11:50:55 +00:00
|
|
|
BOOL APIENTRY
|
2007-10-21 18:35:19 +00:00
|
|
|
DrvBitBlt(
|
|
|
|
IN SURFOBJ *Dest,
|
|
|
|
IN SURFOBJ *Source,
|
|
|
|
IN SURFOBJ *Mask,
|
|
|
|
IN CLIPOBJ *Clip,
|
|
|
|
IN XLATEOBJ *ColorTranslation,
|
|
|
|
IN RECTL *DestRect,
|
|
|
|
IN POINTL *SourcePoint,
|
|
|
|
IN POINTL *MaskPoint,
|
|
|
|
IN BRUSHOBJ *Brush,
|
|
|
|
IN POINTL *BrushPoint,
|
|
|
|
IN ROP4 rop4)
|
2004-01-10 14:39:21 +00:00
|
|
|
{
|
2007-10-21 18:35:19 +00:00
|
|
|
PBLTRECTFUNC BltRectFunc;
|
|
|
|
RECTL CombinedRect;
|
|
|
|
BOOL Ret = FALSE;
|
|
|
|
RECT_ENUM RectEnum;
|
|
|
|
BOOL EnumMore;
|
|
|
|
UINT i;
|
|
|
|
POINTL Pt;
|
|
|
|
ULONG Direction;
|
2012-08-11 22:40:50 +00:00
|
|
|
POINTL FinalSourcePoint;
|
|
|
|
|
|
|
|
if (Source && SourcePoint)
|
|
|
|
{
|
|
|
|
FinalSourcePoint.x = SourcePoint->x;
|
|
|
|
FinalSourcePoint.y = SourcePoint->y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FinalSourcePoint.x = 0;
|
|
|
|
FinalSourcePoint.y = 0;
|
|
|
|
}
|
2007-10-21 18:35:19 +00:00
|
|
|
|
|
|
|
switch (rop4)
|
2004-01-10 14:39:21 +00:00
|
|
|
{
|
2007-10-21 18:35:19 +00:00
|
|
|
case ROP3_TO_ROP4(BLACKNESS):
|
|
|
|
case ROP3_TO_ROP4(PATCOPY):
|
|
|
|
case ROP3_TO_ROP4(WHITENESS):
|
|
|
|
case ROP3_TO_ROP4(PATINVERT):
|
|
|
|
case ROP3_TO_ROP4(DSTINVERT):
|
|
|
|
BltRectFunc = VGADDI_BltBrush;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ROP3_TO_ROP4(SRCCOPY):
|
|
|
|
if (BMF_4BPP == Source->iBitmapFormat && BMF_4BPP == Dest->iBitmapFormat)
|
|
|
|
BltRectFunc = VGADDI_BltSrc;
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R4_MASK:
|
|
|
|
BltRectFunc = VGADDI_BltMask;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (NULL == Clip ? DC_TRIVIAL : Clip->iDComplexity)
|
|
|
|
{
|
|
|
|
case DC_TRIVIAL:
|
|
|
|
Ret = (*BltRectFunc)(Dest, Source, Mask, ColorTranslation, DestRect,
|
|
|
|
SourcePoint, MaskPoint, Brush, BrushPoint,
|
|
|
|
rop4);
|
|
|
|
break;
|
|
|
|
case DC_RECT:
|
|
|
|
/* Clip the blt to the clip rectangle */
|
|
|
|
VGADDI_IntersectRect(&CombinedRect, DestRect, &(Clip->rclBounds));
|
2012-08-11 22:40:50 +00:00
|
|
|
Pt.x = FinalSourcePoint.x + CombinedRect.left - DestRect->left;
|
|
|
|
Pt.y = FinalSourcePoint.y + CombinedRect.top - DestRect->top;
|
2007-10-21 18:35:19 +00:00
|
|
|
Ret = (*BltRectFunc)(Dest, Source, Mask, ColorTranslation, &CombinedRect,
|
|
|
|
&Pt, MaskPoint, Brush, BrushPoint,
|
|
|
|
rop4);
|
|
|
|
break;
|
|
|
|
case DC_COMPLEX:
|
|
|
|
Ret = TRUE;
|
|
|
|
if (Dest == Source)
|
|
|
|
{
|
2012-08-11 22:40:50 +00:00
|
|
|
if (DestRect->top <= FinalSourcePoint.y)
|
|
|
|
Direction = DestRect->left < FinalSourcePoint.y ? CD_RIGHTDOWN : CD_LEFTDOWN;
|
2007-10-21 18:35:19 +00:00
|
|
|
else
|
2012-08-11 22:40:50 +00:00
|
|
|
Direction = DestRect->left < FinalSourcePoint.x ? CD_RIGHTUP : CD_LEFTUP;
|
2007-10-21 18:35:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Direction = CD_ANY;
|
|
|
|
}
|
|
|
|
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, Direction, 0);
|
|
|
|
do
|
|
|
|
{
|
|
|
|
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
|
|
|
|
|
|
|
|
for (i = 0; i < RectEnum.c; i++)
|
|
|
|
{
|
|
|
|
VGADDI_IntersectRect(&CombinedRect, DestRect, RectEnum.arcl + i);
|
2012-08-11 22:40:50 +00:00
|
|
|
Pt.x = FinalSourcePoint.x + CombinedRect.left - DestRect->left;
|
|
|
|
Pt.y = FinalSourcePoint.y + CombinedRect.top - DestRect->top;
|
2007-10-21 18:35:19 +00:00
|
|
|
Ret = (*BltRectFunc)(Dest, Source, Mask, ColorTranslation, &CombinedRect,
|
|
|
|
&Pt, MaskPoint, Brush, BrushPoint, rop4) &&
|
|
|
|
Ret;
|
|
|
|
}
|
|
|
|
} while (EnumMore);
|
|
|
|
break;
|
2004-01-10 14:39:21 +00:00
|
|
|
}
|
|
|
|
|
2007-10-21 18:35:19 +00:00
|
|
|
return Ret;
|
2004-01-10 14:39:21 +00:00
|
|
|
}
|