Commit aa493478 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

gdi32: Where possible directly access the DC instead of using GetCurrentObject().

parent d4d65e2d
......@@ -354,8 +354,8 @@ void DC_UpdateXforms( DC *dc )
if (memcmp(&oldworld2vport, &dc->xformWorld2Vport, sizeof(oldworld2vport)) &&
!GdiIsMetaFileDC(dc->hSelf))
{
SelectObject(dc->hSelf, GetCurrentObject(dc->hSelf, OBJ_FONT));
SelectObject(dc->hSelf, GetCurrentObject(dc->hSelf, OBJ_PEN));
SelectObject(dc->hSelf, dc->hFont);
SelectObject(dc->hSelf, dc->hPen);
}
}
......@@ -1038,7 +1038,7 @@ INT WINAPI SetGraphicsMode( HDC hdc, INT mode )
dc->GraphicsMode = mode;
}
/* font metrics depend on the graphics mode */
if (ret != mode) SelectObject(dc->hSelf, GetCurrentObject(dc->hSelf, OBJ_FONT));
if (ret != mode) SelectObject(dc->hSelf, dc->hFont);
release_dc_ptr( dc );
return ret;
}
......
......@@ -390,9 +390,9 @@ static INT nulldrv_GetTextFace( PHYSDEV dev, INT size, LPWSTR name )
{
INT ret = 0;
LOGFONTW font;
HFONT hfont = GetCurrentObject( dev->hdc, OBJ_FONT );
DC *dc = get_nulldrv_dc( dev );
if (GetObjectW( hfont, sizeof(font), &font ))
if (GetObjectW( dc->hFont, sizeof(font), &font ))
{
ret = strlenW( font.lfFaceName ) + 1;
if (name)
......
......@@ -463,10 +463,11 @@ found:
COLORREF EMFDRV_SetDCBrushColor( PHYSDEV dev, COLORREF color )
{
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
DC *dc = get_physdev_dc( dev );
EMRSELECTOBJECT emr;
DWORD index;
if (GetCurrentObject( dev->hdc, OBJ_BRUSH ) != GetStockObject( DC_BRUSH )) return color;
if (dc->hBrush != GetStockObject( DC_BRUSH )) return color;
if (physDev->dc_brush) DeleteObject( physDev->dc_brush );
if (!(physDev->dc_brush = CreateSolidBrush( color ))) return CLR_INVALID;
......@@ -484,11 +485,12 @@ COLORREF EMFDRV_SetDCBrushColor( PHYSDEV dev, COLORREF color )
COLORREF EMFDRV_SetDCPenColor( PHYSDEV dev, COLORREF color )
{
EMFDRV_PDEVICE *physDev = get_emf_physdev( dev );
DC *dc = get_physdev_dc( dev );
EMRSELECTOBJECT emr;
DWORD index;
LOGPEN logpen = { PS_SOLID, { 0, 0 }, color };
if (GetCurrentObject( dev->hdc, OBJ_PEN ) != GetStockObject( DC_PEN )) return color;
if (dc->hPen != GetStockObject( DC_PEN )) return color;
if (physDev->dc_pen) DeleteObject( physDev->dc_pen );
if (!(physDev->dc_pen = CreatePenIndirect( &logpen ))) return CLR_INVALID;
......
......@@ -2269,7 +2269,7 @@ BOOL WINAPI ExtTextOutW( HDC hdc, INT x, INT y, UINT flags,
}
GetTextMetricsW(hdc, &tm);
GetObjectW(GetCurrentObject(hdc, OBJ_FONT), sizeof(lf), &lf);
GetObjectW(dc->hFont, sizeof(lf), &lf);
if(!(tm.tmPitchAndFamily & TMPF_VECTOR)) /* Non-scalable fonts shouldn't be rotated */
lf.lfEscapement = 0;
......
......@@ -503,6 +503,7 @@ UINT WINAPI GetNearestPaletteIndex(
COLORREF nulldrv_GetNearestColor( PHYSDEV dev, COLORREF color )
{
unsigned char spec_type;
DC *dc = get_nulldrv_dc( dev );
if (!(GetDeviceCaps( dev->hdc, RASTERCAPS ) & RC_PALETTE)) return color;
......@@ -512,7 +513,7 @@ COLORREF nulldrv_GetNearestColor( PHYSDEV dev, COLORREF color )
/* we need logical palette for PALETTERGB and PALETTEINDEX colorrefs */
UINT index;
PALETTEENTRY entry;
HPALETTE hpal = GetCurrentObject( dev->hdc, OBJ_PAL );
HPALETTE hpal = dc->hPalette;
if (!hpal) hpal = GetStockObject( DEFAULT_PALETTE );
if (spec_type == 2) /* PALETTERGB */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment