Commit 6a2decc2 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

gdi32: Move background color to DC_ATTR.

parent 148a2b60
...@@ -261,7 +261,7 @@ static RGBQUAD get_dc_rgb_color( DC *dc, int color_table_size, COLORREF color ) ...@@ -261,7 +261,7 @@ static RGBQUAD get_dc_rgb_color( DC *dc, int color_table_size, COLORREF color )
/* helper to retrieve either both colors or only the background color for monochrome blits */ /* helper to retrieve either both colors or only the background color for monochrome blits */
void get_mono_dc_colors( DC *dc, int color_table_size, BITMAPINFO *info, int count ) void get_mono_dc_colors( DC *dc, int color_table_size, BITMAPINFO *info, int count )
{ {
info->bmiColors[count - 1] = get_dc_rgb_color( dc, color_table_size, dc->backgroundColor ); info->bmiColors[count - 1] = get_dc_rgb_color( dc, color_table_size, dc->attr->background_color );
if (count > 1) info->bmiColors[0] = get_dc_rgb_color( dc, color_table_size, dc->textColor ); if (count > 1) info->bmiColors[0] = get_dc_rgb_color( dc, color_table_size, dc->textColor );
info->bmiHeader.biClrUsed = count; info->bmiHeader.biClrUsed = count;
} }
......
...@@ -86,8 +86,8 @@ static void set_initial_dc_state( DC *dc ) ...@@ -86,8 +86,8 @@ static void set_initial_dc_state( DC *dc )
dc->polyFillMode = ALTERNATE; dc->polyFillMode = ALTERNATE;
dc->stretchBltMode = BLACKONWHITE; dc->stretchBltMode = BLACKONWHITE;
dc->relAbsMode = ABSOLUTE; dc->relAbsMode = ABSOLUTE;
dc->attr->background_mode = OPAQUE; dc->attr->background_mode = OPAQUE;
dc->backgroundColor = RGB( 255, 255, 255 ); dc->attr->background_color = RGB( 255, 255, 255 );
dc->dcBrushColor = RGB( 255, 255, 255 ); dc->dcBrushColor = RGB( 255, 255, 255 );
dc->dcPenColor = RGB( 0, 0, 0 ); dc->dcPenColor = RGB( 0, 0, 0 );
dc->textColor = RGB( 0, 0, 0 ); dc->textColor = RGB( 0, 0, 0 );
...@@ -276,7 +276,7 @@ void DC_InitDC( DC* dc ) ...@@ -276,7 +276,7 @@ void DC_InitDC( DC* dc )
PHYSDEV physdev = GET_DC_PHYSDEV( dc, pRealizeDefaultPalette ); PHYSDEV physdev = GET_DC_PHYSDEV( dc, pRealizeDefaultPalette );
physdev->funcs->pRealizeDefaultPalette( physdev ); physdev->funcs->pRealizeDefaultPalette( physdev );
SetTextColor( dc->hSelf, dc->textColor ); SetTextColor( dc->hSelf, dc->textColor );
SetBkColor( dc->hSelf, dc->backgroundColor ); SetBkColor( dc->hSelf, dc->attr->background_color );
NtGdiSelectPen( dc->hSelf, dc->hPen ); NtGdiSelectPen( dc->hSelf, dc->hPen );
NtGdiSelectBrush( dc->hSelf, dc->hBrush ); NtGdiSelectBrush( dc->hSelf, dc->hBrush );
NtGdiSelectFont( dc->hSelf, dc->hFont ); NtGdiSelectFont( dc->hSelf, dc->hFont );
...@@ -401,7 +401,6 @@ INT CDECL nulldrv_SaveDC( PHYSDEV dev ) ...@@ -401,7 +401,6 @@ INT CDECL nulldrv_SaveDC( PHYSDEV dev )
newdc->polyFillMode = dc->polyFillMode; newdc->polyFillMode = dc->polyFillMode;
newdc->stretchBltMode = dc->stretchBltMode; newdc->stretchBltMode = dc->stretchBltMode;
newdc->relAbsMode = dc->relAbsMode; newdc->relAbsMode = dc->relAbsMode;
newdc->backgroundColor = dc->backgroundColor;
newdc->textColor = dc->textColor; newdc->textColor = dc->textColor;
newdc->dcBrushColor = dc->dcBrushColor; newdc->dcBrushColor = dc->dcBrushColor;
newdc->dcPenColor = dc->dcPenColor; newdc->dcPenColor = dc->dcPenColor;
...@@ -474,8 +473,8 @@ BOOL CDECL nulldrv_RestoreDC( PHYSDEV dev, INT level ) ...@@ -474,8 +473,8 @@ BOOL CDECL nulldrv_RestoreDC( PHYSDEV dev, INT level )
dc->polyFillMode = dcs->polyFillMode; dc->polyFillMode = dcs->polyFillMode;
dc->stretchBltMode = dcs->stretchBltMode; dc->stretchBltMode = dcs->stretchBltMode;
dc->relAbsMode = dcs->relAbsMode; dc->relAbsMode = dcs->relAbsMode;
dc->attr->background_mode = dcs->attr->background_mode; dc->attr->background_mode = dcs->attr->background_mode;
dc->backgroundColor = dcs->backgroundColor; dc->attr->background_color = dcs->attr->background_color;
dc->textColor = dcs->textColor; dc->textColor = dcs->textColor;
dc->dcBrushColor = dcs->dcBrushColor; dc->dcBrushColor = dcs->dcBrushColor;
dc->dcPenColor = dcs->dcPenColor; dc->dcPenColor = dcs->dcPenColor;
...@@ -527,7 +526,7 @@ BOOL CDECL nulldrv_RestoreDC( PHYSDEV dev, INT level ) ...@@ -527,7 +526,7 @@ BOOL CDECL nulldrv_RestoreDC( PHYSDEV dev, INT level )
NtGdiSelectBrush( dev->hdc, dcs->hBrush ); NtGdiSelectBrush( dev->hdc, dcs->hBrush );
NtGdiSelectFont( dev->hdc, dcs->hFont ); NtGdiSelectFont( dev->hdc, dcs->hFont );
NtGdiSelectPen( dev->hdc, dcs->hPen ); NtGdiSelectPen( dev->hdc, dcs->hPen );
SetBkColor( dev->hdc, dcs->backgroundColor); SetBkColor( dev->hdc, dcs->attr->background_color);
SetTextColor( dev->hdc, dcs->textColor); SetTextColor( dev->hdc, dcs->textColor);
GDISelectPalette( dev->hdc, dcs->hPalette, FALSE ); GDISelectPalette( dev->hdc, dcs->hPalette, FALSE );
...@@ -910,22 +909,6 @@ INT WINAPI GetDeviceCaps( HDC hdc, INT cap ) ...@@ -910,22 +909,6 @@ INT WINAPI GetDeviceCaps( HDC hdc, INT cap )
/*********************************************************************** /***********************************************************************
* GetBkColor (GDI32.@)
*/
COLORREF WINAPI GetBkColor( HDC hdc )
{
COLORREF ret = 0;
DC * dc = get_dc_ptr( hdc );
if (dc)
{
ret = dc->backgroundColor;
release_dc_ptr( dc );
}
return ret;
}
/***********************************************************************
* SetBkColor (GDI32.@) * SetBkColor (GDI32.@)
*/ */
COLORREF WINAPI SetBkColor( HDC hdc, COLORREF color ) COLORREF WINAPI SetBkColor( HDC hdc, COLORREF color )
...@@ -938,8 +921,8 @@ COLORREF WINAPI SetBkColor( HDC hdc, COLORREF color ) ...@@ -938,8 +921,8 @@ COLORREF WINAPI SetBkColor( HDC hdc, COLORREF color )
if (dc) if (dc)
{ {
PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetBkColor ); PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetBkColor );
ret = dc->backgroundColor; ret = dc->attr->background_color;
dc->backgroundColor = physdev->funcs->pSetBkColor( physdev, color ); dc->attr->background_color = physdev->funcs->pSetBkColor( physdev, color );
release_dc_ptr( dc ); release_dc_ptr( dc );
} }
return ret; return ret;
......
...@@ -938,7 +938,7 @@ UINT WINAPI SetDIBColorTable( HDC hdc, UINT startpos, UINT entries, const RGBQUA ...@@ -938,7 +938,7 @@ UINT WINAPI SetDIBColorTable( HDC hdc, UINT startpos, UINT entries, const RGBQUA
if (result) /* update colors of selected objects */ if (result) /* update colors of selected objects */
{ {
SetTextColor( hdc, dc->textColor ); SetTextColor( hdc, dc->textColor );
SetBkColor( hdc, dc->backgroundColor ); SetBkColor( hdc, dc->attr->background_color );
NtGdiSelectPen( hdc, dc->hPen ); NtGdiSelectPen( hdc, dc->hPen );
NtGdiSelectBrush( hdc, dc->hBrush ); NtGdiSelectBrush( hdc, dc->hBrush );
} }
......
...@@ -666,7 +666,7 @@ static struct cached_glyph *get_cached_glyph( struct cached_font *font, UINT ind ...@@ -666,7 +666,7 @@ static struct cached_glyph *get_cached_glyph( struct cached_font *font, UINT ind
*/ */
static inline void get_text_bkgnd_masks( DC *dc, const dib_info *dib, rop_mask *mask ) static inline void get_text_bkgnd_masks( DC *dc, const dib_info *dib, rop_mask *mask )
{ {
COLORREF bg = dc->backgroundColor; COLORREF bg = dc->attr->background_color;
mask->and = 0; mask->and = 0;
......
...@@ -193,8 +193,8 @@ DWORD get_pixel_color( DC *dc, const dib_info *dib, COLORREF color, BOOL mono_fi ...@@ -193,8 +193,8 @@ DWORD get_pixel_color( DC *dc, const dib_info *dib, COLORREF color, BOOL mono_fi
if(rgbquad_equal(&fg_quad, color_table + 1)) if(rgbquad_equal(&fg_quad, color_table + 1))
return 1; return 1;
pixel = get_pixel_color( dc, dib, dc->backgroundColor, FALSE ); pixel = get_pixel_color( dc, dib, dc->attr->background_color, FALSE );
if (color == dc->backgroundColor) return pixel; if (color == dc->attr->background_color) return pixel;
else return !pixel; else return !pixel;
} }
...@@ -219,8 +219,8 @@ static inline void get_color_masks( DC *dc, const dib_info *dib, UINT rop, COLOR ...@@ -219,8 +219,8 @@ static inline void get_color_masks( DC *dc, const dib_info *dib, UINT rop, COLOR
return; return;
} }
if (dib->bit_count != 1) color = get_pixel_color( dc, dib, dc->backgroundColor, FALSE ); if (dib->bit_count != 1) color = get_pixel_color( dc, dib, dc->attr->background_color, FALSE );
else if (colorref != dc->backgroundColor) color = !color; else if (colorref != dc->attr->background_color) color = !color;
calc_rop_masks( rop, color, bg_mask ); calc_rop_masks( rop, color, bg_mask );
} }
...@@ -1896,7 +1896,7 @@ static BOOL create_hatch_brush_bits(dibdrv_physdev *pdev, dib_brush *brush, BOOL ...@@ -1896,7 +1896,7 @@ static BOOL create_hatch_brush_bits(dibdrv_physdev *pdev, dib_brush *brush, BOOL
if (brush->colorref & (1 << 24)) /* PALETTEINDEX */ if (brush->colorref & (1 << 24)) /* PALETTEINDEX */
*needs_reselect = TRUE; *needs_reselect = TRUE;
if (dc->attr->background_mode != TRANSPARENT && (dc->backgroundColor & (1 << 24))) if (dc->attr->background_mode != TRANSPARENT && (dc->attr->background_color & (1 << 24)))
*needs_reselect = TRUE; *needs_reselect = TRUE;
brush->dib.funcs->create_rop_masks( &brush->dib, hatches[brush->hatch], brush->dib.funcs->create_rop_masks( &brush->dib, hatches[brush->hatch],
...@@ -1987,7 +1987,7 @@ static BOOL select_pattern_brush( dibdrv_physdev *pdev, dib_brush *brush, BOOL * ...@@ -1987,7 +1987,7 @@ static BOOL select_pattern_brush( dibdrv_physdev *pdev, dib_brush *brush, BOOL *
color_table[0].rgbBlue = GetBValue( color ); color_table[0].rgbBlue = GetBValue( color );
color_table[0].rgbReserved = 0; color_table[0].rgbReserved = 0;
color = make_rgb_colorref( dc, &pdev->dib, dc->backgroundColor, &got_pixel, &pixel ); color = make_rgb_colorref( dc, &pdev->dib, dc->attr->background_color, &got_pixel, &pixel );
color_table[1].rgbRed = GetRValue( color ); color_table[1].rgbRed = GetRValue( color );
color_table[1].rgbGreen = GetGValue( color ); color_table[1].rgbGreen = GetGValue( color );
color_table[1].rgbBlue = GetBValue( color ); color_table[1].rgbBlue = GetBValue( color );
......
...@@ -5694,7 +5694,7 @@ BOOL CDECL nulldrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT ...@@ -5694,7 +5694,7 @@ BOOL CDECL nulldrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT
if (flags & ETO_OPAQUE) if (flags & ETO_OPAQUE)
{ {
RECT rc = *rect; RECT rc = *rect;
HBRUSH brush = CreateSolidBrush( GetNearestColor( dev->hdc, dc->backgroundColor ) ); HBRUSH brush = CreateSolidBrush( GetNearestColor( dev->hdc, dc->attr->background_color ) );
if (brush) if (brush)
{ {
......
...@@ -66,6 +66,15 @@ UINT WINAPI SetTextAlign( HDC hdc, UINT align ) ...@@ -66,6 +66,15 @@ UINT WINAPI SetTextAlign( HDC hdc, UINT align )
} }
/*********************************************************************** /***********************************************************************
* GetBkColor (GDI32.@)
*/
COLORREF WINAPI GetBkColor( HDC hdc )
{
DC_ATTR *dc_attr = get_dc_attr( hdc );
return dc_attr ? dc_attr->background_color : CLR_INVALID;
}
/***********************************************************************
* GetBkMode (GDI32.@) * GetBkMode (GDI32.@)
*/ */
INT WINAPI GetBkMode( HDC hdc ) INT WINAPI GetBkMode( HDC hdc )
......
...@@ -119,7 +119,6 @@ typedef struct tagDC ...@@ -119,7 +119,6 @@ typedef struct tagDC
WORD polyFillMode; WORD polyFillMode;
WORD stretchBltMode; WORD stretchBltMode;
WORD relAbsMode; WORD relAbsMode;
COLORREF backgroundColor;
COLORREF textColor; COLORREF textColor;
COLORREF dcBrushColor; COLORREF dcBrushColor;
COLORREF dcPenColor; COLORREF dcPenColor;
......
...@@ -86,6 +86,9 @@ static void test_dc_values(void) ...@@ -86,6 +86,9 @@ static void test_dc_values(void)
ok(!attr, "attr = %x\n", attr); ok(!attr, "attr = %x\n", attr);
ok(GetLastError() == ERROR_INVALID_HANDLE, "GetLastError() = %u\n", GetLastError()); ok(GetLastError() == ERROR_INVALID_HANDLE, "GetLastError() = %u\n", GetLastError());
attr = GetBkColor(ULongToHandle(0xdeadbeef));
ok(attr == CLR_INVALID, "attr = %x\n", attr);
DeleteDC( hdc ); DeleteDC( hdc );
} }
......
...@@ -901,7 +901,7 @@ static void test_mf_SaveDC(void) ...@@ -901,7 +901,7 @@ static void test_mf_SaveDC(void)
SetPolyFillMode( hdcMetafile, WINDING ); SetPolyFillMode( hdcMetafile, WINDING );
SetBkColor( hdcMetafile, 0x123456 ); SetBkColor( hdcMetafile, 0x123456 );
todo_wine ok( !GetPolyFillMode( hdcMetafile ), "GetPolyFillMode succeeded\n" ); todo_wine ok( !GetPolyFillMode( hdcMetafile ), "GetPolyFillMode succeeded\n" );
todo_wine ok( GetBkColor( hdcMetafile ) == CLR_INVALID, "GetBkColor succeeded\n" ); ok( GetBkColor( hdcMetafile ) == CLR_INVALID, "GetBkColor succeeded\n" );
/* Force Win9x to update DC state */ /* Force Win9x to update DC state */
SetPixelV(hdcMetafile, 50, 50, 0); SetPixelV(hdcMetafile, 50, 50, 0);
......
...@@ -99,6 +99,7 @@ enum ...@@ -99,6 +99,7 @@ enum
typedef struct DC_ATTR typedef struct DC_ATTR
{ {
LONG disabled; /* disabled flag, controled by DCHF_(DISABLE|ENABLE)DC */ LONG disabled; /* disabled flag, controled by DCHF_(DISABLE|ENABLE)DC */
COLORREF background_color;
POINT cur_pos; POINT cur_pos;
INT graphics_mode; INT graphics_mode;
DWORD layout; DWORD layout;
......
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