Commit 8815e638 authored by Alexandre Julliard's avatar Alexandre Julliard

gdi32: Get rid of DC_GetDCPtr in the GDI object functions.

parent 4b14a080
......@@ -374,22 +374,30 @@ static HGDIOBJ BRUSH_SelectObject( HGDIOBJ handle, HDC hdc )
HGDIOBJ ret = 0;
DC *dc = get_dc_ptr( hdc );
if (!dc) return 0;
if (!dc)
{
SetLastError( ERROR_INVALID_HANDLE );
return 0;
}
if ((brush = GDI_GetObjPtr( handle, BRUSH_MAGIC )))
{
if (brush->logbrush.lbStyle == BS_PATTERN)
BITMAP_SetOwnerDC( (HBITMAP)brush->logbrush.lbHatch, dc );
if (dc->funcs->pSelectBrush) handle = dc->funcs->pSelectBrush( dc->physDev, handle );
if (handle)
GDI_inc_ref_count( handle );
GDI_ReleaseObj( handle );
if (dc->funcs->pSelectBrush && !dc->funcs->pSelectBrush( dc->physDev, handle ))
{
GDI_dec_ref_count( handle );
}
else
{
ret = dc->hBrush;
dc->hBrush = handle;
GDI_inc_ref_count( handle );
GDI_dec_ref_count( ret );
}
GDI_ReleaseObj( handle );
}
release_dc_ptr( dc );
return ret;
......
......@@ -823,7 +823,7 @@ BOOL WINAPI DeleteObject( HGDIOBJ obj )
while (header->hdcs)
{
DC *dc = DC_GetDCPtr(header->hdcs->hdc);
DC *dc = get_dc_ptr(header->hdcs->hdc);
struct hdc_list *tmp;
TRACE("hdc %p has interest in %p\n", header->hdcs->hdc, obj);
......@@ -831,7 +831,7 @@ BOOL WINAPI DeleteObject( HGDIOBJ obj )
{
if(dc->funcs->pDeleteObject)
dc->funcs->pDeleteObject( dc->physDev, obj );
DC_ReleaseDCPtr( dc );
release_dc_ptr( dc );
}
tmp = header->hdcs;
header->hdcs = header->hdcs->next;
......@@ -1098,10 +1098,10 @@ DWORD WINAPI GetObjectType( HGDIOBJ handle )
HGDIOBJ WINAPI GetCurrentObject(HDC hdc,UINT type)
{
HGDIOBJ ret = 0;
DC * dc = DC_GetDCPtr( hdc );
DC * dc = get_dc_ptr( hdc );
if (!dc) return 0;
if (dc)
{
switch (type) {
case OBJ_EXTPEN: /* fall through */
case OBJ_PEN: ret = dc->hPen; break;
......@@ -1112,13 +1112,12 @@ HGDIOBJ WINAPI GetCurrentObject(HDC hdc,UINT type)
/* tests show that OBJ_REGION is explicitly ignored */
case OBJ_REGION: break;
default:
/* the SDK only mentions those above */
FIXME("(%p,%d): unknown type.\n",hdc,type);
default:
/* the SDK only mentions those above */
FIXME("(%p,%d): unknown type.\n",hdc,type);
break;
}
DC_ReleaseDCPtr( dc );
}
release_dc_ptr( dc );
return ret;
}
......@@ -1143,23 +1142,15 @@ HGDIOBJ WINAPI SelectObject( HDC hdc, HGDIOBJ hObj )
{
HGDIOBJ ret = 0;
GDIOBJHDR *header;
DC *dc;
TRACE( "(%p,%p)\n", hdc, hObj );
if (!(dc = DC_GetDCPtr( hdc )))
SetLastError( ERROR_INVALID_HANDLE );
else
header = GDI_GetObjPtr( hObj, MAGIC_DONTCARE );
if (header)
{
DC_ReleaseDCPtr( dc );
header = GDI_GetObjPtr( hObj, MAGIC_DONTCARE );
if (header)
{
const struct gdi_obj_funcs *funcs = header->funcs;
GDI_ReleaseObj( hObj );
if (funcs && funcs->pSelectObject) ret = funcs->pSelectObject( hObj, hdc );
}
const struct gdi_obj_funcs *funcs = header->funcs;
GDI_ReleaseObj( hObj );
if (funcs && funcs->pSelectObject) ret = funcs->pSelectObject( hObj, hdc );
}
return ret;
}
......@@ -1437,13 +1428,13 @@ BOOL WINAPI GetColorAdjustment(HDC hdc, LPCOLORADJUSTMENT lpca)
*/
BOOL WINAPI GdiComment(HDC hdc, UINT cbSize, const BYTE *lpData)
{
DC *dc = DC_GetDCPtr(hdc);
DC *dc = get_dc_ptr(hdc);
BOOL ret = FALSE;
if(dc)
{
if (dc->funcs->pGdiComment)
ret = dc->funcs->pGdiComment( dc->physDev, cbSize, lpData );
DC_ReleaseDCPtr( dc );
release_dc_ptr( dc );
}
return ret;
}
......
......@@ -218,19 +218,31 @@ HPEN WINAPI ExtCreatePen( DWORD style, DWORD width,
static HGDIOBJ PEN_SelectObject( HGDIOBJ handle, HDC hdc )
{
HGDIOBJ ret = 0;
DC *dc = DC_GetDCPtr( hdc );
DC *dc = get_dc_ptr( hdc );
if (!dc) return 0;
if (!dc)
{
SetLastError( ERROR_INVALID_HANDLE );
return 0;
}
if (!GDI_inc_ref_count( handle ))
{
release_dc_ptr( dc );
return 0;
}
if (dc->funcs->pSelectPen) handle = dc->funcs->pSelectPen( dc->physDev, handle );
if (handle)
if (dc->funcs->pSelectPen && !dc->funcs->pSelectPen( dc->physDev, handle ))
{
GDI_dec_ref_count( handle );
}
else
{
ret = dc->hPen;
dc->hPen = handle;
GDI_inc_ref_count( handle );
GDI_dec_ref_count( ret );
}
DC_ReleaseDCPtr( dc );
release_dc_ptr( dc );
return ret;
}
......
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