diff --git a/dlls/gdi32/bitmap.c b/dlls/gdi32/bitmap.c index a5c53a91d16..33e55429c7f 100644 --- a/dlls/gdi32/bitmap.c +++ b/dlls/gdi32/bitmap.c @@ -600,6 +600,7 @@ static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, HDC hdc ) HGDIOBJ ret; BITMAPOBJ *bitmap; DC *dc; + PHYSDEV physdev; if (!(dc = get_dc_ptr( hdc ))) return 0; @@ -632,7 +633,8 @@ static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, HDC hdc ) goto done; } - if (dc->funcs->pSelectBitmap && !dc->funcs->pSelectBitmap( dc->physDev, handle )) + physdev = GET_DC_PHYSDEV( dc, pSelectBitmap ); + if (!physdev->funcs->pSelectBitmap( physdev, handle )) { GDI_ReleaseObj( handle ); ret = 0; diff --git a/dlls/gdi32/brush.c b/dlls/gdi32/brush.c index 02020332de8..02fb3a35459 100644 --- a/dlls/gdi32/brush.c +++ b/dlls/gdi32/brush.c @@ -387,13 +387,15 @@ static HGDIOBJ BRUSH_SelectObject( HGDIOBJ handle, HDC hdc ) if ((brush = GDI_GetObjPtr( handle, OBJ_BRUSH ))) { + PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSelectBrush ); + if (brush->logbrush.lbStyle == BS_PATTERN) BITMAP_SetOwnerDC( (HBITMAP)brush->logbrush.lbHatch, dc ); GDI_inc_ref_count( handle ); GDI_ReleaseObj( handle ); - if (dc->funcs->pSelectBrush && !dc->funcs->pSelectBrush( dc->physDev, handle )) + if (!physdev->funcs->pSelectBrush( physdev, handle )) { GDI_dec_ref_count( handle ); } diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c index f25eb8d2d20..66cdc84a0d4 100644 --- a/dlls/gdi32/dc.c +++ b/dlls/gdi32/dc.c @@ -2057,7 +2057,8 @@ COLORREF WINAPI SetDCBrushColor(HDC hdc, COLORREF crColor) { /* If DC_BRUSH is selected, update driver pen color */ HBRUSH hBrush = CreateSolidBrush( crColor ); - dc->funcs->pSelectBrush( dc->physDev, hBrush ); + PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSelectBrush ); + physdev->funcs->pSelectBrush( physdev, hBrush ); DeleteObject( hBrush ); } @@ -2122,7 +2123,8 @@ COLORREF WINAPI SetDCPenColor(HDC hdc, COLORREF crColor) /* If DC_PEN is selected, update the driver pen color */ LOGPEN logpen = { PS_SOLID, { 0, 0 }, crColor }; HPEN hPen = CreatePenIndirect( &logpen ); - dc->funcs->pSelectPen( dc->physDev, hPen ); + PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSelectPen ); + physdev->funcs->pSelectPen( physdev, hPen ); DeleteObject( hPen ); } diff --git a/dlls/gdi32/driver.c b/dlls/gdi32/driver.c index d20bf93abf1..1863499eff9 100644 --- a/dlls/gdi32/driver.c +++ b/dlls/gdi32/driver.c @@ -329,6 +329,11 @@ static BOOL CDECL nulldrv_Chord( PHYSDEV dev, INT left, INT top, INT right, INT return TRUE; } +static BOOL CDECL nulldrv_DeleteObject( PHYSDEV dev, HGDIOBJ obj ) +{ + return TRUE; +} + static BOOL CDECL nulldrv_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom ) { return TRUE; @@ -408,6 +413,31 @@ static BOOL CDECL nulldrv_RoundRect( PHYSDEV dev, INT left, INT top, INT right, return TRUE; } +static HBITMAP CDECL nulldrv_SelectBitmap( PHYSDEV dev, HBITMAP bitmap ) +{ + return bitmap; +} + +static HBRUSH CDECL nulldrv_SelectBrush( PHYSDEV dev, HBRUSH brush ) +{ + return brush; +} + +static HFONT CDECL nulldrv_SelectFont( PHYSDEV dev, HFONT font, HANDLE gdi_font ) +{ + return 0; +} + +static HPALETTE CDECL nulldrv_SelectPalette( PHYSDEV dev, HPALETTE palette, BOOL bkgnd ) +{ + return palette; +} + +static HPEN CDECL nulldrv_SelectPen( PHYSDEV dev, HPEN pen ) +{ + return pen; +} + static void CDECL nulldrv_SetDeviceClipping( PHYSDEV dev, HRGN vis_rgn, HRGN clip_rgn ) { } @@ -506,7 +536,7 @@ const DC_FUNCTIONS null_driver = NULL, /* pCreateDIBSection */ NULL, /* pDeleteBitmap */ NULL, /* pDeleteDC */ - NULL, /* pDeleteObject */ + nulldrv_DeleteObject, /* pDeleteObject */ NULL, /* pDescribePixelFormat */ NULL, /* pDeviceCapabilities */ nulldrv_Ellipse, /* pEllipse */ @@ -566,12 +596,12 @@ const DC_FUNCTIONS null_driver = NULL, /* pSaveDC */ nulldrv_ScaleViewportExtEx, /* pScaleViewportExt */ nulldrv_ScaleWindowExtEx, /* pScaleWindowExt */ - NULL, /* pSelectBitmap */ - NULL, /* pSelectBrush */ + nulldrv_SelectBitmap, /* pSelectBitmap */ + nulldrv_SelectBrush, /* pSelectBrush */ NULL, /* pSelectClipPath */ - NULL, /* pSelectFont */ - NULL, /* pSelectPalette */ - NULL, /* pSelectPen */ + nulldrv_SelectFont, /* pSelectFont */ + nulldrv_SelectPalette, /* pSelectPalette */ + nulldrv_SelectPen, /* pSelectPen */ NULL, /* pSetArcDirection */ NULL, /* pSetBitmapBits */ NULL, /* pSetBkColor */ diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c index c92b6e37538..43abf42971b 100644 --- a/dlls/gdi32/font.c +++ b/dlls/gdi32/font.c @@ -529,6 +529,7 @@ static HGDIOBJ FONT_SelectObject( HGDIOBJ handle, HDC hdc ) { HGDIOBJ ret = 0; DC *dc = get_dc_ptr( hdc ); + PHYSDEV physdev; if (!dc) return 0; @@ -541,7 +542,8 @@ static HGDIOBJ FONT_SelectObject( HGDIOBJ handle, HDC hdc ) if (GetDeviceCaps( dc->hSelf, TEXTCAPS ) & TC_VA_ABLE) dc->gdiFont = WineEngCreateFontInstance( dc, handle ); - if (dc->funcs->pSelectFont) ret = dc->funcs->pSelectFont( dc->physDev, handle, dc->gdiFont ); + physdev = GET_DC_PHYSDEV( dc, pSelectFont ); + ret = physdev->funcs->pSelectFont( physdev, handle, dc->gdiFont ); if (ret && dc->gdiFont) dc->gdiFont = 0; diff --git a/dlls/gdi32/gdiobj.c b/dlls/gdi32/gdiobj.c index 196ebc95e53..35b80686ac3 100644 --- a/dlls/gdi32/gdiobj.c +++ b/dlls/gdi32/gdiobj.c @@ -845,12 +845,10 @@ BOOL WINAPI DeleteObject( HGDIOBJ obj ) if(dc) { - if(dc->funcs->pDeleteObject) - { - GDI_ReleaseObj( obj ); /* release the GDI lock */ - dc->funcs->pDeleteObject( dc->physDev, obj ); - header = GDI_GetObjPtr( obj, 0 ); /* and grab it again */ - } + PHYSDEV physdev = GET_DC_PHYSDEV( dc, pDeleteObject ); + GDI_ReleaseObj( obj ); /* release the GDI lock */ + physdev->funcs->pDeleteObject( physdev, obj ); + header = GDI_GetObjPtr( obj, 0 ); /* and grab it again */ release_dc_ptr( dc ); } HeapFree(GetProcessHeap(), 0, hdcs_head); diff --git a/dlls/gdi32/palette.c b/dlls/gdi32/palette.c index e941b10c52c..e94ed7b28a8 100644 --- a/dlls/gdi32/palette.c +++ b/dlls/gdi32/palette.c @@ -689,7 +689,7 @@ static BOOL PALETTE_DeleteObject( HGDIOBJ handle ) */ HPALETTE WINAPI GDISelectPalette( HDC hdc, HPALETTE hpal, WORD wBkg) { - HPALETTE ret; + HPALETTE ret = 0; DC *dc; TRACE("%p %p\n", hdc, hpal ); @@ -699,16 +699,18 @@ HPALETTE WINAPI GDISelectPalette( HDC hdc, HPALETTE hpal, WORD wBkg) WARN("invalid selected palette %p\n",hpal); return 0; } - if (!(dc = get_dc_ptr( hdc ))) return 0; - ret = dc->hPalette; - if (dc->funcs->pSelectPalette) hpal = dc->funcs->pSelectPalette( dc->physDev, hpal, FALSE ); - if (hpal) + if ((dc = get_dc_ptr( hdc ))) { - dc->hPalette = hpal; - if (!wBkg) hPrimaryPalette = hpal; + PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSelectPalette ); + ret = dc->hPalette; + if (physdev->funcs->pSelectPalette( physdev, hpal, FALSE )) + { + dc->hPalette = hpal; + if (!wBkg) hPrimaryPalette = hpal; + } + else ret = 0; + release_dc_ptr( dc ); } - else ret = 0; - release_dc_ptr( dc ); return ret; } diff --git a/dlls/gdi32/pen.c b/dlls/gdi32/pen.c index a130b1fdd46..61dd0e9d6af 100644 --- a/dlls/gdi32/pen.c +++ b/dlls/gdi32/pen.c @@ -219,6 +219,7 @@ HPEN WINAPI ExtCreatePen( DWORD style, DWORD width, */ static HGDIOBJ PEN_SelectObject( HGDIOBJ handle, HDC hdc ) { + PHYSDEV physdev; HGDIOBJ ret = 0; DC *dc = get_dc_ptr( hdc ); @@ -234,7 +235,8 @@ static HGDIOBJ PEN_SelectObject( HGDIOBJ handle, HDC hdc ) return 0; } - if (dc->funcs->pSelectPen && !dc->funcs->pSelectPen( dc->physDev, handle )) + physdev = GET_DC_PHYSDEV( dc, pSelectPen ); + if (!physdev->funcs->pSelectPen( physdev, handle )) { GDI_dec_ref_count( handle ); }