Giovanni Mascellani : d2d1: Implement D2D1Vec3Length().

Alexandre Julliard julliard at winehq.org
Mon Oct 26 16:59:42 CDT 2020


Module: wine
Branch: master
Commit: 4905921fa587bb6c194134da43827d4723bd64e3
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=4905921fa587bb6c194134da43827d4723bd64e3

Author: Giovanni Mascellani <wine at mascellani.eu>
Date:   Mon Oct 26 20:27:29 2020 +0330

d2d1: Implement D2D1Vec3Length().

Signed-off-by: Giovanni Mascellani <wine at mascellani.eu>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/d2d1/d2d1.spec    |  2 +-
 dlls/d2d1/factory.c    |  7 +++++++
 dlls/d2d1/tests/d2d1.c | 27 ++++++++++++++++++++++++++-
 include/d2d1_1.idl     |  1 +
 4 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/dlls/d2d1/d2d1.spec b/dlls/d2d1/d2d1.spec
index 7b624c7096e..0ae894109fb 100644
--- a/dlls/d2d1/d2d1.spec
+++ b/dlls/d2d1/d2d1.spec
@@ -8,4 +8,4 @@
 @ stub D2D1CreateDeviceContext
 @ stdcall D2D1SinCos(float ptr ptr)
 @ stdcall D2D1Tan(float)
-@ stub D2D1Vec3Length
+@ stdcall D2D1Vec3Length(float float float)
diff --git a/dlls/d2d1/factory.c b/dlls/d2d1/factory.c
index 9c5337590cd..6b6eab766c7 100644
--- a/dlls/d2d1/factory.c
+++ b/dlls/d2d1/factory.c
@@ -728,6 +728,13 @@ float WINAPI D2D1Tan(float angle)
     return tanf(angle);
 }
 
+float WINAPI D2D1Vec3Length(float x, float y, float z)
+{
+    TRACE("x %.8e, y %.8e, z %.8e.\n", x, y, 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 b269770365f..d571cfe8d15 100644
--- a/dlls/d2d1/tests/d2d1.c
+++ b/dlls/d2d1/tests/d2d1.c
@@ -9427,8 +9427,8 @@ static void test_wic_bitmap_format(void)
 
 static void test_math(void)
 {
+    float s, c, t, l;
     unsigned int i;
-    float s, c, t;
 
     static const struct
     {
@@ -9459,6 +9459,24 @@ static void test_math(void)
         {M_PI,         8.74227766e-008f},
     };
 
+    static const struct
+    {
+        float x;
+        float y;
+        float z;
+        float l;
+    }
+    l_data[] =
+    {
+        {0.0f, 0.0f, 0.0f, 0.0f},
+        {1.0f, 0.0f, 0.0f, 1.0f},
+        {0.0f, 1.0f, 0.0f, 1.0f},
+        {0.0f, 0.0f, 1.0f, 1.0f},
+        {1.0f, 1.0f, 1.0f, 1.73205078f},
+        {1.0f, 2.0f, 2.0f, 3.0f},
+        {1.0f, 2.0f, 3.0f, 3.74165750f},
+    };
+
     for (i = 0; i < ARRAY_SIZE(sc_data); ++i)
     {
         D2D1SinCos(sc_data[i].x, &s, &c);
@@ -9474,6 +9492,13 @@ static void test_math(void)
         ok(compare_float(t, t_data[i].t, 1),
                 "Test %u: Got unexpected tan %.8e, expected %.8e.\n", i, t, t_data[i].t);
     }
+
+    for (i = 0; i < ARRAY_SIZE(l_data); ++i)
+    {
+        l = D2D1Vec3Length(l_data[i].x, l_data[i].y, l_data[i].z);
+        ok(compare_float(l, l_data[i].l, 0),
+                "Test %u: Got unexpected length %.8e, expected %.8e.\n", i, l, l_data[i].l);
+    }
 }
 
 START_TEST(d2d1)
diff --git a/include/d2d1_1.idl b/include/d2d1_1.idl
index bd111bd6628..6eab3959cd1 100644
--- a/include/d2d1_1.idl
+++ b/include/d2d1_1.idl
@@ -796,3 +796,4 @@ interface ID2D1Factory1 : ID2D1Factory
         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);




More information about the wine-cvs mailing list