Commit f85bb352 authored by Alexandre Julliard's avatar Alexandre Julliard

gdi32: Pass a brush_pattern structure to the SelectBrush entry point.

parent a1fdd585
......@@ -494,26 +494,21 @@ static HGDIOBJ BRUSH_SelectObject( HGDIOBJ handle, HDC hdc )
if ((brush = GDI_GetObjPtr( handle, OBJ_BRUSH )))
{
PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSelectBrush );
HBITMAP bitmap = brush->pattern.bitmap;
BITMAPINFO *info;
void *bits;
UINT usage;
struct brush_pattern *pattern = &brush->pattern;
if (bitmap && !brush->pattern.info)
if (pattern->bitmap && !pattern->info)
{
BITMAPOBJ *bmp = GDI_GetObjPtr( bitmap, OBJ_BITMAP );
BITMAPOBJ *bmp = GDI_GetObjPtr( pattern->bitmap, OBJ_BITMAP );
/* fetch the bitmap bits if we are selecting into a different type of DC */
if (bmp && bmp->funcs != physdev->funcs) store_bitmap_bits( &brush->pattern, bmp );
GDI_ReleaseObj( bitmap );
if (bmp && bmp->funcs != physdev->funcs) store_bitmap_bits( pattern, bmp );
GDI_ReleaseObj( pattern->bitmap );
}
else if (!pattern->info) pattern = NULL;
info = brush->pattern.info;
bits = brush->pattern.bits.ptr;
usage = brush->pattern.usage;
GDI_inc_ref_count( handle );
GDI_ReleaseObj( handle );
if (!physdev->funcs->pSelectBrush( physdev, handle, bitmap, info, bits, usage ))
if (!physdev->funcs->pSelectBrush( physdev, handle, pattern ))
{
GDI_dec_ref_count( handle );
}
......
......@@ -98,10 +98,7 @@ typedef struct dibdrv_physdev
COLORREF brush_colorref;
dib_info brush_dib;
void *brush_and_bits, *brush_xor_bits;
const BITMAPINFO *brush_pattern_info;
void *brush_pattern_bits;
UINT brush_pattern_usage;
HBITMAP brush_pattern_bitmap;
struct brush_pattern brush_pattern;
BOOL (* brush_rects)(struct dibdrv_physdev *pdev, dib_info *dib, int num, const RECT *rects, INT rop);
} dibdrv_physdev;
......@@ -131,8 +128,7 @@ extern DWORD dibdrv_PutImage( PHYSDEV dev, HBITMAP hbitmap, HRGN clip, BITMAP
const struct gdi_image_bits *bits, struct bitblt_coords *src,
struct bitblt_coords *dst, DWORD rop ) DECLSPEC_HIDDEN;
extern BOOL dibdrv_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT bottom ) DECLSPEC_HIDDEN;
extern HBRUSH dibdrv_SelectBrush( PHYSDEV dev, HBRUSH hbrush, HBITMAP bitmap,
const BITMAPINFO *info, void *bits, UINT usage ) DECLSPEC_HIDDEN;
extern HBRUSH dibdrv_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct brush_pattern *pattern ) DECLSPEC_HIDDEN;
extern HPEN dibdrv_SelectPen( PHYSDEV dev, HPEN hpen ) DECLSPEC_HIDDEN;
extern COLORREF dibdrv_SetDCBrushColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
extern COLORREF dibdrv_SetDCPenColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
......
......@@ -1799,26 +1799,26 @@ static BOOL select_pattern_brush( dibdrv_physdev *pdev, BOOL *needs_reselect )
RECT rect;
dib_info pattern;
if (!pdev->brush_pattern_info)
if (!pdev->brush_pattern.info)
{
BITMAPOBJ *bmp = GDI_GetObjPtr( pdev->brush_pattern_bitmap, OBJ_BITMAP );
BITMAPOBJ *bmp = GDI_GetObjPtr( pdev->brush_pattern.bitmap, OBJ_BITMAP );
BOOL ret;
if (!bmp) return FALSE;
ret = init_dib_info_from_bitmapobj( &pattern, bmp, 0 );
GDI_ReleaseObj( pdev->brush_pattern_bitmap );
GDI_ReleaseObj( pdev->brush_pattern.bitmap );
if (!ret) return FALSE;
}
else if (pdev->brush_pattern_info->bmiHeader.biClrUsed && pdev->brush_pattern_usage == DIB_PAL_COLORS)
else if (pdev->brush_pattern.info->bmiHeader.biClrUsed && pdev->brush_pattern.usage == DIB_PAL_COLORS)
{
copy_bitmapinfo( info, pdev->brush_pattern_info );
copy_bitmapinfo( info, pdev->brush_pattern.info );
fill_color_table_from_pal_colors( info, pdev->dev.hdc );
init_dib_info_from_bitmapinfo( &pattern, info, pdev->brush_pattern_bits, 0 );
init_dib_info_from_bitmapinfo( &pattern, info, pdev->brush_pattern.bits.ptr, 0 );
*needs_reselect = TRUE;
}
else
{
init_dib_info_from_bitmapinfo( &pattern, pdev->brush_pattern_info, pdev->brush_pattern_bits, 0 );
init_dib_info_from_bitmapinfo( &pattern, pdev->brush_pattern.info, pdev->brush_pattern.bits.ptr, 0 );
}
if (pattern.bit_count == 1 && !pattern.color_table)
......@@ -1930,8 +1930,7 @@ static BOOL null_brush(dibdrv_physdev *pdev, dib_info *dib, int num, const RECT
/***********************************************************************
* dibdrv_SelectBrush
*/
HBRUSH dibdrv_SelectBrush( PHYSDEV dev, HBRUSH hbrush, HBITMAP bitmap,
const BITMAPINFO *info, void *bits, UINT usage )
HBRUSH dibdrv_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct brush_pattern *pattern )
{
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSelectBrush );
dibdrv_physdev *pdev = get_dibdrv_pdev(dev);
......@@ -1941,17 +1940,14 @@ HBRUSH dibdrv_SelectBrush( PHYSDEV dev, HBRUSH hbrush, HBITMAP bitmap,
free_pattern_brush( pdev );
if (bitmap || info) /* pattern brush */
if (pattern) /* pattern brush */
{
pdev->brush_rects = pattern_brush;
pdev->brush_style = BS_DIBPATTERN;
pdev->brush_pattern_info = info;
pdev->brush_pattern_bits = bits;
pdev->brush_pattern_usage = usage;
pdev->brush_pattern_bitmap = bitmap;
pdev->brush_pattern = *pattern;
/* brush is actually selected only when it's used */
return next->funcs->pSelectBrush( next, hbrush, bitmap, info, bits, usage );
return next->funcs->pSelectBrush( next, hbrush, pattern );
}
GetObjectW( hbrush, sizeof(logbrush), &logbrush );
......@@ -1983,7 +1979,7 @@ HBRUSH dibdrv_SelectBrush( PHYSDEV dev, HBRUSH hbrush, HBITMAP bitmap,
return 0;
}
return next->funcs->pSelectBrush( next, hbrush, bitmap, info, bits, usage );
return next->funcs->pSelectBrush( next, hbrush, pattern );
}
/***********************************************************************
......
......@@ -526,8 +526,7 @@ static HBITMAP nulldrv_SelectBitmap( PHYSDEV dev, HBITMAP bitmap )
return bitmap;
}
static HBRUSH nulldrv_SelectBrush( PHYSDEV dev, HBRUSH brush, HBITMAP bitmap,
const BITMAPINFO *info, void *bits, UINT usage )
static HBRUSH nulldrv_SelectBrush( PHYSDEV dev, HBRUSH brush, const struct brush_pattern *pattern )
{
return brush;
}
......
......@@ -108,8 +108,7 @@ extern BOOL EMFDRV_ScaleViewportExtEx( PHYSDEV dev, INT xNum, INT xDenom,
extern BOOL EMFDRV_ScaleWindowExtEx( PHYSDEV dev, INT xNum, INT xDenom,
INT yNum, INT yDenom, SIZE *size ) DECLSPEC_HIDDEN;
extern HBITMAP EMFDRV_SelectBitmap( PHYSDEV dev, HBITMAP handle ) DECLSPEC_HIDDEN;
extern HBRUSH EMFDRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, HBITMAP bitmap,
const BITMAPINFO *info, void *bits, UINT usage ) DECLSPEC_HIDDEN;
extern HBRUSH EMFDRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct brush_pattern *pattern ) DECLSPEC_HIDDEN;
extern BOOL EMFDRV_SelectClipPath( PHYSDEV dev, INT iMode ) DECLSPEC_HIDDEN;
extern HFONT EMFDRV_SelectFont( PHYSDEV dev, HFONT handle ) DECLSPEC_HIDDEN;
extern HPEN EMFDRV_SelectPen( PHYSDEV dev, HPEN handle ) DECLSPEC_HIDDEN;
......
......@@ -198,8 +198,7 @@ DWORD EMFDRV_CreateBrushIndirect( PHYSDEV dev, HBRUSH hBrush )
/***********************************************************************
* EMFDRV_SelectBrush
*/
HBRUSH EMFDRV_SelectBrush( PHYSDEV dev, HBRUSH hBrush, HBITMAP bitmap,
const BITMAPINFO *info, void *bits, UINT usage )
HBRUSH EMFDRV_SelectBrush( PHYSDEV dev, HBRUSH hBrush, const struct brush_pattern *pattern )
{
EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*)dev;
EMRSELECTOBJECT emr;
......
......@@ -182,14 +182,6 @@ typedef struct tagBITMAPOBJ
RGBQUAD *color_table; /* DIB color table if <= 8bpp (always 1 << bpp in size) */
} BITMAPOBJ;
struct brush_pattern
{
HBITMAP bitmap; /* bitmap handle for DDB patterns */
BITMAPINFO *info; /* DIB info */
struct gdi_image_bits bits; /* DIB bits */
UINT usage; /* color usage for DIB info */
};
/* bidi.c */
/* Wine_GCPW Flags */
......
......@@ -103,8 +103,7 @@ extern INT MFDRV_SaveDC( PHYSDEV dev ) DECLSPEC_HIDDEN;
extern BOOL MFDRV_ScaleViewportExtEx( PHYSDEV dev, INT xNum, INT xDenom, INT yNum, INT yDenom, SIZE *size ) DECLSPEC_HIDDEN;
extern BOOL MFDRV_ScaleWindowExtEx( PHYSDEV dev, INT xNum, INT xDenom, INT yNum, INT yDenom, SIZE *size ) DECLSPEC_HIDDEN;
extern HBITMAP MFDRV_SelectBitmap( PHYSDEV dev, HBITMAP handle ) DECLSPEC_HIDDEN;
extern HBRUSH MFDRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, HBITMAP bitmap,
const BITMAPINFO *info, void *bits, UINT usage ) DECLSPEC_HIDDEN;
extern HBRUSH MFDRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct brush_pattern *pattern ) DECLSPEC_HIDDEN;
extern BOOL MFDRV_SelectClipPath( PHYSDEV dev, INT iMode ) DECLSPEC_HIDDEN;
extern HFONT MFDRV_SelectFont( PHYSDEV dev, HFONT handle ) DECLSPEC_HIDDEN;
extern HPEN MFDRV_SelectPen( PHYSDEV dev, HPEN handle ) DECLSPEC_HIDDEN;
......
......@@ -229,8 +229,7 @@ done:
/***********************************************************************
* MFDRV_SelectBrush
*/
HBRUSH MFDRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, HBITMAP bitmap,
const BITMAPINFO *info, void *bits, UINT usage )
HBRUSH MFDRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct brush_pattern *pattern )
{
INT16 index;
......
......@@ -27,8 +27,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
/***********************************************************************
* SelectBrush (WINEPS.@)
*/
HBRUSH PSDRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, HBITMAP bitmap,
const BITMAPINFO *info, void *bits, UINT usage )
HBRUSH PSDRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct brush_pattern *pattern )
{
PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
LOGBRUSH logbrush;
......@@ -55,9 +54,7 @@ HBRUSH PSDRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, HBITMAP bitmap,
case BS_PATTERN:
case BS_DIBPATTERN:
physDev->brush.info = info;
physDev->brush.bits = bits;
physDev->brush.usage = usage;
physDev->brush.pattern = *pattern;
break;
default:
......@@ -238,8 +235,8 @@ BOOL PSDRV_Brush(PHYSDEV dev, BOOL EO)
case BS_DIBPATTERN:
if(physDev->pi->ppd->LanguageLevel > 1) {
PSDRV_WriteGSave(dev);
ret = PSDRV_WriteDIBPatternDict(dev, physDev->brush.info,
physDev->brush.bits, physDev->brush.usage );
ret = PSDRV_WriteDIBPatternDict(dev, physDev->brush.pattern.info,
physDev->brush.pattern.bits.ptr, physDev->brush.pattern.usage );
PSDRV_Fill(dev, EO);
PSDRV_WriteGRestore(dev);
} else {
......
......@@ -327,9 +327,7 @@ typedef struct {
typedef struct {
PSCOLOR color;
BOOL set;
const BITMAPINFO *info;
void *bits;
UINT usage;
struct brush_pattern pattern;
} PSBRUSH;
#define MAX_DASHLEN 16
......@@ -456,8 +454,7 @@ extern DWORD PSDRV_PutImage( PHYSDEV dev, HBITMAP hbitmap, HRGN clip, BITMAPINFO
extern BOOL PSDRV_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT bottom ) DECLSPEC_HIDDEN;
extern BOOL PSDRV_RoundRect( PHYSDEV dev, INT left, INT top, INT right,
INT bottom, INT ell_width, INT ell_height ) DECLSPEC_HIDDEN;
extern HBRUSH PSDRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, HBITMAP bitmap,
const BITMAPINFO *info, void *bits, UINT usage ) DECLSPEC_HIDDEN;
extern HBRUSH PSDRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct brush_pattern *pattern ) DECLSPEC_HIDDEN;
extern HFONT PSDRV_SelectFont( PHYSDEV dev, HFONT hfont ) DECLSPEC_HIDDEN;
extern HPEN PSDRV_SelectPen( PHYSDEV dev, HPEN hpen ) DECLSPEC_HIDDEN;
extern COLORREF PSDRV_SetBkColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
......
......@@ -254,11 +254,12 @@ static void BRUSH_SelectPatternBrush( X11DRV_PDEVICE *physDev, HBITMAP hbitmap,
}
/* create a bitmap appropriate for the given DIB pattern brush */
HBITMAP create_brush_bitmap( X11DRV_PDEVICE *physDev, const BITMAPINFO *info, void *bits, UINT usage )
HBITMAP create_brush_bitmap( X11DRV_PDEVICE *physDev, const struct brush_pattern *pattern )
{
HDC memdc;
int bpp = screen_bpp;
HBITMAP bitmap;
const BITMAPINFO *info = pattern->info;
if (physDev->depth == 1 || info->bmiHeader.biBitCount == 1) bpp = 1;
bitmap = CreateBitmap( info->bmiHeader.biWidth, abs(info->bmiHeader.biHeight), 1, bpp, NULL );
......@@ -269,7 +270,8 @@ HBITMAP create_brush_bitmap( X11DRV_PDEVICE *physDev, const BITMAPINFO *info, vo
SelectObject( memdc, bitmap );
DeleteDC( memdc );
SetDIBits( physDev->dev.hdc, bitmap, 0, abs(info->bmiHeader.biHeight), bits, info, usage );
SetDIBits( physDev->dev.hdc, bitmap, 0, abs(info->bmiHeader.biHeight),
pattern->bits.ptr, info, pattern->usage );
return bitmap;
}
......@@ -277,20 +279,20 @@ HBITMAP create_brush_bitmap( X11DRV_PDEVICE *physDev, const BITMAPINFO *info, vo
/***********************************************************************
* SelectBrush (X11DRV.@)
*/
HBRUSH X11DRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, HBITMAP bitmap,
const BITMAPINFO *info, void *bits, UINT usage )
HBRUSH X11DRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct brush_pattern *pattern )
{
X11DRV_PDEVICE *physDev = get_x11drv_dev( dev );
LOGBRUSH logbrush;
if (bitmap || info) /* pattern brush */
if (pattern) /* pattern brush */
{
X_PHYSBITMAP *physbitmap;
HBITMAP bitmap = pattern->bitmap;
BOOL delete_bitmap = FALSE;
if (!bitmap || !(physbitmap = X11DRV_get_phys_bitmap( bitmap )))
{
if (!(bitmap = create_brush_bitmap( physDev, info, bits, usage ))) return 0;
if (!(bitmap = create_brush_bitmap( physDev, pattern ))) return 0;
physbitmap = X11DRV_get_phys_bitmap( bitmap );
delete_bitmap = TRUE;
}
......
......@@ -222,8 +222,7 @@ extern BOOL X11DRV_Rectangle(PHYSDEV dev, INT left, INT top, INT right, INT bott
extern BOOL X11DRV_RoundRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
INT ell_width, INT ell_height ) DECLSPEC_HIDDEN;
extern HBITMAP X11DRV_SelectBitmap( PHYSDEV dev, HBITMAP hbitmap ) DECLSPEC_HIDDEN;
extern HBRUSH X11DRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, HBITMAP bitmap,
const BITMAPINFO *info, void *bits, UINT usage ) DECLSPEC_HIDDEN;
extern HBRUSH X11DRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct brush_pattern *pattern ) DECLSPEC_HIDDEN;
extern HFONT X11DRV_SelectFont( PHYSDEV dev, HFONT hfont ) DECLSPEC_HIDDEN;
extern HPEN X11DRV_SelectPen( PHYSDEV dev, HPEN hpen ) DECLSPEC_HIDDEN;
extern COLORREF X11DRV_SetBkColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
......@@ -269,7 +268,7 @@ extern void X11DRV_FONT_Init( int log_pixels_x, int log_pixels_y ) DECLSPEC_HIDD
extern void X11DRV_XInput2_Init(void) DECLSPEC_HIDDEN;
extern int bitmap_info_size( const BITMAPINFO * info, WORD coloruse ) DECLSPEC_HIDDEN;
extern HBITMAP create_brush_bitmap( X11DRV_PDEVICE *physDev, const BITMAPINFO *info, void *bits, UINT usage ) DECLSPEC_HIDDEN;
extern HBITMAP create_brush_bitmap( X11DRV_PDEVICE *physDev, const struct brush_pattern *pattern ) DECLSPEC_HIDDEN;
extern XImage *X11DRV_DIB_CreateXImage( int width, int height, int depth ) DECLSPEC_HIDDEN;
extern void X11DRV_DIB_DestroyXImage( XImage *image ) DECLSPEC_HIDDEN;
extern HGLOBAL X11DRV_DIB_CreateDIBFromBitmap(HDC hdc, HBITMAP hBmp) DECLSPEC_HIDDEN;
......
......@@ -2620,25 +2620,26 @@ fallback:
/***********************************************************************
* xrenderdrv_SelectBrush
*/
static HBRUSH xrenderdrv_SelectBrush( PHYSDEV dev, HBRUSH hbrush, HBITMAP bitmap,
const BITMAPINFO *info, void *bits, UINT usage )
static HBRUSH xrenderdrv_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct brush_pattern *pattern )
{
struct xrender_physdev *physdev = get_xrender_dev( dev );
X_PHYSBITMAP *physbitmap;
enum wxr_format format;
BOOL delete_bitmap = FALSE;
BITMAP bm;
HBITMAP bitmap;
Pixmap pixmap;
Picture src_pict, dst_pict;
XRenderPictureAttributes pa;
if (!X11DRV_XRender_Installed) goto x11drv_fallback;
if (!bitmap && !info) goto x11drv_fallback;
if (!pattern) goto x11drv_fallback;
if (physdev->format == WXR_FORMAT_MONO) goto x11drv_fallback;
bitmap = pattern->bitmap;
if (!bitmap || !(physbitmap = X11DRV_get_phys_bitmap( bitmap )))
{
if (!(bitmap = create_brush_bitmap( physdev->x11dev, info, bits, usage ))) return 0;
if (!(bitmap = create_brush_bitmap( physdev->x11dev, pattern ))) return 0;
physbitmap = X11DRV_get_phys_bitmap( bitmap );
delete_bitmap = TRUE;
}
......@@ -2676,7 +2677,7 @@ static HBRUSH xrenderdrv_SelectBrush( PHYSDEV dev, HBRUSH hbrush, HBITMAP bitmap
x11drv_fallback:
if (delete_bitmap) DeleteObject( bitmap );
dev = GET_NEXT_PHYSDEV( dev, pSelectBrush );
return dev->funcs->pSelectBrush( dev, hbrush, bitmap, info, bits, usage );
return dev->funcs->pSelectBrush( dev, hbrush, pattern );
}
......
......@@ -52,6 +52,14 @@ struct gdi_image_bits
void *param; /* extra parameter for callback private use */
};
struct brush_pattern
{
HBITMAP bitmap; /* bitmap handle for DDB patterns */
BITMAPINFO *info; /* DIB info */
struct gdi_image_bits bits; /* DIB bits */
UINT usage; /* color usage for DIB info */
};
struct gdi_dc_funcs
{
INT (*pAbortDoc)(PHYSDEV);
......@@ -147,7 +155,7 @@ struct gdi_dc_funcs
BOOL (*pScaleViewportExtEx)(PHYSDEV,INT,INT,INT,INT,SIZE*);
BOOL (*pScaleWindowExtEx)(PHYSDEV,INT,INT,INT,INT,SIZE*);
HBITMAP (*pSelectBitmap)(PHYSDEV,HBITMAP);
HBRUSH (*pSelectBrush)(PHYSDEV,HBRUSH,HBITMAP,const BITMAPINFO*,void*,UINT);
HBRUSH (*pSelectBrush)(PHYSDEV,HBRUSH,const struct brush_pattern*);
BOOL (*pSelectClipPath)(PHYSDEV,INT);
HFONT (*pSelectFont)(PHYSDEV,HFONT);
HPALETTE (*pSelectPalette)(PHYSDEV,HPALETTE,BOOL);
......@@ -205,7 +213,7 @@ struct gdi_dc_funcs
};
/* increment this when you change the DC function table */
#define WINE_GDI_DRIVER_VERSION 20
#define WINE_GDI_DRIVER_VERSION 21
static inline PHYSDEV get_physdev_entry_point( PHYSDEV dev, size_t offset )
{
......
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