Commit 98dd61e2 authored by Alexandre Julliard's avatar Alexandre Julliard

winex11: Don't cache text and background pixel values to support PALETTEINDEX properly.

parent aba9ddc4
...@@ -850,9 +850,12 @@ BOOL X11DRV_StretchBlt( PHYSDEV dst_dev, struct bitblt_coords *dst, ...@@ -850,9 +850,12 @@ BOOL X11DRV_StretchBlt( PHYSDEV dst_dev, struct bitblt_coords *dst,
} }
if (physDevSrc->depth == 1) if (physDevSrc->depth == 1)
{ {
int text_pixel = X11DRV_PALETTE_ToPhysical( physDevDst, GetTextColor(physDevDst->dev.hdc) );
int bkgnd_pixel = X11DRV_PALETTE_ToPhysical( physDevDst, GetBkColor(physDevDst->dev.hdc) );
wine_tsx11_lock(); wine_tsx11_lock();
XSetBackground( gdi_display, physDevDst->gc, physDevDst->textPixel ); XSetBackground( gdi_display, physDevDst->gc, text_pixel );
XSetForeground( gdi_display, physDevDst->gc, physDevDst->backgroundPixel ); XSetForeground( gdi_display, physDevDst->gc, bkgnd_pixel );
XSetFunction( gdi_display, physDevDst->gc, OP_ROP(*opcode) ); XSetFunction( gdi_display, physDevDst->gc, OP_ROP(*opcode) );
XCopyPlane( gdi_display, physDevSrc->drawable, XCopyPlane( gdi_display, physDevSrc->drawable,
physDevDst->drawable, physDevDst->gc, physDevDst->drawable, physDevDst->gc,
...@@ -881,15 +884,18 @@ BOOL X11DRV_StretchBlt( PHYSDEV dst_dev, struct bitblt_coords *dst, ...@@ -881,15 +884,18 @@ BOOL X11DRV_StretchBlt( PHYSDEV dst_dev, struct bitblt_coords *dst,
to color or vice versa, the foreground and background color of to color or vice versa, the foreground and background color of
the device context are used. In fact, it also applies to the the device context are used. In fact, it also applies to the
case when it is converted from mono to mono. */ case when it is converted from mono to mono. */
int text_pixel = X11DRV_PALETTE_ToPhysical( physDevDst, GetTextColor(physDevDst->dev.hdc) );
int bkgnd_pixel = X11DRV_PALETTE_ToPhysical( physDevDst, GetBkColor(physDevDst->dev.hdc) );
if (X11DRV_PALETTE_XPixelToPalette && physDevDst->depth != 1) if (X11DRV_PALETTE_XPixelToPalette && physDevDst->depth != 1)
{ {
XSetBackground( gdi_display, gc, X11DRV_PALETTE_XPixelToPalette[physDevDst->textPixel] ); XSetBackground( gdi_display, gc, X11DRV_PALETTE_XPixelToPalette[text_pixel] );
XSetForeground( gdi_display, gc, X11DRV_PALETTE_XPixelToPalette[physDevDst->backgroundPixel]); XSetForeground( gdi_display, gc, X11DRV_PALETTE_XPixelToPalette[bkgnd_pixel]);
} }
else else
{ {
XSetBackground( gdi_display, gc, physDevDst->textPixel ); XSetBackground( gdi_display, gc, text_pixel );
XSetForeground( gdi_display, gc, physDevDst->backgroundPixel ); XSetForeground( gdi_display, gc, bkgnd_pixel );
} }
XCopyPlane( gdi_display, physDevSrc->drawable, src_pixmap, gc, XCopyPlane( gdi_display, physDevSrc->drawable, src_pixmap, gc,
physDevSrc->dc_rect.left + src->visrect.left, physDevSrc->dc_rect.left + src->visrect.left,
......
...@@ -274,13 +274,13 @@ BOOL X11DRV_SetupGCForPatBlt( X11DRV_PDEVICE *physDev, GC gc, BOOL fMapColors ) ...@@ -274,13 +274,13 @@ BOOL X11DRV_SetupGCForPatBlt( X11DRV_PDEVICE *physDev, GC gc, BOOL fMapColors )
* We need to swap foreground and background because * We need to swap foreground and background because
* Windows does it the wrong way... * Windows does it the wrong way...
*/ */
val.foreground = physDev->backgroundPixel; val.foreground = X11DRV_PALETTE_ToPhysical( physDev, GetBkColor(physDev->dev.hdc) );
val.background = physDev->textPixel; val.background = X11DRV_PALETTE_ToPhysical( physDev, GetTextColor(physDev->dev.hdc) );
} }
else else
{ {
val.foreground = physDev->brush.pixel; val.foreground = physDev->brush.pixel;
val.background = physDev->backgroundPixel; val.background = X11DRV_PALETTE_ToPhysical( physDev, GetBkColor(physDev->dev.hdc) );
} }
if (fMapColors && X11DRV_PALETTE_XPixelToPalette) if (fMapColors && X11DRV_PALETTE_XPixelToPalette)
{ {
...@@ -399,7 +399,7 @@ static BOOL X11DRV_SetupGCForPen( X11DRV_PDEVICE *physDev ) ...@@ -399,7 +399,7 @@ static BOOL X11DRV_SetupGCForPen( X11DRV_PDEVICE *physDev )
val.foreground = physDev->pen.pixel; val.foreground = physDev->pen.pixel;
val.function = X11DRV_XROPfunction[rop2-1]; val.function = X11DRV_XROPfunction[rop2-1];
} }
val.background = physDev->backgroundPixel; val.background = X11DRV_PALETTE_ToPhysical( physDev, GetBkColor(physDev->dev.hdc) );
val.fill_style = FillSolid; val.fill_style = FillSolid;
val.line_width = physDev->pen.width; val.line_width = physDev->pen.width;
if (val.line_width <= 1) { if (val.line_width <= 1) {
...@@ -463,8 +463,8 @@ BOOL X11DRV_SetupGCForText( X11DRV_PDEVICE *physDev ) ...@@ -463,8 +463,8 @@ BOOL X11DRV_SetupGCForText( X11DRV_PDEVICE *physDev )
XGCValues val; XGCValues val;
val.function = GXcopy; /* Text is always GXcopy */ val.function = GXcopy; /* Text is always GXcopy */
val.foreground = physDev->textPixel; val.foreground = X11DRV_PALETTE_ToPhysical( physDev, GetTextColor(physDev->dev.hdc) );
val.background = physDev->backgroundPixel; val.background = X11DRV_PALETTE_ToPhysical( physDev, GetBkColor(physDev->dev.hdc) );
val.fill_style = FillSolid; val.fill_style = FillSolid;
val.font = xfs->fid; val.font = xfs->fid;
...@@ -1493,29 +1493,6 @@ fallback: ...@@ -1493,29 +1493,6 @@ fallback:
return dev->funcs->pGradientFill( dev, vert_array, nvert, grad_array, ngrad, mode ); return dev->funcs->pGradientFill( dev, vert_array, nvert, grad_array, ngrad, mode );
} }
/**********************************************************************
* X11DRV_SetBkColor
*/
COLORREF X11DRV_SetBkColor( PHYSDEV dev, COLORREF color )
{
X11DRV_PDEVICE *physDev = get_x11drv_dev( dev );
physDev->backgroundPixel = X11DRV_PALETTE_ToPhysical( physDev, color );
return color;
}
/**********************************************************************
* X11DRV_SetTextColor
*/
COLORREF X11DRV_SetTextColor( PHYSDEV dev, COLORREF color )
{
X11DRV_PDEVICE *physDev = get_x11drv_dev( dev );
physDev->textPixel = X11DRV_PALETTE_ToPhysical( physDev, color );
return color;
}
static unsigned char *get_icm_profile( unsigned long *size ) static unsigned char *get_icm_profile( unsigned long *size )
{ {
Atom type; Atom type;
......
...@@ -550,7 +550,7 @@ static const struct gdi_dc_funcs x11drv_funcs = ...@@ -550,7 +550,7 @@ static const struct gdi_dc_funcs x11drv_funcs =
NULL, /* pSelectPalette */ NULL, /* pSelectPalette */
X11DRV_SelectPen, /* pSelectPen */ X11DRV_SelectPen, /* pSelectPen */
NULL, /* pSetArcDirection */ NULL, /* pSetArcDirection */
X11DRV_SetBkColor, /* pSetBkColor */ NULL, /* pSetBkColor */
NULL, /* pSetBkMode */ NULL, /* pSetBkMode */
X11DRV_SetDCBrushColor, /* pSetDCBrushColor */ X11DRV_SetDCBrushColor, /* pSetDCBrushColor */
X11DRV_SetDCPenColor, /* pSetDCPenColor */ X11DRV_SetDCPenColor, /* pSetDCPenColor */
...@@ -568,7 +568,7 @@ static const struct gdi_dc_funcs x11drv_funcs = ...@@ -568,7 +568,7 @@ static const struct gdi_dc_funcs x11drv_funcs =
NULL, /* pSetStretchBltMode */ NULL, /* pSetStretchBltMode */
NULL, /* pSetTextAlign */ NULL, /* pSetTextAlign */
NULL, /* pSetTextCharacterExtra */ NULL, /* pSetTextCharacterExtra */
X11DRV_SetTextColor, /* pSetTextColor */ NULL, /* pSetTextColor */
NULL, /* pSetTextJustification */ NULL, /* pSetTextJustification */
NULL, /* pSetViewportExt */ NULL, /* pSetViewportExt */
NULL, /* pSetViewportOrg */ NULL, /* pSetViewportOrg */
......
...@@ -43,6 +43,7 @@ BOOL X11DRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, ...@@ -43,6 +43,7 @@ BOOL X11DRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
X11DRV_PDEVICE *physDev = get_x11drv_dev( dev ); X11DRV_PDEVICE *physDev = get_x11drv_dev( dev );
BOOL restore_region = FALSE; BOOL restore_region = FALSE;
unsigned int i; unsigned int i;
int pixel;
fontObject* pfo = XFONT_GetFontObject( physDev->font ); fontObject* pfo = XFONT_GetFontObject( physDev->font );
XFontStruct* font; XFontStruct* font;
BOOL rotated = FALSE; BOOL rotated = FALSE;
...@@ -70,8 +71,9 @@ BOOL X11DRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, ...@@ -70,8 +71,9 @@ BOOL X11DRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
if (flags & ETO_OPAQUE) if (flags & ETO_OPAQUE)
{ {
pixel = X11DRV_PALETTE_ToPhysical( physDev, GetBkColor(physDev->dev.hdc) );
wine_tsx11_lock(); wine_tsx11_lock();
XSetForeground( gdi_display, physDev->gc, physDev->backgroundPixel ); XSetForeground( gdi_display, physDev->gc, pixel );
XFillRectangle( gdi_display, physDev->drawable, physDev->gc, XFillRectangle( gdi_display, physDev->drawable, physDev->gc,
physDev->dc_rect.left + lprect->left, physDev->dc_rect.top + lprect->top, physDev->dc_rect.left + lprect->left, physDev->dc_rect.top + lprect->top,
lprect->right - lprect->left, lprect->bottom - lprect->top ); lprect->right - lprect->left, lprect->bottom - lprect->top );
...@@ -97,8 +99,9 @@ BOOL X11DRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, ...@@ -97,8 +99,9 @@ BOOL X11DRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
goto END; goto END;
} }
pixel = X11DRV_PALETTE_ToPhysical( physDev, GetTextColor(physDev->dev.hdc) );
wine_tsx11_lock(); wine_tsx11_lock();
XSetForeground( gdi_display, physDev->gc, physDev->textPixel ); XSetForeground( gdi_display, physDev->gc, pixel );
wine_tsx11_unlock(); wine_tsx11_unlock();
if(!rotated) if(!rotated)
{ {
......
...@@ -141,8 +141,6 @@ typedef struct ...@@ -141,8 +141,6 @@ typedef struct
X_PHYSBRUSH brush; X_PHYSBRUSH brush;
X_PHYSBITMAP *bitmap; /* currently selected bitmap for memory DCs */ X_PHYSBITMAP *bitmap; /* currently selected bitmap for memory DCs */
BOOL has_gdi_font; /* is current font a GDI font? */ BOOL has_gdi_font; /* is current font a GDI font? */
int backgroundPixel;
int textPixel;
int depth; /* bit depth of the DC */ int depth; /* bit depth of the DC */
ColorShifts *color_shifts; /* color shifts of the DC */ ColorShifts *color_shifts; /* color shifts of the DC */
int exposures; /* count of graphics exposures operations */ int exposures; /* count of graphics exposures operations */
...@@ -210,14 +208,12 @@ extern HBITMAP X11DRV_SelectBitmap( PHYSDEV dev, HBITMAP hbitmap ) DECLSPEC_HIDD ...@@ -210,14 +208,12 @@ extern HBITMAP X11DRV_SelectBitmap( PHYSDEV dev, HBITMAP hbitmap ) DECLSPEC_HIDD
extern HBRUSH X11DRV_SelectBrush( PHYSDEV dev, HBRUSH hbrush, const struct brush_pattern *pattern ) 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 HFONT X11DRV_SelectFont( PHYSDEV dev, HFONT hfont ) DECLSPEC_HIDDEN;
extern HPEN X11DRV_SelectPen( PHYSDEV dev, HPEN hpen, const struct brush_pattern *pattern ) DECLSPEC_HIDDEN; extern HPEN X11DRV_SelectPen( PHYSDEV dev, HPEN hpen, const struct brush_pattern *pattern ) DECLSPEC_HIDDEN;
extern COLORREF X11DRV_SetBkColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
extern COLORREF X11DRV_SetDCBrushColor( PHYSDEV dev, COLORREF crColor ) DECLSPEC_HIDDEN; extern COLORREF X11DRV_SetDCBrushColor( PHYSDEV dev, COLORREF crColor ) DECLSPEC_HIDDEN;
extern COLORREF X11DRV_SetDCPenColor( PHYSDEV dev, COLORREF crColor ) DECLSPEC_HIDDEN; extern COLORREF X11DRV_SetDCPenColor( PHYSDEV dev, COLORREF crColor ) DECLSPEC_HIDDEN;
extern void X11DRV_SetDeviceClipping( PHYSDEV dev, HRGN rgn ) DECLSPEC_HIDDEN; extern void X11DRV_SetDeviceClipping( PHYSDEV dev, HRGN rgn ) DECLSPEC_HIDDEN;
extern BOOL X11DRV_SetDeviceGammaRamp( PHYSDEV dev, LPVOID ramp ) DECLSPEC_HIDDEN; extern BOOL X11DRV_SetDeviceGammaRamp( PHYSDEV dev, LPVOID ramp ) DECLSPEC_HIDDEN;
extern COLORREF X11DRV_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color ) DECLSPEC_HIDDEN; extern COLORREF X11DRV_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color ) DECLSPEC_HIDDEN;
extern BOOL X11DRV_SetPixelFormat(PHYSDEV dev, int iPixelFormat, const PIXELFORMATDESCRIPTOR *ppfd) DECLSPEC_HIDDEN; extern BOOL X11DRV_SetPixelFormat(PHYSDEV dev, int iPixelFormat, const PIXELFORMATDESCRIPTOR *ppfd) DECLSPEC_HIDDEN;
extern COLORREF X11DRV_SetTextColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
extern BOOL X11DRV_StretchBlt( PHYSDEV dst_dev, struct bitblt_coords *dst, extern BOOL X11DRV_StretchBlt( PHYSDEV dst_dev, struct bitblt_coords *dst,
PHYSDEV src_dev, struct bitblt_coords *src, DWORD rop ) DECLSPEC_HIDDEN; PHYSDEV src_dev, struct bitblt_coords *src, DWORD rop ) DECLSPEC_HIDDEN;
extern BOOL X11DRV_UnrealizePalette( HPALETTE hpal ) DECLSPEC_HIDDEN; extern BOOL X11DRV_UnrealizePalette( HPALETTE hpal ) DECLSPEC_HIDDEN;
......
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