ReactOS is now using NtGdiOpenDCW for CreateD*IC. Tested with Qemu and real hardware.

svn path=/trunk/; revision=26575
This commit is contained in:
James Tabor 2007-04-29 06:50:36 +00:00
parent d05f5dec2f
commit 26e3f1e305
2 changed files with 90 additions and 129 deletions

View file

@ -15,12 +15,16 @@ IntCreateDICW ( LPCWSTR lpwszDriver,
{ {
UNICODE_STRING Device, Output; UNICODE_STRING Device, Output;
HDC hDC = NULL; HDC hDC = NULL;
BOOL Display = FALSE; BOOL Display = FALSE, Default = TRUE;
ULONG UMdhpdev = 0; ULONG UMdhpdev = 0;
HANDLE hspool = NULL; HANDLE hspool = NULL;
if ((!lpwszDevice) && (!lpwszDriver)) return hDC; if ((!lpwszDevice) && (!lpwszDriver))
{
Default = FALSE; // Ask Win32k to set Default device.
Display = TRUE; // Most likely to be DISPLAY.
}
else else
{ {
if (lpwszDevice) // First if (lpwszDevice) // First
@ -47,14 +51,14 @@ IntCreateDICW ( LPCWSTR lpwszDriver,
DPRINT1("Not a DISPLAY device! %wZ\n", &Device); DPRINT1("Not a DISPLAY device! %wZ\n", &Device);
} }
hDC = NtGdiOpenDCW( &Device, hDC = NtGdiOpenDCW( (Default ? &Device : NULL),
(PDEVMODEW) lpInitData, (PDEVMODEW) lpInitData,
(lpwszOutput ? &Output : NULL), (lpwszOutput ? &Output : NULL),
iType, // DCW 0 and ICW 1. iType, // DCW 0 and ICW 1.
hspool, hspool,
(PVOID) NULL, // NULL for now. (PVOID) NULL, // NULL for now.
(PVOID) &UMdhpdev ); (PVOID) &UMdhpdev );
#if 0
// Handle something other than a normal dc object. // Handle something other than a normal dc object.
if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC) if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_DC)
{ {
@ -68,8 +72,9 @@ IntCreateDICW ( LPCWSTR lpwszDriver,
Dc_Attr->pvLDC = pLDC; Dc_Attr->pvLDC = pLDC;
pLDC->hDC = hDC; pLDC->hDC = hDC;
pLDC->iType = LDC_LDC; // 1 (init) local DC, 2 EMF LDC pLDC->iType = LDC_LDC; // 1 (init) local DC, 2 EMF LDC
DbgPrint("DC_ATTR Allocated -> 0x%x\n",Dc_Attr);
} }
#endif
return hDC; return hDC;
} }
@ -83,67 +88,58 @@ CreateDCA (
LPCSTR lpszDriver, LPCSTR lpszDriver,
LPCSTR lpszDevice, LPCSTR lpszDevice,
LPCSTR lpszOutput, LPCSTR lpszOutput,
CONST DEVMODEA * lpInitData CONST DEVMODEA * lpdvmInit
) )
{ {
ANSI_STRING DriverA, DeviceA, OutputA; ANSI_STRING DriverA, DeviceA, OutputA;
UNICODE_STRING DriverU, DeviceU, OutputU; UNICODE_STRING DriverU, DeviceU, OutputU;
HDC hDC; LPDEVMODEW dvmInitW = NULL;
DEVMODEW *lpInitDataW; HDC hDC;
/* /*
* If needed, convert to Unicode * If needed, convert to Unicode
* any string parameter. * any string parameter.
*/ */
if (NULL != lpszDriver) if (NULL != lpszDriver)
{ {
RtlInitAnsiString(&DriverA, (LPSTR)lpszDriver); RtlInitAnsiString(&DriverA, (LPSTR)lpszDriver);
RtlAnsiStringToUnicodeString(&DriverU, &DriverA, TRUE); RtlAnsiStringToUnicodeString(&DriverU, &DriverA, TRUE);
} else } else
DriverU.Buffer = NULL; DriverU.Buffer = NULL;
if (NULL != lpszDevice) if (NULL != lpszDevice)
{ {
RtlInitAnsiString(&DeviceA, (LPSTR)lpszDevice); RtlInitAnsiString(&DeviceA, (LPSTR)lpszDevice);
RtlAnsiStringToUnicodeString(&DeviceU, &DeviceA, TRUE); RtlAnsiStringToUnicodeString(&DeviceU, &DeviceA, TRUE);
} else } else
DeviceU.Buffer = NULL; DeviceU.Buffer = NULL;
if (NULL != lpszOutput) if (NULL != lpszOutput)
{ {
RtlInitAnsiString(&OutputA, (LPSTR)lpszOutput); RtlInitAnsiString(&OutputA, (LPSTR)lpszOutput);
RtlAnsiStringToUnicodeString(&OutputU, &OutputA, TRUE); RtlAnsiStringToUnicodeString(&OutputU, &OutputA, TRUE);
} else } else
OutputU.Buffer = NULL; OutputU.Buffer = NULL;
if (NULL != lpInitData) if ( lpdvmInit )
{ dvmInitW = GdiConvertToDevmodeW((LPDEVMODEA)lpdvmInit);
// lpInitDataW = HeapAllocMem(
} else
lpInitDataW = NULL;
/* hDC = IntCreateDICW ( DriverU.Buffer,
* Call the Unicode version DeviceU.Buffer,
* of CreateDC. OutputU.Buffer,
*/ lpdvmInit ? dvmInitW : NULL,
0 );
HEAP_free (dvmInitW);
/*
* Free Unicode parameters.
*/
RtlFreeUnicodeString(&DriverU);
RtlFreeUnicodeString(&DeviceU);
RtlFreeUnicodeString(&OutputU);
hDC = CreateDCW ( /*
DriverU.Buffer, * Return the possible DC handle.
DeviceU.Buffer, */
OutputU.Buffer, return hDC;
NULL);
// lpInitDataW);
/*
* Free Unicode parameters.
*/
RtlFreeUnicodeString(&DriverU);
RtlFreeUnicodeString(&DeviceU);
RtlFreeUnicodeString(&OutputU);
/*
* Return the possible DC handle.
*/
return hDC;
} }
@ -156,39 +152,15 @@ CreateDCW (
LPCWSTR lpwszDriver, LPCWSTR lpwszDriver,
LPCWSTR lpwszDevice, LPCWSTR lpwszDevice,
LPCWSTR lpwszOutput, LPCWSTR lpwszOutput,
CONST DEVMODEW * lpInitData CONST DEVMODEW *lpInitData
) )
{ {
UNICODE_STRING Driver, Device, Output;
if(lpwszDriver) return IntCreateDICW ( lpwszDriver,
RtlInitUnicodeString(&Driver, lpwszDriver); lpwszDevice,
if(lpwszDevice) lpwszOutput,
RtlInitUnicodeString(&Driver, lpwszDevice); (PDEVMODEW) lpInitData,
if(lpwszOutput) 0 );
RtlInitUnicodeString(&Driver, lpwszOutput);
HDC hDC = NtGdiCreateDC((lpwszDriver ? &Driver : NULL),
(lpwszDevice ? &Device : NULL),
(lpwszOutput ? &Output : NULL),
(PDEVMODEW)lpInitData);
/* DC_ATTR Tests.
if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_DC)
{
PDC_ATTR Dc_Attr;
GdiGetHandleUserData((HGDIOBJ) hDC, (PVOID) &Dc_Attr);
DPRINT1("Test DC_ATTR -> ! 0x%x\n", Dc_Attr);
DPRINT1("Test DC_ATTR access! 0x%x\n", Dc_Attr->pvLDC);
Dc_Attr->pvLDC = (PVOID)1;
DPRINT1("Test DC_ATTR access! 0x%x\n", Dc_Attr->pvLDC);
Dc_Attr->pvLDC = (PVOID)0;
DPRINT1("Test DC_ATTR access! 0x%x\n", Dc_Attr->pvLDC);
}
*/
return hDC;
} }
@ -198,24 +170,17 @@ CreateDCW (
HDC HDC
STDCALL STDCALL
CreateICW( CreateICW(
LPCWSTR lpszDriver, LPCWSTR lpszDriver,
LPCWSTR lpszDevice, LPCWSTR lpszDevice,
LPCWSTR lpszOutput, LPCWSTR lpszOutput,
CONST DEVMODEW * lpdvmInit CONST DEVMODEW *lpdvmInit
) )
{ {
UNICODE_STRING Driver, Device, Output; return IntCreateDICW ( lpszDriver,
lpszDevice,
if(lpszDriver) lpszOutput,
RtlInitUnicodeString(&Driver, lpszDriver); (PDEVMODEW) lpdvmInit,
if(lpszDevice) 1 );
RtlInitUnicodeString(&Device, lpszDevice);
if(lpszOutput)
RtlInitUnicodeString(&Output, lpszOutput);
return NtGdiCreateIC ((lpszDriver ? &Driver : NULL),
(lpszDevice ? &Device : NULL),
(lpszOutput ? &Output : NULL),
(CONST PDEVMODEW)lpdvmInit );
} }
@ -225,22 +190,21 @@ CreateICW(
HDC HDC
STDCALL STDCALL
CreateICA( CreateICA(
LPCSTR lpszDriver, LPCSTR lpszDriver,
LPCSTR lpszDevice, LPCSTR lpszDevice,
LPCSTR lpszOutput, LPCSTR lpszOutput,
CONST DEVMODEA * lpdvmInit CONST DEVMODEA *lpdvmInit
) )
{ {
NTSTATUS Status; NTSTATUS Status;
LPWSTR lpszDriverW, lpszDeviceW, lpszOutputW; LPWSTR lpszDriverW, lpszDeviceW, lpszOutputW;
UNICODE_STRING Driver, Device, Output; LPDEVMODEW dvmInitW = NULL;
LPDEVMODEW dvmInitW = NULL; HDC rc = 0;
HDC rc = 0;
Status = HEAP_strdupA2W ( &lpszDriverW, lpszDriver ); Status = HEAP_strdupA2W ( &lpszDriverW, lpszDriver );
if (!NT_SUCCESS (Status)) if (!NT_SUCCESS (Status))
SetLastError (RtlNtStatusToDosError(Status)); SetLastError (RtlNtStatusToDosError(Status));
else else
{ {
Status = HEAP_strdupA2W ( &lpszDeviceW, lpszDevice ); Status = HEAP_strdupA2W ( &lpszDeviceW, lpszDevice );
if (!NT_SUCCESS (Status)) if (!NT_SUCCESS (Status))
@ -253,23 +217,21 @@ CreateICA(
else else
{ {
if ( lpdvmInit ) if ( lpdvmInit )
dvmInitW = GdiConvertToDevmodeW((LPDEVMODEA)lpdvmInit); dvmInitW = GdiConvertToDevmodeW((LPDEVMODEA)lpdvmInit);
RtlInitUnicodeString(&Driver, lpszDriverW); rc = IntCreateDICW ( lpszDriverW,
RtlInitUnicodeString(&Device, lpszDeviceW); lpszDeviceW,
RtlInitUnicodeString(&Output, lpszOutputW); lpszOutputW,
rc = NtGdiCreateIC ( &Driver, lpdvmInit ? dvmInitW : NULL,
&Device, 1 );
&Output, HEAP_free (dvmInitW);
lpdvmInit ? dvmInitW : NULL );
HEAP_free (dvmInitW);
HEAP_free ( lpszOutputW ); HEAP_free ( lpszOutputW );
} }
HEAP_free ( lpszDeviceW ); HEAP_free ( lpszDeviceW );
} }
HEAP_free ( lpszDriverW ); HEAP_free ( lpszDriverW );
} }
return rc; return rc;
} }

View file

@ -1105,7 +1105,6 @@ NtGdiOpenDCW( PUNICODE_STRING Device,
Status = IntSafeCopyUnicodeString(&SafeDevice, Device); Status = IntSafeCopyUnicodeString(&SafeDevice, Device);
if(!NT_SUCCESS(Status)) if(!NT_SUCCESS(Status))
{ {
RtlFreeUnicodeString(&SafeDevice);
SetLastNtError(Status); SetLastNtError(Status);
return NULL; return NULL;
} }
@ -2340,7 +2339,7 @@ DC_AllocDC(PUNICODE_STRING Driver)
NewDC->vportExtY = 1.0f; NewDC->vportExtY = 1.0f;
NewDC->w.textColor = 0; NewDC->w.textColor = 0;
// NewDC->pDc_Attr->ulForegroundClr = 0; Already Zero // NewDC->pDc_Attr->ulForegroundClr = 0; // Already Zero
// NewDC->pDc_Attr->crForegroundClr = 0; // NewDC->pDc_Attr->crForegroundClr = 0;
NewDC->w.backgroundColor = 0xffffff; NewDC->w.backgroundColor = 0xffffff;