Signed-off-by: Giovanni Mascellani gio@debian.org --- dlls/d2d1/d2d1.spec | 6 ++--- dlls/d2d1/factory.c | 16 +++++++++++ dlls/d2d1/tests/d2d1.c | 61 ++++++++++++++++++++++++++++++++++++++++++ include/d2d1_1.idl | 3 +++ 4 files changed, 83 insertions(+), 3 deletions(-)
diff --git a/dlls/d2d1/d2d1.spec b/dlls/d2d1/d2d1.spec index 0ebcd0af553..0ae894109fb 100644 --- a/dlls/d2d1/d2d1.spec +++ b/dlls/d2d1/d2d1.spec @@ -6,6 +6,6 @@ @ stub D2D1ConvertColorSpace @ stdcall D2D1CreateDevice(ptr ptr ptr) @ stub D2D1CreateDeviceContext -@ stub D2D1SinCos -@ stub D2D1Tan -@ stub D2D1Vec3Length +@ stdcall D2D1SinCos(float ptr ptr) +@ stdcall D2D1Tan(float) +@ stdcall D2D1Vec3Length(float float float) diff --git a/dlls/d2d1/factory.c b/dlls/d2d1/factory.c index 2f50836bbcd..447b00fd2d8 100644 --- a/dlls/d2d1/factory.c +++ b/dlls/d2d1/factory.c @@ -713,6 +713,22 @@ HRESULT WINAPI D2D1CreateDevice(IDXGIDevice *dxgi_device, return hr; }
+void WINAPI D2D1SinCos(FLOAT angle, FLOAT *s, FLOAT *c) +{ + *s = sinf(angle); + *c = cosf(angle); +} + +FLOAT WINAPI D2D1Tan(FLOAT angle) +{ + return tanf(angle); +} + +FLOAT WINAPI D2D1Vec3Length(FLOAT x, FLOAT y, FLOAT z) +{ + return sqrtf(x*x + y*y + z*z); +} + static BOOL get_config_key_dword(HKEY default_key, HKEY application_key, const char *name, DWORD *value) { DWORD type, data, size; diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 166cdfccda6..e6be464162d 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -9425,6 +9425,66 @@ static void test_wic_bitmap_format(void) DestroyWindow(window); }
+static int compare_fp(FLOAT res, FLOAT exp) +{ + if (exp == 0.0f) + return fabsf(res) <= 10 * FLT_MIN; + else + return fabsf((res-exp) / exp) <= 10 * FLT_EPSILON; +} + +static void test_math(void) +{ + FLOAT s, c, t, l; + int i; + + static const FLOAT sc_data[] = + { + 0.0, 0.0, 1.0, + 1.0, 0.8414709568, 0.5403022766, + 2.0, 0.9092974067, -0.4161468446, + M_PI / 2.0, 1.0, -4.371138829e-008, + M_PI, -8.742277657e-008, -1.0, + }; + + static const FLOAT t_data[] = + { + 0.0, 0.0, + 1.0, 1.557407737, + 2.0, -2.185039759, + M_PI / 2.0, -22877332, + M_PI, 8.742277657e-008, + }; + + static const FLOAT l_data[] = + { + 0.0, 0.0, 0.0, 0.0, + 1.0, 0.0, 0.0, 1.0, + 0.0, 1.0, 0.0, 1.0, + 0.0, 0.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 1.732050776, + 1.0, 2.0, 2.0, 3.0, + 1.0, 2.0, 3.0, 3.741657495, + }; + + for (i = 0; i < sizeof(sc_data) / sizeof(sc_data[0]); i += 3) { + D2D1SinCos(sc_data[i], &s, &c); + ok(compare_fp(s, sc_data[i+1]), "Wrong sin(%.10g) (%.10g instead of %.10g).\n", sc_data[i], s, sc_data[i+1]); + ok(compare_fp(c, sc_data[i+2]), "Wrong cos(%.10g) (%.10g instead of %.10g).\n", sc_data[i], c, sc_data[i+2]); + } + + for (i = 0; i < sizeof(t_data) / sizeof(t_data[0]); i += 2) { + t = D2D1Tan(t_data[i]); + ok(compare_fp(t, t_data[i+1]), "Wrong tan(%.10g) (%.10g instead of %.10g).\n", t_data[i], t, t_data[i+1]); + } + + for (i = 0; i < sizeof(l_data) / sizeof(l_data[0]); i += 4) { + l = D2D1Vec3Length(l_data[i], l_data[i+1], l_data[i+2]); + ok(compare_fp(l, l_data[i+3]), "Wrong len(%.10g, %.10g, %.10g) (%.10g instead of %.10g).\n", + l_data[i], l_data[i+1], l_data[i+2], l, l_data[i+3]); + } +} + START_TEST(d2d1) { unsigned int argc, i; @@ -9477,6 +9537,7 @@ START_TEST(d2d1) queue_test(test_max_bitmap_size); queue_test(test_dpi); queue_test(test_wic_bitmap_format); + queue_test(test_math);
run_queued_tests(); } diff --git a/include/d2d1_1.idl b/include/d2d1_1.idl index ddb7669c24b..5a3178845ad 100644 --- a/include/d2d1_1.idl +++ b/include/d2d1_1.idl @@ -794,3 +794,6 @@ interface ID2D1Factory1 : ID2D1Factory
[local] HRESULT __stdcall D2D1CreateDevice(IDXGIDevice *dxgi_device, const D2D1_CREATION_PROPERTIES *creation_properties, ID2D1Device **device); +[local] void __stdcall D2D1SinCos(FLOAT angle, FLOAT *s, FLOAT *c); +[local] FLOAT __stdcall D2D1Tan(FLOAT angle); +[local] FLOAT __stdcall D2D1Vec3Length(FLOAT x, FLOAT y, FLOAT z);
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=80533
Your paranoid android.
=== w2008s64 (32 bit report) ===
d2d1: d2d1: Timeout
=== w2008s64 (64 bit report) ===
d2d1: d2d1: Timeout