[WIN32K]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Thu, 1 Apr 2010 22:36:40 +0000 (22:36 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Thu, 1 Apr 2010 22:36:40 +0000 (22:36 +0000)
- 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
subsystems/win32/win32k/eng/semaphor.c
subsystems/win32/win32k/include/dc.h
subsystems/win32/win32k/ntuser/display.c
subsystems/win32/win32k/objects/dclife.c
subsystems/win32/win32k/objects/dcstate.c

index 7ac40ef..d1d52e5 100644 (file)
@@ -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;
 }
 
index 7dc55b6..4498a15 100644 (file)
@@ -74,8 +74,12 @@ NTAPI
 EngAcquireSemaphoreShared(
     IN HSEMAPHORE hsem)
 {
+    PTHREADINFO pti;
+
     ASSERT(hsem);
     ExEnterCriticalRegionAndAcquireResourceShared((PERESOURCE)hsem);
+    pti = PsGetThreadWin32Thread(PsGetCurrentThread());
+    if (pti) ++pti->dwEngAcquireCount;
 }
 
 /*
index e46bb9b..a662300 100644 (file)
@@ -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);
 }
 
index e56cedb..6e33d55 100644 (file)
@@ -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;
 }
 
index 0487f60..73e527a 100644 (file)
@@ -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;
index e27d1c2..d26cc36 100644 (file)
@@ -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;