Author: tkreuzer
Date: Sun May 29 20:14:40 2011
New Revision: 51999
URL:
http://svn.reactos.org/svn/reactos?rev=51999&view=rev
Log:
[WIN32K]
- Refactor EngLoadFontFile and EngLoadFontFileFD
- Implement more driver support code to query IFIMETRICS and FD_GLYPHSET from the driver
Modified:
branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/font/fntdrvsup.c
branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/font/fontrsrc.c
branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/include/font.h
Modified: branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/font/fntdrvsup.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/subsyst…
==============================================================================
--- 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 May 29 20:14:40 2011
@@ -11,21 +11,6 @@
#define NDEBUG
#include <debug.h>
-BOOL gbAttachedCSRSS;
-
-HSEMAPHORE ghsemFontDriver;
-LIST_ENTRY gleFontDriverList = {&gleFontDriverList, &gleFontDriverList};
-
-
-BOOL FASTCALL
-InitFontSupport(VOID)
-{
- ghsemFontDriver = EngCreateSemaphore();
- if (!ghsemFontDriver) return FALSE;
- return TRUE;
-}
-
-
typedef struct _FONTDEV
{
LIST_ENTRY leLink;
@@ -40,7 +25,26 @@
C_ASSERT(sizeof(GDIINFO) == 0x130);
-//static
+BOOL gbAttachedCSRSS;
+
+HSEMAPHORE ghsemFontDriver;
+LIST_ENTRY gleFontDriverList = {&gleFontDriverList, &gleFontDriverList};
+
+HSEMAPHORE ghsemPFFList;
+LIST_ENTRY glePFFList = {&glePFFList, &glePFFList};
+
+
+BOOL FASTCALL
+InitFontSupport(VOID)
+{
+ ghsemFontDriver = EngCreateSemaphore();
+ if (!ghsemFontDriver) return FALSE;
+ ghsemPFFList = EngCreateSemaphore();
+ if (!ghsemPFFList) return FALSE;
+ return TRUE;
+}
+
+static
VOID
AttachCSRSS(KAPC_STATE *pApcState)
{
@@ -49,7 +53,7 @@
gbAttachedCSRSS = TRUE;
}
-//static
+static
VOID
DetachCSRSS(KAPC_STATE *pApcState)
{
@@ -85,19 +89,18 @@
if (hff == 0) return 0;
return hff;
-
-}
-
+}
+
+static
HFF
-NTAPI
EngLoadFontFileFD(
ULONG cFiles,
- PULONG_PTR piFiles,
+ PFONTFILEVIEW *ppffv,
DESIGNVECTOR *pdv,
ULONG ulCheckSum,
- HDEV *phdev)
-{
- KAPC_STATE ApcState;
+ PFONTDEV *ppfntdev)
+{
+ PULONG_PTR piFiles = (PULONG_PTR)ppffv;
PVOID apvView[FD_MAX_FILES];
ULONG acjView[FD_MAX_FILES];
ULONG i, ulLangID = 0;
@@ -115,10 +118,7 @@
}
}
- /* Attach to CSRSS */
- AttachCSRSS(&ApcState);
-
- /* Acquire font friver list lock */
+ /* Acquire font driver list lock */
EngAcquireSemaphore(ghsemFontDriver);
/* Loop all installed font drivers */
@@ -139,7 +139,7 @@
ulCheckSum);
if (hff)
{
- *phdev = (HDEV)pfntdev;
+ *ppfntdev = pfntdev;
break;
}
}
@@ -147,10 +147,193 @@
/* Release font friver list lock */
EngReleaseSemaphore(ghsemFontDriver);
+ return hff;
+}
+
+static
+BOOL
+PFF_bCompareFiles(
+ PPFF ppff,
+ ULONG cFiles,
+ PFONTFILEVIEW pffv[])
+{
+ ULONG i;
+
+ /* Check if number of files matches */
+ if (ppff->cFiles != cFiles) return FALSE;
+
+ /* Loop all files */
+ for (i = 0; i < cFiles; i++)
+ {
+ /* Check if the files match */
+ if (pffv[i] != ppff->apffv[i]) return FALSE;
+ }
+
+ return TRUE;
+}
+
+static PPFF
+EngFindPFF(ULONG cFiles, PFONTFILEVIEW *ppffv)
+{
+ PLIST_ENTRY ple;
+ PPFF ppff;
+ ASSERT(cFiles >= 1 && cFiles <= FD_MAX_FILES);
+
+ /* Acquire PFF list lock */
+ EngAcquireSemaphore(ghsemPFFList);
+
+ /* Loop all physical font files (PFF) */
+ for (ple = glePFFList.Flink; ple != &glePFFList; ple = ple->Flink)
+ {
+ ppff = CONTAINING_RECORD(ple, PFF, leLink);
+
+ /* Check if the files are already loaded */
+ if (PFF_bCompareFiles(ppff, cFiles, ppffv)) break;
+ }
+
+ /* Release PFF list lock */
+ EngReleaseSemaphore(ghsemPFFList);
+
+ return ple != &glePFFList ? ppff : NULL;
+}
+
+static void
+PFE_vInitialize(
+ PPFE ppfe,
+ PPFF ppff,
+ ULONG iFace)
+{
+ PFONTDEV pfntdev = (PFONTDEV)ppff->hdev;
+ PLDEVOBJ pldev = pfntdev->pldev;
+ ppfe->pPFF = ppff;
+ ppfe->iFont = iFace;
+ ppfe->flPFE = 0;
+
+ ppfe->pid = HandleToUlong(PsGetCurrentProcessId());
+ ppfe->tid = HandleToUlong(PsGetCurrentThreadId());
+
+ /* Query IFIMETRICS */
+ ppfe->pifi = pldev->pfn.QueryFont(pfntdev->dhpdev,
+ ppff->hff,
+ iFace,
+ &ppfe->idifi);
+
+ /* Query FD_GLYPHSET */
+ ppfe->pfdg = pldev->pfn.QueryFontTree(pfntdev->dhpdev,
+ ppff->hff,
+ iFace,
+ QFT_GLYPHSET,
+ &ppfe->idfdg);
+
+ /* No kerning pairs for now */
+ ppfe->pkp = NULL;
+ ppfe->idkp = 0;
+ ppfe->ckp = 0;
+
+ ppfe->iOrientation = 0;
+ ppfe->cjEfdwPFE = 0;
+ //ppfe->pgiset = 0;
+ ppfe->ulTimeStamp = 0;
+ //ppfe->ufi = 0;
+ //ppfe->ql;
+ ppfe->pFlEntry = 0;
+ ppfe->cAlt = 0;
+ ppfe->cPfdgRef = 0;
+ //ppfe->aiFamilyName[];
+
+}
+
+PPFF
+NTAPI
+EngLoadFontFile(
+ IN ULONG cFiles,
+ IN PWCHAR apwszFiles[],
+ IN DESIGNVECTOR *pdv)
+{
+ PFONTFILEVIEW apffv[FD_MAX_FILES];
+ KAPC_STATE ApcState;
+ PPFF ppff = NULL;
+ ULONG i, cjSize, cFaces, ulChecksum = 0;
+ PFONTDEV pfntdev = NULL;
+ HFF hff;
+
+ /* Loop the files */
+ for (i = 0; i < cFiles; i++)
+ {
+ /* Try to load the file */
+ apffv[i] = (PVOID)EngLoadModuleEx(apwszFiles[i], 0, FVF_FONTFILE);
+ if (!apffv[i])
+ {
+ /* Cleanup and return */
+ while (i--) EngFreeModule(apffv[i]);
+ return NULL;
+ }
+ }
+
+ /* Try to find an existing PFF */
+ ppff = EngFindPFF(cFiles, apffv);
+ if (ppff)
+ {
+ /* Cleanup loaded files, we don't need them anymore */
+ for (i = 0; i < cFiles; i++) EngFreeModule(apffv[i]);
+ return ppff;
+ }
+
+ /* Attach to CSRSS */
+ AttachCSRSS(&ApcState);
+
+ /* Try to load the font with any of the font drivers */
+ hff = EngLoadFontFileFD(cFiles, apffv, pdv, ulChecksum, &pfntdev);
+ if (!hff)
+ {
+ DPRINT1("File format is not supported by any font driver\n");
+ goto leave;
+ }
+
+ /* Query the number of faces in the font file */
+ cFaces = pfntdev->pldev->pfn.QueryFontFile(hff, QFF_NUMFACES, 0, NULL);
+
+ /* Allocate a new PFF */
+ cjSize = FIELD_OFFSET(PFF, apfe[cFaces]);
+ ppff = EngAllocMem(FL_ZERO_MEMORY, cjSize, 'ffpG');
+ if (!ppff)
+ {
+ DPRINT1("Failed to allocate %ld bytes\n", cjSize);
+ goto leave;
+ }
+
+ /* Fill the structure */
+ ppff->sizeofThis = cjSize;
+ ppff->cFiles = cFiles;
+ ppff->cFonts = cFaces;
+ ppff->hdev = (HDEV)pfntdev;
+ ppff->hff = hff;
+
+ /* Copy the FONTFILEVIEW pointers */
+ for (i = 0; i < cFiles; i++) ppff->apffv[i] = apffv[i];
+
+ /* Loop all faces in the font file */
+ for (i = 0; i < cFaces; i++)
+ {
+ /* Initialize the face */
+ PFE_vInitialize(&ppff->apfe[i], ppff, i + 1);
+ }
+
+ /* Insert the PFF into the list */
+ EngAcquireSemaphore(ghsemPFFList);
+ InsertTailList(&glePFFList, &ppff->leLink);
+ EngReleaseSemaphore(ghsemPFFList);
+
+leave:
+ if (!ppff)
+ {
+ for (i = 0; i < cFiles; i++) EngFreeModule(apffv[i]);
+ }
+
/* Detach from CSRSS */
DetachCSRSS(&ApcState);
- return hff;
+ return ppff;
}
BOOL
Modified: branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/font/fontrsrc.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/subsyst…
==============================================================================
--- branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/font/fontrsrc.c [iso-8859-1]
(original)
+++ branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/font/fontrsrc.c [iso-8859-1]
Sun May 29 20:14:40 2011
@@ -10,112 +10,6 @@
#define NDEBUG
#include <debug.h>
-
-HSEMAPHORE ghsemPFFList;
-LIST_ENTRY glePFFList = {&glePFFList, &glePFFList};
-
-
-static
-BOOL
-ComparePFF(
- PPFF ppff,
- ULONG cFiles,
- PFONTFILEVIEW pffv[])
-{
- ULONG i;
- ASSERT(cFiles >= 1 && cFiles <= FD_MAX_FILES);
-
- /* Check if number of files matches */
- if (ppff->cFiles != cFiles) return FALSE;
-
- /* Loop all files */
- for (i = 0; i < cFiles; i++)
- {
- /* Check if the files match */
- if (pffv[i] != ppff->apffv[i]) return FALSE;
- }
-
- return TRUE;
-}
-
-PPFF
-NTAPI
-EngLoadFontFile(
- IN ULONG cFiles,
- IN PWCHAR apwszFiles[],
- IN DESIGNVECTOR *pdv)
-{
- PFONTFILEVIEW apffv[FD_MAX_FILES];
- PLIST_ENTRY ple;
- PPFF ppff = NULL;
- ULONG i, cjSize, ulChecksum = 0;
- HDEV hdev;
- HFF hff;
-
- /* Loop the files */
- for (i = 0; i < cFiles; i++)
- {
- /* Try to load the file */
- apffv[i] = (PVOID)EngLoadModuleEx(apwszFiles[i], 0, FVF_FONTFILE);
- if (!apffv[i])
- {
- /* Cleanup and return */
- while (i--) EngFreeModule(apffv[i]);
- return NULL;
- }
- }
-
- /* Acquire PFF list lock */
- EngAcquireSemaphore(ghsemPFFList);
-
- /* Loop all physical font files (PFF) */
- for (ple = glePFFList.Flink; ple != &glePFFList; ple = ple->Flink)
- {
- ppff = CONTAINING_RECORD(ple, PFF, leLink);
-
- /* Check if the files are already loaded */
- if (ComparePFF(ppff, cFiles, apffv))
- {
- /* Unload the loaded files */
- while (i--) EngFreeModule(apffv[i]);
- goto leave;
- }
- }
-
- /* Load the font with any of the font drivers */
- hff = EngLoadFontFileFD(cFiles, (PULONG_PTR)apffv, pdv, ulChecksum, &hdev);
- if (!hff)
- {
- DPRINT1("File format is not supported by any font driver\n");
- while (i--) EngFreeModule(apffv[i]);
- goto leave;
- }
-
- /* Allocate a new PFF */
- cjSize = sizeof(PFF);
- ppff = EngAllocMem(0, cjSize, 'ffpG');
- if (!ppff)
- {
- goto leave;
- }
-
- ppff->sizeofThis = cjSize;
- ppff->cFiles = cFiles;
- ppff->hdev = hdev;
- ppff->hff = hff;
-
- /* Copy the FONTFILEVIEWs */
- for (i = 0; i < cFiles; i++) ppff->apffv[i] = apffv[i];
-
- /* Insert the PFF into the list */
- InsertTailList(&glePFFList, &ppff->leLink);
-
-leave:
- /* Release PFF list lock */
- EngReleaseSemaphore(ghsemPFFList);
-
- return ppff;
-}
INT
NTAPI
Modified: branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/include/font.h
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/subsyst…
==============================================================================
--- branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/include/font.h [iso-8859-1]
(original)
+++ branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/include/font.h [iso-8859-1]
Sun May 29 20:14:40 2011
@@ -14,6 +14,32 @@
} POINTEF, *PPOINTEF;
typedef struct _RFONT *PRFONT;
+
+typedef struct _PFE
+{
+ struct _PFF * pPFF;
+ ULONG_PTR iFont;
+ FLONG flPFE;
+ FD_GLYPHSET *pfdg;
+ ULONG_PTR idfdg;
+ IFIMETRICS * pifi;
+ ULONG_PTR idifi;
+ FD_KERNINGPAIR *pkp;
+ ULONG_PTR idkp;
+ ULONG ckp;
+ ULONG iOrientation;
+ ULONG cjEfdwPFE;
+ //GISET * pgiset;
+ ULONG ulTimeStamp;
+ UNIVERSAL_FONT_ID ufi;
+ DWORD pid;
+ DWORD tid;
+ LIST_ENTRY ql;
+ void * pFlEntry;
+ ULONG cAlt;
+ ULONG cPfdgRef;
+ ULONG aiFamilyName[1];
+} PFE, *PPFE;
typedef struct _PFF
{
@@ -38,33 +64,8 @@
ULONG cFonts;
void *pPvtDataHead;
PFONTFILEVIEW apffv[FD_MAX_FILES];
+ PFE apfe[1];
} PFF, *PPFF;
-
-typedef struct _PFE
-{
- PFF * pPFF;
- ULONG_PTR iFont;
- FLONG flPFE;
- FD_GLYPHSET * pfdg;
- ULONG_PTR ulpId;
- IFIMETRICS * pifi;
- ULONG_PTR idifi;
- FD_KERNINGPAIR *pkp;
- ULONG_PTR idkp;
- ULONG ckp;
- ULONG iOrieintation;
- ULONG cjEfdwPFE;
- //GISET * pgiset;
- ULONG ulTimeStamp;
- UNIVERSAL_FONT_ID ufi;
- DWORD pid;
- DWORD tid;
- LIST_ENTRY ql;
- void * pFlEntry;
- ULONG cAlt;
- ULONG cPfdgRef;
- ULONG aiFamilyName[1];
-} PFE, *PPFE;
typedef struct
{
@@ -219,11 +220,4 @@
NTAPI
DC_prfnt(PDC pdc);
-HFF
-NTAPI
-EngLoadFontFileFD(
- ULONG cFiles,
- PULONG_PTR piFiles,
- DESIGNVECTOR *pdv,
- ULONG ulCheckSum,
- HDEV *phdev);
+