Skip to content

Commit e44b2f4

Browse files
committed
[WIN32K]
- Don't check for presence of driver functions that are not mandatory - Pass graphics device, devmode and log address to PDEVOBJ_CreatePDEV to make it work svn path=/branches/GSoC_2011/GdiFontDriver/; revision=56032
1 parent 97df198 commit e44b2f4

File tree

4 files changed

+64
-47
lines changed

4 files changed

+64
-47
lines changed

win32ss/gdi/eng/ldevobj.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,7 @@ LDEVOBJ_bEnableDriver(
275275

276276
/* Check if the neccessary functions are there */
277277
if ((!pldev->pfn.EnablePDEV) ||
278-
(!pldev->pfn.CompletePDEV) ||
279-
(!pldev->pfn.UnloadFontFile))
278+
(!pldev->pfn.CompletePDEV))
280279
{
281280
DPRINT1("Missing function for gdi driver\n");
282281
return FALSE;
@@ -287,7 +286,6 @@ LDEVOBJ_bEnableDriver(
287286
if ((!pldev->pfn.AssertMode) ||
288287
(!pldev->pfn.EnableSurface) ||
289288
(!pldev->pfn.DisableSurface) ||
290-
(!pldev->pfn.DisableDriver) ||
291289
(!pldev->pfn.DisablePDEV) ||
292290
(!pldev->pfn.GetModes))
293291
{

win32ss/gdi/eng/pdevobj.c

Lines changed: 58 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
*/
88

99
#include <win32k.h>
10-
#define NDEBUG
11-
#include <debug.h>
10+
DBG_DEFAULT_CHANNEL(EngPDev);
1211

1312
PPDEVOBJ gppdevPrimary = NULL;
1413

@@ -134,7 +133,7 @@ PDEVOBJ_bEnablePDEV(
134133
PFN_DrvEnablePDEV pfnEnablePDEV;
135134
ULONG i;
136135

137-
DPRINT("PDEVOBJ_bEnablePDEV()\n");
136+
TRACE("PDEVOBJ_bEnablePDEV()\n");
138137

139138
/* Get the DrvEnablePDEV function */
140139
pfnEnablePDEV = ppdev->pldev->pfn.EnablePDEV;
@@ -186,7 +185,7 @@ PDEVOBJ_bEnablePDEV(
186185
ppdev->ahsurf[i] = gahsurfHatch[i];
187186
}
188187

189-
DPRINT("PDEVOBJ_bEnablePDEV - dhpdev = %p\n", ppdev->dhpdev);
188+
TRACE("PDEVOBJ_bEnablePDEV - dhpdev = %p\n", ppdev->dhpdev);
190189

191190
return TRUE;
192191
}
@@ -203,16 +202,18 @@ PDEVOBJ_vCompletePDEV(
203202
PPDEVOBJ
204203
NTAPI
205204
PDEVOBJ_CreatePDEV(
206-
PLDEVOBJ pldev)
205+
PLDEVOBJ pldev,
206+
PGRAPHICS_DEVICE pGraphicsDevice,
207+
PDEVMODEW pdevmode,
208+
PWSTR pwszLogAddress)
207209
{
208210
PPDEVOBJ ppdev;
209-
LDEVTYPE ldevtype;
210211

211212
/* Allocate a new PDEVOBJ */
212213
ppdev = ExAllocatePoolWithTag(PagedPool, sizeof(PDEVOBJ), GDITAG_PDEV);
213214
if (!ppdev)
214215
{
215-
DPRINT1("failed to allocate a PDEV\n");
216+
ERR("failed to allocate a PDEV\n");
216217
return FALSE;
217218
}
218219

@@ -227,11 +228,14 @@ PDEVOBJ_CreatePDEV(
227228
/* Copy the function table from the LDEVOBJ */
228229
ppdev->pfn = ppdev->pldev->pfn;
229230

231+
/* Set the graphics device */
232+
ppdev->pGraphicsDevice = pGraphicsDevice;
233+
230234
/* Allocate the device lock semaphore */
231235
ppdev->hsemDevLock = EngCreateSemaphore();
232236
if (!ppdev->hsemDevLock)
233237
{
234-
DPRINT1("Failed to create semaphore\n");
238+
ERR("Failed to create semaphore\n");
235239
ExFreePoolWithTag(ppdev, GDITAG_PDEV);
236240
return FALSE;
237241
}
@@ -242,27 +246,48 @@ PDEVOBJ_CreatePDEV(
242246
RtlZeroMemory(ppdev->pEDDgpl, sizeof(EDD_DIRECTDRAW_GLOBAL));
243247

244248
/* Call the drivers DrvEnablePDEV function */
245-
if (!PDEVOBJ_bEnablePDEV(ppdev, NULL, NULL))
249+
if (!PDEVOBJ_bEnablePDEV(ppdev, pdevmode, NULL))
246250
{
247-
DPRINT1("Failed to enable PDEV\n");
251+
ERR("Failed to enable PDEV\n");
248252
EngDeleteSemaphore(ppdev->hsemDevLock);
249253
ExFreePoolWithTag(ppdev, GDITAG_PDEV);
250254
return FALSE;
251255
}
252256

253-
/* Set flags based on the LDEV type */
254-
ldevtype = pldev->ldevtype;
255-
if (ldevtype == LDEV_DEVICE_MIRROR) ppdev->flFlags |= PDEV_CLONE_DEVICE;
256-
else if (ldevtype == LDEV_DEVICE_DISPLAY) ppdev->flFlags |= PDEV_DISPLAY;
257-
else if (ldevtype == LDEV_DEVICE_PRINTER) ppdev->flFlags |= PDEV_PRINTER;
258-
else if (ldevtype == LDEV_DEVICE_META) ppdev->flFlags |= PDEV_META_DEVICE;
259-
else if (ldevtype == LDEV_FONT) ppdev->flFlags |= PDEV_FONTDRIVER;
257+
/* Check what type of driver this is */
258+
if (pldev->ldevtype == LDEV_DEVICE_DISPLAY)
259+
{
260+
/* This is a display device */
261+
ppdev->flFlags |= PDEV_DISPLAY;
262+
263+
/* Check if the driver supports a hardware pointer */
264+
if (ppdev->pfn.SetPointerShape && ppdev->pfn.MovePointer)
265+
{
266+
ppdev->flFlags |= PDEV_HARDWARE_POINTER;
267+
//ppdev->pfnDrvSetPointerShape = ppdev->pfn.SetPointerShape;
268+
ppdev->pfnMovePointer = ppdev->pfn.MovePointer;
269+
}
270+
else
271+
{
272+
ppdev->flFlags |= PDEV_SOFTWARE_POINTER;
273+
//ppdev->pfnDrvSetPointerShape = EngSetPointerShape;
274+
ppdev->pfnMovePointer = EngMovePointer;
275+
}
276+
277+
}
278+
else if (pldev->ldevtype == LDEV_DEVICE_MIRROR)
279+
ppdev->flFlags |= PDEV_CLONE_DEVICE;
280+
else if (pldev->ldevtype == LDEV_DEVICE_PRINTER)
281+
ppdev->flFlags |= PDEV_PRINTER;
282+
else if (pldev->ldevtype == LDEV_DEVICE_META)
283+
ppdev->flFlags |= PDEV_META_DEVICE;
284+
else if (pldev->ldevtype == LDEV_FONT)
285+
ppdev->flFlags |= PDEV_FONTDRIVER;
260286

261287
/* Check if the driver supports fonts */
262288
if (ppdev->devinfo.cFonts != 0) ppdev->flFlags |= PDEV_GOTFONTS;
263289

264-
if (ppdev->pfn.MovePointer) ppdev->flFlags |= PDEV_HARDWARE_POINTER;
265-
290+
/* Check for a gamma ramp table */
266291
if (ppdev->pvGammaRamp) ppdev->flFlags |= PDEV_GAMMARAMP_TABLE;
267292

268293
/* Call the drivers DrvCompletePDEV function */
@@ -297,7 +322,7 @@ PDEVOBJ_pSurface(
297322
/* Increment reference count */
298323
GDIOBJ_vReferenceObjectByPointer(&ppdev->pSurface->BaseObject);
299324

300-
DPRINT("PDEVOBJ_pSurface() returning %p\n", ppdev->pSurface);
325+
TRACE("PDEVOBJ_pSurface() returning %p\n", ppdev->pSurface);
301326
return ppdev->pSurface;
302327
}
303328

@@ -390,16 +415,16 @@ EngCreateDisplayPDEV(
390415
PGRAPHICS_DEVICE pGraphicsDevice;
391416
PLDEVOBJ pldev;
392417
PPDEVOBJ ppdev;
393-
DPRINT("EngCreateDisplayPDEV(%wZ, %p)\n", pustrDeviceName, pdm);
418+
TRACE("EngCreateDisplayPDEV(%wZ, %p)\n", pustrDeviceName, pdm);
394419

395420
/* Try to find the GRAPHICS_DEVICE */
396421
if (pustrDeviceName)
397422
{
398423
pGraphicsDevice = EngpFindGraphicsDevice(pustrDeviceName, 0, 0);
399424
if (!pGraphicsDevice)
400425
{
401-
DPRINT1("No GRAPHICS_DEVICE found for %ls!\n",
402-
pustrDeviceName ? pustrDeviceName->Buffer : 0);
426+
ERR("No GRAPHICS_DEVICE found for %ls!\n",
427+
pustrDeviceName ? pustrDeviceName->Buffer : 0);
403428
return NULL;
404429
}
405430
}
@@ -413,34 +438,27 @@ EngCreateDisplayPDEV(
413438
{
414439
/* ... use the device's default one */
415440
pdm = pGraphicsDevice->pDevModeList[pGraphicsDevice->iDefaultMode].pdm;
416-
DPRINT("Using iDefaultMode = %lu\n", pGraphicsDevice->iDefaultMode);
441+
TRACE("Using iDefaultMode = %lu\n", pGraphicsDevice->iDefaultMode);
417442
}
418443

419444
/* Try to get a diplay driver */
420445
pldev = EngLoadImageEx(pdm->dmDeviceName, LDEV_DEVICE_DISPLAY);
421446
if (!pldev)
422447
{
423-
DPRINT1("Could not load display driver '%ls', '%ls'\n",
424-
pGraphicsDevice->pDiplayDrivers,
425-
pdm->dmDeviceName);
448+
ERR("Could not load display driver '%ls', '%ls'\n",
449+
pGraphicsDevice->pDiplayDrivers, pdm->dmDeviceName);
426450
return NULL;
427451
}
428452

429453
/* Create a new PDEVOBJ */
430-
ppdev = PDEVOBJ_CreatePDEV(pldev);
454+
ppdev = PDEVOBJ_CreatePDEV(pldev, pGraphicsDevice, pdm, NULL);
431455
if (!ppdev)
432456
{
433-
DPRINT1("failed to allocate a PDEV\n");
457+
ERR("failed to create a PDEV\n");
434458
EngUnloadImage(pldev);
435459
return FALSE;
436460
}
437461

438-
/* Set MovePointer function */
439-
ppdev->pfnMovePointer = ppdev->pfn.MovePointer;
440-
if (!ppdev->pfnMovePointer)
441-
ppdev->pfnMovePointer = EngMovePointer;
442-
443-
ppdev->pGraphicsDevice = pGraphicsDevice;
444462

445463
// DxEngGetHdevData asks for Graphics DeviceObject in hSpooler field
446464
ppdev->hSpooler = ppdev->pGraphicsDevice->DeviceObject;
@@ -537,22 +555,21 @@ PDEVOBJ_bSwitchMode(
537555
PPDEVOBJ ppdevTmp;
538556
PSURFACE pSurface;
539557
BOOL retval = FALSE;
558+
TRACE("PDEVOBJ_bSwitchMode, ppdev = %p, pSurface = %p\n", ppdev, ppdev->pSurface);
540559

541560
/* Lock the PDEV */
542561
EngAcquireSemaphore(ppdev->hsemDevLock);
543562

544563
/* And everything else */
545564
EngAcquireSemaphore(ghsemPDEV);
546565

547-
DPRINT1("PDEVOBJ_bSwitchMode, ppdev = %p, pSurface = %p\n", ppdev, ppdev->pSurface);
548-
549566
// Lookup the GraphicsDevice + select DEVMODE
550567
// pdm = PDEVOBJ_pdmMatchDevMode(ppdev, pdm);
551568

552569
/* 1. Temporarily disable the current PDEV */
553570
if (!ppdev->pfn.AssertMode(ppdev->dhpdev, FALSE))
554571
{
555-
DPRINT1("DrvAssertMode failed\n");
572+
ERR("DrvAssertMode failed\n");
556573
goto leave;
557574
}
558575

@@ -561,15 +578,15 @@ PDEVOBJ_bSwitchMode(
561578
ppdevTmp = EngCreateDisplayPDEV(&ustrDevice, pdm);
562579
if (!ppdevTmp)
563580
{
564-
DPRINT1("Failed to create a new PDEV\n");
581+
ERR("Failed to create a new PDEV\n");
565582
goto leave;
566583
}
567584

568585
/* 3. Create a new surface */
569586
pSurface = PDEVOBJ_pSurface(ppdevTmp);
570587
if (!pSurface)
571588
{
572-
DPRINT1("PDEVOBJ_pSurface failed\n");
589+
ERR("PDEVOBJ_pSurface failed\n");
573590
goto leave;
574591
}
575592

@@ -597,8 +614,7 @@ PDEVOBJ_bSwitchMode(
597614
EngReleaseSemaphore(ppdev->hsemDevLock);
598615
EngReleaseSemaphore(ghsemPDEV);
599616

600-
DPRINT1("leave, ppdev = %p, pSurface = %p\n", ppdev, ppdev->pSurface);
601-
617+
TRACE("leave, ppdev = %p, pSurface = %p\n", ppdev, ppdev->pSurface);
602618
return retval;
603619
}
604620

win32ss/gdi/eng/pdevobj.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,10 @@ InitPDEVImpl(VOID);
187187
PPDEVOBJ
188188
NTAPI
189189
PDEVOBJ_CreatePDEV(
190-
struct _LDEVOBJ *pldev);
190+
struct _LDEVOBJ *pldev,
191+
PGRAPHICS_DEVICE pGraphicsDevice,
192+
PDEVMODEW pdevmode,
193+
PWSTR pwszLogAddress);
191194

192195
BOOL
193196
NTAPI

win32ss/gdi/font/fntdrvsup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ EngLoadFontDriver(
278278
}
279279

280280
/* Create a new PDEVOBJ */
281-
ppdev = PDEVOBJ_CreatePDEV(pldev);
281+
ppdev = PDEVOBJ_CreatePDEV(pldev, NULL, NULL, NULL);
282282
if (!ppdev)
283283
{
284284
DPRINT1("failed to allocate a PDEV\n");

0 commit comments

Comments
 (0)