Module: wine Branch: master Commit: a1e31397e17685b4b994158a89ca2b90e41cfe74 URL: http://source.winehq.org/git/wine.git/?a=commit;h=a1e31397e17685b4b994158a89...
Author: Alexandre Julliard julliard@winehq.org Date: Thu Sep 27 20:14:13 2007 +0200
gdi32: Don't pass an object pointer to the SelectObject backend functions.
---
dlls/gdi32/bitmap.c | 31 +++++++++++++++++++------------ dlls/gdi32/brush.c | 30 +++++++++++++++++------------- dlls/gdi32/font.c | 4 ++-- dlls/gdi32/gdi_private.h | 2 +- dlls/gdi32/gdiobj.c | 2 +- dlls/gdi32/pen.c | 4 ++-- dlls/gdi32/region.c | 4 ++-- 7 files changed, 44 insertions(+), 33 deletions(-)
diff --git a/dlls/gdi32/bitmap.c b/dlls/gdi32/bitmap.c index c1d0859..0aa7dd5 100644 --- a/dlls/gdi32/bitmap.c +++ b/dlls/gdi32/bitmap.c @@ -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; }
diff --git a/dlls/gdi32/brush.c b/dlls/gdi32/brush.c index 67d6e08..4b13bc0 100644 --- a/dlls/gdi32/brush.c +++ b/dlls/gdi32/brush.c @@ -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,22 +368,26 @@ 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->logbrush.lbStyle == BS_PATTERN) - BITMAP_SetOwnerDC( (HBITMAP)brush->logbrush.lbHatch, dc ); - - ret = dc->hBrush; - if (dc->funcs->pSelectBrush) handle = dc->funcs->pSelectBrush( dc->physDev, handle ); - if (handle) dc->hBrush = handle; - else ret = 0; - DC_ReleaseDCPtr( dc ); + if ((brush = GDI_GetObjPtr( handle, BRUSH_MAGIC ))) + { + if (brush->logbrush.lbStyle == BS_PATTERN) + BITMAP_SetOwnerDC( (HBITMAP)brush->logbrush.lbHatch, dc ); + + ret = dc->hBrush; + if (dc->funcs->pSelectBrush) handle = dc->funcs->pSelectBrush( dc->physDev, handle ); + if (handle) dc->hBrush = handle; + else ret = 0; + GDI_ReleaseObj( handle ); + } + release_dc_ptr( dc ); return ret; }
diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c index 4265ec9..f76af22 100644 --- a/dlls/gdi32/font.c +++ b/dlls/gdi32/font.c @@ -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 ); diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h index 08ba02b..6ef0b66 100644 --- a/dlls/gdi32/gdi_private.h +++ b/dlls/gdi32/gdi_private.h @@ -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 ); diff --git a/dlls/gdi32/gdiobj.c b/dlls/gdi32/gdiobj.c index 0388c71..25f072c 100644 --- a/dlls/gdi32/gdiobj.c +++ b/dlls/gdi32/gdiobj.c @@ -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 ); diff --git a/dlls/gdi32/pen.c b/dlls/gdi32/pen.c index cc48e4d..1c4381e 100644 --- a/dlls/gdi32/pen.c +++ b/dlls/gdi32/pen.c @@ -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 ); diff --git a/dlls/gdi32/region.c b/dlls/gdi32/region.c index b746447..3627ccb 100644 --- a/dlls/gdi32/region.c +++ b/dlls/gdi32/region.c @@ -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 )); }