From e11e69e45f10788d0e17a6aa3750dc9e4adfd782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Wed, 3 Dec 2003 19:28:23 +0000 Subject: [PATCH] Fix creation of display-compatible DCs svn path=/trunk/; revision=6855 --- reactos/subsys/win32k/objects/dc.c | 121 +++++++++++++---------------- 1 file changed, 55 insertions(+), 66 deletions(-) diff --git a/reactos/subsys/win32k/objects/dc.c b/reactos/subsys/win32k/objects/dc.c index bf91826af80..3d55c780fd9 100644 --- a/reactos/subsys/win32k/objects/dc.c +++ b/reactos/subsys/win32k/objects/dc.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: dc.c,v 1.104 2003/11/30 18:55:57 gvg Exp $ +/* $Id: dc.c,v 1.105 2003/12/03 19:28:23 gvg Exp $ * * DC.C - Device context functions * @@ -131,26 +131,38 @@ NtGdiCreateCompatableDC(HDC hDC) { PDC NewDC, OrigDC; HBITMAP hBitmap; - HDC hNewDC; + HDC hNewDC, DisplayDC; HRGN hVisRgn; BITMAPOBJ *pb; - PSURFGDI SurfGDI; if (hDC == NULL) { - return NtGdiCreateDC(L"DISPLAY", NULL, NULL, NULL); + DisplayDC = NtGdiCreateDC(L"DISPLAY", NULL, NULL, NULL); + if (NULL == DisplayDC) + { + return NULL; + } + hDC = DisplayDC; } /* Allocate a new DC based on the original DC's device */ OrigDC = DC_LockDc(hDC); if (NULL == OrigDC) { + if (NULL != DisplayDC) + { + NtGdiDeleteDC(DisplayDC); + } return NULL; } hNewDC = DC_AllocDC(OrigDC->DriverName); if (NULL == hNewDC) { + if (NULL != DisplayDC) + { + NtGdiDeleteDC(DisplayDC); + } return NULL; } NewDC = DC_LockDc( hNewDC ); @@ -158,55 +170,38 @@ NtGdiCreateCompatableDC(HDC hDC) /* Copy information from original DC to new DC */ NewDC->hSelf = NewDC; - /* FIXME: Should this DC request its own PDEV? */ - if(OrigDC == NULL) - { - NewDC->PDev = PrimarySurface.PDev; - memcpy(NewDC->FillPatternSurfaces, PrimarySurface.FillPatterns, - sizeof(NewDC->FillPatternSurfaces)); - NewDC->GDIInfo = &PrimarySurface.GDIInfo; - NewDC->DevInfo = &PrimarySurface.DevInfo; - SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) PrimarySurface.Handle); - NewDC->w.bitsPerPixel = SurfGDI->BitsPerPixel; - } - else - { - NewDC->PDev = OrigDC->PDev; - NewDC->DMW = OrigDC->DMW; - memcpy(NewDC->FillPatternSurfaces, - OrigDC->FillPatternSurfaces, - sizeof OrigDC->FillPatternSurfaces); - NewDC->GDIInfo = OrigDC->GDIInfo; - NewDC->DevInfo = OrigDC->DevInfo; - NewDC->w.bitsPerPixel = OrigDC->w.bitsPerPixel; - } + NewDC->PDev = OrigDC->PDev; + NewDC->DMW = OrigDC->DMW; + memcpy(NewDC->FillPatternSurfaces, + OrigDC->FillPatternSurfaces, + sizeof OrigDC->FillPatternSurfaces); + NewDC->GDIInfo = OrigDC->GDIInfo; + NewDC->DevInfo = OrigDC->DevInfo; + NewDC->w.bitsPerPixel = OrigDC->w.bitsPerPixel; /* DriverName is copied in the AllocDC routine */ - if(OrigDC == NULL) - { - NewDC->DeviceDriver = (HANDLE) PrimarySurface.VideoDeviceObject; - } - else - { - NewDC->DeviceDriver = OrigDC->DeviceDriver; - NewDC->wndOrgX = OrigDC->wndOrgX; - NewDC->wndOrgY = OrigDC->wndOrgY; - NewDC->wndExtX = OrigDC->wndExtX; - NewDC->wndExtY = OrigDC->wndExtY; - NewDC->vportOrgX = OrigDC->vportOrgX; - NewDC->vportOrgY = OrigDC->vportOrgY; - NewDC->vportExtX = OrigDC->vportExtX; - NewDC->vportExtY = OrigDC->vportExtY; - } + NewDC->DeviceDriver = OrigDC->DeviceDriver; + NewDC->wndOrgX = OrigDC->wndOrgX; + NewDC->wndOrgY = OrigDC->wndOrgY; + NewDC->wndExtX = OrigDC->wndExtX; + NewDC->wndExtY = OrigDC->wndExtY; + NewDC->vportOrgX = OrigDC->vportOrgX; + NewDC->vportOrgY = OrigDC->vportOrgY; + NewDC->vportExtX = OrigDC->vportExtX; + NewDC->vportExtY = OrigDC->vportExtY; /* Create default bitmap */ if (!(hBitmap = NtGdiCreateBitmap( 1, 1, 1, NewDC->w.bitsPerPixel, NULL ))) - { - DC_UnlockDc( hDC ); - DC_UnlockDc( hNewDC ); - DC_FreeDC( hNewDC ); - return NULL; - } + { + DC_UnlockDc( hDC ); + DC_UnlockDc( hNewDC ); + DC_FreeDC( hNewDC ); + if (NULL != DisplayDC) + { + NtGdiDeleteDC(DisplayDC); + } + return NULL; + } NewDC->w.flags = DC_MEMORY; NewDC->w.hBitmap = hBitmap; NewDC->w.hFirstBitmap = hBitmap; @@ -214,23 +209,17 @@ NtGdiCreateCompatableDC(HDC hDC) NewDC->Surface = BitmapToSurf(pb); BITMAPOBJ_UnlockBitmap(hBitmap); - if(OrigDC == NULL) - { - NewDC->w.hPalette = NewDC->DevInfo->hpalDefault; - } - else - { - NewDC->w.hPalette = OrigDC->w.hPalette; - NewDC->w.textColor = OrigDC->w.textColor; - NewDC->w.textAlign = OrigDC->w.textAlign; - NewDC->w.backgroundColor = OrigDC->w.backgroundColor; - NewDC->w.backgroundMode = OrigDC->w.backgroundMode; - } - if (NULL != hDC) - { - DC_UnlockDc( hDC ); - } - DC_UnlockDc( hNewDC ); + NewDC->w.hPalette = OrigDC->w.hPalette; + NewDC->w.textColor = OrigDC->w.textColor; + NewDC->w.textAlign = OrigDC->w.textAlign; + NewDC->w.backgroundColor = OrigDC->w.backgroundColor; + NewDC->w.backgroundMode = OrigDC->w.backgroundMode; + DC_UnlockDc( hDC ); + if (NULL != DisplayDC) + { + NtGdiDeleteDC(DisplayDC); + } + DC_UnlockDc(hNewDC); hVisRgn = NtGdiCreateRectRgn(0, 0, 1, 1); NtGdiSelectVisRgn(hNewDC, hVisRgn); @@ -238,7 +227,7 @@ NtGdiCreateCompatableDC(HDC hDC) DC_InitDC(hNewDC); - return hNewDC; + return hNewDC; } static BOOL FASTCALL