Author: tkreuzer
Date: Tue Jan 1 11:57:58 2013
New Revision: 58081
URL:
http://svn.reactos.org/svn/reactos?rev=58081&view=rev
Log:
[WIN32K]
Exchange fields individually in PDEVOBJ_vSwitchPdev() instead of duplicating a full PDEV
structure on the stack. This saves a lot of stack space.
Modified:
trunk/reactos/win32ss/gdi/eng/pdevobj.c
Modified: trunk/reactos/win32ss/gdi/eng/pdevobj.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/eng/pdevobj.c?…
==============================================================================
--- trunk/reactos/win32ss/gdi/eng/pdevobj.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/eng/pdevobj.c [iso-8859-1] Tue Jan 1 11:57:58 2013
@@ -342,51 +342,67 @@
}
VOID
+FORCEINLINE
+SwitchPointer(
+ _Inout_ PVOID pvPointer1,
+ _Inout_ PVOID pvPointer2)
+{
+ PVOID *ppvPointer1 = pvPointer1;
+ PVOID *ppvPointer2 = pvPointer2;
+ PVOID pvTemp;
+
+ pvTemp = *ppvPointer1;
+ *ppvPointer1 = *ppvPointer2;
+ *ppvPointer2 = pvTemp;
+}
+
+VOID
NTAPI
PDEVOBJ_vSwitchPdev(
PPDEVOBJ ppdev,
PPDEVOBJ ppdev2)
{
- PDEVOBJ pdevTmp;
- DWORD tmpStateFlags;
-
- /* Exchange data */
- pdevTmp = *ppdev;
+ union
+ {
+ DRIVER_FUNCTIONS pfn;
+ GDIINFO gdiinfo;
+ DEVINFO devinfo;
+ DWORD StateFlags;
+ } temp;
/* Exchange driver functions */
+ temp.pfn = ppdev->pfn;
ppdev->pfn = ppdev2->pfn;
- ppdev2->pfn = pdevTmp.pfn;
+ ppdev2->pfn = temp.pfn;
/* Exchange LDEVs */
- ppdev->pldev = ppdev2->pldev;
- ppdev2->pldev = pdevTmp.pldev;
+ SwitchPointer(&ppdev->pldev, &ppdev2->pldev);
/* Exchange DHPDEV */
- ppdev->dhpdev = ppdev2->dhpdev;
- ppdev2->dhpdev = pdevTmp.dhpdev;
+ SwitchPointer(&ppdev->dhpdev, &ppdev2->dhpdev);
/* Exchange surfaces and associate them with their new PDEV */
- ppdev->pSurface = ppdev2->pSurface;
- ppdev2->pSurface = pdevTmp.pSurface;
+ SwitchPointer(&ppdev->pSurface, &ppdev2->pSurface);
ppdev->pSurface->SurfObj.hdev = (HDEV)ppdev;
ppdev2->pSurface->SurfObj.hdev = (HDEV)ppdev2;
/* Exchange devinfo */
+ temp.devinfo = ppdev->devinfo;
ppdev->devinfo = ppdev2->devinfo;
- ppdev2->devinfo = pdevTmp.devinfo;
+ ppdev2->devinfo = temp.devinfo;
/* Exchange gdiinfo */
+ temp.gdiinfo = ppdev->gdiinfo;
ppdev->gdiinfo = ppdev2->gdiinfo;
- ppdev2->gdiinfo = pdevTmp.gdiinfo;
+ ppdev2->gdiinfo = temp.gdiinfo;
/* Exchange DEVMODE */
- ppdev->pdmwDev = ppdev2->pdmwDev;
- ppdev2->pdmwDev = pdevTmp.pdmwDev;
+ SwitchPointer(&ppdev->pdmwDev, &ppdev2->pdmwDev);
/* Exchange state flags */
- tmpStateFlags = ppdev->pGraphicsDevice->StateFlags;
+ temp.StateFlags = ppdev->pGraphicsDevice->StateFlags;
ppdev->pGraphicsDevice->StateFlags =
ppdev2->pGraphicsDevice->StateFlags;
- ppdev2->pGraphicsDevice->StateFlags = tmpStateFlags;
+ ppdev2->pGraphicsDevice->StateFlags = temp.StateFlags;
/* Notify each driver instance of its new HDEV association */
ppdev->pfn.CompletePDEV(ppdev->dhpdev, (HDEV)ppdev);
@@ -407,6 +423,7 @@
/* Lock the PDEV */
EngAcquireSemaphore(ppdev->hsemDevLock);
+
/* And everything else */
EngAcquireSemaphore(ghsemPDEV);
@@ -613,9 +630,10 @@
/** Exported functions ********************************************************/
+_Must_inspect_result_ _Ret_z_
LPWSTR
APIENTRY
-EngGetDriverName(IN HDEV hdev)
+EngGetDriverName(_In_ HDEV hdev)
{
PPDEVOBJ ppdev = (PPDEVOBJ)hdev;