Module: wine Branch: master Commit: 301b5d27726c0cf883ad3ff4805ec064fa22305d URL: http://source.winehq.org/git/wine.git/?a=commit;h=301b5d27726c0cf883ad3ff480...
Author: Dmitry Timoshkov dmitry@codeweavers.com Date: Mon Apr 6 17:16:34 2009 +0900
gdi32: Add a couple of SetGraphicsMode/SetWorldTransform tests, make them pass under Wine.
---
dlls/gdi32/dc.c | 9 +++++++-- dlls/gdi32/tests/mapping.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c index 4d10f22..aa8fbc5 100644 --- a/dlls/gdi32/dc.c +++ b/dlls/gdi32/dc.c @@ -1200,10 +1200,12 @@ BOOL WINAPI GetTransform( HDC hdc, DWORD unknown, LPXFORM xform ) BOOL WINAPI SetWorldTransform( HDC hdc, const XFORM *xform ) { BOOL ret = FALSE; - DC *dc = get_dc_ptr( hdc ); + DC *dc; + + if (!xform) return FALSE;
+ dc = get_dc_ptr( hdc ); if (!dc) return FALSE; - if (!xform) goto done;
/* Check that graphics mode is GM_ADVANCED */ if (dc->GraphicsMode!=GM_ADVANCED) goto done; @@ -1211,6 +1213,9 @@ BOOL WINAPI SetWorldTransform( HDC hdc, const XFORM *xform ) TRACE("eM11 %f eM12 %f eM21 %f eM22 %f eDx %f eDy %f\n", xform->eM11, xform->eM12, xform->eM21, xform->eM22, xform->eDx, xform->eDy);
+ /* The transform must conform to (eM11 * eM22 != eM12 * eM21) requirement */ + if (xform->eM11 * xform->eM22 == xform->eM12 * xform->eM21) goto done; + if (dc->funcs->pSetWorldTransform) { ret = dc->funcs->pSetWorldTransform(dc->physDev, xform); diff --git a/dlls/gdi32/tests/mapping.c b/dlls/gdi32/tests/mapping.c index f3a92e5..ffb92cb 100644 --- a/dlls/gdi32/tests/mapping.c +++ b/dlls/gdi32/tests/mapping.c @@ -85,6 +85,15 @@ static void test_world_transform(void)
hdc = CreateCompatibleDC(0);
+ xform.eM11 = 1.0f; + xform.eM12 = 0.0f; + xform.eM21 = 0.0f; + xform.eM22 = 1.0f; + xform.eDx = 0.0f; + xform.eDy = 0.0f; + ret = SetWorldTransform(hdc, &xform); + ok(!ret, "SetWorldTransform should fail in GM_COMPATIBLE mode\n"); + size_cx = GetDeviceCaps(hdc, HORZSIZE); size_cy = GetDeviceCaps(hdc, VERTSIZE); res_x = GetDeviceCaps(hdc, HORZRES); @@ -144,6 +153,16 @@ static void test_world_transform(void) expect_world_trasform(hdc, 1.0, 1.0); expect_LPtoDP(hdc, 1000, 1000);
+ /* The transform must conform to (eM11 * eM22 != eM12 * eM21) requirement */ + xform.eM11 = 1.0f; + xform.eM12 = 2.0f; + xform.eM21 = 1.0f; + xform.eM22 = 2.0f; + xform.eDx = 0.0f; + xform.eDy = 0.0f; + ret = SetWorldTransform(hdc, &xform); + ok(!ret, "SetWorldTransform should fail with an invalid xform\n"); + xform.eM11 = 20.0f; xform.eM12 = 0.0f; xform.eM21 = 0.0f; @@ -183,6 +202,16 @@ static void test_world_transform(void) expect_world_trasform(hdc, 20.0, 20.0); expect_LPtoDP(hdc, 20000, 20000);
+ ret = SetGraphicsMode(hdc, GM_COMPATIBLE); + ok(ret, "SetGraphicsMode(GM_COMPATIBLE) should not fail if DC has't an identity transform\n"); + ret = GetGraphicsMode(hdc); + ok(ret == GM_COMPATIBLE, "expected GM_COMPATIBLE, got %d\n", ret); + + expect_viewport_ext(hdc, 1, 1); + expect_window_ext(hdc, 1, 1); + expect_world_trasform(hdc, 20.0, 20.0); + expect_LPtoDP(hdc, 20000, 20000); + DeleteDC(hdc); }