Skip to content

Commit 0e765b5

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 707a3f4 commit 0e765b5

File tree

4 files changed

+65
-49
lines changed

4 files changed

+65
-49
lines changed

subsystems/win32/win32k/eng/ldevobj.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,7 @@ LDEVOBJ_bLoadDriver(
264264

265265
/* Check if the neccessary functions are there */
266266
if ((!pldev->pfn.EnablePDEV) ||
267-
(!pldev->pfn.CompletePDEV) ||
268-
(!pldev->pfn.UnloadFontFile))
267+
(!pldev->pfn.CompletePDEV))
269268
{
270269
DPRINT1("Missing function for gdi driver\n");
271270
return FALSE;
@@ -276,7 +275,6 @@ LDEVOBJ_bLoadDriver(
276275
if ((!pldev->pfn.AssertMode) ||
277276
(!pldev->pfn.EnableSurface) ||
278277
(!pldev->pfn.DisableSurface) ||
279-
(!pldev->pfn.DisableDriver) ||
280278
(!pldev->pfn.DisablePDEV) ||
281279
(!pldev->pfn.GetModes))
282280
{

subsystems/win32/win32k/eng/pdevobj.c

Lines changed: 59 additions & 44 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

@@ -104,8 +103,7 @@ PDEVOBJ_bEnablePDEV(
104103
PWSTR pwszLogAddress)
105104
{
106105
PFN_DrvEnablePDEV pfnEnablePDEV;
107-
108-
DPRINT("PDEVOBJ_bEnablePDEV()\n");
106+
TRACE("PDEVOBJ_bEnablePDEV()\n");
109107

110108
/* Get the DrvEnablePDEV function */
111109
pfnEnablePDEV = ppdev->pldev->pfn.EnablePDEV;
@@ -136,8 +134,7 @@ PDEVOBJ_bEnablePDEV(
136134
/* Setup Palette */
137135
ppdev->ppalSurf = PALETTE_ShareLockPalette(ppdev->devinfo.hpalDefault);
138136

139-
DPRINT("PDEVOBJ_bEnablePDEV - dhpdev = %p\n", ppdev->dhpdev);
140-
137+
TRACE("PDEVOBJ_bEnablePDEV - dhpdev = %p\n", ppdev->dhpdev);
141138
return TRUE;
142139
}
143140

@@ -153,16 +150,18 @@ PDEVOBJ_vCompletePDEV(
153150
PPDEVOBJ
154151
NTAPI
155152
PDEVOBJ_CreatePDEV(
156-
PLDEVOBJ pldev)
153+
PLDEVOBJ pldev,
154+
PGRAPHICS_DEVICE pGraphicsDevice,
155+
PDEVMODEW pdevmode,
156+
PWSTR pwszLogAddress)
157157
{
158158
PPDEVOBJ ppdev;
159-
LDEVTYPE ldevtype;
160159

161160
/* Allocate a new PDEVOBJ */
162161
ppdev = ExAllocatePoolWithTag(PagedPool, sizeof(PDEVOBJ), GDITAG_PDEV);
163162
if (!ppdev)
164163
{
165-
DPRINT1("failed to allocate a PDEV\n");
164+
ERR("failed to allocate a PDEV\n");
166165
return FALSE;
167166
}
168167

@@ -177,37 +176,61 @@ PDEVOBJ_CreatePDEV(
177176
/* Copy the function table from the LDEVOBJ */
178177
ppdev->pfn = ppdev->pldev->pfn;
179178

179+
/* Set the graphics device */
180+
ppdev->pGraphicsDevice = pGraphicsDevice;
181+
180182
/* Allocate the device lock semaphore */
181183
ppdev->hsemDevLock = EngCreateSemaphore();
182184
if (!ppdev->hsemDevLock)
183185
{
184-
DPRINT1("Failed to create semaphore\n");
186+
ERR("Failed to create semaphore\n");
185187
ExFreePoolWithTag(ppdev, GDITAG_PDEV);
186188
return FALSE;
187189
}
188190

189191
/* Call the drivers DrvEnablePDEV function */
190-
if (!PDEVOBJ_bEnablePDEV(ppdev, NULL, NULL))
192+
if (!PDEVOBJ_bEnablePDEV(ppdev, pdevmode, NULL))
191193
{
192-
DPRINT1("Failed to enable PDEV\n");
194+
ERR("Failed to enable PDEV\n");
193195
EngDeleteSemaphore(ppdev->hsemDevLock);
194196
ExFreePoolWithTag(ppdev, GDITAG_PDEV);
195197
return FALSE;
196198
}
197199

198-
/* Set flags based on the LDEV type */
199-
ldevtype = pldev->ldevtype;
200-
if (ldevtype == LDEV_DEVICE_MIRROR) ppdev->flFlags |= PDEV_CLONE_DEVICE;
201-
else if (ldevtype == LDEV_DEVICE_DISPLAY) ppdev->flFlags |= PDEV_DISPLAY;
202-
else if (ldevtype == LDEV_DEVICE_PRINTER) ppdev->flFlags |= PDEV_PRINTER;
203-
else if (ldevtype == LDEV_DEVICE_META) ppdev->flFlags |= PDEV_META_DEVICE;
204-
else if (ldevtype == LDEV_FONT) ppdev->flFlags |= PDEV_FONTDRIVER;
200+
/* Check what type of driver this is */
201+
if (pldev->ldevtype == LDEV_DEVICE_DISPLAY)
202+
{
203+
/* This is a display device */
204+
ppdev->flFlags |= PDEV_DISPLAY;
205+
206+
/* Check if the driver supports a hardware pointer */
207+
if (ppdev->pfn.SetPointerShape && ppdev->pfn.MovePointer)
208+
{
209+
ppdev->flFlags |= PDEV_HARDWARE_POINTER;
210+
//ppdev->pfnDrvSetPointerShape = ppdev->pfn.SetPointerShape;
211+
ppdev->pfnMovePointer = ppdev->pfn.MovePointer;
212+
}
213+
else
214+
{
215+
ppdev->flFlags |= PDEV_SOFTWARE_POINTER;
216+
//ppdev->pfnDrvSetPointerShape = EngSetPointerShape;
217+
ppdev->pfnMovePointer = EngMovePointer;
218+
}
219+
220+
}
221+
else if (pldev->ldevtype == LDEV_DEVICE_MIRROR)
222+
ppdev->flFlags |= PDEV_CLONE_DEVICE;
223+
else if (pldev->ldevtype == LDEV_DEVICE_PRINTER)
224+
ppdev->flFlags |= PDEV_PRINTER;
225+
else if (pldev->ldevtype == LDEV_DEVICE_META)
226+
ppdev->flFlags |= PDEV_META_DEVICE;
227+
else if (pldev->ldevtype == LDEV_FONT)
228+
ppdev->flFlags |= PDEV_FONTDRIVER;
205229

206230
/* Check if the driver supports fonts */
207231
if (ppdev->devinfo.cFonts != 0) ppdev->flFlags |= PDEV_GOTFONTS;
208232

209-
if (ppdev->pfn.MovePointer) ppdev->flFlags |= PDEV_HARDWARE_POINTER;
210-
233+
/* Check for a gamma ramp table */
211234
if (ppdev->pvGammaRamp) ppdev->flFlags |= PDEV_GAMMARAMP_TABLE;
212235

213236
/* Call the drivers DrvCompletePDEV function */
@@ -238,7 +261,7 @@ PDEVOBJ_pSurface(
238261
ppdev->pSurface = SURFACE_ShareLockSurface(hsurf);
239262
}
240263

241-
DPRINT("PDEVOBJ_pSurface() returning %p\n", ppdev->pSurface);
264+
TRACE("PDEVOBJ_pSurface() returning %p\n", ppdev->pSurface);
242265
return ppdev->pSurface;
243266
}
244267

@@ -290,16 +313,16 @@ EngCreateDisplayPDEV(
290313
PGRAPHICS_DEVICE pGraphicsDevice;
291314
PLDEVOBJ pldev;
292315
PPDEVOBJ ppdev;
293-
DPRINT("EngCreateDisplayPDEV(%wZ, %p)\n", pustrDeviceName, pdm);
316+
TRACE("EngCreateDisplayPDEV(%wZ, %p)\n", pustrDeviceName, pdm);
294317

295318
/* Try to find the GRAPHICS_DEVICE */
296319
if (pustrDeviceName)
297320
{
298321
pGraphicsDevice = EngpFindGraphicsDevice(pustrDeviceName, 0, 0);
299322
if (!pGraphicsDevice)
300323
{
301-
DPRINT1("No GRAPHICS_DEVICE found for %ls!\n",
302-
pustrDeviceName ? pustrDeviceName->Buffer : 0);
324+
ERR("No GRAPHICS_DEVICE found for %ls!\n",
325+
pustrDeviceName ? pustrDeviceName->Buffer : 0);
303326
return NULL;
304327
}
305328
}
@@ -313,34 +336,27 @@ EngCreateDisplayPDEV(
313336
{
314337
/* ... use the device's default one */
315338
pdm = pGraphicsDevice->pDevModeList[pGraphicsDevice->iDefaultMode].pdm;
316-
DPRINT("Using iDefaultMode = %ld\n", pGraphicsDevice->iDefaultMode);
339+
TRACE("Using iDefaultMode = %ld\n", pGraphicsDevice->iDefaultMode);
317340
}
318341

319342
/* Try to get a diplay driver */
320343
pldev = EngLoadImageEx(pdm->dmDeviceName, LDEV_DEVICE_DISPLAY);
321344
if (!pldev)
322345
{
323-
DPRINT1("Could not load display driver '%ls', '%s'\n",
324-
pGraphicsDevice->pDiplayDrivers,
325-
pdm->dmDeviceName);
346+
ERR("Could not load display driver '%ls', '%s'\n",
347+
pGraphicsDevice->pDiplayDrivers, pdm->dmDeviceName);
326348
return NULL;
327349
}
328350

329351
/* Create a new PDEVOBJ */
330-
ppdev = PDEVOBJ_CreatePDEV(pldev);
352+
ppdev = PDEVOBJ_CreatePDEV(pldev, pGraphicsDevice, pdm, NULL);
331353
if (!ppdev)
332354
{
333-
DPRINT1("failed to allocate a PDEV\n");
355+
ERR("failed to create a PDEV\n");
334356
EngUnloadImage(pldev);
335357
return FALSE;
336358
}
337359

338-
/* Set MovePointer function */
339-
ppdev->pfnMovePointer = ppdev->pfn.MovePointer;
340-
if (!ppdev->pfnMovePointer)
341-
ppdev->pfnMovePointer = EngMovePointer;
342-
343-
ppdev->pGraphicsDevice = pGraphicsDevice;
344360
// Should we change the ative mode of pGraphicsDevice ?
345361
ppdev->pdmwDev = PDEVOBJ_pdmMatchDevMode(ppdev, pdm) ;
346362

@@ -417,21 +433,21 @@ PDEVOBJ_bSwitchMode(
417433
PPDEVOBJ ppdevTmp;
418434
PSURFACE pSurface;
419435
BOOL retval = FALSE;
436+
TRACE("PDEVOBJ_bSwitchMode, ppdev = %p, pSurface = %p\n", ppdev, ppdev->pSurface);
420437

421438
/* Lock the PDEV */
422439
EngAcquireSemaphore(ppdev->hsemDevLock);
440+
423441
/* And everything else */
424442
EngAcquireSemaphore(ghsemPDEV);
425443

426-
DPRINT1("PDEVOBJ_bSwitchMode, ppdev = %p, pSurface = %p\n", ppdev, ppdev->pSurface);
427-
428444
// Lookup the GraphicsDevice + select DEVMODE
429445
// pdm = PDEVOBJ_pdmMatchDevMode(ppdev, pdm);
430446

431447
/* 1. Temporarily disable the current PDEV */
432448
if (!ppdev->pfn.AssertMode(ppdev->dhpdev, FALSE))
433449
{
434-
DPRINT1("DrvAssertMode failed\n");
450+
ERR("DrvAssertMode failed\n");
435451
goto leave;
436452
}
437453

@@ -440,15 +456,15 @@ PDEVOBJ_bSwitchMode(
440456
ppdevTmp = EngCreateDisplayPDEV(&ustrDevice, pdm);
441457
if (!ppdevTmp)
442458
{
443-
DPRINT1("Failed to create a new PDEV\n");
459+
ERR("Failed to create a new PDEV\n");
444460
goto leave;
445461
}
446462

447463
/* 3. Create a new surface */
448464
pSurface = PDEVOBJ_pSurface(ppdevTmp);
449465
if (!pSurface)
450466
{
451-
DPRINT1("DrvEnableSurface failed\n");
467+
ERR("DrvEnableSurface failed\n");
452468
goto leave;
453469
}
454470

@@ -476,8 +492,7 @@ PDEVOBJ_bSwitchMode(
476492
EngReleaseSemaphore(ppdev->hsemDevLock);
477493
EngReleaseSemaphore(ghsemPDEV);
478494

479-
DPRINT1("leave, ppdev = %p, pSurface = %p\n", ppdev, ppdev->pSurface);
480-
495+
TRACE("leave, ppdev = %p, pSurface = %p\n", ppdev, ppdev->pSurface);
481496
return retval;
482497
}
483498

subsystems/win32/win32k/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");

subsystems/win32/win32k/include/pdevobj.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,10 @@ InitPDEVImpl(VOID);
183183
PPDEVOBJ
184184
NTAPI
185185
PDEVOBJ_CreatePDEV(
186-
struct _LDEVOBJ *pldev);
186+
struct _LDEVOBJ *pldev,
187+
PGRAPHICS_DEVICE pGraphicsDevice,
188+
PDEVMODEW pdevmode,
189+
PWSTR pwszLogAddress);
187190

188191
BOOL
189192
NTAPI

0 commit comments

Comments
 (0)