From d1795f674cfdb7657e723e10fac900d3a0e1fa43 Mon Sep 17 00:00:00 2001 From: Gerard Patel Date: Sun, 9 Jan 2000 20:52:53 +0000 Subject: [PATCH] Avoid deleting of the default 1x1 bitmap for memory DCs. --- include/gdi.h | 3 ++- objects/dc.c | 13 +------------ objects/gdiobj.c | 4 ++++ 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/include/gdi.h b/include/gdi.h index c2aace30c92..89bb433f518 100644 --- a/include/gdi.h +++ b/include/gdi.h @@ -97,7 +97,6 @@ typedef struct HBRUSH16 hBrush; HFONT16 hFont; HBITMAP16 hBitmap; - HBITMAP16 hFirstBitmap; /* Bitmap selected at creation of the DC */ HANDLE16 hDevice; HPALETTE16 hPalette; @@ -320,6 +319,8 @@ typedef struct tagDC_FUNCS #define LAST_STOCK_HANDLE ((DWORD)STOCK_DEFAULT_GUI_FONT) +extern HBITMAP hPseudoStockBitmap; + /* Device <-> logical coords conversion */ /* A floating point version of the POINT structure */ diff --git a/objects/dc.c b/objects/dc.c index 5a74029f2d0..036d2bc5975 100644 --- a/objects/dc.c +++ b/objects/dc.c @@ -41,7 +41,6 @@ static void DC_Init_DC_INFO( WIN_DC_INFO *win_dc_info ) win_dc_info->hBrush = STOCK_WHITE_BRUSH; win_dc_info->hFont = STOCK_SYSTEM_FONT; win_dc_info->hBitmap = 0; - win_dc_info->hFirstBitmap = 0; win_dc_info->hDevice = 0; win_dc_info->hPalette = STOCK_DEFAULT_PALETTE; win_dc_info->ROPmode = R2_COPYPEN; @@ -238,7 +237,6 @@ HDC16 WINAPI GetDCState16( HDC16 hdc ) newdc->w.hBrush = dc->w.hBrush; newdc->w.hFont = dc->w.hFont; newdc->w.hBitmap = dc->w.hBitmap; - newdc->w.hFirstBitmap = dc->w.hFirstBitmap; newdc->w.hDevice = dc->w.hDevice; newdc->w.hPalette = dc->w.hPalette; newdc->w.totalExtent = dc->w.totalExtent; @@ -327,7 +325,6 @@ void WINAPI SetDCState16( HDC16 hdc, HDC16 hdcs ) dc->w.flags = dcs->w.flags & ~DC_SAVED; dc->w.devCaps = dcs->w.devCaps; - dc->w.hFirstBitmap = dcs->w.hFirstBitmap; dc->w.hDevice = dcs->w.hDevice; dc->w.totalExtent = dcs->w.totalExtent; dc->w.ROPmode = dcs->w.ROPmode; @@ -629,16 +626,9 @@ HDC WINAPI CreateCompatibleDC( HDC hdc ) TRACE("(%04x): returning %04x\n", hdc, dc->hSelf ); - /* Create default bitmap */ - if (!(hbitmap = CreateBitmap( 1, 1, 1, 1, NULL ))) - { - GDI_HEAP_FREE( dc->hSelf ); - return 0; - } dc->w.flags = DC_MEMORY; dc->w.bitsPerPixel = 1; - dc->w.hBitmap = hbitmap; - dc->w.hFirstBitmap = hbitmap; + dc->w.hBitmap = hPseudoStockBitmap; /* Copy the driver-specific physical device info into * the new DC. The driver may use this read-only info @@ -703,7 +693,6 @@ BOOL WINAPI DeleteDC( HDC hdc ) SelectObject( hdc, STOCK_BLACK_PEN ); SelectObject( hdc, STOCK_WHITE_BRUSH ); SelectObject( hdc, STOCK_SYSTEM_FONT ); - if (dc->w.flags & DC_MEMORY) DeleteObject( dc->w.hFirstBitmap ); if (dc->funcs->pDeleteDC) dc->funcs->pDeleteDC(dc); } diff --git a/objects/gdiobj.c b/objects/gdiobj.c index cb686766617..16357ea0a0d 100644 --- a/objects/gdiobj.c +++ b/objects/gdiobj.c @@ -179,6 +179,8 @@ static GDIOBJHDR * StockObjects[NB_STOCK_OBJECTS] = (GDIOBJHDR *) &DefaultGuiFont }; +HBITMAP hPseudoStockBitmap; /* 1x1 bitmap for memory DCs */ + /****************************************************************************** * * void ReadFontInformation( @@ -359,6 +361,7 @@ BOOL GDI_Init(void) StockObjects[DEFAULT_PALETTE] = (GDIOBJHDR *)GDI_HEAP_LOCK( hpalette ); } + hPseudoStockBitmap = CreateBitmap( 1, 1, 1, 1, NULL ); return TRUE; } @@ -452,6 +455,7 @@ BOOL WINAPI DeleteObject( HGDIOBJ obj ) if (HIWORD(obj)) return FALSE; if ((obj >= FIRST_STOCK_HANDLE) && (obj <= LAST_STOCK_HANDLE)) return TRUE; + if (obj == hPseudoStockBitmap) return TRUE; if (!(header = (GDIOBJHDR *) GDI_HEAP_LOCK( obj ))) return FALSE; TRACE("%04x\n", obj );