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

Alexandre Julliard julliard at winehq.org
Thu Jan 12 13:19:19 CST 2012


Module: wine
Branch: master
Commit: 98dd61e2f3127d60bbcb0ba804bbabdc1f6440de
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=98dd61e2f3127d60bbcb0ba804bbabdc1f6440de

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Jan 11 20:55:35 2012 +0100

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

---

 dlls/winex11.drv/bitblt.c   |   18 ++++++++++++------
 dlls/winex11.drv/graphics.c |   35 ++++++-----------------------------
 dlls/winex11.drv/init.c     |    4 ++--
 dlls/winex11.drv/text.c     |    7 +++++--
 dlls/winex11.drv/x11drv.h   |    4 ----
 5 files changed, 25 insertions(+), 43 deletions(-)

diff --git a/dlls/winex11.drv/bitblt.c b/dlls/winex11.drv/bitblt.c
index a54ca49..801ea08 100644
--- a/dlls/winex11.drv/bitblt.c
+++ b/dlls/winex11.drv/bitblt.c
@@ -850,9 +850,12 @@ BOOL X11DRV_StretchBlt( PHYSDEV dst_dev, struct bitblt_coords *dst,
         }
         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();
-            XSetBackground( gdi_display, physDevDst->gc, physDevDst->textPixel );
-            XSetForeground( gdi_display, physDevDst->gc, physDevDst->backgroundPixel );
+            XSetBackground( gdi_display, physDevDst->gc, text_pixel );
+            XSetForeground( gdi_display, physDevDst->gc, bkgnd_pixel );
             XSetFunction( gdi_display, physDevDst->gc, OP_ROP(*opcode) );
             XCopyPlane( gdi_display, physDevSrc->drawable,
                         physDevDst->drawable, physDevDst->gc,
@@ -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
            the device context are used.  In fact, it also applies to the
            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)
         {
-            XSetBackground( gdi_display, gc, X11DRV_PALETTE_XPixelToPalette[physDevDst->textPixel] );
-            XSetForeground( gdi_display, gc, X11DRV_PALETTE_XPixelToPalette[physDevDst->backgroundPixel]);
+            XSetBackground( gdi_display, gc, X11DRV_PALETTE_XPixelToPalette[text_pixel] );
+            XSetForeground( gdi_display, gc, X11DRV_PALETTE_XPixelToPalette[bkgnd_pixel]);
         }
         else
         {
-            XSetBackground( gdi_display, gc, physDevDst->textPixel );
-            XSetForeground( gdi_display, gc, physDevDst->backgroundPixel );
+            XSetBackground( gdi_display, gc, text_pixel );
+            XSetForeground( gdi_display, gc, bkgnd_pixel );
         }
         XCopyPlane( gdi_display, physDevSrc->drawable, src_pixmap, gc,
                     physDevSrc->dc_rect.left + src->visrect.left,
diff --git a/dlls/winex11.drv/graphics.c b/dlls/winex11.drv/graphics.c
index e317eb9..910dfea 100644
--- a/dlls/winex11.drv/graphics.c
+++ b/dlls/winex11.drv/graphics.c
@@ -274,13 +274,13 @@ BOOL X11DRV_SetupGCForPatBlt( X11DRV_PDEVICE *physDev, GC gc, BOOL fMapColors )
 	 * We need to swap foreground and background because
 	 * Windows does it the wrong way...
 	 */
-	val.foreground = physDev->backgroundPixel;
-	val.background = physDev->textPixel;
+	val.foreground = X11DRV_PALETTE_ToPhysical( physDev, GetBkColor(physDev->dev.hdc) );
+	val.background = X11DRV_PALETTE_ToPhysical( physDev, GetTextColor(physDev->dev.hdc) );
     }
     else
     {
 	val.foreground = physDev->brush.pixel;
-	val.background = physDev->backgroundPixel;
+	val.background = X11DRV_PALETTE_ToPhysical( physDev, GetBkColor(physDev->dev.hdc) );
     }
     if (fMapColors && X11DRV_PALETTE_XPixelToPalette)
     {
@@ -399,7 +399,7 @@ static BOOL X11DRV_SetupGCForPen( X11DRV_PDEVICE *physDev )
 	val.foreground = physDev->pen.pixel;
 	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.line_width = physDev->pen.width;
     if (val.line_width <= 1) {
@@ -463,8 +463,8 @@ BOOL X11DRV_SetupGCForText( X11DRV_PDEVICE *physDev )
 	XGCValues val;
 
 	val.function   = GXcopy;  /* Text is always GXcopy */
-	val.foreground = physDev->textPixel;
-	val.background = physDev->backgroundPixel;
+	val.foreground = X11DRV_PALETTE_ToPhysical( physDev, GetTextColor(physDev->dev.hdc) );
+	val.background = X11DRV_PALETTE_ToPhysical( physDev, GetBkColor(physDev->dev.hdc) );
 	val.fill_style = FillSolid;
 	val.font       = xfs->fid;
 
@@ -1493,29 +1493,6 @@ fallback:
     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 )
 {
     Atom type;
diff --git a/dlls/winex11.drv/init.c b/dlls/winex11.drv/init.c
index 0530e31..de0d029 100644
--- a/dlls/winex11.drv/init.c
+++ b/dlls/winex11.drv/init.c
@@ -550,7 +550,7 @@ static const struct gdi_dc_funcs x11drv_funcs =
     NULL,                               /* pSelectPalette */
     X11DRV_SelectPen,                   /* pSelectPen */
     NULL,                               /* pSetArcDirection */
-    X11DRV_SetBkColor,                  /* pSetBkColor */
+    NULL,                               /* pSetBkColor */
     NULL,                               /* pSetBkMode */
     X11DRV_SetDCBrushColor,             /* pSetDCBrushColor */
     X11DRV_SetDCPenColor,               /* pSetDCPenColor */
@@ -568,7 +568,7 @@ static const struct gdi_dc_funcs x11drv_funcs =
     NULL,                               /* pSetStretchBltMode */
     NULL,                               /* pSetTextAlign */
     NULL,                               /* pSetTextCharacterExtra */
-    X11DRV_SetTextColor,                /* pSetTextColor */
+    NULL,                               /* pSetTextColor */
     NULL,                               /* pSetTextJustification */
     NULL,                               /* pSetViewportExt */
     NULL,                               /* pSetViewportOrg */
diff --git a/dlls/winex11.drv/text.c b/dlls/winex11.drv/text.c
index f0197b6..22a6353 100644
--- a/dlls/winex11.drv/text.c
+++ b/dlls/winex11.drv/text.c
@@ -43,6 +43,7 @@ BOOL X11DRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
     X11DRV_PDEVICE *physDev = get_x11drv_dev( dev );
     BOOL restore_region = FALSE;
     unsigned int i;
+    int pixel;
     fontObject*		pfo = XFONT_GetFontObject( physDev->font );
     XFontStruct*	font;
     BOOL		rotated = FALSE;
@@ -70,8 +71,9 @@ BOOL X11DRV_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
 
     if (flags & ETO_OPAQUE)
     {
+	pixel = X11DRV_PALETTE_ToPhysical( physDev, GetBkColor(physDev->dev.hdc) );
         wine_tsx11_lock();
-        XSetForeground( gdi_display, physDev->gc, physDev->backgroundPixel );
+        XSetForeground( gdi_display, physDev->gc, pixel );
         XFillRectangle( gdi_display, physDev->drawable, physDev->gc,
                         physDev->dc_rect.left + lprect->left, physDev->dc_rect.top + 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,
         goto END;
     }
 
+    pixel = X11DRV_PALETTE_ToPhysical( physDev, GetTextColor(physDev->dev.hdc) );
     wine_tsx11_lock();
-    XSetForeground( gdi_display, physDev->gc, physDev->textPixel );
+    XSetForeground( gdi_display, physDev->gc, pixel );
     wine_tsx11_unlock();
     if(!rotated)
     {
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index 0f155ee..32f51d7 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -141,8 +141,6 @@ typedef struct
     X_PHYSBRUSH   brush;
     X_PHYSBITMAP *bitmap;       /* currently selected bitmap for memory DCs */
     BOOL          has_gdi_font; /* is current font a GDI font? */
-    int           backgroundPixel;
-    int           textPixel;
     int           depth;       /* bit depth of the DC */
     ColorShifts  *color_shifts; /* color shifts of the DC */
     int           exposures;   /* count of graphics exposures operations */
@@ -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 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 COLORREF X11DRV_SetBkColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
 extern COLORREF X11DRV_SetDCBrushColor( 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 BOOL X11DRV_SetDeviceGammaRamp( PHYSDEV dev, LPVOID ramp ) 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 COLORREF X11DRV_SetTextColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
 extern BOOL X11DRV_StretchBlt( PHYSDEV dst_dev, struct bitblt_coords *dst,
                                PHYSDEV src_dev, struct bitblt_coords *src, DWORD rop ) DECLSPEC_HIDDEN;
 extern BOOL X11DRV_UnrealizePalette( HPALETTE hpal ) DECLSPEC_HIDDEN;




More information about the wine-cvs mailing list