Alexandre Julliard : gdi32: Recompute the foreground masks on every use to support PALETTEINDEX colors .

Alexandre Julliard julliard at winehq.org
Fri Dec 23 13:03:22 CST 2011


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Dec 22 16:32:37 2011 +0100

gdi32: Recompute the foreground masks on every use to support PALETTEINDEX colors.

---

 dlls/gdi32/dibdrv/dc.c       |   42 ++++--------------------------------------
 dlls/gdi32/dibdrv/dibdrv.h   |    5 -----
 dlls/gdi32/dibdrv/graphics.c |   25 ++++++++++++-------------
 3 files changed, 16 insertions(+), 56 deletions(-)

diff --git a/dlls/gdi32/dibdrv/dc.c b/dlls/gdi32/dibdrv/dc.c
index f3cf1d5..cdcbd19 100644
--- a/dlls/gdi32/dibdrv/dc.c
+++ b/dlls/gdi32/dibdrv/dc.c
@@ -257,11 +257,6 @@ DWORD convert_bitmapinfo( const BITMAPINFO *src_info, void *src_bits, struct bit
     return ERROR_SUCCESS;
 }
 
-static void update_fg_colors( dibdrv_physdev *pdev )
-{
-    pdev->text_color  = get_pixel_color( pdev, GetTextColor( pdev->dev.hdc ), TRUE );
-}
-
  /***********************************************************************
  *           add_extra_clipping_region
  *
@@ -365,19 +360,6 @@ static HBITMAP dibdrv_SelectBitmap( PHYSDEV dev, HBITMAP bitmap )
 }
 
 /***********************************************************************
- *           dibdrv_SetBkColor
- */
-static COLORREF dibdrv_SetBkColor( PHYSDEV dev, COLORREF color )
-{
-    PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSetBkColor );
-    dibdrv_physdev *pdev = get_dibdrv_pdev(dev);
-
-    update_fg_colors( pdev ); /* Only needed in the 1 bpp case */
-
-    return next->funcs->pSetBkColor( next, color );
-}
-
-/***********************************************************************
  *           dibdrv_SetDeviceClipping
  */
 static void dibdrv_SetDeviceClipping( PHYSDEV dev, HRGN rgn )
@@ -400,11 +382,8 @@ static UINT dibdrv_SetDIBColorTable( PHYSDEV dev, UINT pos, UINT count, const RG
     dibdrv_physdev *pdev = get_dibdrv_pdev(dev);
     TRACE("(%p, %d, %d, %p)\n", dev, pos, count, colors);
 
-    if (pdev->dib.color_table)
-    {
-        update_fg_colors( pdev );
-        update_brush_rop( pdev, GetROP2( dev->hdc ) );
-    }
+    if (pdev->dib.color_table) update_brush_rop( pdev, GetROP2( dev->hdc ) );
+
     return next->funcs->pSetDIBColorTable( next, pos, count, colors );
 }
 
@@ -421,19 +400,6 @@ static INT dibdrv_SetROP2( PHYSDEV dev, INT rop )
     return next->funcs->pSetROP2( next, rop );
 }
 
-/***********************************************************************
- *           dibdrv_SetTextColor
- */
-static COLORREF dibdrv_SetTextColor( PHYSDEV dev, COLORREF color )
-{
-    PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSetTextColor );
-    dibdrv_physdev *pdev = get_dibdrv_pdev(dev);
-
-    pdev->text_color = get_pixel_color( pdev, color, TRUE );
-    update_aa_ranges( pdev );
-
-    return next->funcs->pSetTextColor( next, color );
-}
 
 const struct gdi_dc_funcs dib_driver =
 {
@@ -536,7 +502,7 @@ const struct gdi_dc_funcs dib_driver =
     NULL,                               /* pSelectPalette */
     dibdrv_SelectPen,                   /* pSelectPen */
     NULL,                               /* pSetArcDirection */
-    dibdrv_SetBkColor,                  /* pSetBkColor */
+    NULL,                               /* pSetBkColor */
     NULL,                               /* pSetBkMode */
     dibdrv_SetDCBrushColor,             /* pSetDCBrushColor */
     dibdrv_SetDCPenColor,               /* pSetDCPenColor */
@@ -555,7 +521,7 @@ const struct gdi_dc_funcs dib_driver =
     NULL,                               /* pSetStretchBltMode */
     NULL,                               /* pSetTextAlign */
     NULL,                               /* pSetTextCharacterExtra */
-    dibdrv_SetTextColor,                /* pSetTextColor */
+    NULL,                               /* pSetTextColor */
     NULL,                               /* pSetTextJustification */
     NULL,                               /* pSetViewportExt */
     NULL,                               /* pSetViewportOrg */
diff --git a/dlls/gdi32/dibdrv/dibdrv.h b/dlls/gdi32/dibdrv/dibdrv.h
index 5ff0889..bbb90f4 100644
--- a/dlls/gdi32/dibdrv/dibdrv.h
+++ b/dlls/gdi32/dibdrv/dibdrv.h
@@ -102,10 +102,6 @@ typedef struct dibdrv_physdev
     UINT brush_pattern_usage;
     HBITMAP brush_pattern_bitmap;
     BOOL   (* brush_rects)(struct dibdrv_physdev *pdev, dib_info *dib, int num, const RECT *rects, HRGN clip);
-
-    /* text */
-    DWORD text_color;
-    struct intensity_range glyph_intensities[17];
 } dibdrv_physdev;
 
 #define DEFER_PEN        2
