Use mapped sections for fonts instead of paged pool memory.

svn path=/trunk/; revision=16977
This commit is contained in:
Filip Navara
2005-08-02 20:33:33 +00:00
parent b8940ad696
commit 03eedf362f
+23 -55
View File
@@ -256,22 +256,24 @@ IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristics)
HANDLE FileHandle;
OBJECT_ATTRIBUTES ObjectAttributes;
FILE_STANDARD_INFORMATION FileStdInfo;
PVOID Buffer;
PVOID Buffer = NULL;
IO_STATUS_BLOCK Iosb;
INT Error;
FT_Face Face;
ANSI_STRING AnsiFaceName;
PFONT_ENTRY Entry;
PSECTION_OBJECT SectionObject;
ULONG ViewSize = 0;
/* Open the font file */
InitializeObjectAttributes(&ObjectAttributes, FileName, 0, NULL, NULL);
Status = ZwOpenFile(
&FileHandle,
GENERIC_READ | SYNCHRONIZE,
FILE_GENERIC_READ | SYNCHRONIZE,
&ObjectAttributes,
&Iosb,
0,
FILE_SHARE_READ,
FILE_SYNCHRONOUS_IO_NONALERT);
if (!NT_SUCCESS(Status))
@@ -280,59 +282,25 @@ IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristics)
return 0;
}
/* Get the size of the file */
Status = ZwQueryInformationFile(
FileHandle,
&Iosb,
&FileStdInfo,
sizeof(FileStdInfo),
FileStandardInformation);
Status = MmCreateSection(&SectionObject, SECTION_ALL_ACCESS,
NULL, NULL, PAGE_READONLY,
0, FileHandle, NULL);
if (!NT_SUCCESS(Status))
{
DPRINT("Could not get file size\n");
ZwClose(FileHandle);
return 0;
}
/* Allocate pageable memory for the font */
Buffer = ExAllocatePoolWithTag(
PagedPool,
FileStdInfo.EndOfFile.u.LowPart,
TAG_FNTFILE);
if (Buffer == NULL)
{
DPRINT("Could not allocate memory for font");
ZwClose(FileHandle);
return 0;
}
/* Load the font into memory chunk */
Status = ZwReadFile(
FileHandle,
NULL,
NULL,
NULL,
&Iosb,
Buffer,
FileStdInfo.EndOfFile.u.LowPart,
NULL,
NULL);
if (!NT_SUCCESS(Status))
{
DPRINT("Could not read the font file into memory");
ExFreePool(Buffer);
DPRINT("Could not map file: %wZ\n", FileName);
ZwClose(FileHandle);
return 0;
}
ZwClose(FileHandle);
Status = MmMapViewInSystemSpace(SectionObject, &Buffer, &ViewSize);
if (!NT_SUCCESS(Status))
{
DPRINT("Could not map file: %wZ\n", FileName);
return Status;
}
IntLockFreeType;
Error = FT_New_Memory_Face(
library,
@@ -348,7 +316,7 @@ IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristics)
DPRINT("Unknown font file format\n");
else
DPRINT("Error reading font file (error code: %u)\n", Error);
ExFreePool(Buffer);
ObDereferenceObject(SectionObject);
return 0;
}
@@ -356,7 +324,7 @@ IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristics)
if (!Entry)
{
FT_Done_Face(Face);
ExFreePool(Buffer);
ObDereferenceObject(SectionObject);
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return 0;
}
@@ -365,7 +333,7 @@ IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristics)
if(FontGDI == NULL)
{
FT_Done_Face(Face);
ExFreePool(Buffer);
ObDereferenceObject(SectionObject);
ExFreePool(Entry);
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return 0;
@@ -1559,7 +1527,7 @@ NtGdiExtTextOut(
}
}
BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
BitmapObj = BITMAPOBJ_LockBitmap(DC_BITMAP(dc));
if ( !BitmapObj )
{
goto fail;
@@ -1574,7 +1542,7 @@ NtGdiExtTextOut(
YStart = Start.y + dc->w.DCOrgY;
/* Create the brushes */
PalDestGDI = PALETTE_LockPalette(dc->w.hPalette);
PalDestGDI = PALETTE_LockPalette(DC_PALETTE(dc));
if ( !PalDestGDI )
Mode = PAL_RGB;
else
@@ -1582,7 +1550,7 @@ NtGdiExtTextOut(
Mode = PalDestGDI->Mode;
PALETTE_UnlockPalette(PalDestGDI);
}
XlateObj = (XLATEOBJ*)IntEngCreateXlate(Mode, PAL_RGB, dc->w.hPalette, NULL);
XlateObj = (XLATEOBJ*)IntEngCreateXlate(Mode, PAL_RGB, DC_PALETTE(dc), NULL);
if ( !XlateObj )
{
goto fail;
@@ -1612,7 +1580,7 @@ NtGdiExtTextOut(
}
IntGdiInitBrushInstance(&BrushBgInst, BrushBg, NULL);
}
XlateObj2 = (XLATEOBJ*)IntEngCreateXlate(PAL_RGB, Mode, NULL, dc->w.hPalette);
XlateObj2 = (XLATEOBJ*)IntEngCreateXlate(PAL_RGB, Mode, NULL, DC_PALETTE(dc));
if ( !XlateObj2 )
{
goto fail;