Commit bd2fe1a2 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

winex11.drv: Use global Pictures for the tiles.

parent 030ef1ef
......@@ -84,9 +84,6 @@ struct tagXRENDERINFO
{
int cache_index;
Picture pict;
Picture tile_pict;
Pixmap tile_xpm;
COLORREF lastTextColor;
};
......@@ -602,17 +599,6 @@ void X11DRV_XRender_UpdateDrawable(X11DRV_PDEVICE *physDev)
pXRenderFreePicture(gdi_display, physDev->xrender->pict);
physDev->xrender->pict = 0;
}
if(physDev->xrender->tile_pict)
{
pXRenderFreePicture(gdi_display, physDev->xrender->tile_pict);
physDev->xrender->tile_pict = 0;
}
if(physDev->xrender->tile_xpm)
{
XFreePixmap(gdi_display, physDev->xrender->tile_xpm);
physDev->xrender->tile_xpm = 0;
}
wine_tsx11_unlock();
return;
......@@ -1071,6 +1057,76 @@ static void SmoothGlyphGray(XImage *image, int x, int y, void *bitmap, XGlyphInf
}
}
/*************************************************************
* get_tile_pict
*
* Returns an appropiate Picture for tiling the text colour.
* Call and use result within the xrender_cs
*/
static Picture get_tile_pict(enum drawable_depth_type type, int text_pixel)
{
static struct
{
Pixmap xpm;
Picture pict;
int current_color;
} tiles[2], *tile;
XRenderColor col;
tile = &tiles[type];
if(!tile->xpm)
{
XRenderPictureAttributes pa;
wine_tsx11_lock();
tile->xpm = XCreatePixmap(gdi_display, root_window, 1, 1, pict_formats[type]->depth);
pa.repeat = True;
tile->pict = pXRenderCreatePicture(gdi_display, tile->xpm, pict_formats[type], CPRepeat, &pa);
wine_tsx11_unlock();
/* init current_color to something different from text_pixel */
tile->current_color = ~text_pixel;
if(type == mono_drawable)
{
/* for a 1bpp bitmap we always need a 1 in the tile */
col.red = col.green = col.blue = 0;
col.alpha = 0xffff;
wine_tsx11_lock();
pXRenderFillRectangle(gdi_display, PictOpSrc, tile->pict, &col, 0, 0, 1, 1);
wine_tsx11_unlock();
}
}
if(text_pixel != tile->current_color && type == color_drawable)
{
/* Map 0 -- 0xff onto 0 -- 0xffff */
int r_shift, r_len;
int g_shift, g_len;
int b_shift, b_len;
ExamineBitfield (visual->red_mask, &r_shift, &r_len );
ExamineBitfield (visual->green_mask, &g_shift, &g_len);
ExamineBitfield (visual->blue_mask, &b_shift, &b_len);
col.red = GetField(text_pixel, r_shift, r_len);
col.red |= col.red << 8;
col.green = GetField(text_pixel, g_shift, g_len);
col.green |= col.green << 8;
col.blue = GetField(text_pixel, b_shift, b_len);
col.blue |= col.blue << 8;
col.alpha = 0x0;
wine_tsx11_lock();
pXRenderFillRectangle(gdi_display, PictOpSrc, tile->pict, &col, 0, 0, 1, 1);
wine_tsx11_unlock();
tile->current_color = text_pixel;
}
return tile->pict;
}
static int XRenderErrorHandler(Display *dpy, XErrorEvent *event, void *arg)
{
return 1;
......@@ -1083,7 +1139,6 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag
const RECT *lprect, LPCWSTR wstr, UINT count,
const INT *lpDx )
{
XRenderColor col;
RGNDATA *data;
XGCValues xgcval;
int render_op = PictOpOver;
......@@ -1100,6 +1155,7 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag
double cosEsc, sinEsc;
LOGFONTW lf;
enum drawable_depth_type depth_type = (physDev->depth == 1) ? mono_drawable : color_drawable;
Picture tile_pict = 0;
/* Do we need to disable antialiasing because of palette mode? */
if( !physDev->bitmap || GetObjectW( physDev->bitmap->hbitmap, sizeof(bmp), &bmp ) != sizeof(bmp) ) {
......@@ -1170,6 +1226,8 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag
DeleteObject( clip_region );
}
EnterCriticalSection(&xrender_cs);
if(X11DRV_XRender_Installed) {
if(!physDev->xrender->pict) {
XRenderPictureAttributes pa;
......@@ -1198,68 +1256,15 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag
wine_tsx11_unlock();
HeapFree( GetProcessHeap(), 0, data );
}
}
if(X11DRV_XRender_Installed) {
/* Create a 1x1 pixmap to tile over the font mask */
if(!physDev->xrender->tile_xpm) {
XRenderPictureAttributes pa;
XRenderPictFormat *format = pict_formats[depth_type];
wine_tsx11_lock();
physDev->xrender->tile_xpm = XCreatePixmap(gdi_display,
root_window,
1, 1,
format->depth);
pa.repeat = True;
physDev->xrender->tile_pict = pXRenderCreatePicture(gdi_display,
physDev->xrender->tile_xpm,
format,
CPRepeat, &pa);
wine_tsx11_unlock();
TRACE("Created pixmap of depth %d\n", format->depth);
/* init lastTextColor to something different from textPixel */
physDev->xrender->lastTextColor = ~physDev->textPixel;
}
if(physDev->textPixel != physDev->xrender->lastTextColor) {
if(physDev->depth != 1) {
/* Map 0 -- 0xff onto 0 -- 0xffff */
int r_shift, r_len;
int g_shift, g_len;
int b_shift, b_len;
ExamineBitfield (visual->red_mask, &r_shift, &r_len );
ExamineBitfield (visual->green_mask, &g_shift, &g_len);
ExamineBitfield (visual->blue_mask, &b_shift, &b_len);
col.red = GetField(physDev->textPixel, r_shift, r_len);
col.red |= col.red << 8;
col.green = GetField(physDev->textPixel, g_shift, g_len);
col.green |= col.green << 8;
col.blue = GetField(physDev->textPixel, b_shift, b_len);
col.blue |= col.blue << 8;
col.alpha = 0x0;
} else { /* for a 1bpp bitmap we always need a 1 in the tile */
col.red = col.green = col.blue = 0;
col.alpha = 0xffff;
}
wine_tsx11_lock();
pXRenderFillRectangle(gdi_display, PictOpSrc,
physDev->xrender->tile_pict,
&col, 0, 0, 1, 1);
wine_tsx11_unlock();
physDev->xrender->lastTextColor = physDev->textPixel;
}
tile_pict = get_tile_pict(depth_type, physDev->textPixel);
/* FIXME the mapping of Text/BkColor onto 1 or 0 needs investigation.
*/
if((physDev->depth == 1) && (textPixel == 0))
if((depth_type == mono_drawable) && (textPixel == 0))
render_op = PictOpOutReverse; /* This gives us 'black' text */
}
EnterCriticalSection(&xrender_cs);
entry = glyphsetCache + physDev->xrender->cache_index;
if( disable_antialias == FALSE )
aa_type = entry->aa_default;
......@@ -1325,7 +1330,7 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag
}
wine_tsx11_lock();
pXRenderCompositeText16(gdi_display, render_op,
physDev->xrender->tile_pict,
tile_pict,
physDev->xrender->pict,
formatEntry->font_format,
0, 0, 0, 0, elts, count);
......
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