Skip to content

Commit 52527e1

Browse files
committed
[WIN32K]
- Switch from using a FONTDEV structure to using a PDEVOBJ (it was an idea to save half a KB memory per driver, but it doesn't work well together with display drivers that provide font capabilities) - Modify EngLoadFontDriver to use PDEVOBJ_CreatePDEV instead of manually calling the driver - Implement RFONT_AllocRFONT, RFONT_vDeleteRFONT, RFONT_bQueryDeviceMetrics svn path=/branches/GSoC_2011/GdiFontDriver/; revision=56008
1 parent 7412eb9 commit 52527e1

File tree

2 files changed

+104
-67
lines changed

2 files changed

+104
-67
lines changed

subsystems/win32/win32k/font/fntdrvsup.c

Lines changed: 33 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,6 @@
1111
#define NDEBUG
1212
#include <debug.h>
1313

14-
typedef struct _FONTDEV
15-
{
16-
LIST_ENTRY leLink;
17-
DHPDEV dhpdev;
18-
PLDEVOBJ pldev;
19-
HSURF ahsurf[HS_DDI_MAX];
20-
DEVINFO devinfo;
21-
22-
GDIINFO gdiinfo; // FIXME: something else?
23-
} FONTDEV, *PFONTDEV;
24-
2514
C_ASSERT(sizeof(GDIINFO) == 0x130);
2615

2716

@@ -67,15 +56,15 @@ NTAPI
6756
RFONT_vInitDeviceMetrics(
6857
PRFONT prfnt)
6958
{
70-
PFONTDEV pfntdev = (PFONTDEV)prfnt->hdevProducer;
71-
72-
pfntdev->pldev->pfn.QueryFontData(prfnt->dhpdev,
73-
&prfnt->fobj,
74-
QFD_MAXEXTENTS,
75-
-1,
76-
NULL,
77-
&prfnt->fddm,
78-
sizeof(FD_DEVICEMETRICS));
59+
PPDEVOBJ ppdev = (PPDEVOBJ)prfnt->hdevProducer;
60+
61+
ppdev->pldev->pfn.QueryFontData(prfnt->dhpdev,
62+
&prfnt->fobj,
63+
QFD_MAXEXTENTS,
64+
-1,
65+
NULL,
66+
&prfnt->fddm,
67+
sizeof(FD_DEVICEMETRICS));
7968
}
8069

8170
static
@@ -85,8 +74,8 @@ PFE_vInitialize(
8574
PPFF ppff,
8675
ULONG iFace)
8776
{
88-
PFONTDEV pfntdev = (PFONTDEV)ppff->hdev;
89-
PLDEVOBJ pldev = pfntdev->pldev;
77+
PPDEVOBJ ppdev = (PPDEVOBJ)ppff->hdev;
78+
PLDEVOBJ pldev = ppdev->pldev;
9079
ppfe->pPFF = ppff;
9180
ppfe->iFont = iFace;
9281
ppfe->flPFE = 0;
@@ -95,13 +84,13 @@ PFE_vInitialize(
9584
ppfe->tid = HandleToUlong(PsGetCurrentThreadId());
9685

9786
/* Query IFIMETRICS */
98-
ppfe->pifi = pldev->pfn.QueryFont(pfntdev->dhpdev,
87+
ppfe->pifi = pldev->pfn.QueryFont(ppdev->dhpdev,
9988
ppff->hff,
10089
iFace,
10190
&ppfe->idifi);
10291

10392
/* Query FD_GLYPHSET */
104-
ppfe->pfdg = pldev->pfn.QueryFontTree(pfntdev->dhpdev,
93+
ppfe->pfdg = pldev->pfn.QueryFontTree(ppdev->dhpdev,
10594
ppff->hff,
10695
iFace,
10796
QFT_GLYPHSET,
@@ -168,7 +157,7 @@ EngLoadFontFileFD(
168157
PWCHAR pwcCurrent;
169158
KAPC_STATE ApcState;
170159
PLIST_ENTRY ple;
171-
PFONTDEV pfntdev = NULL;
160+
PPDEVOBJ ppdev = NULL;
172161
HFF hff = 0;
173162
ULONG cFaces, cjSize, i, ulLangID = 0;
174163
PPFF ppff = NULL;
@@ -206,23 +195,23 @@ EngLoadFontFileFD(
206195
}
207196

208197
/* Acquire font driver list lock */
209-
EngAcquireSemaphore(ghsemFontDriver);
198+
EngAcquireSemaphoreShared(ghsemFontDriver);
210199

211200
/* Loop all installed font drivers */
212201
for (ple = gleFontDriverList.Flink;
213202
ple != &gleFontDriverList;
214203
ple = ple->Flink)
215204
{
216-
pfntdev = CONTAINING_RECORD(ple, FONTDEV, leLink);
205+
ppdev = CONTAINING_RECORD(ple, PDEVOBJ, leLink);
217206

218207
/* Call the drivers DrvLoadFontFile function */
219-
hff = pfntdev->pldev->pfn.LoadFontFile(cFiles,
220-
piFiles,
221-
apvView,
222-
acjView,
223-
pdv,
224-
ulLangID,
225-
ulCheckSum);
208+
hff = ppdev->pldev->pfn.LoadFontFile(cFiles,
209+
piFiles,
210+
apvView,
211+
acjView,
212+
pdv,
213+
ulLangID,
214+
ulCheckSum);
226215
if (hff) break;
227216
}
228217

@@ -236,7 +225,7 @@ EngLoadFontFileFD(
236225
}
237226

238227
/* Query the number of faces in the font file */
239-
cFaces = pfntdev->pldev->pfn.QueryFontFile(hff, QFF_NUMFACES, 0, NULL);
228+
cFaces = ppdev->pldev->pfn.QueryFontFile(hff, QFF_NUMFACES, 0, NULL);
240229

241230
/* Allocate a new PFF */
242231
cjSize = FIELD_OFFSET(PFF, apfe[cFaces]);
@@ -251,7 +240,7 @@ EngLoadFontFileFD(
251240
ppff->sizeofThis = cjSize;
252241
ppff->cFiles = cFiles;
253242
ppff->cFonts = cFaces;
254-
ppff->hdev = (HDEV)pfntdev;
243+
ppff->hdev = (HDEV)ppdev;
255244
ppff->hff = hff;
256245

257246
/* Copy the FONTFILEVIEW pointers */
@@ -278,49 +267,28 @@ EngLoadFontDriver(
278267
IN PWSTR pwszDriverName)
279268
{
280269
PLDEVOBJ pldev;
281-
PFONTDEV pfntdev;
270+
PPDEVOBJ ppdev;
282271

283-
/* Load the driver */
272+
/* Try to load the driver */
284273
pldev = EngLoadImageEx(pwszDriverName, LDEV_FONT);
285274
if (!pldev)
286275
{
287-
DPRINT1("Failed to load font driver: %ls\n", pwszDriverName);
276+
DPRINT1("Could not load display driver '%ls'\n", pwszDriverName);
288277
return FALSE;
289278
}
290279

291-
// CHECK if all functions are there
292-
293-
294-
/* Allocate a FONTDEV structure */
295-
pfntdev = EngAllocMem(0, sizeof(FONTDEV), 'vdfG');
296-
if (!pfntdev)
280+
/* Create a new PDEVOBJ */
281+
ppdev = PDEVOBJ_CreatePDEV(pldev);
282+
if (!ppdev)
297283
{
298-
DPRINT1("Failed to allocate FONTDEV structure\n");
284+
DPRINT1("failed to allocate a PDEV\n");
299285
EngUnloadImage(pldev);
300286
return FALSE;
301287
}
302288

303-
pfntdev->pldev = pldev;
304-
305-
/* Call the drivers DrvEnablePDEV function */
306-
pfntdev->dhpdev = pldev->pfn.EnablePDEV(NULL,
307-
NULL,
308-
HS_DDI_MAX,
309-
pfntdev->ahsurf,
310-
sizeof(GDIINFO),
311-
(ULONG*)&pfntdev->gdiinfo,
312-
sizeof(DEVINFO),
313-
&pfntdev->devinfo,
314-
(HDEV)pfntdev,
315-
NULL,
316-
NULL);
317-
318-
/* Call the drivers DrvCompletePDEV function */
319-
pldev->pfn.CompletePDEV(pfntdev->dhpdev, (HDEV)pfntdev);
320-
321289
/* Insert the driver into the list */
322290
EngAcquireSemaphore(ghsemFontDriver);
323-
InsertTailList(&gleFontDriverList, &pfntdev->leLink);
291+
InsertTailList(&gleFontDriverList, &ppdev->leLink);
324292
EngReleaseSemaphore(ghsemFontDriver);
325293

326294
return TRUE;

subsystems/win32/win32k/font/rfont.c

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,79 @@
77

88
#include <win32k.h>
99
#include <include/font.h>
10+
DBG_DEFAULT_CHANNEL(GdiFont);
1011

11-
#define NDEBUG
12-
#include <debug.h>
12+
ULONG gulRFONTUnique = 0;
13+
PRFONT gprfntSystemTT;
1314

15+
PRFONT
16+
NTAPI
17+
RFONT_AllocRFONT(void)
18+
{
19+
PRFONT prfnt;
20+
21+
/* Allocate the RFONT structure */
22+
prfnt = ExAllocatePoolWithTag(PagedPool, sizeof(RFONT), GDITAG_RFONT);
23+
if (!prfnt)
24+
{
25+
ERR("Not enough memory to allocate RFONT\n");
26+
return NULL;
27+
}
28+
29+
/* Zero out the whole structure */
30+
RtlZeroMemory(prfnt, sizeof(RFONT));
31+
32+
/* Set a unique number */
33+
prfnt->fobj.iUniq = InterlockedIncrementUL(&gulRFONTUnique);
34+
35+
36+
return prfnt;
37+
}
38+
39+
VOID
40+
NTAPI
41+
RFONT_vDeleteRFONT(
42+
_Inout_ PRFONT prfnt)
43+
{
44+
ASSERT(prfnt->cSelected == 0);
45+
46+
/* Free the structure */
47+
ExFreePoolWithTag(prfnt, GDITAG_RFONT);
48+
49+
}
50+
51+
BOOL
52+
NTAPI
53+
RFONT_bQueryDeviceMetrics(
54+
PRFONT prfnt)
55+
{
56+
PPDEVOBJ ppdev = (PPDEVOBJ)prfnt->hdevProducer;
57+
PLDEVOBJ pldev = ppdev->pldev;
58+
ULONG ulResult;
59+
60+
/* Preinitialize some fields */
61+
RtlZeroMemory(&prfnt->fddm, sizeof(FD_DEVICEMETRICS));
62+
prfnt->fddm.lNonLinearExtLeading = 0x80000000;
63+
prfnt->fddm.lNonLinearIntLeading = 0x80000000;
64+
prfnt->fddm.lNonLinearMaxCharWidth = 0x80000000;
65+
prfnt->fddm.lNonLinearAvgCharWidth = 0x80000000;
66+
prfnt->fddm.fdxQuantized = prfnt->fdx;
67+
68+
/* Call the fontdriver */
69+
ulResult = pldev->pfn.QueryFontData(prfnt->ppff->dhpdev,
70+
&prfnt->fobj,
71+
QFD_MAXEXTENTS,
72+
-1,
73+
NULL,
74+
&prfnt->fddm,
75+
sizeof(FD_DEVICEMETRICS));
76+
77+
/* Calculate max extents (This seems to be what Windows does) */
78+
prfnt->fxMaxExtent = max(prfnt->fddm.fxMaxAscender, 0) +
79+
max(prfnt->fddm.fxMaxDescender, 0);
80+
81+
return (ulResult != FD_ERROR);
82+
}
1483

1584

1685

0 commit comments

Comments
 (0)