From b0aa4f5a2c6f0f71c9d68acf21b5f259264367dc Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Fri, 14 May 2010 20:19:46 +0000 Subject: [PATCH] [WIN32K] - 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 | 42 ----------------------- subsystems/win32/win32k/include/gdiobj.h | 1 + subsystems/win32/win32k/objects/bitmaps.c | 9 +++-- subsystems/win32/win32k/objects/dclife.c | 10 +----- 4 files changed, 6 insertions(+), 56 deletions(-) diff --git a/subsystems/win32/win32k/include/dc.h b/subsystems/win32/win32k/include/dc.h index d78e200efef..3ab1bf3df78 100644 --- a/subsystems/win32/win32k/include/dc.h +++ b/subsystems/win32/win32k/include/dc.h @@ -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; diff --git a/subsystems/win32/win32k/include/gdiobj.h b/subsystems/win32/win32k/include/gdiobj.h index 16b7e93cd7d..a1a56b7ae24 100644 --- a/subsystems/win32/win32k/include/gdiobj.h +++ b/subsystems/win32/win32k/include/gdiobj.h @@ -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; diff --git a/subsystems/win32/win32k/objects/bitmaps.c b/subsystems/win32/win32k/objects/bitmaps.c index 63cc160243f..3373a302574 100644 --- a/subsystems/win32/win32k/objects/bitmaps.c +++ b/subsystems/win32/win32k/objects/bitmaps.c @@ -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); diff --git a/subsystems/win32/win32k/objects/dclife.c b/subsystems/win32/win32k/objects/dclife.c index 664263348a1..e0f7a28d4c5 100644 --- a/subsystems/win32/win32k/objects/dclife.c +++ b/subsystems/win32/win32k/objects/dclife.c @@ -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; -- 2.17.1