some additions to the GDI engine

svn path=/trunk/; revision=554
This commit is contained in:
Rex Jolliff 1999-06-15 02:27:24 +00:00
parent e0c5a61982
commit 11d31698d5
4 changed files with 279 additions and 84 deletions

View file

@ -0,0 +1,21 @@
typedef struct _WIN_DC_INFO
{
} WIN_DC_INFO;
typedef struct _DC
{
DHPDEV PDev;
DEVMODEW DMW;
HSURF FillPatternSurfaces[HS_DDI_MAX];
GDIINFO GDIInfo;
DEVINFO DevInfo;
HSURF Surface = NULL;
DRIVER_FUNCTIONS DriverFunctions;
HANDLE DeviceDriver;
WIN_DC_INFO WinDCInfo;
} DC, *PDC;

View file

@ -0,0 +1,72 @@
BOOL (*PGD_ENABLEDRIVER)(ULONG, ULONG, PDRVENABLEDATA);
typedef struct _DRIVER_FUNCTIONS
{
PGD_ENABLEDRIVER EnableDriver;
PGD_ENABLEPDEV EnablePDev;
PGD_COMPLETEPDEV CompletePDev;
PGD_DISABLEPDEV DisablePDev;
PGD_ENABLESURFACE EnableSurface;
PGD_DISABLESURFACE DisableSurface;
PGD_ASSERTMODE AssertMode;
PGD_RESETPDEV ResetPDev;
#if 0
PGD_CREATEDEVICEBITMAP,
PGD_DELETEDEVICEBITMAP,
PGD_REALIZEBRUSH,
PGD_DITHERCOLOR,
PGD_STROKEPATH,
PGD_FILLPATH,
PGD_STROKEANDFILLPATH,
PGD_PAINT
PGD_BITBLT,
PGD_COPYBITS,
PGD_STRETCHBLT,
PGD_SETPALETTE,
PGD_TEXTOUT,
PGD_ESCAPE,
PGD_DRAWESCAPE,
PGD_QUERYFONT,
PGD_QUERYFONTTREE,
PGD_QUERYFONTDATA,
PGD_SETPOINTERSHAPE,
PGD_MOVEPOINTER,
PGD_LINETO,
PGD_SENDPAGE,
PGD_STARTPAGE,
PGD_ENDDOC,
PGD_STARTDOC,
PGD_GETGLYPHMODE,
PGD_SYNCHRONIZE,
PGD_SAVESCREENBITS,
PGD_GETMODES,
PGD_FREE,
PGD_DESTROYFONT,
PGD_QUERYFONTCAPS,
PGD_LOADFONTFILE,
PGD_UNLOADFONTFILE,
PGD_FONTMANAGEMENT,
PGD_QUERYTRUETYPETABLE,
PGD_QUERYTRUETYPEOUTLINE,
PGD_GETTRUETYPEFILE,
PGD_QUERYFONTFILE,
PGD_QUERYADVANCEWIDTHS,
PGD_SETPIXELFORMAT,
PGD_DESCRIBEPIXELFORMAT,
PGD_SWAPBUFFERS,
PGD_STARTBANDING,
PGD_NEXTBAND,
PGD_GETDIRECTDRAWINFO,
PGD_ENABLEDIRECTDRAW,
PGD_DISABLEDIRECTDRAW,
PGD_QUERYSPOOLTYPE,
#endif
} DRIVER_FUNCTIONS, *PDRIVER_FUNCTIONS;
BOOL DRIVER_RegisterDriver(PWSTR Name, GD_ENABLEDRIVER EnableDriver);
PDRIVER_FUNCTIONS DRIVER_FindDriver(PWSTR Name);
BOOL DRIVER_BuildFunctions(PWSTR Name, PDRVENABLEDATA DED);
BOOL DRIVER_UnregisterDriver(PWSTR Name);

View file