@@ -234,7 +230,6 @@ extern HRGN add_extra_clipping_region( dibdrv_physdev *pdev, HRGN rgn ) DECLSPEC
 extern void restore_clipping_region( dibdrv_physdev *pdev, HRGN rgn ) DECLSPEC_HIDDEN;
 extern int clip_line(const POINT *start, const POINT *end, const RECT *clip,
                      const bres_params *params, POINT *pt1, POINT *pt2) DECLSPEC_HIDDEN;
-extern void update_aa_ranges( dibdrv_physdev *pdev ) DECLSPEC_HIDDEN;
 
 /* compute the x coordinate corresponding to y on the specified edge */
 static inline int edge_coord( int y, int x1, int y1, int x2, int y2 )
diff --git a/dlls/gdi32/dibdrv/graphics.c b/dlls/gdi32/dibdrv/graphics.c
index 33e7d6d..ad6c4ad 100644
--- a/dlls/gdi32/dibdrv/graphics.c
+++ b/dlls/gdi32/dibdrv/graphics.c
@@ -103,12 +103,6 @@ static inline void get_aa_ranges( COLORREF col, struct intensity_range intensiti
     }
 }
 
-void update_aa_ranges( dibdrv_physdev *pdev )
-{
-    COLORREF text = pdev->dib.funcs->pixel_to_colorref( &pdev->dib, pdev->text_color );
-    get_aa_ranges( text, pdev->glyph_intensities );
-}
-
 /**********************************************************************
  *                 get_text_bkgnd_masks
  *
@@ -124,14 +118,15 @@ static inline void get_text_bkgnd_masks( dibdrv_physdev *pdev, rop_mask *mask )
         mask->xor = get_pixel_color( pdev, bg, FALSE );
     else
     {
-        mask->xor = ~pdev->text_color;
-        if (GetTextColor( pdev->dev.hdc ) == bg)
-            mask->xor = pdev->text_color;
+        COLORREF fg = GetTextColor( pdev->dev.hdc );
+        mask->xor = get_pixel_color( pdev, fg, TRUE );
+        if (fg != bg) mask->xor = ~mask->xor;
     }
 }
 
 static void draw_glyph( dibdrv_physdev *pdev, const POINT *origin, const GLYPHMETRICS *metrics,
-                        const struct gdi_image_bits *image )
+                        const struct gdi_image_bits *image, DWORD text_color,
+                        const struct intensity_range *ranges )
 {
     const WINEREGION *clip = get_wine_region( pdev->clip );
     int i;
@@ -158,7 +153,7 @@ static void draw_glyph( dibdrv_physdev *pdev, const POINT *origin, const GLYPHME
             src_origin.y = clipped_rect.top  - rect.top;
 
             pdev->dib.funcs->draw_glyph( &pdev->dib, &clipped_rect, &glyph_dib, &src_origin,
-                                         pdev->text_color, pdev->glyph_intensities );
+                                         text_color, ranges );
         }
     }
 
@@ -339,8 +334,9 @@ BOOL dibdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
     dibdrv_physdev *pdev = get_dibdrv_pdev(dev);
     UINT aa_flags, i;
     POINT origin;
-    DWORD err;
+    DWORD text_color, err;
     HRGN saved_clip = NULL;
+    struct intensity_range ranges[17];
 
     if (flags & ETO_OPAQUE)
     {
@@ -358,6 +354,9 @@ BOOL dibdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
         DeleteObject( clip );
     }
 
+    text_color = get_pixel_color( pdev, GetTextColor( pdev->dev.hdc ), TRUE );
+    get_aa_ranges( pdev->dib.funcs->pixel_to_colorref( &pdev->dib, text_color ), ranges );
+
     aa_flags = get_font_aa_flags( dev->hdc );
     origin.x = x;
     origin.y = y;
@@ -369,7 +368,7 @@ BOOL dibdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
         err = get_glyph_bitmap( dev->hdc, (UINT)str[i], aa_flags, &metrics, &image );
         if (err) continue;
 
-        if (image.ptr) draw_glyph( pdev, &origin, &metrics, &image );
+        if (image.ptr) draw_glyph( pdev, &origin, &metrics, &image, text_color, ranges );
         if (image.free) image.free( &image );
 
         if (dx)




More information about the wine-cvs mailing list