Commit a1e31397 authored by Alexandre Julliard's avatar Alexandre Julliard

gdi32: Don't pass an object pointer to the SelectObject backend functions.

parent e36ed761
......@@ -33,7 +33,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(bitmap);
static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, void *obj, HDC hdc );
static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, HDC hdc );
static INT BITMAP_GetObject16( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
static INT BITMAP_GetObject( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
static BOOL BITMAP_DeleteObject( HGDIOBJ handle, void *obj );
......@@ -554,32 +554,38 @@ BOOL BITMAP_SetOwnerDC( HBITMAP hbitmap, DC *dc )
/***********************************************************************
* BITMAP_SelectObject
*/
static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, void *obj, HDC hdc )
static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, HDC hdc )
{
HGDIOBJ ret;
BITMAPOBJ *bitmap = obj;
DC *dc = DC_GetDCPtr( hdc );
BITMAPOBJ *bitmap;
DC *dc;
if (!dc) return 0;
if (GetObjectType( hdc ) != OBJ_MEMDC)
if (!(bitmap = GDI_GetObjPtr( handle, BITMAP_MAGIC ))) return 0;
if (!(dc = get_dc_ptr( hdc )))
{
DC_ReleaseDCPtr( dc );
GDI_ReleaseObj( handle );
return 0;
}
if (GetObjectType( hdc ) != OBJ_MEMDC)
{
ret = 0;
goto done;
}
ret = dc->hBitmap;
if (handle == dc->hBitmap) goto done; /* nothing to do */
if (bitmap->header.dwCount && (handle != GetStockObject(DEFAULT_BITMAP)))
{
WARN( "Bitmap already selected in another DC\n" );
DC_ReleaseDCPtr( dc );
return 0;
ret = 0;
goto done;
}
if (!bitmap->funcs && !BITMAP_SetOwnerDC( handle, dc ))
{
DC_ReleaseDCPtr( dc );
return 0;
ret = 0;
goto done;
}
if (dc->funcs->pSelectBitmap) handle = dc->funcs->pSelectBitmap( dc->physDev, handle );
......@@ -594,7 +600,8 @@ static HGDIOBJ BITMAP_SelectObject( HGDIOBJ handle, void *obj, HDC hdc )
else ret = 0;
done:
DC_ReleaseDCPtr( dc );
GDI_ReleaseObj( handle );
release_dc_ptr( dc );
return ret;
}
......
......@@ -42,7 +42,7 @@ typedef struct
#define NB_HATCH_STYLES 6
static HGDIOBJ BRUSH_SelectObject( HGDIOBJ handle, void *obj, HDC hdc );
static HGDIOBJ BRUSH_SelectObject( HGDIOBJ handle, HDC hdc );
static INT BRUSH_GetObject16( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
static INT BRUSH_GetObject( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
static BOOL BRUSH_DeleteObject( HGDIOBJ handle, void *obj );
......@@ -368,14 +368,16 @@ BOOL WINAPI FixBrushOrgEx( HDC hdc, INT x, INT y, LPPOINT oldorg )
/***********************************************************************
* BRUSH_SelectObject
*/
static HGDIOBJ BRUSH_SelectObject( HGDIOBJ handle, void *obj, HDC hdc )
static HGDIOBJ BRUSH_SelectObject( HGDIOBJ handle, HDC hdc )
{
BRUSHOBJ *brush = obj;
HGDIOBJ ret;
DC *dc = DC_GetDCPtr( hdc );
BRUSHOBJ *brush;
HGDIOBJ ret = 0;
DC *dc = get_dc_ptr( hdc );
if (!dc) return 0;
if ((brush = GDI_GetObjPtr( handle, BRUSH_MAGIC )))
{
if (brush->logbrush.lbStyle == BS_PATTERN)
BITMAP_SetOwnerDC( (HBITMAP)brush->logbrush.lbHatch, dc );
......@@ -383,7 +385,9 @@ static HGDIOBJ BRUSH_SelectObject( HGDIOBJ handle, void *obj, HDC hdc )
if (dc->funcs->pSelectBrush) handle = dc->funcs->pSelectBrush( dc->physDev, handle );
if (handle) dc->hBrush = handle;
else ret = 0;
DC_ReleaseDCPtr( dc );
GDI_ReleaseObj( handle );
}
release_dc_ptr( dc );
return ret;
}
......
......@@ -86,7 +86,7 @@ static inline INT INTERNAL_YWSTODS(DC *dc, INT height)
return pt[1].y - pt[0].y;
}
static HGDIOBJ FONT_SelectObject( HGDIOBJ handle, void *obj, HDC hdc );
static HGDIOBJ FONT_SelectObject( HGDIOBJ handle, HDC hdc );
static INT FONT_GetObject16( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
static INT FONT_GetObjectA( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
static INT FONT_GetObjectW( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
......@@ -585,7 +585,7 @@ HFONT WINAPI CreateFontW( INT height, INT width, INT esc,
* drivers that don't support vector fonts they must supply their own
* font.
*/
static HGDIOBJ FONT_SelectObject( HGDIOBJ handle, void *obj, HDC hdc )
static HGDIOBJ FONT_SelectObject( HGDIOBJ handle, HDC hdc )
{
HGDIOBJ ret = 0;
DC *dc = DC_GetDCPtr( hdc );
......
......@@ -71,7 +71,7 @@ typedef struct {
struct gdi_obj_funcs
{
HGDIOBJ (*pSelectObject)( HGDIOBJ handle, void *obj, HDC hdc );
HGDIOBJ (*pSelectObject)( HGDIOBJ handle, HDC hdc );
INT (*pGetObject16)( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
INT (*pGetObjectA)( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
INT (*pGetObjectW)( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
......
......@@ -1150,7 +1150,7 @@ HGDIOBJ WINAPI SelectObject( HDC hdc, HGDIOBJ hObj )
{
if (header->funcs && header->funcs->pSelectObject)
{
ret = header->funcs->pSelectObject( hObj, header, hdc );
ret = header->funcs->pSelectObject( hObj, hdc );
if (ret && ret != hObj && HandleToULong(ret) > COMPLEXREGION)
{
inc_ref_count( header );
......
......@@ -42,7 +42,7 @@ typedef struct
} PENOBJ;
static HGDIOBJ PEN_SelectObject( HGDIOBJ handle, void *obj, HDC hdc );
static HGDIOBJ PEN_SelectObject( HGDIOBJ handle, HDC hdc );
static INT PEN_GetObject16( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
static INT PEN_GetObject( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
......@@ -215,7 +215,7 @@ HPEN WINAPI ExtCreatePen( DWORD style, DWORD width,
/***********************************************************************
* PEN_SelectObject
*/
static HGDIOBJ PEN_SelectObject( HGDIOBJ handle, void *obj, HDC hdc )
static HGDIOBJ PEN_SelectObject( HGDIOBJ handle, HDC hdc )
{
HGDIOBJ ret;
DC *dc = DC_GetDCPtr( hdc );
......
......@@ -120,7 +120,7 @@ typedef struct
} RGNOBJ;
static HGDIOBJ REGION_SelectObject( HGDIOBJ handle, void *obj, HDC hdc );
static HGDIOBJ REGION_SelectObject( HGDIOBJ handle, HDC hdc );
static BOOL REGION_DeleteObject( HGDIOBJ handle, void *obj );
static const struct gdi_obj_funcs region_funcs =
......@@ -549,7 +549,7 @@ static BOOL REGION_DeleteObject( HGDIOBJ handle, void *obj )
/***********************************************************************
* REGION_SelectObject
*/
static HGDIOBJ REGION_SelectObject( HGDIOBJ handle, void *obj, HDC hdc )
static HGDIOBJ REGION_SelectObject( HGDIOBJ handle, HDC hdc )
{
return ULongToHandle(SelectClipRgn( hdc, handle ));
}
......
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