[FORMATTING] General cleanup (indentation, headers...). No code change

svn path=/trunk/; revision=29748
This commit is contained in:
Hervé Poussineau
2007-10-21 18:35:19 +00:00
parent aa6fdab501
commit eb32aa038b
11 changed files with 2711 additions and 2758 deletions
+377 -396
View File
@@ -1,5 +1,9 @@
/*
* entry.c
* PROJECT: ReactOS VGA display driver
* LICENSE: GPL - See COPYING in the top level directory
* FILE: drivers/video/displays/vga/main/enable.c
* PURPOSE:
* PROGRAMMERS:
*/
#include "../vgaddi.h"
@@ -11,145 +15,145 @@
static BOOL VGAInitialized = FALSE;
DRVFN FuncList[] =
static DRVFN FuncList[] =
{
/* Required Display driver fuctions */
{INDEX_DrvAssertMode, (PFN) DrvAssertMode},
{INDEX_DrvCompletePDEV, (PFN) DrvCompletePDEV},
{INDEX_DrvCopyBits, (PFN) DrvCopyBits},
{INDEX_DrvDisablePDEV, (PFN) DrvDisablePDEV},
{INDEX_DrvDisableSurface, (PFN) DrvDisableSurface},
{INDEX_DrvEnablePDEV, (PFN) DrvEnablePDEV},
{INDEX_DrvEnableSurface, (PFN) DrvEnableSurface},
{INDEX_DrvGetModes, (PFN) DrvGetModes},
{INDEX_DrvLineTo, (PFN) DrvLineTo},
{INDEX_DrvPaint, (PFN) DrvPaint},
{INDEX_DrvBitBlt, (PFN) DrvBitBlt},
{INDEX_DrvTransparentBlt, (PFN) DrvTransparentBlt},
{INDEX_DrvMovePointer, (PFN) DrvMovePointer},
{INDEX_DrvSetPointerShape, (PFN) DrvSetPointerShape},
/* Required Display driver fuctions */
{INDEX_DrvAssertMode, (PFN) DrvAssertMode},
{INDEX_DrvCompletePDEV, (PFN) DrvCompletePDEV},
{INDEX_DrvCopyBits, (PFN) DrvCopyBits},
{INDEX_DrvDisablePDEV, (PFN) DrvDisablePDEV},
{INDEX_DrvDisableSurface, (PFN) DrvDisableSurface},
{INDEX_DrvEnablePDEV, (PFN) DrvEnablePDEV},
{INDEX_DrvEnableSurface, (PFN) DrvEnableSurface},
{INDEX_DrvGetModes, (PFN) DrvGetModes},
{INDEX_DrvLineTo, (PFN) DrvLineTo},
{INDEX_DrvPaint, (PFN) DrvPaint},
{INDEX_DrvBitBlt, (PFN) DrvBitBlt},
{INDEX_DrvTransparentBlt, (PFN) DrvTransparentBlt},
{INDEX_DrvMovePointer, (PFN) DrvMovePointer},
{INDEX_DrvSetPointerShape, (PFN) DrvSetPointerShape},
#if 0
/* Optional Display driver functions */
{INDEX_, (PFN) },
{INDEX_DescribePixelFormat, (PFN) VGADDIDescribePixelFormat},
{INDEX_DrvDitherColor, (PFN) VGADDIDitherColor},
{INDEX_DrvFillPath, (PFN) VGADDIFillPath},
{INDEX_DrvGetTrueTypeFile, (PFN) VGADDIGetTrueTypeFile},
{INDEX_DrvLoadFontFile, (PFN) VGADDILoadFontFile},
{INDEX_DrvQueryFont, (PFN) VGADDIQueryFont},
{INDEX_DrvQueryFontCaps, (PFN) VGADDIQueryFontCaps},
{INDEX_DrvQueryFontData, (PFN) VGADDIQueryFontData},
{INDEX_DrvQueryFontFile, (PFN) VGADDIQueryFontFile},
{INDEX_DrvQueryFontTree, (PFN) VGADDIQueryFontTree},
{INDEX_DrvQueryTrueTypeOutline, (PFN) VGADDIQueryTrueTypeOutline},
{INDEX_DrvQueryTrueTypeTable, (PFN) VGADDIQueryTrueTypeTable},
{INDEX_DrvRealizeBrush, (PFN) VGADDIRealizeBrush},
{INDEX_DrvResetPDEV, (PFN) VGADDIResetPDEV},
{INDEX_DrvSetPalette, (PFN) VGADDISetPalette},
{INDEX_DrvSetPixelFormat, (PFN) VGADDISetPixelFormat},
{INDEX_DrvStretchBlt, (PFN) VGADDIStretchBlt},
{INDEX_DrvStrokePath, (PFN) VGADDIStrokePath},
{INDEX_DrvSwapBuffers, (PFN) VGADDISwapBuffers},
{INDEX_DrvTextOut, (PFN) VGADDITextOut},
{INDEX_DrvUnloadFontFile, (PFN) VGADDIUnloadFontFile},
/* Optional Display driver functions */
{INDEX_, },
{INDEX_DescribePixelFormat, (PFN) VGADDIDescribePixelFormat},
{INDEX_DrvDitherColor, (PFN) VGADDIDitherColor},
{INDEX_DrvFillPath, (PFN) VGADDIFillPath},
{INDEX_DrvGetTrueTypeFile, (PFN) VGADDIGetTrueTypeFile},
{INDEX_DrvLoadFontFile, (PFN) VGADDILoadFontFile},
{INDEX_DrvQueryFont, (PFN) VGADDIQueryFont},
{INDEX_DrvQueryFontCaps, (PFN) VGADDIQueryFontCaps},
{INDEX_DrvQueryFontData, (PFN) VGADDIQueryFontData},
{INDEX_DrvQueryFontFile, (PFN) VGADDIQueryFontFile},
{INDEX_DrvQueryFontTree, (PFN) VGADDIQueryFontTree},
{INDEX_DrvQueryTrueTypeOutline, (PFN) VGADDIQueryTrueTypeOutline},
{INDEX_DrvQueryTrueTypeTable, (PFN) VGADDIQueryTrueTypeTable},
{INDEX_DrvRealizeBrush, (PFN) VGADDIRealizeBrush},
{INDEX_DrvResetPDEV, (PFN) VGADDIResetPDEV},
{INDEX_DrvSetPalette, (PFN) VGADDISetPalette},
{INDEX_DrvSetPixelFormat, (PFN) VGADDISetPixelFormat},
{INDEX_DrvStretchBlt, (PFN) VGADDIStretchBlt},
{INDEX_DrvStrokePath, (PFN) VGADDIStrokePath},
{INDEX_DrvSwapBuffers, (PFN) VGADDISwapBuffers},
{INDEX_DrvTextOut, (PFN) VGADDITextOut},
{INDEX_DrvUnloadFontFile, (PFN) VGADDIUnloadFontFile},
#endif
};
GDIINFO gaulCap = {
GDI_DRIVER_VERSION,
DT_RASDISPLAY, // ulTechnology
0, // ulHorzSize
0, // ulVertSize
0, // ulHorzRes (filled in at initialization)
0, // ulVertRes (filled in at initialization)
4, // cBitsPixel
1, // cPlanes
16, // ulNumColors
0, // flRaster (DDI reserved field)
static GDIINFO gaulCap = {
GDI_DRIVER_VERSION,
DT_RASDISPLAY, // ulTechnology
0, // ulHorzSize
0, // ulVertSize
0, // ulHorzRes (filled in at initialization)
0, // ulVertRes (filled in at initialization)
4, // cBitsPixel
1, // cPlanes
16, // ulNumColors
0, // flRaster (DDI reserved field)
96, // ulLogPixelsX (must be set to 96 according to MSDN)
96, // ulLogPixelsY (must be set to 96 according to MSDN)
96, // ulLogPixelsX (must be set to 96 according to MSDN)
96, // ulLogPixelsY (must be set to 96 according to MSDN)
TC_RA_ABLE | TC_SCROLLBLT, // flTextCaps
TC_RA_ABLE | TC_SCROLLBLT, // flTextCaps
6, // ulDACRed
6, // ulDACGree
6, // ulDACBlue
6, // ulDACRed
6, // ulDACGree
6, // ulDACBlue
0x0024, // ulAspectX (one-to-one aspect ratio)
0x0024, // ulAspectY
0x0033, // ulAspectXY
0x0024, // ulAspectX (one-to-one aspect ratio)
0x0024, // ulAspectY
0x0033, // ulAspectXY
1, // xStyleStep
1, // yStyleSte;
3, // denStyleStep
1, // xStyleStep
1, // yStyleSte;
3, // denStyleStep
{ 0, 0 }, // ptlPhysOffset
{ 0, 0 }, // szlPhysSize
{ 0, 0 }, // ptlPhysOffset
{ 0, 0 }, // szlPhysSize
0, // ulNumPalReg (win3.1 16 color drivers say 0 too)
0, // ulNumPalReg (win3.1 16 color drivers say 0 too)
// These fields are for halftone initialization.
{ // ciDevice, ColorInfo
{ 6700, 3300, 0 }, // Red
{ 2100, 7100, 0 }, // Green
{ 1400, 800, 0 }, // Blue
{ 1750, 3950, 0 }, // Cyan
{ 4050, 2050, 0 }, // Magenta
{ 4400, 5200, 0 }, // Yellow
{ 3127, 3290, 0 }, // AlignmentWhite
20000, // RedGamma
20000, // GreenGamma
20000, // BlueGamma
0, 0, 0, 0, 0, 0
},
{ // ciDevice, ColorInfo
{ 6700, 3300, 0 }, // Red
{ 2100, 7100, 0 }, // Green
{ 1400, 800, 0 }, // Blue
{ 1750, 3950, 0 }, // Cyan
{ 4050, 2050, 0 }, // Magenta
{ 4400, 5200, 0 }, // Yellow
{ 3127, 3290, 0 }, // AlignmentWhite
20000, // RedGamma
20000, // GreenGamma
20000, // BlueGamma
0, 0, 0, 0, 0, 0
},
0, // ulDevicePelsDPI
PRIMARY_ORDER_CBA, // ulPrimaryOrder
HT_PATSIZE_4x4_M, // ulHTPatternSize
HT_FORMAT_4BPP_IRGB, // ulHTOutputFormat
HT_FLAG_ADDITIVE_PRIMS, // flHTFlags
0, // ulDevicePelsDPI
PRIMARY_ORDER_CBA, // ulPrimaryOrder
HT_PATSIZE_4x4_M, // ulHTPatternSize
HT_FORMAT_4BPP_IRGB, // ulHTOutputFormat
HT_FLAG_ADDITIVE_PRIMS, // flHTFlags
0, // ulVRefresh
8, // ulBltAlignment
0, // ulPanningHorzRes
0, // ulPanningVertRes
};
0, // ulVRefresh
8, // ulBltAlignment
0, // ulPanningHorzRes
0, // ulPanningVertRes
};
// Palette for VGA
typedef struct _VGALOGPALETTE
{
USHORT ident;
USHORT NumEntries;
PALETTEENTRY PaletteEntry[16];
USHORT ident;
USHORT NumEntries;
PALETTEENTRY PaletteEntry[16];
} VGALOGPALETTE;
const VGALOGPALETTE VGApalette =
{
0x400, // driver version
16, // num entries
{
{ 0x00, 0x00, 0x00, 0x00 }, // 0
{ 0x80, 0x00, 0x00, 0x00 }, // 1
{ 0x00, 0x80, 0x00, 0x00 }, // 2
{ 0x80, 0x80, 0x00, 0x00 }, // 3
{ 0x00, 0x00, 0x80, 0x00 }, // 4
{ 0x80, 0x00, 0x80, 0x00 }, // 5
{ 0x00, 0x80, 0x80, 0x00 }, // 6
{ 0x80, 0x80, 0x80, 0x00 }, // 7
{ 0xc0, 0xc0, 0xc0, 0x00 }, // 8
{ 0xff, 0x00, 0x00, 0x00 }, // 9
{ 0x00, 0xff, 0x00, 0x00 }, // 10
{ 0xff, 0xff, 0x00, 0x00 }, // 11
{ 0x00, 0x00, 0xff, 0x00 }, // 12
{ 0xff, 0x00, 0xff, 0x00 }, // 13
{ 0x00, 0xff, 0xff, 0x00 }, // 14
{ 0xff, 0xff, 0xff, 0x00 } // 15
}
0x400, // driver version
16, // num entries
{
{ 0x00, 0x00, 0x00, 0x00 }, // 0
{ 0x80, 0x00, 0x00, 0x00 }, // 1
{ 0x00, 0x80, 0x00, 0x00 }, // 2
{ 0x80, 0x80, 0x00, 0x00 }, // 3
{ 0x00, 0x00, 0x80, 0x00 }, // 4
{ 0x80, 0x00, 0x80, 0x00 }, // 5
{ 0x00, 0x80, 0x80, 0x00 }, // 6
{ 0x80, 0x80, 0x80, 0x00 }, // 7
{ 0xc0, 0xc0, 0xc0, 0x00 }, // 8
{ 0xff, 0x00, 0x00, 0x00 }, // 9
{ 0x00, 0xff, 0x00, 0x00 }, // 10
{ 0xff, 0xff, 0x00, 0x00 }, // 11
{ 0x00, 0x00, 0xff, 0x00 }, // 12
{ 0xff, 0x00, 0xff, 0x00 }, // 13
{ 0x00, 0xff, 0xff, 0x00 }, // 14
{ 0xff, 0xff, 0xff, 0x00 } // 15
}
};
// Devinfo structure passed back to the engine in DrvEnablePDEV
@@ -160,37 +164,36 @@ const VGALOGPALETTE VGApalette =
DEVINFO devinfoVGA =
{
(GCAPS_OPAQUERECT | GCAPS_HORIZSTRIKE | GCAPS_ALTERNATEFILL | GCAPS_MONO_DITHER | GCAPS_COLOR_DITHER |
GCAPS_WINDINGFILL | GCAPS_DITHERONREALIZE
), // Graphics capabilities
(GCAPS_OPAQUERECT | GCAPS_HORIZSTRIKE | GCAPS_ALTERNATEFILL | GCAPS_MONO_DITHER | GCAPS_COLOR_DITHER |
GCAPS_WINDINGFILL | GCAPS_DITHERONREALIZE
), // Graphics capabilities
SYSTM_LOGFONT, // Default font description
HELVE_LOGFONT, // ANSI variable font description
COURI_LOGFONT, // ANSI fixed font description
0, // Count of device fonts
BMF_4BPP, // preferred DIB format
8, // Width of color dither
8, // Height of color dither
0 // Default palette to use for this device
SYSTM_LOGFONT, // Default font description
HELVE_LOGFONT, // ANSI variable font description
COURI_LOGFONT, // ANSI fixed font description
0, // Count of device fonts
BMF_4BPP, // preferred DIB format
8, // Width of color dither
8, // Height of color dither
0 // Default palette to use for this device
};
BOOL APIENTRY
DrvEnableDriver(IN ULONG EngineVersion,
IN ULONG SizeOfDED,
OUT PDRVENABLEDATA DriveEnableData)
IN ULONG SizeOfDED,
OUT PDRVENABLEDATA DriveEnableData)
{
/* EngDebugPrint("VGADDI", "DrvEnableDriver called...\n", 0); */
/* EngDebugPrint("VGADDI", "DrvEnableDriver called...\n", 0); */
vgaPreCalc();
vgaPreCalc();
VGADDI_InitializeOffScreenMem((640 * 480) >> 3, 65536 - ((640 * 480) >> 3));
VGADDI_InitializeOffScreenMem((SCREEN_X * SCREEN_Y) >> 3, 65536 - ((SCREEN_X * SCREEN_Y) >> 3));
DriveEnableData->pdrvfn = FuncList;
DriveEnableData->c = sizeof(FuncList) / sizeof(DRVFN);
DriveEnableData->iDriverVersion = DDI_DRIVER_VERSION_NT4;
DriveEnableData->pdrvfn = FuncList;
DriveEnableData->c = sizeof(FuncList) / sizeof(DRVFN);
DriveEnableData->iDriverVersion = DDI_DRIVER_VERSION_NT4;
return TRUE;
return TRUE;
}
// DrvDisableDriver
@@ -204,7 +207,7 @@ DrvEnableDriver(IN ULONG EngineVersion,
VOID APIENTRY
DrvDisableDriver(VOID)
{
return;
return;
}
// ----------------------------------------------- Driver Implementation
@@ -232,47 +235,43 @@ DrvDisableDriver(VOID)
DHPDEV APIENTRY
DrvEnablePDEV(IN DEVMODEW *DM,
IN LPWSTR LogAddress,
IN ULONG PatternCount,
OUT HSURF *SurfPatterns,
IN ULONG GDIInfoSize,
OUT ULONG *GDIInfo,
IN ULONG DevInfoSize,
OUT DEVINFO *DevInfo,
IN HDEV Dev,
IN LPWSTR DeviceName,
IN HANDLE Driver)
IN LPWSTR LogAddress,
IN ULONG PatternCount,
OUT HSURF *SurfPatterns,
IN ULONG GDIInfoSize,
OUT ULONG *GDIInfo,
IN ULONG DevInfoSize,
OUT DEVINFO *DevInfo,
IN HDEV Dev,
IN LPWSTR DeviceName,
IN HANDLE Driver)
{
PPDEV PDev;
PPDEV PDev;
PDev = EngAllocMem(FL_ZERO_MEMORY, sizeof(PDEV), ALLOC_TAG);
if (PDev == NULL)
PDev = EngAllocMem(FL_ZERO_MEMORY, sizeof(PDEV), ALLOC_TAG);
if (PDev == NULL)
{
EngDebugPrint(DBG_PREFIX, "EngAllocMem failed for PDEV\n", 0);
return(NULL);
EngDebugPrint(DBG_PREFIX, "EngAllocMem failed for PDEV\n", 0);
return NULL;
}
PDev->KMDriver = Driver;
DPRINT( "PDev: %x, Driver: %x\n", PDev, PDev->KMDriver );
PDev->KMDriver = Driver;
DPRINT( "PDev: %x, Driver: %x\n", PDev, PDev->KMDriver );
gaulCap.ulHorzRes = 640;
gaulCap.ulVertRes = 480;
if (sizeof(GDIINFO) < GDIInfoSize)
{
GDIInfoSize = sizeof(GDIINFO);
}
memcpy(GDIInfo, &gaulCap, GDIInfoSize);
DM->dmBitsPerPel = gaulCap.cBitsPixel * gaulCap.cPlanes;
DM->dmPelsWidth = gaulCap.ulHorzRes;
DM->dmPelsHeight = gaulCap.ulVertRes;
gaulCap.ulHorzRes = SCREEN_X;
gaulCap.ulVertRes = SCREEN_Y;
if (sizeof(GDIINFO) < GDIInfoSize)
GDIInfoSize = sizeof(GDIINFO);
memcpy(GDIInfo, &gaulCap, GDIInfoSize);
DM->dmBitsPerPel = gaulCap.cBitsPixel * gaulCap.cPlanes;
DM->dmPelsWidth = gaulCap.ulHorzRes;
DM->dmPelsHeight = gaulCap.ulVertRes;
devinfoVGA.hpalDefault = EngCreatePalette(PAL_INDEXED, 16, (ULONG *) VGApalette.PaletteEntry, 0, 0, 0);
if (sizeof(DEVINFO) < DevInfoSize)
{
DevInfoSize = sizeof(DEVINFO);
}
memcpy(DevInfo, &devinfoVGA, DevInfoSize);
devinfoVGA.hpalDefault = EngCreatePalette(PAL_INDEXED, 16, (ULONG *) VGApalette.PaletteEntry, 0, 0, 0);
if (sizeof(DEVINFO) < DevInfoSize)
DevInfoSize = sizeof(DEVINFO);
memcpy(DevInfo, &devinfoVGA, DevInfoSize);
return (DHPDEV) PDev;
return (DHPDEV) PDev;
}
@@ -283,319 +282,301 @@ DrvEnablePDEV(IN DEVMODEW *DM,
VOID APIENTRY
DrvCompletePDEV(IN DHPDEV PDev,
IN HDEV Dev)
IN HDEV Dev)
{
((PPDEV) PDev)->GDIDevHandle = Dev; // Handle to the DC
((PPDEV) PDev)->GDIDevHandle = Dev; // Handle to the DC
}
BOOL APIENTRY
DrvAssertMode(IN DHPDEV DPev,
IN BOOL Enable)
IN BOOL Enable)
{
PPDEV ppdev = (PPDEV)DPev;
ULONG returnedDataLength;
PPDEV ppdev = (PPDEV)DPev;
ULONG returnedDataLength;
if(Enable==TRUE)
{
// Reenable our graphics mode
if (!InitPointer(ppdev))
if(Enable==TRUE)
{
// Failed to set pointer
return FALSE;
}
/* Reenable our graphics mode */
if (!InitPointer(ppdev))
{
/* Failed to set pointer */
return FALSE;
}
if (!VGAInitialized)
{
if (!InitVGA(ppdev, FALSE))
{
// Failed to initialize the VGA
return FALSE;
}
VGAInitialized = TRUE;
if (!VGAInitialized)
{
if (!InitVGA(ppdev, FALSE))
{
/* Failed to initialize the VGA */
return FALSE;
}
VGAInitialized = TRUE;
}
} else {
// Go back to last known mode
DPRINT( "ppdev: %x, KMDriver: %x", ppdev, ppdev->KMDriver );
if (EngDeviceIoControl(ppdev->KMDriver, IOCTL_VIDEO_RESET_DEVICE, NULL, 0, NULL, 0, &returnedDataLength))
{
// Failed to go back to mode
return FALSE;
}
VGAInitialized = FALSE;
}
return TRUE;
else
{
/* Go back to last known mode */
DPRINT( "ppdev: %x, KMDriver: %x", ppdev, ppdev->KMDriver );
if (EngDeviceIoControl(ppdev->KMDriver, IOCTL_VIDEO_RESET_DEVICE, NULL, 0, NULL, 0, &returnedDataLength))
{
/* Failed to go back to mode */
return FALSE;
}
VGAInitialized = FALSE;
}
return TRUE;
}
VOID APIENTRY
DrvDisablePDEV(IN DHPDEV PDev)
{
PPDEV ppdev = (PPDEV)PDev;
PPDEV ppdev = (PPDEV)PDev;
// EngDeletePalette(devinfoVGA.hpalDefault);
if (ppdev->pjPreallocSSBBuffer != NULL)
{
EngFreeMem(ppdev->pjPreallocSSBBuffer);
}
/* EngDeletePalette(devinfoVGA.hpalDefault); */
if (ppdev->pjPreallocSSBBuffer)
EngFreeMem(ppdev->pjPreallocSSBBuffer);
if (ppdev->pucDIB4ToVGAConvBuffer != NULL)
{
EngFreeMem(ppdev->pucDIB4ToVGAConvBuffer);
}
DPRINT( "Freeing PDEV\n" );
EngFreeMem(PDev);
if (ppdev->pucDIB4ToVGAConvBuffer)
EngFreeMem(ppdev->pucDIB4ToVGAConvBuffer);
DPRINT("Freeing PDEV\n");
EngFreeMem(PDev);
}
VOID APIENTRY
DrvDisableSurface(IN DHPDEV PDev)
{
PPDEV ppdev = (PPDEV)PDev;
PDEVSURF pdsurf = ppdev->AssociatedSurf;
CHECKPOINT;
DPRINT( "KMDriver: %x\n", ppdev->KMDriver );
DeinitVGA(ppdev);
// EngFreeMem(pdsurf->BankSelectInfo);
CHECKPOINT;
if (pdsurf->BankInfo != NULL) {
EngFreeMem(pdsurf->BankInfo);
}
CHECKPOINT;
if (pdsurf->BankInfo2RW != NULL) {
EngFreeMem(pdsurf->BankInfo2RW);
}
CHECKPOINT;
if (pdsurf->BankBufferPlane0 != NULL) {
EngFreeMem(pdsurf->BankBufferPlane0);
}
CHECKPOINT;
if (ppdev->pPointerAttributes != NULL) {
EngFreeMem(ppdev->pPointerAttributes);
}
CHECKPOINT;
// free any pending saved screen bit blocks
PPDEV ppdev = (PPDEV)PDev;
PDEVSURF pdsurf = ppdev->AssociatedSurf;
DPRINT("KMDriver: %x\n", ppdev->KMDriver);
DeinitVGA(ppdev);
/* EngFreeMem(pdsurf->BankSelectInfo); */
if (pdsurf->BankInfo != NULL)
EngFreeMem(pdsurf->BankInfo);
if (pdsurf->BankInfo2RW != NULL)
EngFreeMem(pdsurf->BankInfo2RW);
if (pdsurf->BankBufferPlane0 != NULL)
EngFreeMem(pdsurf->BankBufferPlane0);
if (ppdev->pPointerAttributes != NULL)
EngFreeMem(ppdev->pPointerAttributes);
/* free any pending saved screen bit blocks */
#if 0
pSSB = pdsurf->ssbList;
while (pSSB != (PSAVED_SCREEN_BITS) NULL) {
pSSB = pdsurf->ssbList;
while (pSSB != (PSAVED_SCREEN_BITS) NULL)
{
/* Point to the next saved screen bits block */
pSSBNext = (PSAVED_SCREEN_BITS) pSSB->pvNextSSB;
// Point to the next saved screen bits block
pSSBNext = (PSAVED_SCREEN_BITS) pSSB->pvNextSSB;
// Free the current block
EngFreeMem(pSSB);
pSSB = pSSBNext;
/* Free the current block */
EngFreeMem(pSSB);
pSSB = pSSBNext;
}
#endif
EngDeleteSurface((HSURF) ppdev->SurfHandle);
// EngFreeMem(pdsurf); // free the surface
EngDeleteSurface((HSURF) ppdev->SurfHandle);
/* EngFreeMem(pdsurf); */ /* free the surface */
}
static VOID
InitSavedBits(PPDEV ppdev)
InitSavedBits(IN PPDEV ppdev)
{
if (!(ppdev->fl & DRIVER_OFFSCREEN_REFRESHED))
{
return;
}
if (!(ppdev->fl & DRIVER_OFFSCREEN_REFRESHED))
return;
// set up rect to right of visible screen
ppdev->SavedBitsRight.left = ppdev->sizeSurf.cx;
ppdev->SavedBitsRight.top = 0;
ppdev->SavedBitsRight.right = ppdev->sizeMem.cx-PLANAR_PELS_PER_CPU_ADDRESS;
ppdev->SavedBitsRight.bottom = ppdev->sizeSurf.cy;
if ((ppdev->SavedBitsRight.right <= ppdev->SavedBitsRight.left) ||
(ppdev->SavedBitsRight.bottom <= ppdev->SavedBitsRight.top))
{
ppdev->SavedBitsRight.left = 0;
/* set up rect to right of visible screen */
ppdev->SavedBitsRight.left = ppdev->sizeSurf.cx;
ppdev->SavedBitsRight.top = 0;
ppdev->SavedBitsRight.right = 0;
ppdev->SavedBitsRight.bottom = 0;
}
ppdev->SavedBitsRight.right = ppdev->sizeMem.cx - PLANAR_PELS_PER_CPU_ADDRESS;
ppdev->SavedBitsRight.bottom = ppdev->sizeSurf.cy;
// set up rect below visible screen
ppdev->SavedBitsBottom.left = 0;
ppdev->SavedBitsBottom.top = ppdev->sizeSurf.cy;
ppdev->SavedBitsBottom.right = ppdev->sizeMem.cx-PLANAR_PELS_PER_CPU_ADDRESS;
ppdev->SavedBitsBottom.bottom = ppdev->sizeMem.cy - ppdev->NumScansUsedByPointer;
if ((ppdev->SavedBitsRight.right <= ppdev->SavedBitsRight.left) ||
(ppdev->SavedBitsRight.bottom <= ppdev->SavedBitsRight.top))
{
ppdev->SavedBitsRight.left = 0;
ppdev->SavedBitsRight.top = 0;
ppdev->SavedBitsRight.right = 0;
ppdev->SavedBitsRight.bottom = 0;
}
if ((ppdev->SavedBitsBottom.right <= ppdev->SavedBitsBottom.left) ||
(ppdev->SavedBitsBottom.bottom <= ppdev->SavedBitsBottom.top))
{
/* set up rect below visible screen */
ppdev->SavedBitsBottom.left = 0;
ppdev->SavedBitsBottom.top = 0;
ppdev->SavedBitsBottom.right = 0;
ppdev->SavedBitsBottom.bottom = 0;
}
ppdev->SavedBitsBottom.top = ppdev->sizeSurf.cy;
ppdev->SavedBitsBottom.right = ppdev->sizeMem.cx - PLANAR_PELS_PER_CPU_ADDRESS;
ppdev->SavedBitsBottom.bottom = ppdev->sizeMem.cy - ppdev->NumScansUsedByPointer;
ppdev->BitsSaved = FALSE;
if ((ppdev->SavedBitsBottom.right <= ppdev->SavedBitsBottom.left) ||
(ppdev->SavedBitsBottom.bottom <= ppdev->SavedBitsBottom.top))
{
ppdev->SavedBitsBottom.left = 0;
ppdev->SavedBitsBottom.top = 0;
ppdev->SavedBitsBottom.right = 0;
ppdev->SavedBitsBottom.bottom = 0;
}
return;
ppdev->BitsSaved = FALSE;
}
HSURF APIENTRY
DrvEnableSurface(IN DHPDEV PDev)
{
PPDEV ppdev = (PPDEV)PDev;
PDEVSURF pdsurf;
DHSURF dhsurf;
HSURF hsurf;
PPDEV ppdev = (PPDEV)PDev;
PDEVSURF pdsurf;
DHSURF dhsurf;
HSURF hsurf;
DPRINT("DrvEnableSurface() called\n");
DPRINT("DrvEnableSurface() called\n");
// Initialize the VGA
if (!VGAInitialized)
/* Initialize the VGA */
if (!VGAInitialized)
{
if (!InitVGA(ppdev, TRUE))
{
goto error_done;
}
VGAInitialized = TRUE;
if (!InitVGA(ppdev, TRUE))
goto error_done;
VGAInitialized = TRUE;
}
// dhsurf is of type DEVSURF, which is the drivers specialized surface type
dhsurf = (DHSURF)EngAllocMem(0, sizeof(DEVSURF), ALLOC_TAG);
if (dhsurf == (DHSURF) 0)
{
goto error_done;
}
/* dhsurf is of type DEVSURF, which is the drivers specialized surface type */
dhsurf = (DHSURF)EngAllocMem(0, sizeof(DEVSURF), ALLOC_TAG);
if (dhsurf == (DHSURF) 0)
goto error_done;
pdsurf = (PDEVSURF) dhsurf;
pdsurf->ident = DEVSURF_IDENT;
pdsurf->flSurf = 0;
pdsurf->Format = BMF_PHYSDEVICE;
pdsurf->jReserved1 = 0;
pdsurf->jReserved2 = 0;
pdsurf->ppdev = ppdev;
pdsurf->sizeSurf.cx = ppdev->sizeSurf.cx;
pdsurf->sizeSurf.cy = ppdev->sizeSurf.cy;
pdsurf->NextPlane = 0;
pdsurf->Scan0 = ppdev->fbScreen;
pdsurf->BitmapStart = ppdev->fbScreen;
pdsurf->StartBmp = ppdev->fbScreen;
pdsurf->BankInfo = NULL;
pdsurf->BankInfo2RW = NULL;
pdsurf->BankBufferPlane0 = NULL;
pdsurf = (PDEVSURF) dhsurf;
pdsurf->ident = DEVSURF_IDENT;
pdsurf->flSurf = 0;
pdsurf->Format = BMF_PHYSDEVICE;
pdsurf->jReserved1 = 0;
pdsurf->jReserved2 = 0;
pdsurf->ppdev = ppdev;
pdsurf->sizeSurf.cx = ppdev->sizeSurf.cx;
pdsurf->sizeSurf.cy = ppdev->sizeSurf.cy;
pdsurf->NextPlane = 0;
pdsurf->Scan0 = ppdev->fbScreen;
pdsurf->BitmapStart = ppdev->fbScreen;
pdsurf->StartBmp = ppdev->fbScreen;
pdsurf->BankInfo = NULL;
pdsurf->BankInfo2RW = NULL;
pdsurf->BankBufferPlane0 = NULL;
/* pdsurf->Conv = &ConvertBuffer[0]; */
/* pdsurf->Conv = &ConvertBuffer[0]; */
if (!InitPointer(ppdev)) {
DbgPrint("DrvEnablePDEV failed bInitPointer\n");
goto error_clean;
}
if (!InitPointer(ppdev))
{
DPRINT1("DrvEnablePDEV failed bInitPointer\n");
goto error_clean;
}
/* if (!SetUpBanking(pdsurf, ppdev)) {
DISPDBG((0, "DrvEnablePDEV failed SetUpBanking\n"));
goto error_clean;
} BANKING CODE UNIMPLEMENTED */
/* if (!SetUpBanking(pdsurf, ppdev))
{
DPRINT1("DrvEnablePDEV failed SetUpBanking\n");
goto error_clean;
} BANKING CODE UNIMPLEMENTED */
if ((hsurf = EngCreateDeviceSurface(dhsurf, ppdev->sizeSurf, BMF_4BPP)) ==
(HSURF)0)
{
// Call to EngCreateDeviceSurface failed
EngDebugPrint("VGADDI:", "EngCreateDeviceSurface call failed\n", 0);
goto error_clean;
}
if ((hsurf = EngCreateDeviceSurface(dhsurf, ppdev->sizeSurf, BMF_4BPP)) ==
(HSURF)0)
{
/* Call to EngCreateDeviceSurface failed */
DPRINT("EngCreateDeviceSurface call failed\n");
goto error_clean;
}
InitSavedBits(ppdev);
InitSavedBits(ppdev);
if (EngAssociateSurface(hsurf, ppdev->GDIDevHandle, HOOK_BITBLT | HOOK_PAINT | HOOK_LINETO | HOOK_COPYBITS |
HOOK_TRANSPARENTBLT))
{
/* EngDebugPrint("VGADDI:", "Successfully associated surface\n", 0); */
ppdev->SurfHandle = hsurf;
ppdev->AssociatedSurf = pdsurf;
if (EngAssociateSurface(hsurf, ppdev->GDIDevHandle, HOOK_BITBLT | HOOK_PAINT | HOOK_LINETO | HOOK_COPYBITS |
HOOK_TRANSPARENTBLT))
{
DPRINT("Successfully associated surface\n");
ppdev->SurfHandle = hsurf;
ppdev->AssociatedSurf = pdsurf;
// Set up an empty saved screen block list
pdsurf->ssbList = NULL;
/* Set up an empty saved screen block list */
pdsurf->ssbList = NULL;
return(hsurf);
}
DPRINT( "EngAssociateSurface() failed\n" );
EngDeleteSurface(hsurf);
return hsurf;
}
DPRINT("EngAssociateSurface() failed\n");
EngDeleteSurface(hsurf);
error_clean:
EngFreeMem(dhsurf);
EngFreeMem(dhsurf);
error_done:
return((HSURF)0);
return (HSURF)0;
}
ULONG APIENTRY
DrvGetModes(IN HANDLE Driver,
IN ULONG DataSize,
OUT PDEVMODEW DM)
IN ULONG DataSize,
OUT PDEVMODEW DM)
{
DWORD NumModes;
DWORD ModeSize;
DWORD OutputSize;
DWORD OutputModes = DataSize / (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE);
PVIDEO_MODE_INFORMATION VideoModeInformation, VideoTemp;
DWORD NumModes;
DWORD ModeSize;
DWORD OutputSize;
DWORD OutputModes = DataSize / (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE);
PVIDEO_MODE_INFORMATION VideoModeInformation, VideoTemp;
NumModes = getAvailableModes(Driver,
(PVIDEO_MODE_INFORMATION *) &VideoModeInformation,
&ModeSize);
NumModes = getAvailableModes(Driver,
(PVIDEO_MODE_INFORMATION *) &VideoModeInformation,
&ModeSize);
if (NumModes == 0)
{
return 0;
}
if (NumModes == 0)
return 0;
if (DM == NULL)
{
OutputSize = NumModes * (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE);
} else {
OutputSize=0;
VideoTemp = VideoModeInformation;
do
if (DM == NULL)
{
if (VideoTemp->Length != 0)
{
if (OutputModes == 0)
OutputSize = NumModes * (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE);
}
else
{
OutputSize=0;
VideoTemp = VideoModeInformation;
do
{
break;
}
if (VideoTemp->Length != 0)
{
if (OutputModes == 0)
break;
memset(DM, 0, sizeof(DEVMODEW));
memcpy(DM->dmDeviceName, DLL_NAME, sizeof(DLL_NAME));
memset(DM, 0, sizeof(DEVMODEW));
memcpy(DM->dmDeviceName, DLL_NAME, sizeof(DLL_NAME));
DM->dmSpecVersion = DM_SPECVERSION;
DM->dmDriverVersion = DM_SPECVERSION;
DM->dmSize = sizeof(DEVMODEW);
DM->dmDriverExtra = DRIVER_EXTRA_SIZE;
DM->dmBitsPerPel = VideoTemp->NumberOfPlanes *
VideoTemp->BitsPerPlane;
DM->dmPelsWidth = VideoTemp->VisScreenWidth;
DM->dmPelsHeight = VideoTemp->VisScreenHeight;
DM->dmDisplayFrequency = VideoTemp->Frequency;
DM->dmDisplayFlags = 0;
DM->dmSpecVersion = DM_SPECVERSION;
DM->dmDriverVersion = DM_SPECVERSION;
DM->dmSize = sizeof(DEVMODEW);
DM->dmDriverExtra = DRIVER_EXTRA_SIZE;
DM->dmBitsPerPel = VideoTemp->NumberOfPlanes *
VideoTemp->BitsPerPlane;
DM->dmPelsWidth = VideoTemp->VisScreenWidth;
DM->dmPelsHeight = VideoTemp->VisScreenHeight;
DM->dmDisplayFrequency = VideoTemp->Frequency;
DM->dmDisplayFlags = 0;
DM->dmFields = DM_BITSPERPEL |
DM_PELSWIDTH |
DM_PELSHEIGHT |
DM_DISPLAYFREQUENCY |
DM_DISPLAYFLAGS ;
DM->dmFields = DM_BITSPERPEL |
DM_PELSWIDTH |
DM_PELSHEIGHT |
DM_DISPLAYFREQUENCY |
DM_DISPLAYFLAGS ;
// next DEVMODE entry
OutputModes--;
/* next DEVMODE entry */
OutputModes--;
DM = (PDEVMODEW) ( ((ULONG)DM) + sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE);
DM = (PDEVMODEW) ( ((ULONG)DM) + sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE);
OutputSize += (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE);
}
OutputSize += (sizeof(DEVMODEW) + DRIVER_EXTRA_SIZE);
}
VideoTemp = (PVIDEO_MODE_INFORMATION)(((PUCHAR)VideoTemp) + ModeSize);
VideoTemp = (PVIDEO_MODE_INFORMATION)(((PUCHAR)VideoTemp) + ModeSize);
} while (--NumModes);
}
return OutputSize;
} while (--NumModes);
}
return OutputSize;
}
/* EOF */
@@ -1,3 +1,11 @@
/*
* PROJECT: ReactOS VGA display driver
* LICENSE: GPL - See COPYING in the top level directory
* FILE: drivers/video/displays/vga/objects/bitblt.c
* PURPOSE:
* PROGRAMMERS:
*/
#include "../vgaddi.h"
#include "../vgavideo/vgavideo.h"
#include "brush.h"
@@ -18,465 +26,485 @@ typedef BOOL (APIENTRY *PBLTRECTFUNC)(SURFOBJ* OutputObj,
POINTL* BrushOrigin,
ROP4 Rop4);
static BOOL FASTCALL VGADDI_IntersectRect(RECTL* prcDst, RECTL* prcSrc1, RECTL* prcSrc2)
static BOOL FASTCALL VGADDI_IntersectRect(
OUT RECTL* prcDst,
IN RECTL* prcSrc1,
IN RECTL* prcSrc2)
{
static const RECTL rclEmpty = { 0, 0, 0, 0 };
static const RECTL rclEmpty = { 0, 0, 0, 0 };
prcDst->left = max(prcSrc1->left, prcSrc2->left);
prcDst->right = min(prcSrc1->right, prcSrc2->right);
prcDst->left = max(prcSrc1->left, prcSrc2->left);
prcDst->right = min(prcSrc1->right, prcSrc2->right);
if (prcDst->left < prcDst->right)
{
prcDst->top = max(prcSrc1->top, prcSrc2->top);
prcDst->bottom = min(prcSrc1->bottom, prcSrc2->bottom);
if (prcDst->left < prcDst->right)
{
prcDst->top = max(prcSrc1->top, prcSrc2->top);
prcDst->bottom = min(prcSrc1->bottom, prcSrc2->bottom);
if (prcDst->top < prcDst->bottom) return(TRUE);
}
if (prcDst->top < prcDst->bottom) return(TRUE);
}
*prcDst = rclEmpty;
*prcDst = rclEmpty;
return(FALSE);
return FALSE;
}
void DIB_BltToVGA_Fixed(int x, int y, int w, int h, void *b, int Source_lDelta, int mod);
BOOL
DIBtoVGA(SURFOBJ *Dest, SURFOBJ *Source, XLATEOBJ *ColorTranslation,
RECTL *DestRect, POINTL *SourcePoint)
DIBtoVGA(
IN SURFOBJ *Dest,
IN SURFOBJ *Source,
IN XLATEOBJ *ColorTranslation,
IN RECTL *DestRect,
IN POINTL *SourcePoint)
{
LONG dx, dy;
LONG dx, dy;
dx = DestRect->right - DestRect->left;
dy = DestRect->bottom - DestRect->top;
dx = DestRect->right - DestRect->left;
dy = DestRect->bottom - DestRect->top;
if (NULL == ColorTranslation || 0 != (ColorTranslation->flXlate & XO_TRIVIAL))
if (NULL == ColorTranslation || 0 != (ColorTranslation->flXlate & XO_TRIVIAL))
{
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);
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);
}
else
else
{
/* 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);
/* 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);
}
return FALSE;
return FALSE;
}
BOOL
VGAtoDIB(SURFOBJ *Dest, SURFOBJ *Source, XLATEOBJ *ColorTranslation,
RECTL *DestRect, POINTL *SourcePoint)
VGAtoDIB(
IN SURFOBJ *Dest,
IN SURFOBJ *Source,
IN XLATEOBJ *ColorTranslation,
IN RECTL *DestRect,
IN POINTL *SourcePoint)
{
LONG i, j, dx, dy;
BYTE *GDIpos, *initial;
LONG i, j, dx, dy;
UCHAR *GDIpos, *initial;
// Used by the temporary DFB
DEVSURF DestDevSurf;
/* Used by the temporary DFB */
DEVSURF DestDevSurf;
// FIXME: Optimize to retrieve entire bytes at a time (see /display/vgavideo/vgavideo.c:vgaGetByte)
/* FIXME: Optimize to retrieve entire bytes at a time (see ../vgavideo/vgavideo.c:vgaGetByte) */
GDIpos = Dest->pvScan0 /* + (DestRect->top * Dest->lDelta) + (DestRect->left >> 1) */ ;
dx = DestRect->right - DestRect->left;
dy = DestRect->bottom - DestRect->top;
GDIpos = Dest->pvScan0 /* + (DestRect->top * Dest->lDelta) + (DestRect->left >> 1) */ ;
dx = DestRect->right - DestRect->left;
dy = DestRect->bottom - DestRect->top;
if(ColorTranslation == NULL)
{
// Prepare a Dest Dev Target and copy from the DFB to the DIB
DestDevSurf.NextScan = Dest->lDelta;
DestDevSurf.StartBmp = Dest->pvScan0;
DIB_BltFromVGA(SourcePoint->x, SourcePoint->y, dx, dy, Dest->pvScan0, Dest->lDelta);
} else {
// Color translation
for(j=SourcePoint->y; j<SourcePoint->y+dy; j++)
if (ColorTranslation == NULL)
{
initial = GDIpos;
for(i=SourcePoint->x; i<SourcePoint->x+dx; i++)
{
*GDIpos = XLATEOBJ_iXlate(ColorTranslation, vgaGetPixel(i, j));
GDIpos+=1;
}
GDIpos = initial + Dest->lDelta;
/* Prepare a Dest Dev Target and copy from the DFB to the DIB */
DestDevSurf.NextScan = Dest->lDelta;
DestDevSurf.StartBmp = Dest->pvScan0;
DIB_BltFromVGA(SourcePoint->x, SourcePoint->y, dx, dy, Dest->pvScan0, Dest->lDelta);
}
}
return FALSE;
else
{
/* 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;
}
}
return FALSE;
}
BOOL
DFBtoVGA(SURFOBJ *Dest, SURFOBJ *Source, XLATEOBJ *ColorTranslation,
RECTL *DestRect, POINTL *SourcePoint)
DFBtoVGA(
IN SURFOBJ *Dest,
IN SURFOBJ *Source,
IN XLATEOBJ *ColorTranslation,
IN RECTL *DestRect,
IN POINTL *SourcePoint)
{
return FALSE;
// Do DFBs need color translation??
/* Do DFBs need color translation?? */
return FALSE;
}
BOOL
VGAtoDFB(SURFOBJ *Dest, SURFOBJ *Source, XLATEOBJ *ColorTranslation,
RECTL *DestRect, POINTL *SourcePoint)
VGAtoDFB(
IN SURFOBJ *Dest,
IN SURFOBJ *Source,
IN XLATEOBJ *ColorTranslation,
IN RECTL *DestRect,
IN POINTL *SourcePoint)
{
return FALSE;
// Do DFBs need color translation??
/* Do DFBs need color translation?? */
return FALSE;
}
BOOL
VGAtoVGA(SURFOBJ *Dest, SURFOBJ *Source, XLATEOBJ *ColorTranslation,
RECTL *DestRect, POINTL *SourcePoint)
VGAtoVGA(
IN SURFOBJ *Dest,
IN SURFOBJ *Source,
IN XLATEOBJ *ColorTranslation,
IN RECTL *DestRect,
IN POINTL *SourcePoint)
{
LONG i, i2, j, dx, dy, alterx, altery;
//LARGE_INTEGER Start, End; // for performance measurement only
static char buf[640];
LONG i, i2, j, dx, dy, alterx, altery;
static char buf[SCREEN_X];
// Calculate deltas
/* Calculate deltas */
dx = DestRect->right - DestRect->left;
dy = DestRect->bottom - DestRect->top;
dx = DestRect->right - DestRect->left;
dy = DestRect->bottom - DestRect->top;
alterx = DestRect->left - SourcePoint->x;
altery = DestRect->top - SourcePoint->y;
alterx = DestRect->left - SourcePoint->x;
altery = DestRect->top - SourcePoint->y;
i = SourcePoint->x;
i2 = i + alterx;
//KeQueryTickCount ( &Start );
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
{
for(j = (SourcePoint->y + dy - 1); j >= SourcePoint->y; j--)
{
LONG j2 = j + altery;
vgaReadScan ( i, j, dx, buf );
vgaWriteScan ( i2, j2, dx, buf );
}
}
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
{
for(j=(SourcePoint->y+dy-1); j>=SourcePoint->y; j--)
{
LONG j2 = j + altery;
vgaReadScan ( i, j, dx, buf );
vgaWriteScan ( i2, j2, dx, buf );
}
}
//KeQueryTickCount ( &End );
//DbgPrint ( "VgaBitBlt timing: %lu\n", (ULONG)(End.QuadPart-Start.QuadPart) );
return TRUE;
return TRUE;
}
BOOL APIENTRY
VGADDI_BltBrush(SURFOBJ* Dest, SURFOBJ* Source, SURFOBJ* MaskSurf,
XLATEOBJ* ColorTranslation, RECTL* DestRect,
POINTL* SourcePoint, POINTL* MaskPoint,
BRUSHOBJ* Brush, POINTL* BrushPoint, ROP4 Rop4)
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;
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)
/* 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)
{
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)
{
return(FALSE);
}
/* Get the brush colour. */
switch (GET_OPINDEX_FROM_ROP4(Rop4))
{
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;
}
/* Select write mode 3. */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x05);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0x03);
/* Setup set/reset register. */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x00);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, (UCHAR)SolidColor);
/* Enable writes to all pixels. */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x08);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0xFF);
/* Set up data rotate. */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x03);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, RasterOp);
/* Fill any pixels on the left which don't fall into a full row of eight. */
if ((DestRect->left % 8) != 0)
{
/* 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;
}
}
/* 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++)
{
Video = (PUCHAR)vidmem + i * 80 + (Left >> 3);
for (j = 0; j < Length; j++, Video++)
{
#if 0
(VOID)READ_REGISTER_UCHAR(Video);
WRITE_REGISTER_UCHAR(Video, 0xFF);
#else
char volatile Temp = *Video;
Temp |= 0;
*Video = 0xFF;
#endif
}
}
/* Fill any pixels on the right which don't fall into a complete row. */
if ((DestRect->right % 8) != 0)
{
/* 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);
}
}
/* 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;
}
BOOL APIENTRY
VGADDI_BltSrc(SURFOBJ* Dest, SURFOBJ* Source, SURFOBJ* Mask,
XLATEOBJ* ColorTranslation, RECTL* DestRect, POINTL* SourcePoint,
POINTL* MaskOrigin, BRUSHOBJ* Brush, POINTL* BrushOrigin, ROP4 Rop4)
{
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
{
/* Punt blts not involving a device or a device-bitmap. */
return(FALSE);
}
BltOperation(Dest, Source, ColorTranslation, DestRect, SourcePoint);
return(TRUE);
}
BOOL APIENTRY
VGADDI_BltMask(SURFOBJ* Dest, SURFOBJ* Source, SURFOBJ* Mask,
XLATEOBJ* ColorTranslation, RECTL* DestRect,
POINTL* SourcePoint, POINTL* MaskPoint, BRUSHOBJ* Brush,
POINTL* BrushPoint, ROP4 Rop4)
{
LONG i, j, dx, dy, c8;
BYTE *tMask, *lMask;
dx = DestRect->right - DestRect->left;
dy = DestRect->bottom - DestRect->top;
if (ColorTranslation == NULL)
{
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;
}
}
}
return TRUE;
}
BOOL APIENTRY
DrvBitBlt(SURFOBJ *Dest,
SURFOBJ *Source,
SURFOBJ *Mask,
CLIPOBJ *Clip,
XLATEOBJ *ColorTranslation,
RECTL *DestRect,
POINTL *SourcePoint,
POINTL *MaskPoint,
BRUSHOBJ *Brush,
POINTL *BrushPoint,
ROP4 rop4)
{
PBLTRECTFUNC BltRectFunc;
RECTL CombinedRect;
BOOL Ret = FALSE;
RECT_ENUM RectEnum;
BOOL EnumMore;
unsigned i;
POINTL Pt;
ULONG Direction;
switch (rop4)
{
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));
Pt.x = SourcePoint->x + CombinedRect.left - DestRect->left;
Pt.y = SourcePoint->y + CombinedRect.top - DestRect->top;
Ret = (*BltRectFunc)(Dest, Source, Mask, ColorTranslation, &CombinedRect,
&Pt, MaskPoint, Brush, BrushPoint,
rop4);
break;
case DC_COMPLEX:
Ret = TRUE;
if (Dest == Source)
{
if (DestRect->top <= SourcePoint->y)
{
Direction = DestRect->left < SourcePoint->x ? CD_RIGHTDOWN : CD_LEFTDOWN;
}
else
{
Direction = DestRect->left < SourcePoint->x ? CD_RIGHTUP : CD_LEFTUP;
}
}
else
{
Direction = CD_ANY;
}
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, Direction, 0);
do
{
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
/* Get the brush colour. */
switch (GET_OPINDEX_FROM_ROP4(Rop4))
{
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;
}
for (i = 0; i < RectEnum.c; i++)
{
VGADDI_IntersectRect(&CombinedRect, DestRect, RectEnum.arcl + i);
Pt.x = SourcePoint->x + CombinedRect.left - DestRect->left;
Pt.y = SourcePoint->y + CombinedRect.top - DestRect->top;
Ret = (*BltRectFunc)(Dest, Source, Mask, ColorTranslation, &CombinedRect,
&Pt, MaskPoint, Brush, BrushPoint, rop4) &&
Ret;
}
}
while (EnumMore);
break;
}
/* Select write mode 3. */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x05);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0x03);
return Ret;
/* Setup set/reset register. */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x00);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, (UCHAR)SolidColor);
/* Enable writes to all pixels. */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x08);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0xFF);
/* Set up data rotate. */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x03);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, RasterOp);
/* Fill any pixels on the left which don't fall into a full row of eight. */
if ((DestRect->left % 8) != 0)
{
/* 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;
}
}
/* 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++)
{
Video = (PUCHAR)vidmem + i * 80 + (Left >> 3);
for (j = 0; j < Length; j++, Video++)
{
#if 0
(VOID)READ_REGISTER_UCHAR(Video);
WRITE_REGISTER_UCHAR(Video, 0xFF);
#else
char volatile Temp = *Video;
Temp |= 0;
*Video = 0xFF;
#endif
}
}
/* Fill any pixels on the right which don't fall into a complete row. */
if ((DestRect->right % 8) != 0)
{
/* 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);
}
}
/* 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;
}
BOOL APIENTRY
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)
{
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
{
/* Punt blts not involving a device or a device-bitmap. */
return FALSE;
}
BltOperation(Dest, Source, ColorTranslation, DestRect, SourcePoint);
return TRUE;
}
BOOL APIENTRY
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)
{
LONG i, j, dx, dy, c8;
BYTE *tMask, *lMask;
dx = DestRect->right - DestRect->left;
dy = DestRect->bottom - DestRect->top;
if (ColorTranslation == NULL)
{
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;
}
}
}
return TRUE;
}
BOOL APIENTRY
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)
{
PBLTRECTFUNC BltRectFunc;
RECTL CombinedRect;
BOOL Ret = FALSE;
RECT_ENUM RectEnum;
BOOL EnumMore;
UINT i;
POINTL Pt;
ULONG Direction;
switch (rop4)
{
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));
Pt.x = SourcePoint->x + CombinedRect.left - DestRect->left;
Pt.y = SourcePoint->y + CombinedRect.top - DestRect->top;
Ret = (*BltRectFunc)(Dest, Source, Mask, ColorTranslation, &CombinedRect,
&Pt, MaskPoint, Brush, BrushPoint,
rop4);
break;
case DC_COMPLEX:
Ret = TRUE;
if (Dest == Source)
{
if (DestRect->top <= SourcePoint->y)
Direction = DestRect->left < SourcePoint->x ? CD_RIGHTDOWN : CD_LEFTDOWN;
else
Direction = DestRect->left < SourcePoint->x ? CD_RIGHTUP : CD_LEFTUP;
}
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);
Pt.x = SourcePoint->x + CombinedRect.left - DestRect->left;
Pt.y = SourcePoint->y + CombinedRect.top - DestRect->top;
Ret = (*BltRectFunc)(Dest, Source, Mask, ColorTranslation, &CombinedRect,
&Pt, MaskPoint, Brush, BrushPoint, rop4) &&
Ret;
}
} while (EnumMore);
break;
}
return Ret;
}
@@ -1,38 +1,47 @@
/*
* PROJECT: ReactOS VGA display driver
* LICENSE: GPL - See COPYING in the top level directory
* FILE: drivers/video/displays/vga/objects/copybits.c
* PURPOSE:
* PROGRAMMERS:
*/
#include "../vgaddi.h"
#include "../vgavideo/vgavideo.h"
#include <debug.h>
BOOL APIENTRY
DrvCopyBits(OUT SURFOBJ* DestObj,
IN SURFOBJ* SourceObj,
IN CLIPOBJ* ClipObj,
IN XLATEOBJ* XLateObj,
IN RECTL* DestRectL,
IN POINTL* SrcPointL)
DrvCopyBits(
OUT SURFOBJ* DestObj,
IN SURFOBJ* SourceObj,
IN CLIPOBJ* ClipObj,
IN XLATEOBJ* XLateObj,
IN RECTL* DestRectL,
IN POINTL* SrcPointL)
{
BOOL Done = FALSE;
BOOL Done = FALSE;
if (STYPE_BITMAP == DestObj->iType && BMF_4BPP == DestObj->iBitmapFormat &&
STYPE_DEVICE == SourceObj->iType)
if (STYPE_BITMAP == DestObj->iType && BMF_4BPP == DestObj->iBitmapFormat &&
STYPE_DEVICE == SourceObj->iType)
{
/* Screen to 4 BPP DIB */
DIB_BltFromVGA(SrcPointL->x, SrcPointL->y,
DestRectL->right - DestRectL->left,
DestRectL->bottom - DestRectL->top,
DestObj->pvScan0, DestObj->lDelta);
Done = TRUE;
/* Screen to 4 BPP DIB */
DIB_BltFromVGA(SrcPointL->x, SrcPointL->y,
DestRectL->right - DestRectL->left,
DestRectL->bottom - DestRectL->top,
DestObj->pvScan0, DestObj->lDelta);
Done = TRUE;
}
else if (STYPE_DEVICE == DestObj->iType &&
STYPE_BITMAP == SourceObj->iType && BMF_4BPP == SourceObj->iBitmapFormat)
else if (STYPE_DEVICE == DestObj->iType &&
STYPE_BITMAP == SourceObj->iType && BMF_4BPP == SourceObj->iBitmapFormat)
{
/* 4 BPP DIB to Screen */
DIB_BltToVGA(DestRectL->left, DestRectL->top,
DestRectL->right - DestRectL->left,
DestRectL->bottom - DestRectL->top,
SourceObj->pvScan0, SourceObj->lDelta,
0);
Done = TRUE;
/* 4 BPP DIB to Screen */
DIB_BltToVGA(DestRectL->left, DestRectL->top,
DestRectL->right - DestRectL->left,
DestRectL->bottom - DestRectL->top,
SourceObj->pvScan0, SourceObj->lDelta,
0);
Done = TRUE;
}
return Done;
return Done;
}
@@ -1,21 +1,9 @@
/*
* ReactOS VGA driver
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* PROJECT: ReactOS VGA display driver
* LICENSE: GPL - See COPYING in the top level directory
* FILE: drivers/video/displays/vga/objects/lineto.c
* PURPOSE:
* PROGRAMMERS: Copyright (C) 1998-2003 ReactOS Team
*/
#include "../vgaddi.h"
@@ -25,263 +13,279 @@
* Draw a line from top-left to bottom-right
*/
static void FASTCALL
vgaNWtoSE(CLIPOBJ* Clip, BRUSHOBJ* Brush, LONG x, LONG y, LONG deltax, LONG deltay)
vgaNWtoSE(
IN CLIPOBJ* Clip,
IN BRUSHOBJ* Brush,
IN LONG x,
IN LONG y,
IN LONG deltax,
IN LONG deltay)
{
int i;
int error;
BOOLEAN EnumMore;
PRECTL ClipRect;
RECT_ENUM RectEnum;
ULONG Pixel = Brush->iSolidColor;
LONG delta;
int i;
int error;
BOOLEAN EnumMore;
PRECTL ClipRect;
RECT_ENUM RectEnum;
ULONG Pixel = Brush->iSolidColor;
LONG delta;
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, CD_RIGHTDOWN, 0);
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
ClipRect = RectEnum.arcl;
delta = max(deltax, deltay);
i = 0;
error = delta/2;
while (i < delta && (ClipRect < RectEnum.arcl + RectEnum.c || EnumMore))
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, CD_RIGHTDOWN, 0);
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
ClipRect = RectEnum.arcl;
delta = max(deltax, deltay);
i = 0;
error = delta / 2;
while (i < delta && (ClipRect < RectEnum.arcl + RectEnum.c || EnumMore))
{
while ((ClipRect < RectEnum.arcl + RectEnum.c /* there's still a current clip rect */
&& (ClipRect->bottom <= y /* but it's above us */
|| (ClipRect->top <= y && ClipRect->right <= x))) /* or to the left of us */
|| EnumMore) /* no current clip rect, but rects left */
{
/* Skip to the next clip rect */
if (RectEnum.arcl + RectEnum.c <= ClipRect)
{
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
ClipRect = RectEnum.arcl;
}
else
{
ClipRect++;
}
}
if ( ClipRect < RectEnum.arcl + RectEnum.c ) /* If there's no current clip rect we're done */
{
if (ClipRect->left <= x && ClipRect->top <= y)
{
vgaPutPixel ( x, y, Pixel );
}
if ( deltax < deltay )
{
y++;
error += deltax;
if ( error >= deltay )
{
x++;
error -= deltay;
}
}
else
{
x++;
error += deltay;
if ( error >= deltax )
{
y++;
error -= deltax;
}
}
i++;
}
while ((ClipRect < RectEnum.arcl + RectEnum.c /* there's still a current clip rect */
&& (ClipRect->bottom <= y /* but it's above us */
|| (ClipRect->top <= y && ClipRect->right <= x))) /* or to the left of us */
|| EnumMore) /* no current clip rect, but rects left */
{
/* Skip to the next clip rect */
if (RectEnum.arcl + RectEnum.c <= ClipRect)
{
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
ClipRect = RectEnum.arcl;
}
else
{
ClipRect++;
}
}
if ( ClipRect < RectEnum.arcl + RectEnum.c ) /* If there's no current clip rect we're done */
{
if (ClipRect->left <= x && ClipRect->top <= y)
vgaPutPixel ( x, y, Pixel );
if ( deltax < deltay )
{
y++;
error += deltax;
if ( error >= deltay )
{
x++;
error -= deltay;
}
}
else
{
x++;
error += deltay;
if ( error >= deltax )
{
y++;
error -= deltax;
}
}
i++;
}
}
}
static void FASTCALL
vgaSWtoNE(CLIPOBJ* Clip, BRUSHOBJ* Brush, LONG x, LONG y, LONG deltax, LONG deltay)
vgaSWtoNE(
IN CLIPOBJ* Clip,
IN BRUSHOBJ* Brush,
IN LONG x,
IN LONG y,
IN LONG deltax,
IN LONG deltay)
{
int i;
int error;
BOOLEAN EnumMore;
PRECTL ClipRect;
RECT_ENUM RectEnum;
ULONG Pixel = Brush->iSolidColor;
LONG delta;
int i;
int error;
BOOLEAN EnumMore;
PRECTL ClipRect;
RECT_ENUM RectEnum;
ULONG Pixel = Brush->iSolidColor;
LONG delta;
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, CD_RIGHTUP, 0);
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
ClipRect = RectEnum.arcl;
delta = max(deltax, deltay);
i = 0;
error = delta/2;
while (i < delta && (ClipRect < RectEnum.arcl + RectEnum.c || EnumMore))
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, CD_RIGHTUP, 0);
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
ClipRect = RectEnum.arcl;
delta = max(deltax, deltay);
i = 0;
error = delta / 2;
while (i < delta && (ClipRect < RectEnum.arcl + RectEnum.c || EnumMore))
{
while ((ClipRect < RectEnum.arcl + RectEnum.c
&& (y < ClipRect->top
|| (y < ClipRect->bottom && ClipRect->right <= x)))
|| EnumMore)
{
if (RectEnum.arcl + RectEnum.c <= ClipRect)
{
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
ClipRect = RectEnum.arcl;
}
else
{
ClipRect++;
}
}
if (ClipRect < RectEnum.arcl + RectEnum.c)
{
if (ClipRect->left <= x && y < ClipRect->bottom)
{
vgaPutPixel(x, y, Pixel);
}
if (deltax < deltay)
{
y--;
error = error + deltax;
if (deltay <= error)
{
x++;
error = error - deltay;
}
}
else
{
x++;
error = error + deltay;
if (deltax <= error)
{
y--;
error = error - deltax;
}
}
i++;
}
while ((ClipRect < RectEnum.arcl + RectEnum.c
&& (y < ClipRect->top
|| (y < ClipRect->bottom && ClipRect->right <= x)))
|| EnumMore)
{
if (RectEnum.arcl + RectEnum.c <= ClipRect)
{
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
ClipRect = RectEnum.arcl;
}
else
{
ClipRect++;
}
}
if (ClipRect < RectEnum.arcl + RectEnum.c)
{
if (ClipRect->left <= x && y < ClipRect->bottom)
vgaPutPixel(x, y, Pixel);
if (deltax < deltay)
{
y--;
error = error + deltax;
if (deltay <= error)
{
x++;
error = error - deltay;
}
}
else
{
x++;
error = error + deltay;
if (deltax <= error)
{
y--;
error = error - deltax;
}
}
i++;
}
}
}
static void FASTCALL
vgaNEtoSW(CLIPOBJ* Clip, BRUSHOBJ* Brush, LONG x, LONG y, LONG deltax, LONG deltay)
vgaNEtoSW(
IN CLIPOBJ* Clip,
IN BRUSHOBJ* Brush,
IN LONG x,
IN LONG y,
IN LONG deltax,
IN LONG deltay)
{
int i;
int error;
BOOLEAN EnumMore;
PRECTL ClipRect;
RECT_ENUM RectEnum;
ULONG Pixel = Brush->iSolidColor;
LONG delta;
int i;
int error;
BOOLEAN EnumMore;
PRECTL ClipRect;
RECT_ENUM RectEnum;
ULONG Pixel = Brush->iSolidColor;
LONG delta;
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, CD_LEFTDOWN, 0);
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
ClipRect = RectEnum.arcl;
delta = max(deltax, deltay);
i = 0;
error = delta/2;
while (i < delta && (ClipRect < RectEnum.arcl + RectEnum.c || EnumMore))
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, CD_LEFTDOWN, 0);
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
ClipRect = RectEnum.arcl;
delta = max(deltax, deltay);
i = 0;
error = delta / 2;
while (i < delta && (ClipRect < RectEnum.arcl + RectEnum.c || EnumMore))
{
while ((ClipRect < RectEnum.arcl + RectEnum.c
&& (ClipRect->bottom <= y
|| (ClipRect->top <= y && x < ClipRect->left)))
|| EnumMore)
{
if (RectEnum.arcl + RectEnum.c <= ClipRect)
{
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
ClipRect = RectEnum.arcl;
}
else
{
ClipRect++;
}
}
if (ClipRect < RectEnum.arcl + RectEnum.c)
{
if (x < ClipRect->right && ClipRect->top <= y)
{
vgaPutPixel(x, y, Pixel);
}
if (deltax < deltay)
{
y++;
error = error + deltax;
if (deltay <= error)
{
x--;
error = error - deltay;
}
}
else
{
x--;
error = error + deltay;
if (deltax <= error)
{
y++;
error = error - deltax;
}
}
i++;
}
while ((ClipRect < RectEnum.arcl + RectEnum.c
&& (ClipRect->bottom <= y
|| (ClipRect->top <= y && x < ClipRect->left)))
|| EnumMore)
{
if (RectEnum.arcl + RectEnum.c <= ClipRect)
{
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
ClipRect = RectEnum.arcl;
}
else
{
ClipRect++;
}
}
if (ClipRect < RectEnum.arcl + RectEnum.c)
{
if (x < ClipRect->right && ClipRect->top <= y)
vgaPutPixel(x, y, Pixel);
if (deltax < deltay)
{
y++;
error = error + deltax;
if (deltay <= error)
{
x--;
error = error - deltay;
}
}
else
{
x--;
error = error + deltay;
if (deltax <= error)
{
y++;
error = error - deltax;
}
}
i++;
}
}
}
static void FASTCALL
vgaSEtoNW(CLIPOBJ* Clip, BRUSHOBJ* Brush, LONG x, LONG y, LONG deltax, LONG deltay)
vgaSEtoNW(
IN CLIPOBJ* Clip,
IN BRUSHOBJ* Brush,
IN LONG x,
IN LONG y,
IN LONG deltax,
IN LONG deltay)
{
int i;
int error;
BOOLEAN EnumMore;
PRECTL ClipRect;
RECT_ENUM RectEnum;
ULONG Pixel = Brush->iSolidColor;
LONG delta;
int i;
int error;
BOOLEAN EnumMore;
PRECTL ClipRect;
RECT_ENUM RectEnum;
ULONG Pixel = Brush->iSolidColor;
LONG delta;
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, CD_LEFTUP, 0);
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
ClipRect = RectEnum.arcl;
delta = max(deltax, deltay);
i = 0;
error = delta/2;
while (i < delta && (ClipRect < RectEnum.arcl + RectEnum.c || EnumMore))
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, CD_LEFTUP, 0);
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
ClipRect = RectEnum.arcl;
delta = max(deltax, deltay);
i = 0;
error = delta / 2;
while (i < delta && (ClipRect < RectEnum.arcl + RectEnum.c || EnumMore))
{
while ((ClipRect < RectEnum.arcl + RectEnum.c
&& (y < ClipRect->top
|| (y < ClipRect->bottom && x < ClipRect->left)))
|| EnumMore)
{
if (RectEnum.arcl + RectEnum.c <= ClipRect)
{
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
ClipRect = RectEnum.arcl;
}
else
{
ClipRect++;
}
}
if (ClipRect < RectEnum.arcl + RectEnum.c)
{
if (x < ClipRect->right && y < ClipRect->bottom)
{
vgaPutPixel(x, y, Pixel);
}
if (deltax < deltay)
{
y--;
error = error + deltax;
if (deltay <= error)
{
x--;
error = error - deltay;
}
}
else
{
x--;
error = error + deltay;
if (deltax <= error)
{
y--;
error = error - deltax;
}
}
i++;
}
while ((ClipRect < RectEnum.arcl + RectEnum.c
&& (y < ClipRect->top
|| (y < ClipRect->bottom && x < ClipRect->left)))
|| EnumMore)
{
if (RectEnum.arcl + RectEnum.c <= ClipRect)
{
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
ClipRect = RectEnum.arcl;
}
else
{
ClipRect++;
}
}
if (ClipRect < RectEnum.arcl + RectEnum.c)
{
if (x < ClipRect->right && y < ClipRect->bottom)
vgaPutPixel(x, y, Pixel);
if (deltax < deltay)
{
y--;
error = error + deltax;
if (deltay <= error)
{
x--;
error = error - deltay;
}
}
else
{
x--;
error = error + deltay;
if (deltax <= error)
{
y--;
error = error - deltax;
}
}
i++;
}
}
}
@@ -290,124 +294,114 @@ vgaSEtoNW(CLIPOBJ* Clip, BRUSHOBJ* Brush, LONG x, LONG y, LONG deltax, LONG delt
* FIXME: Non-solid Brush
*/
BOOL APIENTRY
DrvLineTo(SURFOBJ *DestObj,
CLIPOBJ *Clip,
BRUSHOBJ *Brush,
LONG x1,
LONG y1,
LONG x2,
LONG y2,
RECTL *RectBounds,
MIX mix)
DrvLineTo(
IN SURFOBJ *DestObj,
IN CLIPOBJ *Clip,
IN BRUSHOBJ *Brush,
IN LONG x1,
IN LONG y1,
IN LONG x2,
IN LONG y2,
IN RECTL *RectBounds,
IN MIX mix)
{
LONG x, y, deltax, deltay, xchange, ychange, hx, vy;
ULONG i;
ULONG Pixel = Brush->iSolidColor;
RECT_ENUM RectEnum;
BOOL EnumMore;
LONG x, y, deltax, deltay, xchange, ychange, hx, vy;
ULONG i;
ULONG Pixel = Brush->iSolidColor;
RECT_ENUM RectEnum;
BOOL EnumMore;
x = x1;
y = y1;
deltax = x2 - x1;
deltay = y2 - y1;
x = x1;
y = y1;
deltax = x2 - x1;
deltay = y2 - y1;
if (deltax < 0)
if (deltax < 0)
{
xchange = -1;
deltax = - deltax;
hx = x2+1;
//x--;
xchange = -1;
deltax = - deltax;
hx = x2+1;
//x--;
}
else
else
{
xchange = 1;
hx = x1;
xchange = 1;
hx = x1;
}
if (deltay < 0)
if (deltay < 0)
{
ychange = -1;
deltay = - deltay;
vy = y2+1;
//y--;
ychange = -1;
deltay = - deltay;
vy = y2+1;
//y--;
}
else
else
{
ychange = 1;
vy = y1;
ychange = 1;
vy = y1;
}
if (y1 == y2)
if (y1 == y2)
{
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, CD_RIGHTDOWN, 0);
do
{
EnumMore = CLIPOBJ_bEnum(Clip, sizeof(RectEnum), (PVOID) &RectEnum);
for (i = 0; i < RectEnum.c && RectEnum.arcl[i].top <= y1; i++)
{
if (y1 < RectEnum.arcl[i].bottom &&
RectEnum.arcl[i].left <= hx + deltax &&
hx < RectEnum.arcl[i].right)
{
vgaHLine(max(hx, RectEnum.arcl[i].left), y1,
min(hx + deltax, RectEnum.arcl[i].right)
-max(hx, RectEnum.arcl[i].left), Pixel);
}
}
}
while (EnumMore);
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, CD_RIGHTDOWN, 0);
do
{
EnumMore = CLIPOBJ_bEnum(Clip, sizeof(RectEnum), (PVOID) &RectEnum);
for (i = 0; i < RectEnum.c && RectEnum.arcl[i].top <= y1; i++)
{
if (y1 < RectEnum.arcl[i].bottom &&
RectEnum.arcl[i].left <= hx + deltax &&
hx < RectEnum.arcl[i].right)
{
vgaHLine(max(hx, RectEnum.arcl[i].left), y1,
min(hx + deltax, RectEnum.arcl[i].right)
-max(hx, RectEnum.arcl[i].left), Pixel);
}
}
} while (EnumMore);
}
else if (x1 == x2)
else if (x1 == x2)
{
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, CD_RIGHTDOWN, 0);
do
{
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
for (i = 0; i < RectEnum.c; i++)
{
if (RectEnum.arcl[i].left <= x1 &&
x1 < RectEnum.arcl[i].right &&
RectEnum.arcl[i].top <= vy + deltay &&
vy < RectEnum.arcl[i].bottom)
{
vgaVLine(x1,
max(vy, RectEnum.arcl[i].top),
min(vy + deltay, RectEnum.arcl[i].bottom)
- max(vy, RectEnum.arcl[i].top),
Pixel);
}
}
}
while (EnumMore);
CLIPOBJ_cEnumStart(Clip, FALSE, CT_RECTANGLES, CD_RIGHTDOWN, 0);
do
{
EnumMore = CLIPOBJ_bEnum(Clip, (ULONG) sizeof(RectEnum), (PVOID) &RectEnum);
for (i = 0; i < RectEnum.c; i++)
{
if (RectEnum.arcl[i].left <= x1 &&
x1 < RectEnum.arcl[i].right &&
RectEnum.arcl[i].top <= vy + deltay &&
vy < RectEnum.arcl[i].bottom)
{
vgaVLine(x1,
max(vy, RectEnum.arcl[i].top),
min(vy + deltay, RectEnum.arcl[i].bottom)
- max(vy, RectEnum.arcl[i].top),
Pixel);
}
}
} while (EnumMore);
}
else
else
{
if (0 < xchange)
{
if (0 < ychange)
{
vgaNWtoSE(Clip, Brush, x, y, deltax, deltay);
}
else
{
vgaSWtoNE(Clip, Brush, x, y, deltax, deltay);
}
}
else
{
if (0 < ychange)
{
vgaNEtoSW(Clip, Brush, x, y, deltax, deltay);
}
else
{
vgaSEtoNW(Clip, Brush, x, y, deltax, deltay);
}
}
if (0 < xchange)
{
if (0 < ychange)
vgaNWtoSE(Clip, Brush, x, y, deltax, deltay);
else
vgaSWtoNE(Clip, Brush, x, y, deltax, deltay);
}
else
{
if (0 < ychange)
vgaNEtoSW(Clip, Brush, x, y, deltax, deltay);
else
vgaSEtoNW(Clip, Brush, x, y, deltax, deltay);
}
}
return TRUE;
return TRUE;
}
/* EOF */
@@ -1,25 +1,9 @@
/*
* ReactOS kernel
* Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* PROJECT: ReactOS VGA16 display driver
* FILE: drivers/dd/vga/display/objects/offscreen.c
* PURPOSE: Manages off-screen video memory.
* PROJECT: ReactOS VGA display driver
* LICENSE: GPL - See COPYING in the top level directory
* FILE: drivers/video/displays/vga/objects/offscreen.c
* PURPOSE: Manages off-screen video memory
* PROGRAMMERS: Copyright (C) 1998-2001 ReactOS Team
*/
/* INCLUDES ******************************************************************/
@@ -35,158 +19,161 @@ static LIST_ENTRY SavedBitsList;
/* FUNCTIONS *****************************************************************/
VOID
VGADDI_BltFromSavedScreenBits(ULONG DestX,
ULONG DestY,
PSAVED_SCREEN_BITS Src,
ULONG SizeX,
ULONG SizeY)
VGADDI_BltFromSavedScreenBits(
IN ULONG DestX,
IN ULONG DestY,
IN PSAVED_SCREEN_BITS Src,
IN ULONG SizeX,
IN ULONG SizeY)
{
PUCHAR DestOffset;
PUCHAR SrcOffset;
ULONG i, j;
PUCHAR DestOffset;
PUCHAR SrcOffset;
ULONG i, j;
/* Select write mode 1. */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 5);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 1);
/* Select write mode 1. */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 5);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 1);
SrcOffset = (PUCHAR)vidmem + Src->Offset;
for (i = 0; i < SizeY; i++)
SrcOffset = (PUCHAR)vidmem + Src->Offset;
for (i = 0; i < SizeY; i++)
{
DestOffset = (PUCHAR)vidmem + (i + DestY) * 80 + (DestX >> 3);
//FIXME: in the loop below we should treat the case when SizeX is not divisible by 8, i.e. partial bytes
for (j = 0; j < SizeX>>3; j++, SrcOffset++, DestOffset++)
{
(VOID)READ_REGISTER_UCHAR(SrcOffset);
WRITE_REGISTER_UCHAR(DestOffset, 0);
}
DestOffset = (PUCHAR)vidmem + (i + DestY) * 80 + (DestX >> 3);
//FIXME: in the loop below we should treat the case when SizeX is not divisible by 8, i.e. partial bytes
for (j = 0; j < SizeX>>3; j++, SrcOffset++, DestOffset++)
{
(VOID)READ_REGISTER_UCHAR(SrcOffset);
WRITE_REGISTER_UCHAR(DestOffset, 0);
}
}
/* Select write mode 2. */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 5);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 2);
/* Select write mode 2. */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 5);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 2);
}
VOID
VGADDI_BltToSavedScreenBits(PSAVED_SCREEN_BITS Dest,
ULONG SourceX,
ULONG SourceY,
ULONG SizeX,
ULONG SizeY)
VGADDI_BltToSavedScreenBits(
IN PSAVED_SCREEN_BITS Dest,
IN ULONG SourceX,
IN ULONG SourceY,
IN ULONG SizeX,
IN ULONG SizeY)
{
PUCHAR DestOffset;
PUCHAR SrcOffset;
ULONG i, j;
PUCHAR DestOffset;
PUCHAR SrcOffset;
ULONG i, j;
/* Select write mode 1. */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 5);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 1);
/* Select write mode 1. */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 5);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 1);
DestOffset = (PUCHAR)vidmem + Dest->Offset;
DestOffset = (PUCHAR)vidmem + Dest->Offset;
for (i = 0; i < SizeY; i++)
for (i = 0; i < SizeY; i++)
{
SrcOffset = (PUCHAR)vidmem + (SourceY + i) * 80 + (SourceX >> 3);
//FIXME: in the loop below we should treat the case when SizeX is not divisible by 8, i.e. partial bytes
for (j = 0; j < SizeX>>3; j++, SrcOffset++, DestOffset++)
{
(VOID)READ_REGISTER_UCHAR(SrcOffset);
WRITE_REGISTER_UCHAR(DestOffset, 0);
}
SrcOffset = (PUCHAR)vidmem + (SourceY + i) * 80 + (SourceX >> 3);
//FIXME: in the loop below we should treat the case when SizeX is not divisible by 8, i.e. partial bytes
for (j = 0; j < SizeX>>3; j++, SrcOffset++, DestOffset++)
{
(VOID)READ_REGISTER_UCHAR(SrcOffset);
WRITE_REGISTER_UCHAR(DestOffset, 0);
}
}
/* Select write mode 2. */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 5);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 2);
/* Select write mode 2. */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 5);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 2);
}
VOID
VGADDI_FreeSavedScreenBits(PSAVED_SCREEN_BITS SavedBits)
{
SavedBits->Free = TRUE;
SavedBits->Free = TRUE;
if (SavedBits->ListEntry.Blink != &SavedBitsList)
if (SavedBits->ListEntry.Blink != &SavedBitsList)
{
PSAVED_SCREEN_BITS Previous;
PSAVED_SCREEN_BITS Previous;
Previous = CONTAINING_RECORD(SavedBits->ListEntry.Blink,
SAVED_SCREEN_BITS, ListEntry);
if (Previous->Free)
{
Previous->Size += SavedBits->Size;
RemoveEntryList(&SavedBits->ListEntry);
EngFreeMem(SavedBits);
SavedBits = Previous;
}
Previous = CONTAINING_RECORD(SavedBits->ListEntry.Blink,
SAVED_SCREEN_BITS, ListEntry);
if (Previous->Free)
{
Previous->Size += SavedBits->Size;
RemoveEntryList(&SavedBits->ListEntry);
EngFreeMem(SavedBits);
SavedBits = Previous;
}
}
if (SavedBits->ListEntry.Flink != &SavedBitsList)
if (SavedBits->ListEntry.Flink != &SavedBitsList)
{
PSAVED_SCREEN_BITS Next;
PSAVED_SCREEN_BITS Next;
Next = CONTAINING_RECORD(SavedBits->ListEntry.Flink, SAVED_SCREEN_BITS,
ListEntry);
if (Next->Free)
{
SavedBits->Size += Next->Size;
RemoveEntryList(&SavedBits->ListEntry);
EngFreeMem(SavedBits);
}
Next = CONTAINING_RECORD(SavedBits->ListEntry.Flink, SAVED_SCREEN_BITS,
ListEntry);
if (Next->Free)
{
SavedBits->Size += Next->Size;
RemoveEntryList(&SavedBits->ListEntry);
EngFreeMem(SavedBits);
}
}
}
PSAVED_SCREEN_BITS
VGADDI_AllocSavedScreenBits(ULONG Size)
{
PSAVED_SCREEN_BITS Current;
PLIST_ENTRY CurrentEntry;
PSAVED_SCREEN_BITS Best;
PSAVED_SCREEN_BITS New;
PSAVED_SCREEN_BITS Current;
PLIST_ENTRY CurrentEntry;
PSAVED_SCREEN_BITS Best;
PSAVED_SCREEN_BITS New;
Best = NULL;
CurrentEntry = SavedBitsList.Flink;
while (CurrentEntry != &SavedBitsList)
Best = NULL;
CurrentEntry = SavedBitsList.Flink;
while (CurrentEntry != &SavedBitsList)
{
Current = CONTAINING_RECORD(CurrentEntry, SAVED_SCREEN_BITS, ListEntry);
Current = CONTAINING_RECORD(CurrentEntry, SAVED_SCREEN_BITS, ListEntry);
if (Current->Free && Current->Size >= Size &&
(Best == NULL || (Current->Size - Size) < (Best->Size - Size)))
{
Best = Current;
}
if (Current->Free && Current->Size >= Size &&
(Best == NULL || (Current->Size - Size) < (Best->Size - Size)))
{
Best = Current;
}
CurrentEntry = CurrentEntry->Flink;
CurrentEntry = CurrentEntry->Flink;
}
if (Best == NULL)
if (!Best)
return NULL;
if (Best->Size == Size)
{
return(NULL);
Best->Free = FALSE;
return Best;
}
if (Best->Size == Size)
else
{
Best->Free = FALSE;
return(Best);
}
else
{
New = EngAllocMem(0, sizeof(SAVED_SCREEN_BITS), ALLOC_TAG);
New->Free = FALSE;
New->Offset = Best->Offset + Size;
New->Size = Size;
Best->Size -= Size;
InsertHeadList(&Best->ListEntry, &New->ListEntry);
return(New);
New = EngAllocMem(0, sizeof(SAVED_SCREEN_BITS), ALLOC_TAG);
New->Free = FALSE;
New->Offset = Best->Offset + Size;
New->Size = Size;
Best->Size -= Size;
InsertHeadList(&Best->ListEntry, &New->ListEntry);
return New;
}
}
VOID
VGADDI_InitializeOffScreenMem(ULONG Start, ULONG Length)
VGADDI_InitializeOffScreenMem(
IN ULONG Start,
IN ULONG Length)
{
PSAVED_SCREEN_BITS FreeBits;
PSAVED_SCREEN_BITS FreeBits;
InitializeListHead(&SavedBitsList);
InitializeListHead(&SavedBitsList);
FreeBits = EngAllocMem(0, sizeof(SAVED_SCREEN_BITS), ALLOC_TAG);
FreeBits->Free = TRUE;
FreeBits->Offset = Start;
FreeBits->Size = Length;
InsertHeadList(&SavedBitsList, &FreeBits->ListEntry);
FreeBits = EngAllocMem(0, sizeof(SAVED_SCREEN_BITS), ALLOC_TAG);
FreeBits->Free = TRUE;
FreeBits->Offset = Start;
FreeBits->Size = Length;
InsertHeadList(&SavedBitsList, &FreeBits->ListEntry);
}
+201 -187
View File
@@ -1,3 +1,10 @@
/*
* PROJECT: ReactOS VGA display driver
* LICENSE: GPL - See COPYING in the top level directory
* FILE: drivers/video/displays/vga/objects/paint.c
* PURPOSE:
* PROGRAMMERS:
*/
#include "../vgaddi.h"
#include "../vgavideo/vgavideo.h"
@@ -7,235 +14,242 @@
BOOL VGADDIFillSolid(SURFOBJ *Surface, RECTL Dimensions, ULONG iColor)
{
int x, y, x2, y2, w, h, j;
ULONG offset, pre1;
ULONG orgpre1, orgx, midpre1, tmppre1;
int ileftpix, imidpix, irightpix;
/* double leftpix, midpix, rightpix;*/
UCHAR a;
int x, y, x2, y2, w, h, j;
ULONG offset, pre1;
ULONG orgpre1, orgx, midpre1, tmppre1;
int ileftpix, imidpix, irightpix;
/* double leftpix, midpix, rightpix;*/
UCHAR a;
// Swap dimensions so that x, y are at topmost left
if ( Dimensions.right < Dimensions.left )
{
x = Dimensions.right;
x2 = Dimensions.left;
}
else
{
x2 = Dimensions.right;
x = Dimensions.left;
}
if ( Dimensions.bottom < Dimensions.top )
{
y = Dimensions.bottom;
y2 = Dimensions.top;
}
else
{
y2 = Dimensions.bottom;
y = Dimensions.top;
}
/* Swap dimensions so that x, y are at topmost left */
if ( Dimensions.right < Dimensions.left )
{
x = Dimensions.right;
x2 = Dimensions.left;
}
else
{
x2 = Dimensions.right;
x = Dimensions.left;
}
if ( Dimensions.bottom < Dimensions.top )
{
y = Dimensions.bottom;
y2 = Dimensions.top;
}
else
{
y2 = Dimensions.bottom;
y = Dimensions.top;
}
// Calculate the width and height
w = x2 - x;
h = y2 - y;
/* Calculate the width and height */
w = x2 - x;
h = y2 - y;
DPRINT("VGADDIFillSolid: x:%d, y:%d, w:%d, h:%d\n", x, y, w, h);
DPRINT("VGADDIFillSolid: x:%d, y:%d, w:%d, h:%d\n", x, y, w, h);
// Calculate the starting offset
offset = xconv[x]+y80[y];
/* Calculate the starting offset */
offset = xconv[x]+y80[y];
// Make a note of original x
orgx = x;
/* Make a note of original x */
orgx = x;
// Calculate the left mask pixels, middle bytes and right mask pixel
ileftpix = 7 - mod8(x-1);
irightpix = mod8(x+w);
imidpix = (w-ileftpix-irightpix) / 8;
/* Calculate the left mask pixels, middle bytes and right mask pixel */
ileftpix = 7 - mod8(x-1);
irightpix = mod8(x+w);
imidpix = (w-ileftpix-irightpix) / 8;
pre1 = xconv[(x-1)&~7] + y80[y];
orgpre1=pre1;
pre1 = xconv[(x-1)&~7] + y80[y];
orgpre1=pre1;
// check for overlap ( very horizontally skinny rect )
if ( (ileftpix+irightpix) > w )
{
int mask = startmasks[ileftpix] & endmasks[irightpix];
/* check for overlap ( very horizontally skinny rect ) */
if ( (ileftpix+irightpix) > w )
{
int mask = startmasks[ileftpix] & endmasks[irightpix];
WRITE_PORT_UCHAR((PUCHAR)GRA_I,0x08); // set the mask
WRITE_PORT_UCHAR((PUCHAR)GRA_D,mask);
WRITE_PORT_UCHAR((PUCHAR)GRA_I,0x08); // set the mask
WRITE_PORT_UCHAR((PUCHAR)GRA_D,mask);
tmppre1 = pre1;
for ( j = y; j < y+h; j++ )
{
a = READ_REGISTER_UCHAR ( vidmem+tmppre1 );
WRITE_REGISTER_UCHAR ( vidmem+tmppre1, iColor );
tmppre1 += 80;
}
return TRUE;
}
if ( ileftpix > 0 )
{
/* Write left pixels */
WRITE_PORT_UCHAR((PUCHAR)GRA_I,0x08); // set the mask
WRITE_PORT_UCHAR((PUCHAR)GRA_D,startmasks[ileftpix]);
tmppre1 = pre1;
for ( j = y; j < y+h; j++ )
{
a = READ_REGISTER_UCHAR(vidmem + tmppre1);
WRITE_REGISTER_UCHAR(vidmem + tmppre1, iColor);
tmppre1 += 80;
}
/* Prepare new x for the middle */
x = orgx + 8;
}
if ( imidpix > 0 )
{
midpre1=xconv[x] + y80[y];
/* Set mask to all pixels in byte */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x08);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0xff);
for ( j = y; j < y+h; j++ )
{
memset(vidmem+midpre1, iColor, imidpix); // write middle pixels, no need to read in latch because of the width
midpre1 += 80;
}
}
x = orgx + w - irightpix;
pre1 = xconv[x] + y80[y];
/* Write right pixels */
WRITE_PORT_UCHAR((PUCHAR)GRA_I,0x08); // set the mask bits
WRITE_PORT_UCHAR((PUCHAR)GRA_D,endmasks[irightpix]);
tmppre1 = pre1;
for ( j = y; j < y+h; j++ )
{
a = READ_REGISTER_UCHAR ( vidmem+tmppre1 );
WRITE_REGISTER_UCHAR ( vidmem+tmppre1, iColor );
tmppre1 += 80;
a = READ_REGISTER_UCHAR(vidmem + pre1);
WRITE_REGISTER_UCHAR(vidmem + pre1, iColor);
pre1 += 80;
}
return TRUE;
}
if ( ileftpix > 0 )
{
// Write left pixels
WRITE_PORT_UCHAR((PUCHAR)GRA_I,0x08); // set the mask
WRITE_PORT_UCHAR((PUCHAR)GRA_D,startmasks[ileftpix]);
tmppre1 = pre1;
for ( j = y; j < y+h; j++ )
{
a = READ_REGISTER_UCHAR(vidmem + tmppre1);
WRITE_REGISTER_UCHAR(vidmem + tmppre1, iColor);
tmppre1 += 80;
}
// Prepare new x for the middle
x = orgx + 8;
}
if ( imidpix > 0 )
{
midpre1=xconv[x] + y80[y];
// Set mask to all pixels in byte
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x08);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0xff);
for ( j = y; j < y+h; j++ )
{
memset(vidmem+midpre1, iColor, imidpix); // write middle pixels, no need to read in latch because of the width
midpre1 += 80;
}
}
x = orgx + w - irightpix;
pre1 = xconv[x] + y80[y];
// Write right pixels
WRITE_PORT_UCHAR((PUCHAR)GRA_I,0x08); // set the mask bits
WRITE_PORT_UCHAR((PUCHAR)GRA_D,endmasks[irightpix]);
for ( j = y; j < y+h; j++ )
{
a = READ_REGISTER_UCHAR(vidmem + pre1);
WRITE_REGISTER_UCHAR(vidmem + pre1, iColor);
pre1 += 80;
}
return TRUE;
}
BOOL VGADDIPaintRgn(SURFOBJ *Surface, CLIPOBJ *ClipRegion, ULONG iColor, MIX Mix,
BRUSHINST *BrushInst, POINTL *BrushPoint)
BOOL VGADDIPaintRgn(
IN SURFOBJ *Surface,
IN CLIPOBJ *ClipRegion,
IN ULONG iColor,
IN MIX Mix,
IN BRUSHINST *BrushInst,
IN POINTL *BrushPoint)
{
RECT_ENUM RectEnum;
BOOL EnumMore;
RECT_ENUM RectEnum;
BOOL EnumMore;
DPRINT("VGADDIPaintRgn: iMode: %d, iDComplexity: %d\n Color:%d\n", ClipRegion->iMode, ClipRegion->iDComplexity, iColor);
switch(ClipRegion->iMode) {
DPRINT("VGADDIPaintRgn: iMode: %d, iDComplexity: %d\n Color:%d\n", ClipRegion->iMode, ClipRegion->iDComplexity, iColor);
switch(ClipRegion->iMode)
{
case TC_RECTANGLES:
case TC_RECTANGLES:
/* Rectangular clipping can be handled without enumeration.
Note that trivial clipping is not possible, since the clipping
region defines the area to fill */
/* Rectangular clipping can be handled without enumeration.
Note that trivial clipping is not possible, since the clipping
region defines the area to fill */
if (ClipRegion->iDComplexity == DC_RECT)
{
DPRINT("VGADDIPaintRgn Rect:%d %d %d %d\n", ClipRegion->rclBounds.left, ClipRegion->rclBounds.top, ClipRegion->rclBounds.right, ClipRegion->rclBounds.bottom);
VGADDIFillSolid(Surface, ClipRegion->rclBounds, iColor);
}
else
{
/* Enumerate all the rectangles and draw them */
if (ClipRegion->iDComplexity == DC_RECT)
{
DPRINT("VGADDIPaintRgn Rect:%d %d %d %d\n", ClipRegion->rclBounds.left, ClipRegion->rclBounds.top, ClipRegion->rclBounds.right, ClipRegion->rclBounds.bottom);
VGADDIFillSolid(Surface, ClipRegion->rclBounds, iColor);
} else {
/* Enumerate all the rectangles and draw them */
CLIPOBJ_cEnumStart(ClipRegion, FALSE, CT_RECTANGLES, CD_ANY, 0);
CLIPOBJ_cEnumStart(ClipRegion, FALSE, CT_RECTANGLES, CD_ANY, 0);
do
{
UINT i;
EnumMore = CLIPOBJ_bEnum(ClipRegion, sizeof(RectEnum), (PVOID) &RectEnum);
DPRINT("EnumMore: %d, count: %d\n", EnumMore, RectEnum.c);
for( i=0; i<RectEnum.c; i++)
{
DPRINT("VGADDI enum Rect:%d %d %d %d\n", RectEnum.arcl[i].left, RectEnum.arcl[i].top, RectEnum.arcl[i].right, RectEnum.arcl[i].bottom);
VGADDIFillSolid(Surface, RectEnum.arcl[i], iColor);
}
} while (EnumMore);
}
return TRUE;
do {
UINT i;
EnumMore = CLIPOBJ_bEnum(ClipRegion, sizeof(RectEnum), (PVOID) &RectEnum);
DPRINT("EnumMore: %d, count: %d\n", EnumMore, RectEnum.c);
for( i=0; i<RectEnum.c; i++){
DPRINT("VGADDI enum Rect:%d %d %d %d\n", RectEnum.arcl[i].left, RectEnum.arcl[i].top, RectEnum.arcl[i].right, RectEnum.arcl[i].bottom);
VGADDIFillSolid(Surface, RectEnum.arcl[i], iColor);
}
} while (EnumMore);
}
return(TRUE);
default:
return(FALSE);
}
default:
return FALSE;
}
}
BOOL APIENTRY
DrvPaint(IN SURFOBJ *Surface,
IN CLIPOBJ *ClipRegion,
IN BRUSHOBJ *Brush,
IN POINTL *BrushOrigin,
IN MIX Mix)
DrvPaint(
IN SURFOBJ *Surface,
IN CLIPOBJ *ClipRegion,
IN BRUSHOBJ *Brush,
IN POINTL *BrushOrigin,
IN MIX Mix)
{
ULONG iSolidColor;
ULONG iSolidColor;
iSolidColor = Brush->iSolidColor; // FIXME: Realizations and the like
iSolidColor = Brush->iSolidColor; // FIXME: Realizations and the like
// If the foreground and background Mixes are the same,
// (LATER or if there's no brush mask)
// then see if we can use the solid brush accelerators
// If the foreground and background Mixes are the same,
// (LATER or if there's no brush mask)
// then see if we can use the solid brush accelerators
// FIXME: Put in the mix switch below
// Brush color parameter doesn't matter for these rops
return(VGADDIPaintRgn(Surface, ClipRegion, iSolidColor, Mix, NULL, BrushOrigin));
// FIXME: Put in the mix switch below
// Brush color parameter doesn't matter for these rops
return(VGADDIPaintRgn(Surface, ClipRegion, iSolidColor, Mix, NULL, BrushOrigin));
if ((Mix & 0xFF) == ((Mix >> 8) & 0xFF))
{
switch (Mix & 0xFF)
{
case 0:
break;
if ((Mix & 0xFF) == ((Mix >> 8) & 0xFF))
{
switch (Mix & 0xFF)
{
case 0:
break;
// FIXME: Implement all these millions of ROPs
// For now we don't support brushes -- everything is solid
// FIXME: Implement all these millions of ROPs
// For now we don't support brushes -- everything is solid
case R2_MASKNOTPEN:
case R2_NOTCOPYPEN:
case R2_XORPEN:
case R2_MASKPEN:
case R2_NOTXORPEN:
case R2_MERGENOTPEN:
case R2_COPYPEN:
case R2_MERGEPEN:
case R2_NOTMERGEPEN:
case R2_MASKPENNOT:
case R2_NOTMASKPEN:
case R2_MERGEPENNOT:
case R2_MASKNOTPEN:
case R2_NOTCOPYPEN:
case R2_XORPEN:
case R2_MASKPEN:
case R2_NOTXORPEN:
case R2_MERGENOTPEN:
case R2_COPYPEN:
case R2_MERGEPEN:
case R2_NOTMERGEPEN:
case R2_MASKPENNOT:
case R2_NOTMASKPEN:
case R2_MERGEPENNOT:
// Rops that are implicit solid colors
case R2_NOT:
case R2_WHITE:
case R2_BLACK:
// Rops that are implicit solid colors
case R2_NOT:
case R2_WHITE:
case R2_BLACK:
// FIXME: The Paint region belongs HERE
// FIXME: The Paint region belongs HERE
case R2_NOP:
return(TRUE);
case R2_NOP:
return TRUE;
default:
break;
}
}
default:
break;
}
}
/*
doBitBlt:
// If VGADDIPaint can't do it, VGADDIBitBlt can.. or it might just loop back
// here and we have a nice infinite loop
// If VGADDIPaint can't do it, VGADDIBitBlt can.. or it might just loop back
// here and we have a nice infinite loop
return( VGADDIBitBlt(Surface, (SURFOBJ *)NULL, (SURFOBJ *)NULL, ClipRegion,
(XLATEOBJ *)NULL, &ClipRegion->rclBounds,
NULL, (POINTL *)NULL, Brush, BrushOrigin,
NULL) ); UNIMPLEMENTED */
return( VGADDIBitBlt(Surface, (SURFOBJ *)NULL, (SURFOBJ *)NULL, ClipRegion,
(XLATEOBJ *)NULL, &ClipRegion->rclBounds,
NULL, (POINTL *)NULL, Brush, BrushOrigin,
NULL) ); UNIMPLEMENTED */
}
@@ -1,25 +1,9 @@
/*
* ReactOS kernel
* Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* PROJECT: ReactOS VGA16 display driver
* FILE: drivers/dd/vga/display/objects/pointer.c
* PURPOSE: Draws the mouse pointer.
* PROJECT: ReactOS VGA display driver
* LICENSE: GPL - See COPYING in the top level directory
* FILE: drivers/video/displays/vga/objects/pointer.c
* PURPOSE: Draws the mouse pointer
* PROGRAMMERS: Copyright (C) 1998-2001 ReactOS Team
*/
/* INCLUDES ******************************************************************/
@@ -38,356 +22,355 @@ static VOID VGADDI_ShowCursor(PPDEV ppdev, PRECTL prcl);
/* FUNCTIONS *****************************************************************/
VOID
VGADDI_BltPointerToVGA(LONG StartX, LONG StartY, ULONG SizeX,
ULONG SizeY, PUCHAR MaskBits, ULONG MaskPitch, ULONG MaskOp)
VGADDI_BltPointerToVGA(
IN LONG StartX,
IN LONG StartY,
IN ULONG SizeX,
IN ULONG SizeY,
IN PUCHAR MaskBits,
IN ULONG MaskPitch,
IN ULONG MaskOp)
{
ULONG DestX, EndX, DestY, EndY;
UCHAR Mask;
PUCHAR Video;
PUCHAR Src;
UCHAR SrcValue;
ULONG i, j;
ULONG Left;
ULONG Length;
LONG Bits;
ULONG DestX, EndX, DestY, EndY;
UCHAR Mask;
PUCHAR Video;
PUCHAR Src;
UCHAR SrcValue;
ULONG i, j;
ULONG Left;
ULONG Length;
LONG Bits;
DestX = StartX < 0 ? 0 : StartX;
DestY = StartY < 0 ? 0 : StartY;
EndX = StartX + SizeX;
EndY = StartY + SizeY;
DestX = StartX < 0 ? 0 : StartX;
DestY = StartY < 0 ? 0 : StartY;
EndX = StartX + SizeX;
EndY = StartY + SizeY;
/* Set write mode zero. */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 5);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0);
/* Set write mode zero. */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 5);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0);
/* Select raster op. */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 3);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, MaskOp);
/* Select raster op. */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 3);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, MaskOp);
if ((DestX % 8) != 0)
if ((DestX % 8) != 0)
{
/* Disable writes to pixels outside of the destination rectangle. */
Mask = (1 << (8 - (DestX % 8))) - 1;
if ((EndX - DestX) < (8 - (DestX % 8)))
{
Mask &= ~((1 << (8 - (EndX % 8))) - 1);
}
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x8);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, Mask);
/* Disable writes to pixels outside of the destination rectangle. */
Mask = (1 << (8 - (DestX % 8))) - 1;
if ((EndX - DestX) < (8 - (DestX % 8)))
{
Mask &= ~((1 << (8 - (EndX % 8))) - 1);
}
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x8);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, Mask);
/* Write the mask. */
Video = (PUCHAR)vidmem + DestY * 80 + (DestX >> 3);
Src = MaskBits + (SizeY - (DestY - StartY)) * MaskPitch;
for (i = DestY; i < EndY; i++, Video += 80)
{
Src -= MaskPitch;
SrcValue = (*Src) >> (DestX % 8);
(VOID)READ_REGISTER_UCHAR(Video);
WRITE_REGISTER_UCHAR(Video, SrcValue);
}
/* Write the mask. */
Video = (PUCHAR)vidmem + DestY * 80 + (DestX >> 3);
Src = MaskBits + (SizeY - (DestY - StartY)) * MaskPitch;
for (i = DestY; i < EndY; i++, Video += 80)
{
Src -= MaskPitch;
SrcValue = (*Src) >> (DestX % 8);
(VOID)READ_REGISTER_UCHAR(Video);
WRITE_REGISTER_UCHAR(Video, SrcValue);
}
}
/* Enable writes to all pixels. */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x8);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0xFF);
/* Enable writes to all pixels. */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x8);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0xFF);
/* Have we finished. */
if ((EndX - DestX) < (8 - (DestX % 8)))
/* Have we finished. */
if ((EndX - DestX) < (8 - (DestX % 8)))
return;
/* Fill any whole rows of eight pixels. */
Left = (DestX + 7) & ~0x7;
Length = (EndX >> 3) - (Left >> 3);
Bits = StartX;
while (Bits < 0)
Bits += 8;
Bits = Bits % 8;
for (i = DestY; i < EndY; i++)
{
return;
Video = (PUCHAR)vidmem + i * 80 + (Left >> 3);
Src = MaskBits + (EndY - i - 1) * MaskPitch + ((DestX - StartX) >> 3);
for (j = 0; j < Length; j++, Video++, Src++)
{
if (Bits != 0)
{
SrcValue = (Src[0] << (8 - Bits));
SrcValue |= (Src[1] >> Bits);
}
else
{
SrcValue = Src[0];
}
(VOID)READ_REGISTER_UCHAR(Video);
WRITE_REGISTER_UCHAR(Video, SrcValue);
}
}
/* Fill any whole rows of eight pixels. */
Left = (DestX + 7) & ~0x7;
Length = (EndX >> 3) - (Left >> 3);
Bits = StartX;
while (Bits < 0)
/* Fill any pixels on the right which don't fall into a complete row. */
if ((EndX % 8) != 0)
{
Bits += 8;
}
Bits = Bits % 8;
for (i = DestY; i < EndY; i++)
{
Video = (PUCHAR)vidmem + i * 80 + (Left >> 3);
Src = MaskBits + (EndY - i - 1) * MaskPitch + ((DestX - StartX) >> 3);
for (j = 0; j < Length; j++, Video++, Src++)
{
if (Bits != 0)
{
SrcValue = (Src[0] << (8 - Bits));
SrcValue |= (Src[1] >> Bits);
}
else
{
SrcValue = Src[0];
}
(VOID)READ_REGISTER_UCHAR(Video);
WRITE_REGISTER_UCHAR(Video, SrcValue);
}
/* Disable writes to pixels outside the destination rectangle. */
Mask = ~((1 << (8 - (EndX % 8))) - 1);
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x8);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, Mask);
Video = (PUCHAR)vidmem + DestY * 80 + (EndX >> 3);
Src = MaskBits + (SizeY - (DestY - StartY)) * MaskPitch + (SizeX >> 3) - 1;
for (i = DestY; i < EndY; i++, Video += 80)
{
Src -= MaskPitch;
SrcValue = (Src[0] << (8 - Bits));
(VOID)READ_REGISTER_UCHAR(Video);
WRITE_REGISTER_UCHAR(Video, SrcValue);
}
/* Restore the default write masks. */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x8);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0xFF);
}
/* Fill any pixels on the right which don't fall into a complete row. */
if ((EndX % 8) != 0)
{
/* Disable writes to pixels outside the destination rectangle. */
Mask = ~((1 << (8 - (EndX % 8))) - 1);
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x8);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, Mask);
/* Set write mode two. */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 5);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 2);
Video = (PUCHAR)vidmem + DestY * 80 + (EndX >> 3);
Src = MaskBits + (SizeY - (DestY - StartY)) * MaskPitch + (SizeX >> 3) - 1;
for (i = DestY; i < EndY; i++, Video+=80)
{
Src -= MaskPitch;
SrcValue = (Src[0] << (8 - Bits));
(VOID)READ_REGISTER_UCHAR(Video);
WRITE_REGISTER_UCHAR(Video, SrcValue);
}
/* Restore the default write masks. */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 0x8);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0xFF);
}
/* Set write mode two. */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 5);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 2);
/* Select raster op replace. */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 3);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0);
/* Select raster op replace. */
WRITE_PORT_UCHAR((PUCHAR)GRA_I, 3);
WRITE_PORT_UCHAR((PUCHAR)GRA_D, 0);
}
BOOL InitPointer(PPDEV ppdev)
{
ULONG CursorWidth = 32, CursorHeight = 32;
ULONG PointerAttributesSize;
ULONG SavedMemSize;
ULONG CursorWidth = 32, CursorHeight = 32;
ULONG PointerAttributesSize;
ULONG SavedMemSize;
ppdev->xyHotSpot.x = 0;
ppdev->xyHotSpot.y = 0;
ppdev->xyHotSpot.x = 0;
ppdev->xyHotSpot.y = 0;
/* Determine the size of the pointer attributes */
PointerAttributesSize = sizeof(VIDEO_POINTER_ATTRIBUTES) +
((CursorWidth * CursorHeight * 2) >> 3);
/* Determine the size of the pointer attributes */
PointerAttributesSize = sizeof(VIDEO_POINTER_ATTRIBUTES) +
((CursorWidth * CursorHeight * 2) >> 3);
/* Allocate memory for pointer attributes */
ppdev->pPointerAttributes = EngAllocMem(0, PointerAttributesSize, ALLOC_TAG);
/* Allocate memory for pointer attributes */
ppdev->pPointerAttributes = EngAllocMem(0, PointerAttributesSize, ALLOC_TAG);
ppdev->pPointerAttributes->Flags = 0; /* FIXME: Do this right */
ppdev->pPointerAttributes->Width = CursorWidth;
ppdev->pPointerAttributes->Height = CursorHeight;
ppdev->pPointerAttributes->WidthInBytes = CursorWidth >> 3;
ppdev->pPointerAttributes->Enable = 0;
ppdev->pPointerAttributes->Column = 0;
ppdev->pPointerAttributes->Row = 0;
ppdev->pPointerAttributes->Flags = 0; /* FIXME: Do this right */
ppdev->pPointerAttributes->Width = CursorWidth;
ppdev->pPointerAttributes->Height = CursorHeight;
ppdev->pPointerAttributes->WidthInBytes = CursorWidth >> 3;
ppdev->pPointerAttributes->Enable = 0;
ppdev->pPointerAttributes->Column = 0;
ppdev->pPointerAttributes->Row = 0;
/* Allocate memory for the pixels behind the cursor */
SavedMemSize = ((((CursorWidth + 7) & ~0x7) + 16) * CursorHeight) >> 3;
ppdev->ImageBehindCursor = VGADDI_AllocSavedScreenBits(SavedMemSize);
/* Allocate memory for the pixels behind the cursor */
SavedMemSize = ((((CursorWidth + 7) & ~0x7) + 16) * CursorHeight) >> 3;
ppdev->ImageBehindCursor = VGADDI_AllocSavedScreenBits(SavedMemSize);
return(TRUE);
return TRUE;
}
VOID APIENTRY
DrvMovePointer(IN SURFOBJ* pso,
IN LONG x,
IN LONG y,
IN PRECTL prcl)
DrvMovePointer(
IN SURFOBJ* pso,
IN LONG x,
IN LONG y,
IN PRECTL prcl)
{
PPDEV ppdev = (PPDEV)pso->dhpdev;
PPDEV ppdev = (PPDEV)pso->dhpdev;
VGADDI_HideCursor(ppdev);
VGADDI_HideCursor(ppdev);
if(x != -1)
{
ppdev->pPointerAttributes->Column = x;
ppdev->pPointerAttributes->Row = y;
if(x != -1)
{
ppdev->pPointerAttributes->Column = x;
ppdev->pPointerAttributes->Row = y;
VGADDI_ShowCursor(ppdev, prcl);
}
VGADDI_ShowCursor(ppdev, prcl);
}
}
ULONG APIENTRY
DrvSetPointerShape(SURFOBJ* pso,
SURFOBJ* psoMask,
SURFOBJ* psoColor,
XLATEOBJ* pxlo,
LONG xHot,
LONG yHot,
LONG x,
LONG y,
PRECTL prcl,
ULONG fl)
DrvSetPointerShape(
IN SURFOBJ* pso,
IN SURFOBJ* psoMask,
IN SURFOBJ* psoColor,
IN XLATEOBJ* pxlo,
IN LONG xHot,
IN LONG yHot,
IN LONG x,
IN LONG y,
IN PRECTL prcl,
IN ULONG fl)
{
PPDEV ppdev = (PPDEV)pso->dhpdev;
ULONG NewWidth, NewHeight;
PUCHAR Src, Dest;
ULONG i;
PPDEV ppdev = (PPDEV)pso->dhpdev;
ULONG NewWidth, NewHeight;
PUCHAR Src, Dest;
ULONG i;
if (! psoMask)
if (!psoMask)
return SPS_DECLINE;
/* Hide the cursor */
VGADDI_HideCursor(ppdev);
NewWidth = abs(psoMask->lDelta) << 3;
NewHeight = (psoMask->cjBits / abs(psoMask->lDelta)) / 2;
/* Reallocate the space for the cursor if necessary. */
if (ppdev->pPointerAttributes->Width != NewWidth ||
ppdev->pPointerAttributes->Height != NewHeight)
{
return SPS_DECLINE;
ULONG PointerAttributesSize;
PVIDEO_POINTER_ATTRIBUTES NewPointerAttributes;
ULONG SavedMemSize;
/* Determine the size of the pointer attributes */
PointerAttributesSize = sizeof(VIDEO_POINTER_ATTRIBUTES) +
((NewWidth * NewHeight * 2) >> 3);
/* Allocate memory for pointer attributes */
NewPointerAttributes = EngAllocMem(0, PointerAttributesSize, ALLOC_TAG);
*NewPointerAttributes = *ppdev->pPointerAttributes;
NewPointerAttributes->Width = NewWidth;
NewPointerAttributes->Height = NewHeight;
NewPointerAttributes->WidthInBytes = NewWidth >> 3;
EngFreeMem(ppdev->pPointerAttributes);
ppdev->pPointerAttributes = NewPointerAttributes;
/* Reallocate the space for the saved bits. */
VGADDI_FreeSavedScreenBits(ppdev->ImageBehindCursor);
SavedMemSize = ((((NewWidth + 7) & ~0x7) + 16) * NewHeight) >> 3;
ppdev->ImageBehindCursor = VGADDI_AllocSavedScreenBits(SavedMemSize);
}
/* Hide the cursor */
VGADDI_HideCursor(ppdev);
NewWidth = abs(psoMask->lDelta) << 3;
NewHeight = (psoMask->cjBits / abs(psoMask->lDelta)) / 2;
/* Reallocate the space for the cursor if necessary. */
if (ppdev->pPointerAttributes->Width != NewWidth ||
ppdev->pPointerAttributes->Height != NewHeight)
Src = (PUCHAR)psoMask->pvScan0;
/* Copy the new cursor in. */
for (i = 0; i < (NewHeight * 2); i++)
{
ULONG PointerAttributesSize;
PVIDEO_POINTER_ATTRIBUTES NewPointerAttributes;
ULONG SavedMemSize;
/* Determine the size of the pointer attributes */
PointerAttributesSize = sizeof(VIDEO_POINTER_ATTRIBUTES) +
((NewWidth * NewHeight * 2) >> 3);
/* Allocate memory for pointer attributes */
NewPointerAttributes = EngAllocMem(0, PointerAttributesSize, ALLOC_TAG);
*NewPointerAttributes = *ppdev->pPointerAttributes;
NewPointerAttributes->Width = NewWidth;
NewPointerAttributes->Height = NewHeight;
NewPointerAttributes->WidthInBytes = NewWidth >> 3;
EngFreeMem(ppdev->pPointerAttributes);
ppdev->pPointerAttributes = NewPointerAttributes;
/* Reallocate the space for the saved bits. */
VGADDI_FreeSavedScreenBits(ppdev->ImageBehindCursor);
SavedMemSize = ((((NewWidth + 7) & ~0x7) + 16) * NewHeight) >> 3;
ppdev->ImageBehindCursor = VGADDI_AllocSavedScreenBits(SavedMemSize);
Dest = (PUCHAR)ppdev->pPointerAttributes->Pixels;
if (i >= NewHeight)
Dest += (((NewHeight * 3) - i - 1) * (NewWidth >> 3));
else
Dest += ((NewHeight - i - 1) * (NewWidth >> 3));
memcpy(Dest, Src, NewWidth >> 3);
Src += psoMask->lDelta;
}
Src = (PUCHAR)psoMask->pvScan0;
/* Copy the new cursor in. */
for (i = 0; i < (NewHeight * 2); i++)
/* Set the new cursor position */
ppdev->xyHotSpot.x = xHot;
ppdev->xyHotSpot.y = yHot;
if(x != -1)
{
Dest = (PUCHAR)ppdev->pPointerAttributes->Pixels;
if (i >= NewHeight)
{
Dest += (((NewHeight * 3) - i - 1) * (NewWidth >> 3));
}
else
{
Dest += ((NewHeight - i - 1) * (NewWidth >> 3));
}
memcpy(Dest, Src, NewWidth >> 3);
Src += psoMask->lDelta;
ppdev->pPointerAttributes->Column = x;
ppdev->pPointerAttributes->Row = y;
/* show the cursor */
VGADDI_ShowCursor(ppdev, prcl);
}
/* Set the new cursor position */
ppdev->xyHotSpot.x = xHot;
ppdev->xyHotSpot.y = yHot;
if(x != -1)
{
ppdev->pPointerAttributes->Column = x;
ppdev->pPointerAttributes->Row = y;
/* show the cursor */
VGADDI_ShowCursor(ppdev, prcl);
}
return SPS_ACCEPT_EXCLUDE;
return SPS_ACCEPT_EXCLUDE;
}
static VOID FASTCALL
VGADDI_ComputePointerRect(PPDEV ppdev, LONG X, LONG Y, PRECTL Rect)
VGADDI_ComputePointerRect(
IN PPDEV ppdev,
IN LONG X,
IN LONG Y,
IN PRECTL Rect)
{
ULONG SizeX, SizeY;
ULONG SizeX, SizeY;
SizeX = min(((X + (LONG)ppdev->pPointerAttributes->Width) + 7) & ~0x7, ppdev->sizeSurf.cx);
SizeX -= (X & ~0x7);
SizeY = min((LONG)ppdev->pPointerAttributes->Height, ppdev->sizeSurf.cy - Y);
SizeX = min(((X + (LONG)ppdev->pPointerAttributes->Width) + 7) & ~0x7, ppdev->sizeSurf.cx);
SizeX -= (X & ~0x7);
SizeY = min((LONG)ppdev->pPointerAttributes->Height, ppdev->sizeSurf.cy - Y);
Rect->left = max(X, 0) & ~0x7;
Rect->top = max(Y, 0);
Rect->right = Rect->left + SizeX;
Rect->bottom = Rect->top + SizeY;
Rect->left = max(X, 0) & ~0x7;
Rect->top = max(Y, 0);
Rect->right = Rect->left + SizeX;
Rect->bottom = Rect->top + SizeY;
}
static VOID
VGADDI_HideCursor(PPDEV ppdev)
{
if(ppdev->pPointerAttributes->Enable)
{
LONG cx, cy;
RECTL Rect;
if(ppdev->pPointerAttributes->Enable)
{
LONG cx, cy;
RECTL Rect;
ppdev->pPointerAttributes->Enable = 0;
ppdev->pPointerAttributes->Enable = 0;
cx = ppdev->pPointerAttributes->Column - ppdev->xyHotSpot.x;
cy = ppdev->pPointerAttributes->Row - ppdev->xyHotSpot.y;
cx = ppdev->pPointerAttributes->Column - ppdev->xyHotSpot.x;
cy = ppdev->pPointerAttributes->Row - ppdev->xyHotSpot.y;
VGADDI_ComputePointerRect(ppdev, cx, cy, &Rect);
VGADDI_ComputePointerRect(ppdev, cx, cy, &Rect);
/* Display what was behind cursor */
VGADDI_BltFromSavedScreenBits(Rect.left,
Rect.top,
ppdev->ImageBehindCursor,
Rect.right - Rect.left,
Rect.bottom - Rect.top);
}
/* Display what was behind cursor */
VGADDI_BltFromSavedScreenBits(Rect.left,
Rect.top,
ppdev->ImageBehindCursor,
Rect.right - Rect.left,
Rect.bottom - Rect.top);
}
}
static VOID
VGADDI_ShowCursor(PPDEV ppdev, PRECTL prcl)
{
LONG cx, cy;
PUCHAR AndMask, XorMask;
ULONG SizeX, SizeY;
RECTL Rect;
LONG cx, cy;
PUCHAR AndMask, XorMask;
ULONG SizeX, SizeY;
RECTL Rect;
if(ppdev->pPointerAttributes->Enable)
{
return;
}
/* Mark the cursor as currently displayed. */
ppdev->pPointerAttributes->Enable = 1;
if(ppdev->pPointerAttributes->Enable)
return;
cx = ppdev->pPointerAttributes->Column - ppdev->xyHotSpot.x;
cy = ppdev->pPointerAttributes->Row - ppdev->xyHotSpot.y;
/* Mark the cursor as currently displayed. */
ppdev->pPointerAttributes->Enable = 1;
/* Capture pixels behind the cursor */
VGADDI_ComputePointerRect(ppdev, cx, cy, &Rect);
cx = ppdev->pPointerAttributes->Column - ppdev->xyHotSpot.x;
cy = ppdev->pPointerAttributes->Row - ppdev->xyHotSpot.y;
VGADDI_BltToSavedScreenBits(ppdev->ImageBehindCursor,
Rect.left,
Rect.top,
Rect.right - Rect.left,
Rect.bottom - Rect.top);
/* Capture pixels behind the cursor */
VGADDI_ComputePointerRect(ppdev, cx, cy, &Rect);
/* Display the cursor. */
SizeX = min((LONG)ppdev->pPointerAttributes->Width, ppdev->sizeSurf.cx - cx);
SizeY = min((LONG)ppdev->pPointerAttributes->Height, ppdev->sizeSurf.cy - cy);
AndMask = ppdev->pPointerAttributes->Pixels +
(ppdev->pPointerAttributes->Height - SizeY) * ppdev->pPointerAttributes->WidthInBytes;
VGADDI_BltPointerToVGA(cx,
cy,
SizeX,
SizeY,
AndMask,
ppdev->pPointerAttributes->WidthInBytes,
VGA_AND);
XorMask = AndMask +
ppdev->pPointerAttributes->WidthInBytes *
ppdev->pPointerAttributes->Height;
VGADDI_BltPointerToVGA(cx,
cy,
SizeX,
SizeY,
XorMask,
ppdev->pPointerAttributes->WidthInBytes,
VGA_XOR);
VGADDI_BltToSavedScreenBits(ppdev->ImageBehindCursor,
Rect.left,
Rect.top,
Rect.right - Rect.left,
Rect.bottom - Rect.top);
if (NULL != prcl)
{
*prcl = Rect;
}
/* Display the cursor. */
SizeX = min((LONG)ppdev->pPointerAttributes->Width, ppdev->sizeSurf.cx - cx);
SizeY = min((LONG)ppdev->pPointerAttributes->Height, ppdev->sizeSurf.cy - cy);
AndMask = ppdev->pPointerAttributes->Pixels +
(ppdev->pPointerAttributes->Height - SizeY) * ppdev->pPointerAttributes->WidthInBytes;
VGADDI_BltPointerToVGA(cx,
cy,
SizeX,
SizeY,
AndMask,
ppdev->pPointerAttributes->WidthInBytes,
VGA_AND);
XorMask = AndMask +
ppdev->pPointerAttributes->WidthInBytes *
ppdev->pPointerAttributes->Height;
VGADDI_BltPointerToVGA(cx,
cy,
SizeX,
SizeY,
XorMask,
ppdev->pPointerAttributes->WidthInBytes,
VGA_XOR);
if (NULL != prcl)
*prcl = Rect;
}
@@ -1,190 +1,203 @@
/*
* PROJECT: ReactOS VGA display driver
* LICENSE: GPL - See COPYING in the top level directory
* FILE: drivers/video/displays/vga/objects/screen.c
* PURPOSE:
* PROGRAMMERS:
*/
#include "../vgaddi.h"
#include "../vgavideo/vgavideo.h"
static WORD PaletteBuffer[] = {
16, 0, // 16 entries, start with 0
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
16, 0, // 16 entries, start with 0
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
};
static BYTE ColorBuffer[] = {
16, // 16 entries
0, 0,
0, // start with 0
0x00, 0x00, 0x00, 0x00, // black
0x2A, 0x00, 0x15, 0x00, // red
0x00, 0x2A, 0x15, 0x00, // green
0x2A, 0x2A, 0x15, 0x00, // brown
0x00, 0x00, 0x2A, 0x00, // blue
0x2A, 0x15, 0x2A, 0x00, // magenta
0x15, 0x2A, 0x2A, 0x00, // cyan
0x21, 0x22, 0x23, 0x00, // dark gray
0x30, 0x31, 0x32, 0x00, // light gray
0x3F, 0x00, 0x00, 0x00, // bright red
0x00, 0x3F, 0x00, 0x00, // bright green
0x3F, 0x3F, 0x00, 0x00, // bright yellow
0x00, 0x00, 0x3F, 0x00, // bright blue
0x3F, 0x00, 0x3F, 0x00, // bright magenta
0x00, 0x3F, 0x3F, 0x00, // bright cyan
0x3F, 0x3F, 0x3F, 0x00 // bright white
16, // 16 entries
0, 0,
0, // start with 0
0x00, 0x00, 0x00, 0x00, // black
0x2A, 0x00, 0x15, 0x00, // red
0x00, 0x2A, 0x15, 0x00, // green
0x2A, 0x2A, 0x15, 0x00, // brown
0x00, 0x00, 0x2A, 0x00, // blue
0x2A, 0x15, 0x2A, 0x00, // magenta
0x15, 0x2A, 0x2A, 0x00, // cyan
0x21, 0x22, 0x23, 0x00, // dark gray
0x30, 0x31, 0x32, 0x00, // light gray
0x3F, 0x00, 0x00, 0x00, // bright red
0x00, 0x3F, 0x00, 0x00, // bright green
0x3F, 0x3F, 0x00, 0x00, // bright yellow
0x00, 0x00, 0x3F, 0x00, // bright blue
0x3F, 0x00, 0x3F, 0x00, // bright magenta
0x00, 0x3F, 0x3F, 0x00, // bright cyan
0x3F, 0x3F, 0x3F, 0x00 // bright white
};
DWORD getAvailableModes(HANDLE Driver,
PVIDEO_MODE_INFORMATION *modeInformation,
DWORD *ModeSize)
DWORD getAvailableModes(
IN HANDLE Driver,
OUT PVIDEO_MODE_INFORMATION *modeInformation,
OUT DWORD *ModeSize)
{
ULONG Temp;
VIDEO_NUM_MODES modes;
PVIDEO_MODE_INFORMATION VideoTemp;
// get number of modes supported
if (EngDeviceIoControl(Driver,
IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES,
NULL,
0,
&modes,
sizeof(VIDEO_NUM_MODES),
&Temp))
{
// get modes failed
return(0);
}
*ModeSize = modes.ModeInformationLength;
// allocate buffer for the mini-port to write the modes in
*modeInformation = (PVIDEO_MODE_INFORMATION)
EngAllocMem(0, modes.NumModes *
modes.ModeInformationLength, ALLOC_TAG);
if (*modeInformation == (PVIDEO_MODE_INFORMATION) NULL)
{
// couldn't allocate buffer
return 0;
}
// Ask the mini-port to fill in the available modes.
if (EngDeviceIoControl(Driver,
IOCTL_VIDEO_QUERY_AVAIL_MODES,
NULL,
0,
*modeInformation,
modes.NumModes * modes.ModeInformationLength,
&Temp))
{
// failed to query modes
EngFreeMem(*modeInformation);
*modeInformation = (PVIDEO_MODE_INFORMATION) NULL;
return(0);
}
// Which modes supported by miniport driver are also suppoted by us, the
// display driver
Temp = modes.NumModes;
VideoTemp = *modeInformation;
// Reject mode if it's not 4 planes or not graphic or not 1 bits per pel
while (Temp--)
{
if ((VideoTemp->NumberOfPlanes != 4 ) ||
!(VideoTemp->AttributeFlags & VIDEO_MODE_GRAPHICS) ||
(VideoTemp->BitsPerPlane != 1) ||
BROKEN_RASTERS(VideoTemp->ScreenStride, VideoTemp->VisScreenHeight))
ULONG Temp;
VIDEO_NUM_MODES modes;
PVIDEO_MODE_INFORMATION VideoTemp;
/* get number of modes supported */
if (EngDeviceIoControl(Driver,
IOCTL_VIDEO_QUERY_NUM_AVAIL_MODES,
NULL,
0,
&modes,
sizeof(VIDEO_NUM_MODES),
&Temp))
{
VideoTemp->Length = 0;
/* get modes failed */
return 0;
}
VideoTemp = (PVIDEO_MODE_INFORMATION)(((PUCHAR)VideoTemp) + modes.ModeInformationLength);
}
*ModeSize = modes.ModeInformationLength;
return modes.NumModes;
/* allocate buffer for the mini-port to write the modes in */
*modeInformation = (PVIDEO_MODE_INFORMATION)
EngAllocMem(0, modes.NumModes *
modes.ModeInformationLength, ALLOC_TAG);
if (*modeInformation == (PVIDEO_MODE_INFORMATION) NULL)
{
/* couldn't allocate buffer */
return 0;
}
/* Ask the mini-port to fill in the available modes. */
if (EngDeviceIoControl(Driver,
IOCTL_VIDEO_QUERY_AVAIL_MODES,
NULL,
0,
*modeInformation,
modes.NumModes * modes.ModeInformationLength,
&Temp))
{
/* failed to query modes */
EngFreeMem(*modeInformation);
*modeInformation = (PVIDEO_MODE_INFORMATION) NULL;
return 0;
}
/* Which modes supported by miniport driver are also suppoted by us, the
* display driver */
Temp = modes.NumModes;
VideoTemp = *modeInformation;
/* Reject mode if it's not 4 planes or not graphic or not 1 bits per pel */
while (Temp--)
{
if ((VideoTemp->NumberOfPlanes != 4 ) ||
!(VideoTemp->AttributeFlags & VIDEO_MODE_GRAPHICS) ||
(VideoTemp->BitsPerPlane != 1) ||
BROKEN_RASTERS(VideoTemp->ScreenStride, VideoTemp->VisScreenHeight))
{
VideoTemp->Length = 0;
}
VideoTemp = (PVIDEO_MODE_INFORMATION)(((PUCHAR)VideoTemp) + modes.ModeInformationLength);
}
return modes.NumModes;
}
BOOL DeinitVGA(PPDEV ppdev)
{
VIDEO_MEMORY VideoMemory;
ULONG ReturnedDataLength;
VIDEO_MEMORY VideoMemory;
ULONG ReturnedDataLength;
VideoMemory.RequestedVirtualAddress = (PVOID)ppdev->fbScreen;
VideoMemory.RequestedVirtualAddress = (PVOID)ppdev->fbScreen;
if (EngDeviceIoControl(ppdev->KMDriver,
IOCTL_VIDEO_UNMAP_VIDEO_MEMORY,
(PVOID)&VideoMemory,
sizeof(VIDEO_MEMORY),
NULL,
0,
&ReturnedDataLength))
if (EngDeviceIoControl(ppdev->KMDriver,
IOCTL_VIDEO_UNMAP_VIDEO_MEMORY,
(PVOID)&VideoMemory,
sizeof(VIDEO_MEMORY),
NULL,
0,
&ReturnedDataLength))
{
DbgPrint("Failed to unmap video memory.\n");
DbgBreakPoint();
return(FALSE);
//DPRINT1("Failed to unmap video memory.\n");
DbgBreakPoint();
return FALSE;
}
return(TRUE);
return TRUE;
}
BOOL InitVGA(PPDEV ppdev, BOOL bFirst)
{
ULONG ReturnedDataLength;
VIDEO_MEMORY VideoMemory;
VIDEO_MEMORY_INFORMATION VideoMemoryInfo;
ULONG ReturnedDataLength;
VIDEO_MEMORY VideoMemory;
VIDEO_MEMORY_INFORMATION VideoMemoryInfo;
ppdev->sizeSurf.cx = 640;
ppdev->sizeSurf.cy = 480;
ppdev->ModeNum = 12;
ppdev->sizeSurf.cx = 640;
ppdev->sizeSurf.cy = 480;
ppdev->ModeNum = 12;
// Set the mode that was requested
if (EngDeviceIoControl(ppdev->KMDriver,
IOCTL_VIDEO_SET_CURRENT_MODE,
&ppdev->ModeNum,
sizeof(VIDEO_MODE),
NULL,
0,
&ReturnedDataLength)) {
return(FALSE);
}
/* Set the mode that was requested */
if (EngDeviceIoControl(ppdev->KMDriver,
IOCTL_VIDEO_SET_CURRENT_MODE,
&ppdev->ModeNum,
sizeof(VIDEO_MODE),
NULL,
0,
&ReturnedDataLength))
{
return FALSE;
}
// set up internal palette
if (EngDeviceIoControl(ppdev->KMDriver,
IOCTL_VIDEO_SET_PALETTE_REGISTERS,
(PVOID) PaletteBuffer,
sizeof (PaletteBuffer),
NULL,
0,
&ReturnedDataLength)) {
return(FALSE);
}
/* set up internal palette */
if (EngDeviceIoControl(ppdev->KMDriver,
IOCTL_VIDEO_SET_PALETTE_REGISTERS,
(PVOID) PaletteBuffer,
sizeof (PaletteBuffer),
NULL,
0,
&ReturnedDataLength))
{
return FALSE;
}
// set up the DAC
if (EngDeviceIoControl(ppdev->KMDriver,
IOCTL_VIDEO_SET_COLOR_REGISTERS,
(PVOID) ColorBuffer,
sizeof (ColorBuffer),
NULL,
0,
&ReturnedDataLength)) {
return(FALSE);
}
/* set up the DAC */
if (EngDeviceIoControl(ppdev->KMDriver,
IOCTL_VIDEO_SET_COLOR_REGISTERS,
(PVOID) ColorBuffer,
sizeof (ColorBuffer),
NULL,
0,
&ReturnedDataLength))
{
return FALSE;
}
if (bFirst) {
// map video memory into virtual memory
VideoMemory.RequestedVirtualAddress = NULL;
if (bFirst)
{
/* map video memory into virtual memory */
VideoMemory.RequestedVirtualAddress = NULL;
if (EngDeviceIoControl(ppdev->KMDriver,
IOCTL_VIDEO_MAP_VIDEO_MEMORY,
(PVOID) &VideoMemory,
sizeof (VIDEO_MEMORY),
(PVOID) &VideoMemoryInfo,
sizeof (VideoMemoryInfo),
&ReturnedDataLength)) {
// Failed to map to virtual memory
return (FALSE);
}
if (EngDeviceIoControl(ppdev->KMDriver,
IOCTL_VIDEO_MAP_VIDEO_MEMORY,
(PVOID) &VideoMemory,
sizeof (VIDEO_MEMORY),
(PVOID) &VideoMemoryInfo,
sizeof (VideoMemoryInfo),
&ReturnedDataLength))
{
/* Failed to map to virtual memory */
return FALSE;
}
ppdev->fbScreen = VideoMemoryInfo.FrameBufferBase;
vidmem = (PUCHAR)ppdev->fbScreen;
}
ppdev->fbScreen = VideoMemoryInfo.FrameBufferBase;
vidmem = (PUCHAR)ppdev->fbScreen;
}
return TRUE;
return TRUE;
}
@@ -1,3 +1,11 @@
/*
* PROJECT: ReactOS VGA display driver
* LICENSE: GPL - See COPYING in the top level directory
* FILE: drivers/video/displays/vga/objects/transblt.c
* PURPOSE:
* PROGRAMMERS:
*/
#include "../vgaddi.h"
#include "../vgavideo/vgavideo.h"
#include "brush.h"
@@ -7,28 +15,29 @@
#include <debug.h>
BOOL APIENTRY
DrvTransparentBlt(SURFOBJ* Dest,
SURFOBJ* Source,
CLIPOBJ* Clip,
XLATEOBJ* ColorTranslation,
RECTL* DestRect,
RECTL* SourceRect,
ULONG TransparentColor,
ULONG Reserved)
DrvTransparentBlt(
IN SURFOBJ* Dest,
IN SURFOBJ* Source,
IN CLIPOBJ* Clip,
IN XLATEOBJ* ColorTranslation,
IN RECTL* DestRect,
IN RECTL* SourceRect,
IN ULONG TransparentColor,
IN ULONG Reserved)
{
LONG dx, dy, sx, sy;
LONG dx, dy, sx, sy;
dx = abs(DestRect->right - DestRect->left);
dy = abs(DestRect->bottom - DestRect->top);
dx = abs(DestRect->right - DestRect->left);
dy = abs(DestRect->bottom - DestRect->top);
sx = abs(SourceRect->right - SourceRect->left);
sy = abs(SourceRect->bottom - SourceRect->top);
sx = abs(SourceRect->right - SourceRect->left);
sy = abs(SourceRect->bottom - SourceRect->top);
if(sx<dx) dx = sx;
if(sy<dy) dy = sy;
if (sx < dx) dx = sx;
if (sy < dy) dy = sy;
// FIXME: adjust using SourceRect
DIB_TransparentBltToVGA(DestRect->left, DestRect->top, dx, dy, Source->pvScan0, Source->lDelta, TransparentColor);
/* FIXME: adjust using SourceRect */
DIB_TransparentBltToVGA(DestRect->left, DestRect->top, dx, dy, Source->pvScan0, Source->lDelta, TransparentColor);
return TRUE;
return TRUE;
}
@@ -1,11 +1,4 @@
; $Id: vgaddi.def 26978 2007-06-03 16:45:34Z greatlrd $
;
; vgaddi.def
;
; ReactOS Operating System
;
; From Anders Norlander's w32api-0.1.5 vgaddi.def.
;
LIBRARY vgaddi.dll
EXPORTS
DrvEnableDriver@12
File diff suppressed because it is too large Load Diff