diff --git a/dlls/gdi32/bitblt.c b/dlls/gdi32/bitblt.c index 8aaada67cdf..b58419f1c78 100644 --- a/dlls/gdi32/bitblt.c +++ b/dlls/gdi32/bitblt.c @@ -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 */ 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 ); info->bmiHeader.biClrUsed = count; } diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c index 5b79058679f..3f7806735e2 100644 --- a/dlls/gdi32/dc.c +++ b/dlls/gdi32/dc.c @@ -86,8 +86,8 @@ static void set_initial_dc_state( DC *dc ) dc->polyFillMode = ALTERNATE; dc->stretchBltMode = BLACKONWHITE; dc->relAbsMode = ABSOLUTE; - dc->attr->background_mode = OPAQUE; - dc->backgroundColor = RGB( 255, 255, 255 ); + dc->attr->background_mode = OPAQUE; + dc->attr->background_color = RGB( 255, 255, 255 ); dc->dcBrushColor = RGB( 255, 255, 255 ); dc->dcPenColor = RGB( 0, 0, 0 ); dc->textColor = RGB( 0, 0, 0 ); @@ -276,7 +276,7 @@ void DC_InitDC( DC* dc ) PHYSDEV physdev = GET_DC_PHYSDEV( dc, pRealizeDefaultPalette ); physdev->funcs->pRealizeDefaultPalette( physdev ); SetTextColor( dc->hSelf, dc->textColor ); - SetBkColor( dc->hSelf, dc->backgroundColor ); + SetBkColor( dc->hSelf, dc->attr->background_color ); NtGdiSelectPen( dc->hSelf, dc->hPen ); NtGdiSelectBrush( dc->hSelf, dc->hBrush ); NtGdiSelectFont( dc->hSelf, dc->hFont ); @@ -401,7 +401,6 @@ INT CDECL nulldrv_SaveDC( PHYSDEV dev ) newdc->polyFillMode = dc->polyFillMode; newdc->stretchBltMode = dc->stretchBltMode; newdc->relAbsMode = dc->relAbsMode; - newdc->backgroundColor = dc->backgroundColor; newdc->textColor = dc->textColor; newdc->dcBrushColor = dc->dcBrushColor; newdc->dcPenColor = dc->dcPenColor; @@ -474,8 +473,8 @@ BOOL CDECL nulldrv_RestoreDC( PHYSDEV dev, INT level ) dc->polyFillMode = dcs->polyFillMode; dc->stretchBltMode = dcs->stretchBltMode; dc->relAbsMode = dcs->relAbsMode; - dc->attr->background_mode = dcs->attr->background_mode; - dc->backgroundColor = dcs->backgroundColor; + dc->attr->background_mode = dcs->attr->background_mode; + dc->attr->background_color = dcs->attr->background_color; dc->textColor = dcs->textColor; dc->dcBrushColor = dcs->dcBrushColor; dc->dcPenColor = dcs->dcPenColor; @@ -527,7 +526,7 @@ BOOL CDECL nulldrv_RestoreDC( PHYSDEV dev, INT level ) NtGdiSelectBrush( dev->hdc, dcs->hBrush ); NtGdiSelectFont( dev->hdc, dcs->hFont ); NtGdiSelectPen( dev->hdc, dcs->hPen ); - SetBkColor( dev->hdc, dcs->backgroundColor); + SetBkColor( dev->hdc, dcs->attr->background_color); SetTextColor( dev->hdc, dcs->textColor); GDISelectPalette( dev->hdc, dcs->hPalette, FALSE ); @@ -909,22 +908,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.@) */ @@ -938,8 +921,8 @@ COLORREF WINAPI SetBkColor( HDC hdc, COLORREF color ) if (dc) { PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetBkColor ); - ret = dc->backgroundColor; - dc->backgroundColor = physdev->funcs->pSetBkColor( physdev, color ); + ret = dc->attr->background_color; + dc->attr->background_color = physdev->funcs->pSetBkColor( physdev, color ); release_dc_ptr( dc ); } return ret; diff --git a/dlls/gdi32/dib.c b/dlls/gdi32/dib.c index 6fa96e1c128..4c65b271661 100644 --- a/dlls/gdi32/dib.c +++ b/dlls/gdi32/dib.c @@ -938,7 +938,7 @@ UINT WINAPI SetDIBColorTable( HDC hdc, UINT startpos, UINT entries, const RGBQUA if (result) /* update colors of selected objects */ { SetTextColor( hdc, dc->textColor ); - SetBkColor( hdc, dc->backgroundColor ); + SetBkColor( hdc, dc->attr->background_color ); NtGdiSelectPen( hdc, dc->hPen ); NtGdiSelectBrush( hdc, dc->hBrush ); } diff --git a/dlls/gdi32/dibdrv/graphics.c b/dlls/gdi32/dibdrv/graphics.c index c97b529e75a..402b1b10323 100644 --- a/dlls/gdi32/dibdrv/graphics.c +++ b/dlls/gdi32/dibdrv/graphics.c @@ -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 ) { - COLORREF bg = dc->backgroundColor; + COLORREF bg = dc->attr->background_color; mask->and = 0; diff --git a/dlls/gdi32/dibdrv/objects.c b/dlls/gdi32/dibdrv/objects.c index 489b2497ff2..e34e78550eb 100644 --- a/dlls/gdi32/dibdrv/objects.c +++ b/dlls/gdi32/dibdrv/objects.c @@ -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)) return 1; - pixel = get_pixel_color( dc, dib, dc->backgroundColor, FALSE ); - if (color == dc->backgroundColor) return pixel; + pixel = get_pixel_color( dc, dib, dc->attr->background_color, FALSE ); + if (color == dc->attr->background_color) return pixel; else return !pixel; } @@ -219,8 +219,8 @@ static inline void get_color_masks( DC *dc, const dib_info *dib, UINT rop, COLOR return; } - if (dib->bit_count != 1) color = get_pixel_color( dc, dib, dc->backgroundColor, FALSE ); - else if (colorref != dc->backgroundColor) color = !color; + if (dib->bit_count != 1) color = get_pixel_color( dc, dib, dc->attr->background_color, FALSE ); + else if (colorref != dc->attr->background_color) color = !color; calc_rop_masks( rop, color, bg_mask ); } @@ -1896,7 +1896,7 @@ static BOOL create_hatch_brush_bits(dibdrv_physdev *pdev, dib_brush *brush, BOOL if (brush->colorref & (1 << 24)) /* PALETTEINDEX */ *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; 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 * color_table[0].rgbBlue = GetBValue( color ); 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].rgbGreen = GetGValue( color ); color_table[1].rgbBlue = GetBValue( color ); diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c index de480315960..858b4a59e4d 100644 --- a/dlls/gdi32/font.c +++ b/dlls/gdi32/font.c @@ -5694,7 +5694,7 @@ BOOL CDECL nulldrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT if (flags & ETO_OPAQUE) { RECT rc = *rect; - HBRUSH brush = CreateSolidBrush( GetNearestColor( dev->hdc, dc->backgroundColor ) ); + HBRUSH brush = CreateSolidBrush( GetNearestColor( dev->hdc, dc->attr->background_color ) ); if (brush) { diff --git a/dlls/gdi32/gdidc.c b/dlls/gdi32/gdidc.c index 1f687bdb369..10ba4d1eaac 100644 --- a/dlls/gdi32/gdidc.c +++ b/dlls/gdi32/gdidc.c @@ -65,6 +65,15 @@ UINT WINAPI SetTextAlign( HDC hdc, UINT align ) return ret; } +/*********************************************************************** + * 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.@) */ diff --git a/dlls/gdi32/ntgdi_private.h b/dlls/gdi32/ntgdi_private.h index a4cf6780242..65a06db61e5 100644 --- a/dlls/gdi32/ntgdi_private.h +++ b/dlls/gdi32/ntgdi_private.h @@ -119,7 +119,6 @@ typedef struct tagDC WORD polyFillMode; WORD stretchBltMode; WORD relAbsMode; - COLORREF backgroundColor; COLORREF textColor; COLORREF dcBrushColor; COLORREF dcPenColor; diff --git a/dlls/gdi32/tests/dc.c b/dlls/gdi32/tests/dc.c index 3d5da4acb74..054279bf46c 100644 --- a/dlls/gdi32/tests/dc.c +++ b/dlls/gdi32/tests/dc.c @@ -86,6 +86,9 @@ static void test_dc_values(void) ok(!attr, "attr = %x\n", attr); ok(GetLastError() == ERROR_INVALID_HANDLE, "GetLastError() = %u\n", GetLastError()); + attr = GetBkColor(ULongToHandle(0xdeadbeef)); + ok(attr == CLR_INVALID, "attr = %x\n", attr); + DeleteDC( hdc ); } diff --git a/dlls/gdi32/tests/metafile.c b/dlls/gdi32/tests/metafile.c index c2273e45ccd..1a38735f044 100644 --- a/dlls/gdi32/tests/metafile.c +++ b/dlls/gdi32/tests/metafile.c @@ -901,7 +901,7 @@ static void test_mf_SaveDC(void) SetPolyFillMode( hdcMetafile, WINDING ); SetBkColor( hdcMetafile, 0x123456 ); 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 */ SetPixelV(hdcMetafile, 50, 50, 0); diff --git a/include/ntgdi.h b/include/ntgdi.h index b5b8dbd5fdc..cb238b6eda1 100644 --- a/include/ntgdi.h +++ b/include/ntgdi.h @@ -99,6 +99,7 @@ enum typedef struct DC_ATTR { LONG disabled; /* disabled flag, controled by DCHF_(DISABLE|ENABLE)DC */ + COLORREF background_color; POINT cur_pos; INT graphics_mode; DWORD layout;