@ -6,23 +6,12 @@
#include <windows.h>
#include <ddk/ntddk.h>
#include <win32k/dc.h>
#include <win32k/driver.h>
// --------------------------------------------------------- File Statics
/* FIXME: these should probably be placed in an object in the future */
HANDLE gDriverHandle = NULL;
DRVENABLEDATA gDED;
typedef struct _DC
{
DHPDEV PDev;
DEVMODEW DMW;
HSURF FillPatternSurfaces[HS_DDI_MAX];
GDIINFO GDIInfo;
DEVINFO DevInfo;
HSURF Surface = NULL;
} DC, *PDC;
DC gSurfaceDC;
DC gSurfaceDC;
// ----------------------------------------------------- Public Functions
@ -37,89 +26,92 @@ NTSTATUS W32kCreateDC(HDC *DC,
CONST PDEVMODE InitData)
{
NTSTATUS Status;
PGD_ENABLEDRIVER GDEnableDriver;
UNICODE_STRING DeviceName, ErrorMsg;
OBJECT_ATTRIBUTES ObjectAttributes;
/* Is this a request for a printer DC? */
if (wcsicmp(Driver, L"DISPLAY"))
/* Get the DDI driver's entry point */
if ((GDEnableDriver = DRIVER_FindDriver(Driver)) == NULL)
{
UNIMPLEMENTED;
return STATUS_UNSUCCESSFUL;
}
/* Initialize driver pair here on first call for display DC. */
if (gDriverHandle == NULL)
/* FIXME: left off here... */
/* FIXME: allocate a DC object */
/* FIXME: recode the rest of the function to use the allocated DC */
/* FIXME: should get the device name from the DRIVER funcs */
RtlInitUnicodeString(&DeviceName, L"\\Device\\DISPLAY");
InitializeObjectAttributes(&ObjectAttributes,
&DeviceName,
0,
NULL,
NULL);
Status = ZwOpenFile(&NewDC->DeviceDriver,
FILE_ALL_ACCESS,
&ObjectAttributes,
NULL,
0,
FILE_SYNCHRONOUS_IO_ALERT);
if (!NT_SUCCESS(Status))
{
/* FIXME: should get the device name from the registry */
RtlInitUnicodeString(&DeviceName, L"\\Device\\DISPLAY");
InitializeObjectAttributes(&ObjectAttributes,
&DeviceName,
0,
NULL,
NULL);
Status = ZwOpenFile(&gDriverHandle,
FILE_ALL_ACCESS,
&ObjectAttributes,
NULL,
0,
FILE_SYNCHRONOUS_IO_ALERT);
if (!NT_SUCCESS(Status))
{
DbgPrint("Failed to open display device\n");
DbgGetErrorText(Status, &ErrorMsg, 0xf);
DbgPrint("%W\n", &ErrorMsg);
RtlFreeUnicodeString(&ErrorMsg);
return Status;
}
DbgPrint("Failed to open display device\n");
DbgGetErrorText(Status, &ErrorMsg, 0xf);
DbgPrint("%W\n", &ErrorMsg);
RtlFreeUnicodeString(&ErrorMsg);
return Status;
}
/* Call DrvEnableDriver */
RtlZeroMemory(&gDED, sizeof(gDED));
if (!DrvEnableDriver(DDI_DRIVER_VERSION, sizeof(gDED), &gDED))
{
DbgPrint("DrvEnableDriver failed\n");
return STATUS_UNSUCCESSFUL;
}
/* Call DrvEnableDriver */
/* FIXME: we should only call this once, so the data should be stored in
* DRIVER funcs */
RtlZeroMemory(&gDED, sizeof(gDED));
if (!GDEnableDriver(DDI_DRIVER_VERSION, sizeof(gDED), &gDED))
{
DbgPrint("DrvEnableDriver failed\n");
return STATUS_UNSUCCESSFUL;
}
/* Allocate a phyical device handle from the driver */
if (gSurfaceDC.PDev == NULL)
/* FIXME: get mode selection information from somewhere */
if (Device != NULL)
{
RtlZeroMemory(&gSurfaceDC, sizeof(gSurfaceDC));
/* FIXME: get mode selection information from somewhere */
if (Device != NULL)
{
wcsncpy(gDMW.dmDeviceName, Device, DMMAXDEVICENAME);
}
gSurfaceDC.DMW.dmSize = sizeof(gSurfaceDC.DMW);
gSurfaceDC.DMW.dmFields = 0x000fc000;
gSurfaceDC.DMW.dmLogPixels = 96;
gSurfaceDC.DMW.BitsPerPel = 8;
gSurfaceDC.DMW.dmPelsWidth = 640;
gSurfaceDC.DMW.dmPelsHeight = 480;
gSurfaceDC.DMW.dmDisplayFlags = 0;
gSurfaceDC.DMW.dmDisplayFrequency = 0;
gSurfaceDC.PDev = DrvEnablePDEV(&gSurfaceDC.DMW,
L"",
HS_DDI_MAX,
gSurfaceDC.FillPatternSurfaces,
sizeof(gSurfaceDC.GDIInfo),
&gSurfaceDC.GDIInfo,
sizeof(gSurfaceDC.DevInfo),
&gSurfaceDC.DevInfo,
NULL,
L"",
gDriverHandle);
if (gSurfaceDC.PDev == NULL)
{
DbgPrint("DrvEnablePDEV failed\n");
return STATUS_UNSUCCESSFUL;
}
DrvCompletePDEV(gSurfaceDC.PDev, gSurfaceDC);
gSurfaceDC.Surface = DrvEnableSurface(gSurfaceDC.PDev);
wcsncpy(gDMW.dmDeviceName, Device, DMMAXDEVICENAME);
}
*DC = &SurfaceDC;
gSurfaceDC.DMW.dmSize = sizeof(gSurfaceDC.DMW);
gSurfaceDC.DMW.dmFields = 0x000fc000;
gSurfaceDC.DMW.dmLogPixels = 96;
gSurfaceDC.DMW.BitsPerPel = 8;
gSurfaceDC.DMW.dmPelsWidth = 640;
gSurfaceDC.DMW.dmPelsHeight = 480;
gSurfaceDC.DMW.dmDisplayFlags = 0;
gSurfaceDC.DMW.dmDisplayFrequency = 0;
/* FIXME: get the function pointer from the DED struct */
gSurfaceDC.PDev = GDEnablePDEV(&NewDC->DMW,
L"",
HS_DDI_MAX,
NewDC->FillPatternSurfaces,
sizeof(NewDC->GDIInfo),
&NewDC->GDIInfo,
sizeof(NewDC->DevInfo),
&NewDC->DevInfo,
NULL,
L"",
NewDC->DeviceDriver);
if (NewDC->PDev == NULL)
{
DbgPrint("DrvEnablePDEV failed\n");
return STATUS_UNSUCCESSFUL;
}
/* FIXME: get func pointer from DED */
GDCompletePDEV(NewDC->PDev, NewDC);
/* FIXME: get func pointer from DED */
NewDC->Surface = GDEnableSurface(NewDC->PDev);
*DC = NewDC;
return STATUS_SUCCESS;
}

