[WIN32K]
authorJérôme Gardou <jerome.gardou@reactos.org>
Fri, 14 May 2010 20:19:46 +0000 (20:19 +0000)
committerJérôme Gardou <jerome.gardou@reactos.org>
Fri, 14 May 2010 20:19:46 +0000 (20:19 +0000)
  - clean up some unused code
  - use GDIOBJ_IncrementShareCount on Timo suggestion
  - use ppdev semaphore as sort criterion in DC_vPrepareDCsForBlit, spotted by Timo
  - Get ownership before freeing the object in GDIOBJ_ShareUnlockObjByPtr, as whoever set it ready to die had the right to

svn path=/branches/reactos-yarotows/; revision=47205

subsystems/win32/win32k/include/dc.h
subsystems/win32/win32k/include/gdiobj.h
subsystems/win32/win32k/objects/bitmaps.c
subsystems/win32/win32k/objects/dclife.c

index d78e200..3ab1bf3 100644 (file)
@@ -152,52 +152,10 @@ typedef struct _DC
 
 /* Internal functions *********************************************************/
 
-#if 1
 #define  DC_LockDc(hDC)  \
   ((PDC) GDIOBJ_LockObj ((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC))
 #define  DC_UnlockDc(pDC)  \
   GDIOBJ_UnlockObjByPtr ((POBJ)pDC)
-#else
-
-VOID NTAPI EngAcquireSemaphoreShared(IN HSEMAPHORE hsem);
-
-PDC
-FORCEINLINE
-DC_LockDc(HDC hdc)
-{
-    PDC pdc;
-    pdc = GDIOBJ_LockObj(hdc, GDILoObjType_LO_DC_TYPE);
-
-    /* Direct DC's need PDEV locking */
-    if(pdc && pdc->dctype == DCTYPE_DIRECT)
-    {
-        /* Acquire shared PDEV lock */
-        EngAcquireSemaphoreShared(pdc->ppdev->hsemDevLock);
-
-        /* Update Surface if needed */
-        if(pdc->dclevel.pSurface != pdc->ppdev->pSurface)
-        {
-            if(pdc->dclevel.pSurface) SURFACE_ShareUnlockSurface(pdc->dclevel.pSurface);
-            pdc->dclevel.pSurface = PDEVOBJ_pSurface(pdc->ppdev);
-        }
-    }
-    return pdc;
-}
-
-void
-FORCEINLINE
-DC_UnlockDc(PDC pdc)
-{
-    if(pdc->dctype == DCTYPE_DIRECT)
-    {
-        /* Release PDEV lock */
-        EngReleaseSemaphore(pdc->ppdev->hsemDevLock);
-    }
-
-    GDIOBJ_UnlockObjByPtr(&pdc->BaseObject);
-}
-#endif
-
 
 extern PDC defaultDCstate;
 
index 16b7e93..a1a56b7 100644 (file)
@@ -113,6 +113,7 @@ GDIOBJ_ShareUnlockObjByPtr(POBJ Object)
     ASSERT(cLocks >= 0);
     if ((flags & BASEFLAG_READY_TO_DIE) && (cLocks == 0))
     {
+        GDIOBJ_SetOwnership(hobj, PsGetCurrentProcess());
         GDIOBJ_FreeObjByHandle(hobj, GDI_OBJECT_TYPE_DONTCARE);
     }
     return cLocks;
index 63cc160..3373a30 100644 (file)
@@ -95,7 +95,7 @@ IntGdiCreateBitmap(
     {
         case 1:
             psurfBmp->ppal = &gpalMono;
-            gpalMono.BaseObject.ulShareCount++;
+            GDIOBJ_IncrementShareCount((POBJ)&gpalMono);
             break;
         case 4:
         case 8:
@@ -103,16 +103,15 @@ IntGdiCreateBitmap(
             break;
         case 15:
             psurfBmp->ppal = &gpalRGB555;
-            gpalRGB555.BaseObject.ulShareCount++;
+            GDIOBJ_IncrementShareCount((POBJ)&gpalRGB555);
             break;
         case 16:
             psurfBmp->ppal = &gpalRGB565;
-            gpalRGB565.BaseObject.ulShareCount++;
-            break;
+            GDIOBJ_IncrementShareCount((POBJ)&gpalRGB565);
         case 24:
         case 32:
             psurfBmp->ppal = &gpalRGB;
-            gpalRGB.BaseObject.ulShareCount++;
+            GDIOBJ_IncrementShareCount((POBJ)&gpalRGB);
             break;
         default:
             DPRINT1("Could not determine palette for bit depth %u.\n", BitsPixel);
index 6642633..e0f7a28 100644 (file)
@@ -115,14 +115,6 @@ DC_vInitDc(
     DCTYPE dctype,
     PPDEVOBJ ppdev)
 {
-#if 0
-    if (dctype == DCTYPE_DIRECT)
-    {
-        /* Lock ppdev */
-        EngAcquireSemaphoreShared(ppdev->hsemDevLock);
-    }
-#endif
-
     /* Setup some basic fields */
     pdc->dctype = dctype;
     pdc->ppdev = ppdev;
@@ -496,7 +488,7 @@ DC_vPrepareDCsForBlit(PDC pdc1,
     /* Lock them in good order */
     if(pdc2)
     {
-        if((ULONG_PTR)pdc1->BaseObject.hHmgr >= (ULONG_PTR)pdc2->BaseObject.hHmgr)
+        if((ULONG_PTR)pdc1->ppdev->hsemDevLock >= (ULONG_PTR)pdc2->ppdev->hsemDevLock)
         {
             pdcFirst = pdc1;
             prcFirst = &rc1;