Author: tkreuzer Date: Sun Feb 27 17:51:37 2011 New Revision: 50921
URL: http://svn.reactos.org/svn/reactos?rev=50921&view=rev Log: [WIN32K] - mark surface as not selected in DC_vSelectSurface when its released from a DC NtGdiSelectBitmap: - Don't allow selecting a bitmap into a dc that is already selected! - Use DC_vSelectSurface instead of manually selecting - set the DC size based on bitmap size
Modified: trunk/reactos/subsystems/win32/win32k/eng/bitblt.c trunk/reactos/subsystems/win32/win32k/include/dc.h trunk/reactos/subsystems/win32/win32k/objects/dcobjs.c
Modified: trunk/reactos/subsystems/win32/win32k/eng/bitblt.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/eng... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/eng/bitblt.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/eng/bitblt.c [iso-8859-1] Sun Feb 27 17:51:37 2011 @@ -541,8 +541,6 @@ BOOL bResult; RECTL rclClipped; RECTL rclSrc; -// INTENG_ENTER_LEAVE EnterLeaveSource; -// INTENG_ENTER_LEAVE EnterLeaveDest; PFN_DrvBitBlt pfnBitBlt;
ASSERT(psoTrg); @@ -552,9 +550,9 @@ rclClipped = *prclTrg; RECTL_vMakeWellOrdered(&rclClipped);
- /* Clip target rect against the bounds of the clipping region */ if (pco) { + /* Clip target rect against the bounds of the clipping region */ if (!RECTL_bIntersectRect(&rclClipped, &rclClipped, &pco->rclBounds)) { /* Nothing left */
Modified: trunk/reactos/subsystems/win32/win32k/include/dc.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/inc... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/include/dc.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/include/dc.h [iso-8859-1] Sun Feb 27 17:51:37 2011 @@ -213,7 +213,10 @@ { PSURFACE psurfOld = pdc->dclevel.pSurface; if (psurfOld) + { + psurfOld->hdc = NULL; SURFACE_ShareUnlockSurface(psurfOld); + } if (psurfNew) GDIOBJ_IncrementShareCount((POBJ)psurfNew); pdc->dclevel.pSurface = psurfNew;
Modified: trunk/reactos/subsystems/win32/win32k/objects/dcobjs.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/obj... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/dcobjs.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/objects/dcobjs.c [iso-8859-1] Sun Feb 27 17:51:37 2011 @@ -257,9 +257,10 @@ PDC pdc; PDC_ATTR pdcattr; HBITMAP hbmpOld; - PSURFACE psurfNew, psurfOld; + PSURFACE psurfNew; HRGN hVisRgn; SIZEL sizlBitmap = {1, 1}; + HDC hdcOld; ASSERT_NOGDILOCKS();
/* Verify parameters */ @@ -280,8 +281,17 @@ return NULL; }
- /* Save the old bitmap */ - psurfOld = pdc->dclevel.pSurface; + /* Check if there was a bitmap selected before */ + if (pdc->dclevel.pSurface) + { + /* Return its handle */ + hbmpOld = pdc->dclevel.pSurface->BaseObject.hHmgr; + } + else + { + /* Return default bitmap */ + hbmpOld = StockObjects[DEFAULT_BITMAP]; + }
/* Check if the default bitmap was passed */ if (hbmp == StockObjects[DEFAULT_BITMAP]) @@ -300,16 +310,17 @@ DC_UnlockDc(pdc); return NULL; } -#if 0 // FIXME: bug bug, causes problems + /* Set the bitmp's hdc */ - if (InterlockedCompareExchangePointer((PVOID*)&psurfNew->hdc, hdc, 0)) + hdcOld = InterlockedCompareExchangePointer((PVOID*)&psurfNew->hdc, hdc, 0); + if (hdcOld != NULL && hdcOld != hdc) { /* The bitmap is already selected, fail */ SURFACE_ShareUnlockSurface(psurfNew); DC_UnlockDc(pdc); return NULL; } -#endif + /* Get the bitmap size */ sizlBitmap = psurfNew->SurfObj.sizlBitmap;
@@ -325,25 +336,14 @@ } }
- /* Select the new bitmap */ - pdc->dclevel.pSurface = psurfNew; - - /* Check if there was a bitmap selected before */ - if (psurfOld) - { - hbmpOld = psurfOld->BaseObject.hHmgr; - - /* Reset hdc of old bitmap, this surface isn't selected anymore */ - psurfOld->hdc = NULL; - - /* Release the old bitmap */ - SURFACE_ShareUnlockSurface(psurfOld); - } - else - { - /* Return default bitmap */ - hbmpOld = StockObjects[DEFAULT_BITMAP]; - } + /* Select the new surface, release the old */ + DC_vSelectSurface(pdc, psurfNew); + + /* Set the new size */ + pdc->dclevel.sizl = sizlBitmap; + + /* Release one reference we added */ + SURFACE_ShareUnlockSurface(psurfNew);
/* Mark the dc brushes invalid */ pdcattr->ulDirty_ |= DIRTY_FILL | DIRTY_LINE;