View file

@ -0,0 +1,110 @@
/* $Id: driver.c,v 1.1 1999/06/15 02:26:43 rex Exp $
*
* GDI Driver support routines
* (mostly swiped from Wine)
*
*/
#include <win32k/driver.h>
typedef struct _GRAPHICS_DRIVER
{
PWSTR Name;
PGD_ENABLEDRIVER EnableDriver;
struct _GRAPHICS_DRIVER *Next;
} GRAPHICS_DRIVER, *PGRAPHICS_DRIVER;
static PGRAPHICS_DRIVER DriverList;
static PGRAPHICS_DRIVER GenericDriver;
BOOL DRIVER_RegisterDriver(PWSTR Name, PGD_ENABLEDRIVER EnableDriver)
{
PGRAPHICS_DRIVER Driver = ExAllocatePool(NonPagedPool, sizeof(*Driver));
if (!Driver)
{
return FALSE;
}
Driver->EnableDriver = EnableDriver;
if (Name)
{
Driver->Name = ExAllocatePool(NonPagedPool,
(wcslen(Name) + 1) * sizeof(WCHAR));
wcscpy(Driver->Name, Name);
Driver->Next = DriverList;
DriverList = Driver;
return TRUE;
}
if (GenericDriver != NULL)
{
ExFreePool(Driver);
return FALSE;
}
Driver->name = NULL;
GenericDriver = Driver;
return TRUE;
}
PGD_ENABLEDRIVER DRIVER_FindDriver(PWSTR Name)
{
GRAPHICS_DRIVER *Driver = DriverList;
while (Driver && Name)
{
if (!wcsicmp( Driver->Name, Name))
{
return Driver->EnableDriver;
}
Driver = Driver->Next;
}
return GenericDriver ? GenericDriver->EnableDriver : NULL;
}
BOOL DRIVER_UnregisterDriver(PWSTR Name)
{
PGRAPHICS_DRIVER Driver = NULL;
if (Name)
{
if (DriverList != NULL)
{
if (!wcsicmp(DriverList->Name, Name))
{
Driver = DriverList;
DriverList = DriverList->Next;
}
else
{
Driver = DriverList;
while (Driver->Next && wcsicmp(Driver->Name, Name))
{
Driver = Driver->Next;
}
}
}
}
else
{
if (GenericDriver != NULL)
{
Driver = GenericDriver;
GenericDriver = NULL;
}
}
if (Driver != NULL)
{
ExFreePool(Driver->Name);
ExFreePool(Driver);
return TRUE;
}
else
{
return FALSE;
}
}