X-Git-Url: https://git.reactos.org/?p=reactos.git;a=blobdiff_plain;f=reactos%2Fsubsystems%2Fwin32%2Fwin32k%2Fobjects%2Fdcobjs.c;h=6975b60146f483c4059fe295812402233d35669a;hp=25e54cb36c78d19d5eb4b86c2b247cb547869e3b;hb=736733be4d488d3215f953111ed445fc62078573;hpb=760940d0bd2de1ebdcc15675d5ba2ab893a6d05d diff --git a/reactos/subsystems/win32/win32k/objects/dcobjs.c b/reactos/subsystems/win32/win32k/objects/dcobjs.c index 25e54cb36c7..6975b60146f 100644 --- a/reactos/subsystems/win32/win32k/objects/dcobjs.c +++ b/reactos/subsystems/win32/win32k/objects/dcobjs.c @@ -257,9 +257,10 @@ NtGdiSelectBitmap( 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 @@ NtGdiSelectBitmap( 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 @@ NtGdiSelectBitmap( 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 @@ NtGdiSelectBitmap( } } - /* Select the new bitmap */ - pdc->dclevel.pSurface = psurfNew; + /* Select the new surface, release the old */ + DC_vSelectSurface(pdc, 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; + /* Set the new size */ + pdc->dclevel.sizl = sizlBitmap; - /* Release the old bitmap */ - SURFACE_ShareUnlockSurface(psurfOld); - } - else - { - /* Return default bitmap */ - hbmpOld = StockObjects[DEFAULT_BITMAP]; - } + /* Release one reference we added */ + SURFACE_ShareUnlockSurface(psurfNew); /* Mark the dc brushes invalid */ pdcattr->ulDirty_ |= DIRTY_FILL | DIRTY_LINE;