Author: tkreuzer Date: Sun Mar 4 19:20:41 2012 New Revision: 56008
URL: http://svn.reactos.org/svn/reactos?rev=56008&view=rev Log: [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
Modified: branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/font/fntdrvsup.c branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/font/rfont.c
Modified: branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/font/fntdrvsup.c URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/subsyste... ============================================================================== --- branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/font/fntdrvsup.c [iso-8859-1] (original) +++ branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/font/fntdrvsup.c [iso-8859-1] Sun Mar 4 19:20:41 2012 @@ -11,17 +11,6 @@ #define NDEBUG #include <debug.h>
-typedef struct _FONTDEV -{ - LIST_ENTRY leLink; - DHPDEV dhpdev; - PLDEVOBJ pldev; - HSURF ahsurf[HS_DDI_MAX]; - DEVINFO devinfo; - - GDIINFO gdiinfo; // FIXME: something else? -} FONTDEV, *PFONTDEV; - C_ASSERT(sizeof(GDIINFO) == 0x130);
@@ -67,15 +56,15 @@ RFONT_vInitDeviceMetrics( PRFONT prfnt) { - PFONTDEV pfntdev = (PFONTDEV)prfnt->hdevProducer; - - pfntdev->pldev->pfn.QueryFontData(prfnt->dhpdev, - &prfnt->fobj, - QFD_MAXEXTENTS, - -1, - NULL, - &prfnt->fddm, - sizeof(FD_DEVICEMETRICS)); + PPDEVOBJ ppdev = (PPDEVOBJ)prfnt->hdevProducer; + + ppdev->pldev->pfn.QueryFontData(prfnt->dhpdev, + &prfnt->fobj, + QFD_MAXEXTENTS, + -1, + NULL, + &prfnt->fddm, + sizeof(FD_DEVICEMETRICS)); }
static @@ -85,8 +74,8 @@ PPFF ppff, ULONG iFace) { - PFONTDEV pfntdev = (PFONTDEV)ppff->hdev; - PLDEVOBJ pldev = pfntdev->pldev; + PPDEVOBJ ppdev = (PPDEVOBJ)ppff->hdev; + PLDEVOBJ pldev = ppdev->pldev; ppfe->pPFF = ppff; ppfe->iFont = iFace; ppfe->flPFE = 0; @@ -95,13 +84,13 @@ ppfe->tid = HandleToUlong(PsGetCurrentThreadId());
/* Query IFIMETRICS */ - ppfe->pifi = pldev->pfn.QueryFont(pfntdev->dhpdev, + ppfe->pifi = pldev->pfn.QueryFont(ppdev->dhpdev, ppff->hff, iFace, &ppfe->idifi);
/* Query FD_GLYPHSET */ - ppfe->pfdg = pldev->pfn.QueryFontTree(pfntdev->dhpdev, + ppfe->pfdg = pldev->pfn.QueryFontTree(ppdev->dhpdev, ppff->hff, iFace, QFT_GLYPHSET, @@ -168,7 +157,7 @@ PWCHAR pwcCurrent; KAPC_STATE ApcState; PLIST_ENTRY ple; - PFONTDEV pfntdev = NULL; + PPDEVOBJ ppdev = NULL; HFF hff = 0; ULONG cFaces, cjSize, i, ulLangID = 0; PPFF ppff = NULL; @@ -206,23 +195,23 @@ }
/* Acquire font driver list lock */ - EngAcquireSemaphore(ghsemFontDriver); + EngAcquireSemaphoreShared(ghsemFontDriver);
/* Loop all installed font drivers */ for (ple = gleFontDriverList.Flink; ple != &gleFontDriverList; ple = ple->Flink) { - pfntdev = CONTAINING_RECORD(ple, FONTDEV, leLink); + ppdev = CONTAINING_RECORD(ple, PDEVOBJ, leLink);
/* Call the drivers DrvLoadFontFile function */ - hff = pfntdev->pldev->pfn.LoadFontFile(cFiles, - piFiles, - apvView, - acjView, - pdv, - ulLangID, - ulCheckSum); + hff = ppdev->pldev->pfn.LoadFontFile(cFiles, + piFiles, + apvView, + acjView, + pdv, + ulLangID, + ulCheckSum); if (hff) break; }
@@ -236,7 +225,7 @@ }
/* Query the number of faces in the font file */ - cFaces = pfntdev->pldev->pfn.QueryFontFile(hff, QFF_NUMFACES, 0, NULL); + cFaces = ppdev->pldev->pfn.QueryFontFile(hff, QFF_NUMFACES, 0, NULL);
/* Allocate a new PFF */ cjSize = FIELD_OFFSET(PFF, apfe[cFaces]); @@ -251,7 +240,7 @@ ppff->sizeofThis = cjSize; ppff->cFiles = cFiles; ppff->cFonts = cFaces; - ppff->hdev = (HDEV)pfntdev; + ppff->hdev = (HDEV)ppdev; ppff->hff = hff;
/* Copy the FONTFILEVIEW pointers */ @@ -278,49 +267,28 @@ IN PWSTR pwszDriverName) { PLDEVOBJ pldev; - PFONTDEV pfntdev; - - /* Load the driver */ + PPDEVOBJ ppdev; + + /* Try to load the driver */ pldev = EngLoadImageEx(pwszDriverName, LDEV_FONT); if (!pldev) { - DPRINT1("Failed to load font driver: %ls\n", pwszDriverName); + DPRINT1("Could not load display driver '%ls'\n", pwszDriverName); return FALSE; }
- // CHECK if all functions are there - - - /* Allocate a FONTDEV structure */ - pfntdev = EngAllocMem(0, sizeof(FONTDEV), 'vdfG'); - if (!pfntdev) - { - DPRINT1("Failed to allocate FONTDEV structure\n"); + /* Create a new PDEVOBJ */ + ppdev = PDEVOBJ_CreatePDEV(pldev); + if (!ppdev) + { + DPRINT1("failed to allocate a PDEV\n"); EngUnloadImage(pldev); return FALSE; }
- pfntdev->pldev = pldev; - - /* Call the drivers DrvEnablePDEV function */ - pfntdev->dhpdev = pldev->pfn.EnablePDEV(NULL, - NULL, - HS_DDI_MAX, - pfntdev->ahsurf, - sizeof(GDIINFO), - (ULONG*)&pfntdev->gdiinfo, - sizeof(DEVINFO), - &pfntdev->devinfo, - (HDEV)pfntdev, - NULL, - NULL); - - /* Call the drivers DrvCompletePDEV function */ - pldev->pfn.CompletePDEV(pfntdev->dhpdev, (HDEV)pfntdev); - /* Insert the driver into the list */ EngAcquireSemaphore(ghsemFontDriver); - InsertTailList(&gleFontDriverList, &pfntdev->leLink); + InsertTailList(&gleFontDriverList, &ppdev->leLink); EngReleaseSemaphore(ghsemFontDriver);
return TRUE;
Modified: branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/font/rfont.c URL: http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/subsyste... ============================================================================== --- branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/font/rfont.c [iso-8859-1] (original) +++ branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/font/rfont.c [iso-8859-1] Sun Mar 4 19:20:41 2012 @@ -7,10 +7,79 @@
#include <win32k.h> #include <include/font.h> - -#define NDEBUG -#include <debug.h> - +DBG_DEFAULT_CHANNEL(GdiFont); + +ULONG gulRFONTUnique = 0; +PRFONT gprfntSystemTT; + +PRFONT +NTAPI +RFONT_AllocRFONT(void) +{ + PRFONT prfnt; + + /* Allocate the RFONT structure */ + prfnt = ExAllocatePoolWithTag(PagedPool, sizeof(RFONT), GDITAG_RFONT); + if (!prfnt) + { + ERR("Not enough memory to allocate RFONT\n"); + return NULL; + } + + /* Zero out the whole structure */ + RtlZeroMemory(prfnt, sizeof(RFONT)); + + /* Set a unique number */ + prfnt->fobj.iUniq = InterlockedIncrementUL(&gulRFONTUnique); + + + return prfnt; +} + +VOID +NTAPI +RFONT_vDeleteRFONT( + _Inout_ PRFONT prfnt) +{ + ASSERT(prfnt->cSelected == 0); + + /* Free the structure */ + ExFreePoolWithTag(prfnt, GDITAG_RFONT); + +} + +BOOL +NTAPI +RFONT_bQueryDeviceMetrics( + PRFONT prfnt) +{ + PPDEVOBJ ppdev = (PPDEVOBJ)prfnt->hdevProducer; + PLDEVOBJ pldev = ppdev->pldev; + ULONG ulResult; + + /* Preinitialize some fields */ + RtlZeroMemory(&prfnt->fddm, sizeof(FD_DEVICEMETRICS)); + prfnt->fddm.lNonLinearExtLeading = 0x80000000; + prfnt->fddm.lNonLinearIntLeading = 0x80000000; + prfnt->fddm.lNonLinearMaxCharWidth = 0x80000000; + prfnt->fddm.lNonLinearAvgCharWidth = 0x80000000; + prfnt->fddm.fdxQuantized = prfnt->fdx; + + /* Call the fontdriver */ + ulResult = pldev->pfn.QueryFontData(prfnt->ppff->dhpdev, + &prfnt->fobj, + QFD_MAXEXTENTS, + -1, + NULL, + &prfnt->fddm, + sizeof(FD_DEVICEMETRICS)); + + /* Calculate max extents (This seems to be what Windows does) */ + prfnt->fxMaxExtent = max(prfnt->fddm.fxMaxAscender, 0) + + max(prfnt->fddm.fxMaxDescender, 0); + + return (ulResult != FD_ERROR); +}