Commit 0967de74 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

gdi32: Introduce a unified function to perform COLORREF to pixel color mapping.

parent 67196377
......@@ -323,8 +323,8 @@ DWORD convert_bitmapinfo( const BITMAPINFO *src_info, void *src_bits, struct bit
static void update_fg_colors( dibdrv_physdev *pdev )
{
pdev->pen_color = get_fg_color( pdev, pdev->pen_colorref );
pdev->brush_color = get_fg_color( pdev, pdev->brush_colorref );
pdev->pen_color = get_pixel_color( pdev, pdev->pen_colorref, TRUE );
pdev->brush_color = get_pixel_color( pdev, pdev->brush_colorref, TRUE );
}
static void update_masks( dibdrv_physdev *pdev, INT rop )
......@@ -427,7 +427,7 @@ static COLORREF dibdrv_SetBkColor( PHYSDEV dev, COLORREF color )
PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSetBkColor );
dibdrv_physdev *pdev = get_dibdrv_pdev(dev);
pdev->bkgnd_color = pdev->dib.funcs->colorref_to_pixel( &pdev->dib, color );
pdev->bkgnd_color = get_pixel_color( pdev, color, FALSE );
if( GetBkMode(dev->hdc) == OPAQUE )
calc_and_xor_masks( GetROP2(dev->hdc), pdev->bkgnd_color, &pdev->bkgnd_and, &pdev->bkgnd_xor );
......@@ -488,7 +488,7 @@ static UINT dibdrv_SetDIBColorTable( PHYSDEV dev, UINT pos, UINT count, const RG
if( pos + count > pdev->dib.color_table_size ) count = pdev->dib.color_table_size - pos;
memcpy( pdev->dib.color_table + pos, colors, count * sizeof(RGBQUAD) );
pdev->bkgnd_color = pdev->dib.funcs->colorref_to_pixel( &pdev->dib, GetBkColor( dev->hdc ) );
pdev->bkgnd_color = get_pixel_color( pdev, GetBkColor( dev->hdc ), FALSE );
update_fg_colors( pdev );
update_masks( pdev, GetROP2( dev->hdc ) );
......
......@@ -198,7 +198,7 @@ extern void free_dib_info(dib_info *dib) DECLSPEC_HIDDEN;
extern void free_pattern_brush(dibdrv_physdev *pdev) DECLSPEC_HIDDEN;
extern void copy_dib_color_info(dib_info *dst, const dib_info *src) DECLSPEC_HIDDEN;
extern BOOL convert_dib(dib_info *dst, const dib_info *src) DECLSPEC_HIDDEN;
extern DWORD get_fg_color(dibdrv_physdev *pdev, COLORREF color) DECLSPEC_HIDDEN;
extern DWORD get_pixel_color(dibdrv_physdev *pdev, COLORREF color, BOOL mono_fixup) DECLSPEC_HIDDEN;
extern BOOL brush_rects( dibdrv_physdev *pdev, int num, const RECT *rects ) DECLSPEC_HIDDEN;
extern HRGN add_extra_clipping_region( dibdrv_physdev *pdev, HRGN rgn ) DECLSPEC_HIDDEN;
extern void restore_clipping_region( dibdrv_physdev *pdev, HRGN rgn ) DECLSPEC_HIDDEN;
......
......@@ -124,7 +124,7 @@ static inline BOOL rgbquad_equal(const RGBQUAD *a, const RGBQUAD *b)
}
/******************************************************************
* get_fg_color
* get_pixel_color
*
* 1 bit bitmaps map the fg/bg colors as follows:
* If the fg colorref exactly matches one of the color table entries then
......@@ -132,20 +132,20 @@ static inline BOOL rgbquad_equal(const RGBQUAD *a, const RGBQUAD *b)
* Otherwise the bg color is mapped to the closest entry in the table and
* the fg takes the other one.
*/
DWORD get_fg_color( dibdrv_physdev *pdev, COLORREF fg )
DWORD get_pixel_color( dibdrv_physdev *pdev, COLORREF color, BOOL mono_fixup )
{
RGBQUAD fg_quad;
if(pdev->dib.bit_count != 1)
return pdev->dib.funcs->colorref_to_pixel( &pdev->dib, fg );
if (pdev->dib.bit_count != 1 || !mono_fixup)
return pdev->dib.funcs->colorref_to_pixel( &pdev->dib, color );
fg_quad = rgbquad_from_colorref( fg );
fg_quad = rgbquad_from_colorref( color );
if(rgbquad_equal(&fg_quad, pdev->dib.color_table))
return 0;
if(rgbquad_equal(&fg_quad, pdev->dib.color_table + 1))
return 1;
if(fg == GetBkColor(pdev->dev.hdc)) return pdev->bkgnd_color;
if(color == GetBkColor(pdev->dev.hdc)) return pdev->bkgnd_color;
else return pdev->bkgnd_color ? 0 : 1;
}
......@@ -987,7 +987,7 @@ HPEN dibdrv_SelectPen( PHYSDEV dev, HPEN hpen )
logpen.lopnColor = GetDCPenColor( dev->hdc );
pdev->pen_colorref = logpen.lopnColor;
pdev->pen_color = get_fg_color( pdev, pdev->pen_colorref );
pdev->pen_color = get_pixel_color( pdev, pdev->pen_colorref, TRUE );
calc_and_xor_masks(GetROP2(dev->hdc), pdev->pen_color, &pdev->pen_and, &pdev->pen_xor);
pdev->pen_pattern = dash_patterns[PS_SOLID];
......@@ -1039,7 +1039,7 @@ COLORREF dibdrv_SetDCPenColor( PHYSDEV dev, COLORREF color )
if (GetCurrentObject(dev->hdc, OBJ_PEN) == GetStockObject( DC_PEN ))
{
pdev->pen_colorref = color;
pdev->pen_color = get_fg_color( pdev, pdev->pen_colorref );
pdev->pen_color = get_pixel_color( pdev, pdev->pen_colorref, TRUE );
calc_and_xor_masks(GetROP2(dev->hdc), pdev->pen_color, &pdev->pen_and, &pdev->pen_xor);
}
......@@ -1311,7 +1311,7 @@ HBRUSH dibdrv_SelectBrush( PHYSDEV dev, HBRUSH hbrush )
{
case BS_SOLID:
pdev->brush_colorref = logbrush.lbColor;
pdev->brush_color = get_fg_color( pdev, pdev->brush_colorref );
pdev->brush_color = get_pixel_color( pdev, pdev->brush_colorref, TRUE );
calc_and_xor_masks(GetROP2(dev->hdc), pdev->brush_color, &pdev->brush_and, &pdev->brush_xor);
pdev->brush_rects = solid_brush;
pdev->defer &= ~DEFER_BRUSH;
......@@ -1363,7 +1363,7 @@ HBRUSH dibdrv_SelectBrush( PHYSDEV dev, HBRUSH hbrush )
if(logbrush.lbHatch > HS_DIAGCROSS) return 0;
pdev->brush_hatch = logbrush.lbHatch;
pdev->brush_colorref = logbrush.lbColor;
pdev->brush_color = get_fg_color( pdev, pdev->brush_colorref );
pdev->brush_color = get_pixel_color( pdev, pdev->brush_colorref, TRUE );
calc_and_xor_masks(GetROP2(dev->hdc), pdev->brush_color, &pdev->brush_and, &pdev->brush_xor);
pdev->brush_rects = pattern_brush;
pdev->defer &= ~DEFER_BRUSH;
......@@ -1388,7 +1388,7 @@ COLORREF dibdrv_SetDCBrushColor( PHYSDEV dev, COLORREF color )
if (GetCurrentObject(dev->hdc, OBJ_BRUSH) == GetStockObject( DC_BRUSH ))
{
pdev->brush_colorref = color;
pdev->brush_color = get_fg_color( pdev, pdev->brush_colorref );
pdev->brush_color = get_pixel_color( pdev, pdev->brush_colorref, TRUE );
calc_and_xor_masks(GetROP2(dev->hdc), pdev->brush_color, &pdev->brush_and, &pdev->brush_xor);
}
......
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