From f09720f7d7e32ea46903c645668b289c193f3f8e Mon Sep 17 00:00:00 2001 From: Rex Jolliff Date: Thu, 9 Dec 1999 02:45:06 +0000 Subject: [PATCH] some more video code svn path=/trunk/; revision=840 --- reactos/include/ddk/ntddvid.h | 32 +++++++++++++++++++++---- reactos/include/win32k/driver.h | 2 ++ reactos/ntoskrnl/cm/registry.c | 3 +-- reactos/subsys/win32k/misc/driver.c | 36 ++++++++++++++++++++++++++++- reactos/subsys/win32k/objects/dc.c | 16 +++++++++---- 5 files changed, 77 insertions(+), 12 deletions(-) diff --git a/reactos/include/ddk/ntddvid.h b/reactos/include/ddk/ntddvid.h index 19d5bb9d75d..248f5360c59 100644 --- a/reactos/include/ddk/ntddvid.h +++ b/reactos/include/ddk/ntddvid.h @@ -189,12 +189,36 @@ typedef VOID (*PBANKED_SECTION_ROUTINE)(IN ULONG ReadBank, IN ULONG WriteBank, /* FIXME: replace with proper typedefs */ typedef PVOID PVIDEO_CLUT; -typedef PVOID PVIDEO_MEMORY; -typedef PVOID PVIDEO_MEMORY_INFORMATION; -typedef PVOID PVIDEO_MODE; + +typedef struct _VIDEO_MEMORY +{ + PVOID RequestedVirtualAddress; +} VIDEO_MEMORY, *PVIDEO_MEMORY; + +typedef struct _VIDEO_MEMORY_INFORMATION +{ + PVOID VideoRamBase; + ULONG VideoRamLength; + PVOID FrameBufferBase; + ULONG FrameBufferLength; +} VIDEO_MEMORY_INFORMATION, *PVIDEO_MEMORY_INFORMATION; + +typedef struct _VIDEO_MODE +{ + ULONG RequestedMode; +} VIDEO_MODE, *PVIDEO_MODE; + +/* FIXME: replace with proper typedefs */ typedef PVOID PVIDEO_MODE_INFORMATION; typedef PVOID PVIDEO_NUM_MODES; -typedef PVOID PVIDEO_SHARE_MEMORY; + +typedef struct _VIDEO_SHARE_MEMORY +{ + HANDLE ProcessHandle; + ULONG ViewOffset; + ULONG ViewSize; + PVOID RequestedVirtualAddress; +} VIDEO_SHARE_MEMORY, *PVIDEO_SHARE_MEMORY; ULONG STDCALL VideoPortCompareMemory(IN PVOID Source1, IN PVOID Source2, IN ULONG Length); VOID STDCALL VideoPortDebugPrint(IN ULONG DebugPrintLevel, IN PCHAR DebugMessage, ...); diff --git a/reactos/include/win32k/driver.h b/reactos/include/win32k/driver.h index ce7d825aa62..6314b291e76 100644 --- a/reactos/include/win32k/driver.h +++ b/reactos/include/win32k/driver.h @@ -159,6 +159,8 @@ HANDLE DRIVER_FindMPDriver(LPCWSTR Name); BOOL DRIVER_BuildDDIFunctions(PDRVENABLEDATA DED, PDRIVER_FUNCTIONS DF); BOOL DRIVER_UnregisterDriver(LPCWSTR Name); +INT DRIVER_ReferenceDriver (LPCWSTR Name); +INT DRIVER_UnreferenceDriver (LPCWSTR Name); #endif diff --git a/reactos/ntoskrnl/cm/registry.c b/reactos/ntoskrnl/cm/registry.c index 9ad16599eae..844ea78d680 100644 --- a/reactos/ntoskrnl/cm/registry.c +++ b/reactos/ntoskrnl/cm/registry.c @@ -1,4 +1,4 @@ -/* $Id: registry.c,v 1.21 1999/11/24 11:51:46 dwelch Exp $ +/* $Id: registry.c,v 1.22 1999/12/09 02:45:05 rex Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -1374,7 +1374,6 @@ CmiObjectParse(PVOID ParsedObject, PWSTR *Path) return NewKeyObject; } - /* FIXME: this access of RootKeyBlock should be guarded by spinlock */ CurKeyBlock = CmiGetKeyBlock(RegistryFile, RegistryFile->HeaderBlock->RootKeyBlock); diff --git a/reactos/subsys/win32k/misc/driver.c b/reactos/subsys/win32k/misc/driver.c index 46ef658b247..53b2c089b76 100644 --- a/reactos/subsys/win32k/misc/driver.c +++ b/reactos/subsys/win32k/misc/driver.c @@ -1,4 +1,4 @@ -/* $Id: driver.c,v 1.5 1999/11/20 21:51:19 ekohl Exp $ +/* $Id: driver.c,v 1.6 1999/12/09 02:45:05 rex Exp $ * * GDI Driver support routines * (mostly swiped from Wine) @@ -18,6 +18,7 @@ typedef struct _GRAPHICS_DRIVER { PWSTR Name; PGD_ENABLEDRIVER EnableDriver; + int ReferenceCount; struct _GRAPHICS_DRIVER *Next; } GRAPHICS_DRIVER, *PGRAPHICS_DRIVER; @@ -31,6 +32,7 @@ BOOL DRIVER_RegisterDriver(LPCWSTR Name, PGD_ENABLEDRIVER EnableDriver) { return FALSE; } + Driver->ReferenceCount = 0; Driver->EnableDriver = EnableDriver; if (Name) { @@ -174,3 +176,35 @@ BOOL DRIVER_UnregisterDriver(LPCWSTR Name) } } +INT DRIVER_ReferenceDriver (LPCWSTR Name) +{ + GRAPHICS_DRIVER *Driver = DriverList; + + while (Driver && Name) + { + if (!_wcsicmp( Driver->Name, Name)) + { + return ++Driver->ReferenceCount; + } + Driver = Driver->Next; + } + + return GenericDriver ? ++GenericDriver->ReferenceCount : 0; +} + +INT DRIVER_UnreferenceDriver (LPCWSTR Name) +{ + GRAPHICS_DRIVER *Driver = DriverList; + + while (Driver && Name) + { + if (!_wcsicmp( Driver->Name, Name)) + { + return --Driver->ReferenceCount; + } + Driver = Driver->Next; + } + + return GenericDriver ? --GenericDriver->ReferenceCount : 0; +} + diff --git a/reactos/subsys/win32k/objects/dc.c b/reactos/subsys/win32k/objects/dc.c index e4343f638d7..4a0f3529b0b 100644 --- a/reactos/subsys/win32k/objects/dc.c +++ b/reactos/subsys/win32k/objects/dc.c @@ -1,4 +1,4 @@ -/* $Id: dc.c,v 1.9 1999/11/17 20:54:05 rex Exp $ +/* $Id: dc.c,v 1.10 1999/12/09 02:45:06 rex Exp $ * * DC.C - Device context functions * @@ -105,7 +105,8 @@ HDC STDCALL W32kCreateCompatableDC(HDC hDC) return NULL; } - + DRIVER_ReferenceDriver (NewDC->DriverName); + /* Copy information from original DC to new DC */ NewDC->hSelf = NewDC; @@ -243,6 +244,8 @@ HDC STDCALL W32kCreateDC(LPCWSTR Driver, /* Complete initialization of the physical device */ NewDC->DriverFunctions.CompletePDev(NewDC->PDev, NewDC); + DRIVER_ReferenceDriver (Driver); + /* Enable the drawing surface */ NewDC->Surface = NewDC->DriverFunctions.EnableSurface(NewDC->PDev); @@ -277,9 +280,12 @@ BOOL STDCALL W32kDeleteDC(HDC DCHandle) return FALSE; } - DCToDelete->DriverFunctions.DisableSurface(DCToDelete->PDev); - DCToDelete->DriverFunctions.DisablePDev(DCToDelete->PDev); - + if (!DRIVER_UnreferenceDriver (DCToDelete->DriverName)) + { + DCToDelete->DriverFunctions.DisableSurface(DCToDelete->PDev); + DCToDelete->DriverFunctions.DisablePDev(DCToDelete->PDev); + } + /* First delete all saved DCs */ while (DCToDelete->saveLevel) {