From 705ea2a9c3834fef08ddad1916ac209a9ae5af15 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Thu, 1 Apr 2010 22:36:40 +0000 Subject: [PATCH] [WIN32K] - EngAcquireSemaphoreShared: update dwEngAcquireCount - DC_LockDc/DC_UnlockDc: Acquire PDEV lock only for direct DCs, in that case also update the pSurface pointer - When copying DC states, copy the surface only for memory dcs - after switching the mode, update system metrics and redraw the desktop window. - Remove testdraw code. svn path=/branches/reactos-yarotows/; revision=46658 --- subsystems/win32/win32k/eng/pdevobj.c | 33 ----------------------- subsystems/win32/win32k/eng/semaphor.c | 4 +++ subsystems/win32/win32k/include/dc.h | 18 +++++++++++-- subsystems/win32/win32k/ntuser/display.c | 19 +++++++++++++ subsystems/win32/win32k/objects/dclife.c | 7 +++-- subsystems/win32/win32k/objects/dcstate.c | 9 ++++++- 6 files changed, 52 insertions(+), 38 deletions(-) diff --git a/subsystems/win32/win32k/eng/pdevobj.c b/subsystems/win32/win32k/eng/pdevobj.c index 7ac40ef577b..d1d52e5f2b9 100644 --- a/subsystems/win32/win32k/eng/pdevobj.c +++ b/subsystems/win32/win32k/eng/pdevobj.c @@ -329,37 +329,6 @@ PDEVOBJ_vSwitchPdev( ppdev2->pfn.CompletePDEV(ppdev2->dhpdev, (HDEV)ppdev2); } -void -TestDraw() -{ - RECTL rclTrg; - PPDEVOBJ ppdev; - PDC pdc; - - ppdev = EngpGetPDEV(0); - - pdc = DC_AllocDcWithHandle(); - DC_vInitDc(pdc, 0, ppdev); - - - rclTrg.left = rclTrg.top = 0; - rclTrg.right = rclTrg.bottom = 400; - - IntEngBitBltEx(&ppdev->pSurface->SurfObj, - NULL, - NULL, - NULL, - NULL, - &rclTrg, - NULL, - NULL, - &pdc->eboFill.BrushObject, - NULL, - ROP3_TO_ROP4(PATCOPY), - FALSE); - - ASSERT(FALSE); -} BOOL NTAPI @@ -430,8 +399,6 @@ leave: DPRINT1("leave, ppdev = %p, pSurface = %p\n", ppdev, ppdev->pSurface); ASSERT(ppdev->pSurface->BitsLock); - TestDraw(); - return retval; } diff --git a/subsystems/win32/win32k/eng/semaphor.c b/subsystems/win32/win32k/eng/semaphor.c index 7dc55b66182..4498a158757 100644 --- a/subsystems/win32/win32k/eng/semaphor.c +++ b/subsystems/win32/win32k/eng/semaphor.c @@ -74,8 +74,12 @@ NTAPI EngAcquireSemaphoreShared( IN HSEMAPHORE hsem) { + PTHREADINFO pti; + ASSERT(hsem); ExEnterCriticalRegionAndAcquireResourceShared((PERESOURCE)hsem); + pti = PsGetThreadWin32Thread(PsGetCurrentThread()); + if (pti) ++pti->dwEngAcquireCount; } /* diff --git a/subsystems/win32/win32k/include/dc.h b/subsystems/win32/win32k/include/dc.h index e46bb9b4c6b..a662300c931 100644 --- a/subsystems/win32/win32k/include/dc.h +++ b/subsystems/win32/win32k/include/dc.h @@ -169,7 +169,16 @@ DC_LockDc(HDC hdc) { PDC pdc; pdc = GDIOBJ_LockObj(hdc, GDILoObjType_LO_DC_TYPE); - if(pdc) EngAcquireSemaphoreShared(pdc->ppdev->hsemDevLock); + + /* Direct DC's need PDEV locking */ + if(pdc && pdc->dctype == DCTYPE_DIRECT) + { + /* Acquire shared PDEV lock */ + EngAcquireSemaphoreShared(pdc->ppdev->hsemDevLock); + + /* Get the current surface */ + pdc->dclevel.pSurface = pdc->ppdev->pSurface; + } return pdc; } @@ -177,7 +186,12 @@ void FORCEINLINE DC_UnlockDc(PDC pdc) { - EngReleaseSemaphore(pdc->ppdev->hsemDevLock); + if(pdc->dctype == DCTYPE_DIRECT) + { + /* Release PDEV lock */ + EngReleaseSemaphore(pdc->ppdev->hsemDevLock); + } + GDIOBJ_UnlockObjByPtr(&pdc->BaseObject); } diff --git a/subsystems/win32/win32k/ntuser/display.c b/subsystems/win32/win32k/ntuser/display.c index e56cedba686..6e33d55ae22 100644 --- a/subsystems/win32/win32k/ntuser/display.c +++ b/subsystems/win32/win32k/ntuser/display.c @@ -710,6 +710,8 @@ NtUserEnumDisplaySettings( return Status; } +BOOL APIENTRY UserClipCursor(RECTL *prcl); +VOID APIENTRY UserRedrawDesktop(); LONG APIENTRY @@ -725,6 +727,7 @@ UserChangeDisplaySettings( HKEY hkey; NTSTATUS Status; PPDEVOBJ ppdev; + PDESKTOP pdesk; /* If no DEVMODE is given, use registry settings */ if (!pdm) @@ -793,6 +796,19 @@ UserChangeDisplaySettings( DISP_CHANGE_FAILED : DISP_CHANGE_RESTART; } + /* Update the system metrics */ + InitMetrics(); + + /* Remove all cursor clipping */ + UserClipCursor(NULL); + + pdesk = IntGetActiveDesktop(); + IntHideDesktop(pdesk); + co_IntShowDesktop(pdesk, ppdev->gdiinfo.ulHorzRes, ppdev->gdiinfo.ulVertRes); + //UserRedrawDesktop(); + + //IntvGetDeviceCaps(&PrimarySurface, &GdiHandleTable->DevCaps); + /* Send message */ } @@ -883,10 +899,13 @@ NtUserChangeDisplaySettings( } // FIXME: Copy videoparameters + UserEnterExclusive(); /* Call internal function */ Ret = UserChangeDisplaySettings(pustrDevice, lpDevMode, hwnd, dwflags, NULL); + UserLeave(); + return Ret; } diff --git a/subsystems/win32/win32k/objects/dclife.c b/subsystems/win32/win32k/objects/dclife.c index 0487f60e2d7..73e527a9197 100644 --- a/subsystems/win32/win32k/objects/dclife.c +++ b/subsystems/win32/win32k/objects/dclife.c @@ -117,8 +117,11 @@ DC_vInitDc( DCTYPE dctype, PPDEVOBJ ppdev) { - /* Lock ppdev */ - EngAcquireSemaphoreShared(ppdev->hsemDevLock); + if (dctype == DCTYPE_DIRECT) + { + /* Lock ppdev */ + EngAcquireSemaphoreShared(ppdev->hsemDevLock); + } /* Setup some basic fields */ pdc->dctype = dctype; diff --git a/subsystems/win32/win32k/objects/dcstate.c b/subsystems/win32/win32k/objects/dcstate.c index e27d1c24df5..d26cc365c96 100644 --- a/subsystems/win32/win32k/objects/dcstate.c +++ b/subsystems/win32/win32k/objects/dcstate.c @@ -41,7 +41,6 @@ DC_vCopyState(PDC pdcSrc, PDC pdcDst, BOOL To) pdcDst->dclevel.hpal = pdcSrc->dclevel.hpal; /* Handle references here correctly */ - DC_vSelectSurface(pdcDst, pdcSrc->dclevel.pSurface); DC_vSelectFillBrush(pdcDst, pdcSrc->dclevel.pbrFill); DC_vSelectLineBrush(pdcDst, pdcSrc->dclevel.pbrLine); DC_vSelectPalette(pdcDst, pdcSrc->dclevel.ppal); @@ -160,6 +159,10 @@ DC_vRestoreDC( /* Copy the state back */ DC_vCopyState(pdcSave, pdc, FALSE); + /* Only memory DC's change their surface */ + if (pdcSave->dctype == DCTYPE_MEMORY) + DC_vSelectSurface(pdc, pdcSave->dclevel.pSurface); + // Restore Path by removing it, if the Save flag is set. // BeginPath will takecare of the rest. if (pdc->dclevel.hPath && pdc->dclevel.flPath & DCPATH_SAVE) @@ -274,6 +277,10 @@ NtGdiSaveDC( /* Copy the current state */ DC_vCopyState(pdc, pdcSave, TRUE); + /* Only memory DC's change their surface */ + if (pdc->dctype == DCTYPE_MEMORY) + DC_vSelectSurface(pdcSave, pdc->dclevel.pSurface); + /* Copy path. FIXME: why this way? */ pdcSave->dclevel.hPath = pdc->dclevel.hPath; pdcSave->dclevel.flPath = pdc->dclevel.flPath | DCPATH_SAVESTATE;