Commit 995e2104 authored by Alexandre Julliard's avatar Alexandre Julliard

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

parent a196ad8f
...@@ -210,76 +210,6 @@ static void BRUSH_SelectSolidBrush( X11DRV_PDEVICE *physDev, COLORREF color ) ...@@ -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 ) static BOOL select_pattern_brush( X11DRV_PDEVICE *physdev, const struct brush_pattern *pattern )
{ {
XVisualInfo vis; XVisualInfo vis;
...@@ -330,14 +260,7 @@ HBRUSH X11DRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct brush_patter ...@@ -330,14 +260,7 @@ HBRUSH X11DRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct brush_patter
if (pattern) /* pattern brush */ if (pattern) /* pattern brush */
{ {
X_PHYSBITMAP *physbitmap; if (!select_pattern_brush( physDev, pattern )) return 0;
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 );
TRACE("BS_PATTERN\n"); TRACE("BS_PATTERN\n");
physDev->brush.style = BS_PATTERN; physDev->brush.style = BS_PATTERN;
return hbrush; return hbrush;
......
...@@ -221,7 +221,6 @@ extern void X11DRV_Xcursor_Init(void) DECLSPEC_HIDDEN; ...@@ -221,7 +221,6 @@ extern void X11DRV_Xcursor_Init(void) DECLSPEC_HIDDEN;
extern void X11DRV_BITMAP_Init(void) DECLSPEC_HIDDEN; extern void X11DRV_BITMAP_Init(void) DECLSPEC_HIDDEN;
extern void X11DRV_XInput2_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_get_phys_bitmap( HBITMAP hbitmap ) DECLSPEC_HIDDEN;
extern X_PHYSBITMAP *X11DRV_init_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; extern X_PHYSBITMAP *X11DRV_create_phys_bitmap( HBITMAP hbitmap, const BITMAP *bitmap, int depth ) DECLSPEC_HIDDEN;
......
...@@ -2589,56 +2589,34 @@ fallback: ...@@ -2589,56 +2589,34 @@ fallback:
static HBRUSH xrenderdrv_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct brush_pattern *pattern ) static HBRUSH xrenderdrv_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct brush_pattern *pattern )
{ {
struct xrender_physdev *physdev = get_xrender_dev( dev ); struct xrender_physdev *physdev = get_xrender_dev( dev );
X_PHYSBITMAP *physbitmap;
BOOL delete_bitmap = FALSE;
BITMAP bm;
HBITMAP bitmap;
Pixmap pixmap; Pixmap pixmap;
XRenderPictFormat *pict_format; XVisualInfo vis;
Picture src_pict, dst_pict; XRenderPictFormat *format = physdev->pict_format;
XRenderPictureAttributes pa;
if (!pattern) goto x11drv_fallback; if (!pattern) goto x11drv_fallback;
if (pattern->info->bmiHeader.biBitCount == 1) goto x11drv_fallback;
if (physdev->format == WXR_FORMAT_MONO) goto x11drv_fallback; if (physdev->format == WXR_FORMAT_MONO) goto x11drv_fallback;
bitmap = pattern->bitmap; memset( &vis, 0, sizeof(vis) );
if (!bitmap || !(physbitmap = X11DRV_get_phys_bitmap( bitmap ))) vis.depth = format->depth;
{ vis.red_mask = format->direct.redMask << format->direct.red;
if (!(bitmap = create_brush_bitmap( physdev->x11dev, pattern ))) return 0; vis.green_mask = format->direct.greenMask << format->direct.green;
physbitmap = X11DRV_get_phys_bitmap( bitmap ); vis.blue_mask = format->direct.blueMask << format->direct.blue;
delete_bitmap = TRUE;
}
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(); 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 ); if (physdev->x11dev->brush.pixmap) XFreePixmap( gdi_display, physdev->x11dev->brush.pixmap );
physdev->x11dev->brush.pixmap = pixmap; physdev->x11dev->brush.pixmap = pixmap;
physdev->x11dev->brush.fillStyle = FillTiled; physdev->x11dev->brush.fillStyle = FillTiled;
physdev->x11dev->brush.pixel = 0; /* ignored */ physdev->x11dev->brush.pixel = 0; /* ignored */
physdev->x11dev->brush.style = BS_PATTERN; physdev->x11dev->brush.style = BS_PATTERN;
wine_tsx11_unlock(); wine_tsx11_unlock();
if (delete_bitmap) DeleteObject( bitmap );
return hbrush; return hbrush;
x11drv_fallback: x11drv_fallback:
if (delete_bitmap) DeleteObject( bitmap );
dev = GET_NEXT_PHYSDEV( dev, pSelectBrush ); dev = GET_NEXT_PHYSDEV( dev, pSelectBrush );
return dev->funcs->pSelectBrush( dev, hbrush, pattern ); return dev->funcs->pSelectBrush( dev, hbrush, pattern );
} }
......
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