winex11: Always create the brush pixmap from the pattern bits.

This commit is contained in:
Alexandre Julliard 2012-05-23 21:44:59 +02:00
parent a196ad8fc1
commit 995e2104df
3 changed files with 12 additions and 112 deletions

View file

@ -210,76 +210,6 @@ static void BRUSH_SelectSolidBrush( X11DRV_PDEVICE *physDev, COLORREF color )
}
/***********************************************************************
* BRUSH_SelectPatternBrush
*/
static void BRUSH_SelectPatternBrush( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, X_PHYSBITMAP *physBitmap )
{
BITMAP bitmap;
GetObjectW( hbitmap, sizeof(bitmap), &bitmap );
wine_tsx11_lock();
if (physDev->brush.pixmap) XFreePixmap( gdi_display, physDev->brush.pixmap );
if ((physDev->depth == 1) && (physBitmap->depth != 1))
{
/* Special case: a color pattern on a monochrome DC */
physDev->brush.pixmap = XCreatePixmap( gdi_display, root_window,
bitmap.bmWidth, bitmap.bmHeight, 1);
/* FIXME: should probably convert to monochrome instead */
XCopyPlane( gdi_display, physBitmap->pixmap, physDev->brush.pixmap,
get_bitmap_gc(1), 0, 0, bitmap.bmWidth, bitmap.bmHeight, 0, 0, 1 );
}
else
{
physDev->brush.pixmap = XCreatePixmap( gdi_display, root_window,
bitmap.bmWidth, bitmap.bmHeight, physBitmap->depth );
XCopyArea( gdi_display, physBitmap->pixmap, physDev->brush.pixmap,
get_bitmap_gc(physBitmap->depth), 0, 0, bitmap.bmWidth, bitmap.bmHeight, 0, 0 );
}
wine_tsx11_unlock();
if (physBitmap->depth > 1)
{
physDev->brush.fillStyle = FillTiled;
physDev->brush.pixel = 0; /* Ignored */
}
else
{
physDev->brush.fillStyle = FillOpaqueStippled;
physDev->brush.pixel = -1; /* Special case (see DC_SetupGCForBrush) */
}
}
/* create a bitmap appropriate for the given DIB pattern brush */
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 );
if (!bitmap) return 0;
/* make sure it's owned by x11drv */
memdc = CreateCompatibleDC( physDev->dev.hdc );
SelectObject( memdc, bitmap );
DeleteDC( memdc );
if (!X11DRV_get_phys_bitmap( bitmap ))
{
DeleteObject( bitmap );
return 0;
}
SetDIBits( physDev->dev.hdc, bitmap, 0, abs(info->bmiHeader.biHeight),
pattern->bits.ptr, info, pattern->usage );
return bitmap;
}
static BOOL select_pattern_brush( X11DRV_PDEVICE *physdev, const struct brush_pattern *pattern )
{
XVisualInfo vis;
@ -330,14 +260,7 @@ HBRUSH X11DRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct brush_patter
if (pattern) /* pattern brush */
{
X_PHYSBITMAP *physbitmap;
HBITMAP bitmap = pattern->bitmap;
if (!bitmap || !(physbitmap = X11DRV_get_phys_bitmap( bitmap )))
{
if (!select_pattern_brush( physDev, pattern )) return 0;
}
else BRUSH_SelectPatternBrush( physDev, bitmap, physbitmap );
if (!select_pattern_brush( physDev, pattern )) return 0;
TRACE("BS_PATTERN\n");
physDev->brush.style = BS_PATTERN;
return hbrush;

View file

@ -221,7 +221,6 @@ extern void X11DRV_Xcursor_Init(void) DECLSPEC_HIDDEN;
extern void X11DRV_BITMAP_Init(void) DECLSPEC_HIDDEN;
extern void X11DRV_XInput2_Init(void) DECLSPEC_HIDDEN;
extern HBITMAP create_brush_bitmap( X11DRV_PDEVICE *physDev, const struct brush_pattern *pattern ) DECLSPEC_HIDDEN;
extern X_PHYSBITMAP *X11DRV_get_phys_bitmap( HBITMAP hbitmap ) DECLSPEC_HIDDEN;
extern X_PHYSBITMAP *X11DRV_init_phys_bitmap( HBITMAP hbitmap ) DECLSPEC_HIDDEN;
extern X_PHYSBITMAP *X11DRV_create_phys_bitmap( HBITMAP hbitmap, const BITMAP *bitmap, int depth ) DECLSPEC_HIDDEN;

View file

@ -2589,56 +2589,34 @@ fallback:
static HBRUSH xrenderdrv_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct brush_pattern *pattern )
{
struct xrender_physdev *physdev = get_xrender_dev( dev );
X_PHYSBITMAP *physbitmap;
BOOL delete_bitmap = FALSE;
BITMAP bm;
HBITMAP bitmap;
Pixmap pixmap;
XRenderPictFormat *pict_format;
Picture src_pict, dst_pict;
XRenderPictureAttributes pa;
XVisualInfo vis;
XRenderPictFormat *format = physdev->pict_format;
if (!pattern) goto x11drv_fallback;
if (pattern->info->bmiHeader.biBitCount == 1) 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, pattern ))) return 0;
physbitmap = X11DRV_get_phys_bitmap( bitmap );
delete_bitmap = TRUE;
}
memset( &vis, 0, sizeof(vis) );
vis.depth = format->depth;
vis.red_mask = format->direct.redMask << format->direct.red;
vis.green_mask = format->direct.greenMask << format->direct.green;
vis.blue_mask = format->direct.blueMask << format->direct.blue;
if (physbitmap->format == WXR_FORMAT_MONO) goto x11drv_fallback;
if (!(pict_format = pict_formats[physbitmap->format])) goto x11drv_fallback;
GetObjectW( bitmap, sizeof(bm), &bm );
pixmap = create_pixmap_from_image( physdev->dev.hdc, &vis, pattern->info,
&pattern->bits, pattern->usage );
if (!pixmap) return 0;
wine_tsx11_lock();
pixmap = XCreatePixmap( gdi_display, root_window, bm.bmWidth, bm.bmHeight,
physdev->pict_format->depth );
pa.repeat = RepeatNone;
src_pict = pXRenderCreatePicture(gdi_display, physbitmap->pixmap, pict_format, CPRepeat, &pa);
dst_pict = pXRenderCreatePicture(gdi_display, pixmap, physdev->pict_format, CPRepeat, &pa);
xrender_blit( PictOpSrc, src_pict, 0, dst_pict, 0, 0, bm.bmWidth, bm.bmHeight,
0, 0, bm.bmWidth, bm.bmHeight, 1.0, 1.0 );
pXRenderFreePicture( gdi_display, src_pict );
pXRenderFreePicture( gdi_display, dst_pict );
if (physdev->x11dev->brush.pixmap) XFreePixmap( gdi_display, physdev->x11dev->brush.pixmap );
physdev->x11dev->brush.pixmap = pixmap;
physdev->x11dev->brush.fillStyle = FillTiled;
physdev->x11dev->brush.pixel = 0; /* ignored */
physdev->x11dev->brush.style = BS_PATTERN;
wine_tsx11_unlock();
if (delete_bitmap) DeleteObject( bitmap );
return hbrush;
x11drv_fallback:
if (delete_bitmap) DeleteObject( bitmap );
dev = GET_NEXT_PHYSDEV( dev, pSelectBrush );
return dev->funcs->pSelectBrush( dev, hbrush, pattern );
}