Alexandre Julliard : gdi32: Store foreground/ background color even when passed CLR_INVALID.
Alexandre Julliard
julliard at winehq.org
Thu Jan 12 13:19:23 CST 2012
Module: wine
Branch: master
Commit: f8fa169da0c8fd7aa75c3d87a6d7c5ba1625bf20
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f8fa169da0c8fd7aa75c3d87a6d7c5ba1625bf20
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Jan 12 15:51:54 2012 +0100
gdi32: Store foreground/background color even when passed CLR_INVALID.
---
dlls/gdi32/dc.c | 16 ++++------------
dlls/gdi32/tests/dc.c | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 12 deletions(-)
diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c
index b1065de..e4f31814 100644
--- a/dlls/gdi32/dc.c
+++ b/dlls/gdi32/dc.c
@@ -853,12 +853,8 @@ COLORREF WINAPI SetBkColor( HDC hdc, COLORREF color )
if (dc)
{
PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetBkColor );
- color = physdev->funcs->pSetBkColor( physdev, color );
- if (color != CLR_INVALID)
- {
- ret = dc->backgroundColor;
- dc->backgroundColor = color;
- }
+ ret = dc->backgroundColor;
+ dc->backgroundColor = physdev->funcs->pSetBkColor( physdev, color );
release_dc_ptr( dc );
}
return ret;
@@ -894,12 +890,8 @@ COLORREF WINAPI SetTextColor( HDC hdc, COLORREF color )
if (dc)
{
PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetTextColor );
- color = physdev->funcs->pSetTextColor( physdev, color );
- if (color != CLR_INVALID)
- {
- ret = dc->textColor;
- dc->textColor = color;
- }
+ ret = dc->textColor;
+ dc->textColor = physdev->funcs->pSetTextColor( physdev, color );
release_dc_ptr( dc );
}
return ret;
diff --git a/dlls/gdi32/tests/dc.c b/dlls/gdi32/tests/dc.c
index 25d6982..d8276f4 100644
--- a/dlls/gdi32/tests/dc.c
+++ b/dlls/gdi32/tests/dc.c
@@ -54,6 +54,41 @@ static void dump_region(HRGN hrgn)
HeapFree( GetProcessHeap(), 0, data );
}
+static void test_dc_values(void)
+{
+ HDC hdc = CreateDCA("DISPLAY", NULL, NULL, NULL);
+ COLORREF color;
+
+ ok( hdc != NULL, "CreateDC failed\n" );
+ color = SetBkColor( hdc, 0x12345678 );
+ ok( color == 0xffffff, "initial color %08x\n", color );
+ color = GetBkColor( hdc );
+ ok( color == 0x12345678, "wrong color %08x\n", color );
+ color = SetBkColor( hdc, 0xffffffff );
+ ok( color == 0x12345678, "wrong color %08x\n", color );
+ color = GetBkColor( hdc );
+ ok( color == 0xffffffff, "wrong color %08x\n", color );
+ color = SetBkColor( hdc, 0 );
+ ok( color == 0xffffffff, "wrong color %08x\n", color );
+ color = GetBkColor( hdc );
+ ok( color == 0, "wrong color %08x\n", color );
+
+ color = SetTextColor( hdc, 0xffeeddcc );
+ ok( color == 0, "initial color %08x\n", color );
+ color = GetTextColor( hdc );
+ ok( color == 0xffeeddcc, "wrong color %08x\n", color );
+ color = SetTextColor( hdc, 0xffffffff );
+ ok( color == 0xffeeddcc, "wrong color %08x\n", color );
+ color = GetTextColor( hdc );
+ ok( color == 0xffffffff, "wrong color %08x\n", color );
+ color = SetTextColor( hdc, 0 );
+ ok( color == 0xffffffff, "wrong color %08x\n", color );
+ color = GetTextColor( hdc );
+ ok( color == 0, "wrong color %08x\n", color );
+
+ DeleteDC( hdc );
+}
+
static void test_savedc_2(void)
{
HWND hwnd;
@@ -999,6 +1034,7 @@ static void test_printer_dc(void)
START_TEST(dc)
{
pSetLayout = (void *)GetProcAddress( GetModuleHandle("gdi32.dll"), "SetLayout");
+ test_dc_values();
test_savedc();
test_savedc_2();
test_GdiConvertToDevmodeW();
More information about the wine-cvs
mailing list