Author: tkreuzer
Date: Sun May 29 09:29:31 2011
New Revision: 51989
URL:
http://svn.reactos.org/svn/reactos?rev=51989&view=rev
Log:
[WIN32K]
- Implement NtGdiSelectFont
Modified:
branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/font/dcfont.c
branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/font/fontrsrc.c
branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/include/dc.h
branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/objects/dclife.c
Modified: branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/font/dcfont.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/subsyst…
==============================================================================
--- branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/font/dcfont.c [iso-8859-1]
(original)
+++ branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/font/dcfont.c [iso-8859-1]
Sun May 29 09:29:31 2011
@@ -11,6 +11,41 @@
#define NDEBUG
#include <debug.h>
+static
+HFONT
+DC_hSelectFont(PDC pdc, HFONT hlfntNew)
+{
+ PLFONT plfntNew;
+ HFONT hlfntOld;
+
+ /* Get the current selected font */
+ hlfntOld = pdc->dclevel.plfnt->baseobj.hHmgr;
+
+ /* Check if a new font should be selected */
+ if (hlfntNew != hlfntOld)
+ {
+ /* Lock the new font */
+ plfntNew = LFONT_ShareLockFont(hlfntNew);
+ if (plfntNew)
+ {
+ /* Success, dereference the old font */
+ LFONT_ShareUnlockFont(pdc->dclevel.plfnt);
+
+ /* Select the new font */
+ pdc->dclevel.plfnt = plfntNew;
+ pdc->pdcattr->hlfntNew = hlfntNew;
+ }
+ else
+ {
+ /* Failed, restore old, return NULL */
+ pdc->pdcattr->hlfntNew = hlfntOld;
+ hlfntOld = NULL;
+ }
+ }
+
+ return hlfntOld;
+}
+
#if 0
PRFONT
NTAPI
@@ -19,28 +54,13 @@
PLFONT plfnt;
PRFONT prfnt;
- /* Check if new font was selected */
- if (pdc->pdcattr->ulDirty_ & DIRTY_TEXT)
- {
- /* Lock the new font */
- plfnt = LFONT_ShareLockFont(pdc->pdcattr->hlfntNew);
- if (plfnt)
- {
- LFONT_ShareUnlockFont(pdc->dclevel.pFont);
- pdc->dclevel.pFont = plfnt;
- }
- else
- {
- // FIXME: test how selecting an invalid font is handled
- pdc->pdcattr->hlfntNew = pdc->dclevel.pFont;
- }
- }
+ /* Select "current" font */
+ DC_hSelectFont(pdc->pdcattr->hlfntNew);
/* Check if font is already realized */
if (pdc->hlfntCur != pdc->pdcattr->hlfntNew)
{
-
- prfnt = LFONT_prfntRealizeFont(pdc->dclevel.pFont);
+ prfnt = LFONT_prfntRealizeFont(pdc->dclevel.plfnt);
/* Dereference the old RFONT */
RFONT_ShareUnlockFont(pdc->prfnt);
@@ -147,8 +167,22 @@
APIENTRY
NtGdiSelectFont(
IN HDC hdc,
- IN HFONT hf)
+ IN HFONT hlfnt)
{
- ASSERT(FALSE);
- return 0;
+ PDC pdc;
+ HFONT hlfntOld;
+
+ /* Lock the DC */
+ pdc = DC_LockDc(hdc);
+ if (!pdc)
+ {
+ return NULL;
+ }
+
+ /* Call the internal function */
+ hlfntOld = DC_hSelectFont(pdc, hlfnt);
+
+ /* Unlock DC and return result */
+ DC_UnlockDc(pdc);
+ return hlfntOld;
}
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 09:29:31 2011
@@ -12,7 +12,6 @@
#include <debug.h>
HSEMAPHORE ghsemPFFList;
-PPFF gppffList;
LIST_ENTRY glePFFList = {&glePFFList, &glePFFList};
Modified: branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/include/dc.h
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/subsyst…
==============================================================================
--- branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/include/dc.h [iso-8859-1]
(original)
+++ branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/include/dc.h [iso-8859-1] Sun
May 29 09:29:31 2011
@@ -69,7 +69,7 @@
POINTL ptlBrushOrigin;
PBRUSH pbrFill;
PBRUSH pbrLine;
- PVOID plfnt; /* LFONTOBJ* (TEXTOBJ*) */
+ struct _LFONT *plfnt;
HGDIOBJ hPath; /* HPATH */
FLONG flPath;
LINEATTRS laPath; /* 0x20 bytes */
Modified: branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/objects/dclife.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/GdiFontDriver/subsyst…
==============================================================================
--- branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/objects/dclife.c [iso-8859-1]
(original)
+++ branches/GSoC_2011/GdiFontDriver/subsystems/win32/win32k/objects/dclife.c [iso-8859-1]
Sun May 29 09:29:31 2011
@@ -310,7 +310,9 @@
// pdc->dclevel.ca =
/* Setup font data */
- pdc->hlfntCur = NULL; // FIXME: 2f0a0cf8
+ pdc->dcattr.hlfntNew = StockObjects[SYSTEM_FONT];
+ pdc->hlfntCur = NULL;
+ pdc->dclevel.plfnt =
(PVOID)GDIOBJ_ReferenceObjectByHandle(pdc->dcattr.hlfntNew, GDIObjType_LFONT_TYPE); //
LFONT_ShareLockFont(pdc->dcattr.hlfntNew);
pdc->pPFFList = NULL;
pdc->flSimulationFlags = 0;
pdc->lEscapement = 0;
@@ -322,8 +324,6 @@
pdc->dcattr.lRelAbs = 1;
pdc->dcattr.lBreakExtra = 0;
pdc->dcattr.cBreak = 0;
- pdc->dcattr.hlfntNew = StockObjects[SYSTEM_FONT];
-// pdc->dclevel.pFont = LFONT_ShareLockFont(pdc->dcattr.hlfntNew);
/* Other stuff */
pdc->hdcNext = NULL;