mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
Create a PDEV for the display driver only once.
svn path=/trunk/; revision=3520
This commit is contained in:
parent
c14f0762b7
commit
af353b6572
4 changed files with 149 additions and 107 deletions
|
@ -1,7 +1,7 @@
|
|||
#include "../vgaddi.h"
|
||||
|
||||
ULONG oldx, oldy;
|
||||
PUCHAR behindCursor;
|
||||
static PUCHAR ImageBehindCursor;
|
||||
|
||||
void vgaHideCursor(PPDEV ppdev);
|
||||
void vgaShowCursor(PPDEV ppdev);
|
||||
|
@ -26,7 +26,8 @@ BOOL InitPointer(PPDEV ppdev)
|
|||
ppdev->pPointerAttributes->Row = 0;
|
||||
|
||||
// Allocate memory for the pixels behind the cursor
|
||||
behindCursor = EngAllocMem(0, ppdev->pPointerAttributes->WidthInBytes * ppdev->pPointerAttributes->Height, ALLOC_TAG);
|
||||
ImageBehindCursor =
|
||||
EngAllocMem(0, ppdev->pPointerAttributes->WidthInBytes * ppdev->pPointerAttributes->Height, ALLOC_TAG);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -81,8 +82,8 @@ DrvSetPointerShape(PSURFOBJ pso,
|
|||
if(psoColor != NULL) RtlCopyMemory(ppdev->pPointerAttributes->Pixels + 256, psoColor->pvBits, psoColor->cjBits);
|
||||
ppdev->pPointerAttributes->WidthInBytes = psoMask->lDelta;
|
||||
|
||||
EngFreeMem(behindCursor);
|
||||
behindCursor = EngAllocMem(0, ppdev->pPointerAttributes->WidthInBytes * ppdev->pPointerAttributes->Height, ALLOC_TAG);
|
||||
EngFreeMem(ImageBehindCursor);
|
||||
ImageBehindCursor = EngAllocMem(0, ppdev->pPointerAttributes->WidthInBytes * ppdev->pPointerAttributes->Height, ALLOC_TAG);
|
||||
|
||||
// Set the new cursor position
|
||||
ppdev->xyCursor.x = x;
|
||||
|
@ -111,7 +112,7 @@ void vgaHideCursor(PPDEV ppdev)
|
|||
DFB_BltToVGA(oldx, oldy,
|
||||
ppdev->pPointerAttributes->Width,
|
||||
ppdev->pPointerAttributes->Height,
|
||||
behindCursor,
|
||||
ImageBehindCursor,
|
||||
ppdev->pPointerAttributes->WidthInBytes);
|
||||
|
||||
ppdev->pPointerAttributes->Enable = 0;
|
||||
|
@ -130,7 +131,7 @@ void vgaShowCursor(PPDEV ppdev)
|
|||
// Used to repaint background
|
||||
DFB_BltFromVGA(ppdev->xyCursor.x, ppdev->xyCursor.y,
|
||||
ppdev->pPointerAttributes->Width, ppdev->pPointerAttributes->Height,
|
||||
behindCursor, ppdev->pPointerAttributes->WidthInBytes);
|
||||
ImageBehindCursor, ppdev->pPointerAttributes->WidthInBytes);
|
||||
|
||||
// Display the cursor
|
||||
DFB_BltToVGA_Transparent(ppdev->xyCursor.x, ppdev->xyCursor.y,
|
||||
|
|
|
@ -7,6 +7,17 @@
|
|||
#include <win32k/gdiobj.h>
|
||||
#include <win32k/path.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HANDLE Handle;
|
||||
DHPDEV PDev;
|
||||
DEVMODEW DMW;
|
||||
HSURF FillPatterns[HS_DDI_MAX];
|
||||
GDIINFO GDIInfo;
|
||||
DEVINFO DevInfo;
|
||||
DRIVER_FUNCTIONS DriverFunctions;
|
||||
} GDIDEVICE;
|
||||
|
||||
/* (RJJ) Taken from WINE */
|
||||
typedef struct _DEVICECAPS
|
||||
{
|
||||
|
|
|
@ -190,8 +190,9 @@ EngAssociateSurface(IN HSURF Surface,
|
|||
{
|
||||
SURFOBJ *SurfObj;
|
||||
SURFGDI *SurfGDI;
|
||||
GDIDEVICE* Device;
|
||||
|
||||
PDC Dc = (PDC)Dev;
|
||||
Device = (GDIDEVICE*)Dev;
|
||||
|
||||
SurfGDI = (PVOID)AccessInternalObject((ULONG)Surface);
|
||||
SurfObj = (PVOID)AccessUserObject((ULONG)Surface);
|
||||
|
@ -200,23 +201,23 @@ EngAssociateSurface(IN HSURF Surface,
|
|||
SurfObj->hdev = Dev;
|
||||
|
||||
// Hook up specified functions
|
||||
if(Hooks & HOOK_BITBLT) SurfGDI->BitBlt = Dc->DriverFunctions.BitBlt;
|
||||
if(Hooks & HOOK_TRANSPARENTBLT) SurfGDI->TransparentBlt = Dc->DriverFunctions.TransparentBlt;
|
||||
if(Hooks & HOOK_STRETCHBLT) SurfGDI->StretchBlt = (PFN_StretchBlt)Dc->DriverFunctions.StretchBlt;
|
||||
if(Hooks & HOOK_TEXTOUT) SurfGDI->TextOut = Dc->DriverFunctions.TextOut;
|
||||
if(Hooks & HOOK_PAINT) SurfGDI->Paint = Dc->DriverFunctions.Paint;
|
||||
if(Hooks & HOOK_STROKEPATH) SurfGDI->StrokePath = Dc->DriverFunctions.StrokePath;
|
||||
if(Hooks & HOOK_FILLPATH) SurfGDI->FillPath = Dc->DriverFunctions.FillPath;
|
||||
if(Hooks & HOOK_STROKEANDFILLPATH) SurfGDI->StrokeAndFillPath = Dc->DriverFunctions.StrokeAndFillPath;
|
||||
if(Hooks & HOOK_LINETO) SurfGDI->LineTo = Dc->DriverFunctions.LineTo;
|
||||
if(Hooks & HOOK_COPYBITS) SurfGDI->CopyBits = Dc->DriverFunctions.CopyBits;
|
||||
if(Hooks & HOOK_SYNCHRONIZE) SurfGDI->Synchronize = Dc->DriverFunctions.Synchronize;
|
||||
if(Hooks & HOOK_BITBLT) SurfGDI->BitBlt = Device->DriverFunctions.BitBlt;
|
||||
if(Hooks & HOOK_TRANSPARENTBLT) SurfGDI->TransparentBlt = Device->DriverFunctions.TransparentBlt;
|
||||
if(Hooks & HOOK_STRETCHBLT) SurfGDI->StretchBlt = (PFN_StretchBlt)Device->DriverFunctions.StretchBlt;
|
||||
if(Hooks & HOOK_TEXTOUT) SurfGDI->TextOut = Device->DriverFunctions.TextOut;
|
||||
if(Hooks & HOOK_PAINT) SurfGDI->Paint = Device->DriverFunctions.Paint;
|
||||
if(Hooks & HOOK_STROKEPATH) SurfGDI->StrokePath = Device->DriverFunctions.StrokePath;
|
||||
if(Hooks & HOOK_FILLPATH) SurfGDI->FillPath = Device->DriverFunctions.FillPath;
|
||||
if(Hooks & HOOK_STROKEANDFILLPATH) SurfGDI->StrokeAndFillPath = Device->DriverFunctions.StrokeAndFillPath;
|
||||
if(Hooks & HOOK_LINETO) SurfGDI->LineTo = Device->DriverFunctions.LineTo;
|
||||
if(Hooks & HOOK_COPYBITS) SurfGDI->CopyBits = Device->DriverFunctions.CopyBits;
|
||||
if(Hooks & HOOK_SYNCHRONIZE) SurfGDI->Synchronize = Device->DriverFunctions.Synchronize;
|
||||
if(Hooks & HOOK_SYNCHRONIZEACCESS) SurfGDI->SynchronizeAccess = TRUE;
|
||||
|
||||
SurfGDI->CreateDeviceBitmap = Dc->DriverFunctions.CreateDeviceBitmap;
|
||||
SurfGDI->SetPalette = Dc->DriverFunctions.SetPalette;
|
||||
SurfGDI->MovePointer = Dc->DriverFunctions.MovePointer;
|
||||
SurfGDI->SetPointerShape = (PFN_SetPointerShape)Dc->DriverFunctions.SetPointerShape;
|
||||
SurfGDI->CreateDeviceBitmap = Device->DriverFunctions.CreateDeviceBitmap;
|
||||
SurfGDI->SetPalette = Device->DriverFunctions.SetPalette;
|
||||
SurfGDI->MovePointer = Device->DriverFunctions.MovePointer;
|
||||
SurfGDI->SetPointerShape = (PFN_SetPointerShape)Device->DriverFunctions.SetPointerShape;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: dc.c,v 1.39 2002/09/17 23:43:29 dwelch Exp $
|
||||
/* $Id: dc.c,v 1.40 2002/09/18 23:56:48 dwelch Exp $
|
||||
*
|
||||
* DC.C - Device context functions
|
||||
*
|
||||
|
@ -81,6 +81,7 @@ INT STDCALL func_name( HDC hdc, INT mode ) \
|
|||
return prevMode; \
|
||||
}
|
||||
|
||||
|
||||
VOID BitmapToSurf(HDC hdc, PSURFGDI SurfGDI, PSURFOBJ SurfObj, PBITMAPOBJ Bitmap);
|
||||
|
||||
// --------------------------------------------------------- File Statics
|
||||
|
@ -183,17 +184,104 @@ HDC STDCALL W32kCreateCompatableDC(HDC hDC)
|
|||
|
||||
#include <ddk/ntddvid.h>
|
||||
|
||||
static GDIDEVICE PrimarySurface;
|
||||
static BOOL PrimarySurfaceCreated = FALSE;
|
||||
|
||||
BOOL STDCALL W32kCreatePrimarySurface(LPCWSTR Driver,
|
||||
LPCWSTR Device)
|
||||
{
|
||||
PGD_ENABLEDRIVER GDEnableDriver;
|
||||
HANDLE DeviceDriver;
|
||||
DRVENABLEDATA DED;
|
||||
PSURFOBJ SurfObj;
|
||||
|
||||
/* Open the miniport driver */
|
||||
if ((DeviceDriver = DRIVER_FindMPDriver(Driver)) == NULL)
|
||||
{
|
||||
DPRINT("FindMPDriver failed\n");
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
/* Get the DDI driver's entry point */
|
||||
/* FIXME: Retrieve DDI driver name from registry */
|
||||
if ((GDEnableDriver = DRIVER_FindDDIDriver(L"\\SystemRoot\\system32\\drivers\\vgaddi.dll")) == NULL)
|
||||
{
|
||||
DPRINT("FindDDIDriver failed\n");
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
/* Call DDI driver's EnableDriver function */
|
||||
RtlZeroMemory(&DED, sizeof(DED));
|
||||
|
||||
if (!GDEnableDriver(DDI_DRIVER_VERSION, sizeof(DED), &DED))
|
||||
{
|
||||
DPRINT("DrvEnableDriver failed\n");
|
||||
return(FALSE);
|
||||
}
|
||||
DPRINT("Building DDI Functions\n");
|
||||
|
||||
/* Construct DDI driver function dispatch table */
|
||||
if (!DRIVER_BuildDDIFunctions(&DED, &PrimarySurface.DriverFunctions))
|
||||
{
|
||||
DPRINT("BuildDDIFunctions failed\n");
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
/* Allocate a phyical device handle from the driver */
|
||||
if (Device != NULL)
|
||||
{
|
||||
DPRINT("Device in u: %u\n", Device);
|
||||
// wcsncpy(NewDC->DMW.dmDeviceName, Device, DMMAXDEVICENAME); FIXME: this crashes everything?
|
||||
}
|
||||
|
||||
DPRINT("Enabling PDev\n");
|
||||
|
||||
PrimarySurface.PDev =
|
||||
PrimarySurface.DriverFunctions.EnablePDev(&PrimarySurface.DMW,
|
||||
L"",
|
||||
HS_DDI_MAX,
|
||||
PrimarySurface.FillPatterns,
|
||||
sizeof(PrimarySurface.GDIInfo),
|
||||
(ULONG *) &PrimarySurface.GDIInfo,
|
||||
sizeof(PrimarySurface.DevInfo),
|
||||
&PrimarySurface.DevInfo,
|
||||
NULL,
|
||||
L"",
|
||||
DeviceDriver);
|
||||
if (PrimarySurface.PDev == NULL)
|
||||
{
|
||||
DPRINT("DrvEnablePDEV failed\n");
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
DPRINT("calling completePDev\n");
|
||||
|
||||
/* Complete initialization of the physical device */
|
||||
PrimarySurface.DriverFunctions.CompletePDev(PrimarySurface.PDev,
|
||||
&PrimarySurface);
|
||||
|
||||
DPRINT("calling DRIVER_ReferenceDriver\n");
|
||||
|
||||
DRIVER_ReferenceDriver (Driver);
|
||||
|
||||
DPRINT("calling EnableSurface\n");
|
||||
|
||||
/* Enable the drawing surface */
|
||||
PrimarySurface.Handle =
|
||||
PrimarySurface.DriverFunctions.EnableSurface(PrimarySurface.PDev);
|
||||
|
||||
SurfObj = (PSURFOBJ)AccessUserObject(PrimarySurface.Handle);
|
||||
SurfObj->dhpdev = PrimarySurface.PDev;
|
||||
}
|
||||
|
||||
HDC STDCALL W32kCreateDC(LPCWSTR Driver,
|
||||
LPCWSTR Device,
|
||||
LPCWSTR Output,
|
||||
CONST PDEVMODEW InitData)
|
||||
{
|
||||
PGD_ENABLEDRIVER GDEnableDriver;
|
||||
{
|
||||
HDC hNewDC;
|
||||
PDC NewDC;
|
||||
HDC hDC = NULL;
|
||||
DRVENABLEDATA DED;
|
||||
PSURFOBJ SurfObj;
|
||||
HDC hDC = NULL;
|
||||
|
||||
/* Check for existing DC object */
|
||||
if ((hNewDC = DC_FindOpenDC(Driver)) != NULL)
|
||||
|
@ -213,44 +301,25 @@ HDC STDCALL W32kCreateDC(LPCWSTR Driver,
|
|||
NewDC = DC_HandleToPtr( hNewDC );
|
||||
ASSERT( NewDC );
|
||||
|
||||
/* Open the miniport driver */
|
||||
if ((NewDC->DeviceDriver = DRIVER_FindMPDriver(Driver)) == NULL)
|
||||
{
|
||||
DPRINT("FindMPDriver failed\n");
|
||||
goto Failure;
|
||||
}
|
||||
if (!PrimarySurfaceCreated)
|
||||
{
|
||||
if (!W32kCreatePrimarySurface(Driver, Device))
|
||||
{
|
||||
DC_ReleasePtr( hNewDC );
|
||||
DC_FreeDC(hNewDC);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
PrimarySurfaceCreated = TRUE;
|
||||
NewDC->DMW = PrimarySurface.DMW;
|
||||
NewDC->DevInfo = PrimarySurface.DevInfo;
|
||||
NewDC->GDIInfo = PrimarySurface.GDIInfo;
|
||||
memcpy(NewDC->FillPatternSurfaces, PrimarySurface.FillPatterns,
|
||||
sizeof(NewDC->FillPatternSurfaces));
|
||||
NewDC->PDev = PrimarySurface.PDev;
|
||||
NewDC->Surface = PrimarySurface.Handle;
|
||||
NewDC->DriverFunctions = PrimarySurface.DriverFunctions;
|
||||
|
||||
/* Get the DDI driver's entry point */
|
||||
/* FIXME: Retrieve DDI driver name from registry */
|
||||
if ((GDEnableDriver = DRIVER_FindDDIDriver(L"\\SystemRoot\\system32\\drivers\\vgaddi.dll")) == NULL)
|
||||
{
|
||||
DPRINT("FindDDIDriver failed\n");
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
/* Call DDI driver's EnableDriver function */
|
||||
RtlZeroMemory(&DED, sizeof(DED));
|
||||
|
||||
if (!GDEnableDriver(DDI_DRIVER_VERSION, sizeof(DED), &DED))
|
||||
{
|
||||
DPRINT("DrvEnableDriver failed\n");
|
||||
goto Failure;
|
||||
}
|
||||
DPRINT("Building DDI Functions\n");
|
||||
|
||||
/* Construct DDI driver function dispatch table */
|
||||
if (!DRIVER_BuildDDIFunctions(&DED, &NewDC->DriverFunctions))
|
||||
{
|
||||
DPRINT("BuildDDIFunctions failed\n");
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
/* Allocate a phyical device handle from the driver */
|
||||
if (Device != NULL)
|
||||
{
|
||||
DPRINT("Device in u: %u\n", Device);
|
||||
// wcsncpy(NewDC->DMW.dmDeviceName, Device, DMMAXDEVICENAME); FIXME: this crashes everything?
|
||||
}
|
||||
NewDC->DMW.dmSize = sizeof(NewDC->DMW);
|
||||
NewDC->DMW.dmFields = 0x000fc000;
|
||||
|
||||
|
@ -264,43 +333,8 @@ HDC STDCALL W32kCreateDC(LPCWSTR Driver,
|
|||
NewDC->DMW.dmDisplayFrequency = 0;
|
||||
|
||||
NewDC->w.bitsPerPixel = 4; // FIXME: set this here??
|
||||
|
||||
DPRINT("Enabling PDev\n");
|
||||
|
||||
NewDC->PDev = NewDC->DriverFunctions.EnablePDev(&NewDC->DMW,
|
||||
L"",
|
||||
HS_DDI_MAX,
|
||||
NewDC->FillPatternSurfaces,
|
||||
sizeof(NewDC->GDIInfo),
|
||||
(ULONG *) &NewDC->GDIInfo,
|
||||
sizeof(NewDC->DevInfo),
|
||||
&NewDC->DevInfo,
|
||||
NULL,
|
||||
L"",
|
||||
NewDC->DeviceDriver);
|
||||
if (NewDC->PDev == NULL)
|
||||
{
|
||||
DPRINT("DrvEnablePDEV failed\n");
|
||||
goto Failure;
|
||||
}
|
||||
|
||||
DPRINT("calling completePDev\n");
|
||||
|
||||
/* Complete initialization of the physical device */
|
||||
NewDC->DriverFunctions.CompletePDev(NewDC->PDev, NewDC);
|
||||
|
||||
DPRINT("calling DRIVER_ReferenceDriver\n");
|
||||
|
||||
DRIVER_ReferenceDriver (Driver);
|
||||
|
||||
DPRINT("calling EnableSurface\n");
|
||||
|
||||
/* Enable the drawing surface */
|
||||
NewDC->Surface = NewDC->DriverFunctions.EnableSurface(NewDC->PDev); // hsurf
|
||||
NewDC->w.hPalette = NewDC->DevInfo.hpalDefault;
|
||||
|
||||
SurfObj = (PSURFOBJ)AccessUserObject(NewDC->Surface);
|
||||
SurfObj->dhpdev = NewDC->PDev;
|
||||
|
||||
NewDC->w.hPalette = NewDC->DevInfo.hpalDefault;
|
||||
|
||||
DPRINT("Bits per pel: %u\n", NewDC->w.bitsPerPixel);
|
||||
|
||||
|
@ -313,11 +347,6 @@ HDC STDCALL W32kCreateDC(LPCWSTR Driver,
|
|||
DC_ReleasePtr( hNewDC );
|
||||
|
||||
return hNewDC;
|
||||
|
||||
Failure:
|
||||
DC_ReleasePtr( hNewDC );
|
||||
DC_FreeDC(hNewDC);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
HDC STDCALL W32kCreateIC(LPCWSTR Driver,
|
||||
|
|
Loading…
Reference in a new issue