[PATCH 05/12] d3drm: Implement frame AddTranslation

Jeff Smith whydoubt at gmail.com
Thu Jun 13 23:27:30 CDT 2019


Signed-off-by: Jeff Smith <whydoubt at gmail.com>
---
 dlls/d3drm/frame.c       | 50 ++++++++++++++++++++++++++++++++++++++++++------
 dlls/d3drm/tests/d3drm.c | 13 +++++++++++++
 2 files changed, 57 insertions(+), 6 deletions(-)

diff --git a/dlls/d3drm/frame.c b/dlls/d3drm/frame.c
index 5df85e4fe2..df8bd9b78b 100644
--- a/dlls/d3drm/frame.c
+++ b/dlls/d3drm/frame.c
@@ -1030,25 +1030,63 @@ static HRESULT WINAPI d3drm_frame1_AddTransform(IDirect3DRMFrame *iface,
 static HRESULT WINAPI d3drm_frame3_AddTranslation(IDirect3DRMFrame3 *iface,
         D3DRMCOMBINETYPE type, D3DVALUE x, D3DVALUE y, D3DVALUE z)
 {
-    FIXME("iface %p, type %#x, x %.8e, y %.8e, z %.8e stub!\n", iface, type, x, y, z);
+    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
 
-    return E_NOTIMPL;
+    TRACE("iface %p, type %#x, x %.8e, y %.8e, z %.8e.\n", iface, type, x, y, z);
+
+    switch (type)
+    {
+        case D3DRMCOMBINE_REPLACE:
+            memcpy(frame->transform, identity, sizeof(D3DRMMATRIX4D));
+            frame->transform[3][0] = x;
+            frame->transform[3][1] = y;
+            frame->transform[3][2] = z;
+            break;
+
+        case D3DRMCOMBINE_BEFORE:
+            frame->transform[3][0] += frame->transform[0][0] * x +
+                                      frame->transform[1][0] * y +
+                                      frame->transform[2][0] * z;
+            frame->transform[3][1] += frame->transform[0][1] * x +
+                                      frame->transform[1][1] * y +
+                                      frame->transform[2][1] * z;
+            frame->transform[3][2] += frame->transform[0][2] * x +
+                                      frame->transform[1][2] * y +
+                                      frame->transform[2][2] * z;
+            break;
+
+        case D3DRMCOMBINE_AFTER:
+            frame->transform[3][0] += x;
+            frame->transform[3][1] += y;
+            frame->transform[3][2] += z;
+            break;
+
+        default:
+            WARN("Unknown Combine Type %u\n", type);
+            return D3DRMERR_BADVALUE;
+    }
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm_frame2_AddTranslation(IDirect3DRMFrame2 *iface,
         D3DRMCOMBINETYPE type, D3DVALUE x, D3DVALUE y, D3DVALUE z)
 {
-    FIXME("iface %p, type %#x, x %.8e, y %.8e, z %.8e stub!\n", iface, type, x, y, z);
+    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
 
-    return E_NOTIMPL;
+    TRACE("iface %p, type %#x, x %.8e, y %.8e, z %.8e.\n", iface, type, x, y, z);
+
+    return d3drm_frame3_AddTranslation(&frame->IDirect3DRMFrame3_iface, type, x, y, z);
 }
 
 static HRESULT WINAPI d3drm_frame1_AddTranslation(IDirect3DRMFrame *iface,
         D3DRMCOMBINETYPE type, D3DVALUE x, D3DVALUE y, D3DVALUE z)
 {
-    FIXME("iface %p, type %#x, x %.8e, y %.8e, z %.8e stub!\n", iface, type, x, y, z);
+    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);
 
-    return E_NOTIMPL;
+    TRACE("iface %p, type %#x, x %.8e, y %.8e, z %.8e.\n", iface, type, x, y, z);
+
+    return d3drm_frame3_AddTranslation(&frame->IDirect3DRMFrame3_iface, type, x, y, z);
 }
 
 static HRESULT WINAPI d3drm_frame3_AddScale(IDirect3DRMFrame3 *iface,
diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c
index e9e789823c..335e0a4f2d 100644
--- a/dlls/d3drm/tests/d3drm.c
+++ b/dlls/d3drm/tests/d3drm.c
@@ -2857,6 +2857,19 @@ static void test_frame_transform(void)
     ok(hr == D3DRMERR_BADVALUE, "AddTransform: BADVALUE error expected when last column != [0 0 0 1]\n");
 
 
+    SET_TRANSFORM(frame, 2,0,0, 0,2,0, 0,0,2, 0,0,0);
+    hr = IDirect3DRMFrame_AddTranslation(frame, D3DRMCOMBINE_REPLACE, 3.0f, 3.0f, 3.0f);
+    EXPECT_TRANSFORM("AddTranslation (REPLACE)", frame, 1,0,0, 0,1,0, 0,0,1, 3,3,3);
+
+    SET_TRANSFORM(frame, 2,0,0, 0,2,0, 0,0,2, 0,0,0);
+    hr = IDirect3DRMFrame_AddTranslation(frame, D3DRMCOMBINE_BEFORE, 3.0f, 3.0f, 3.0f);
+    EXPECT_TRANSFORM("AddTranslation (BEFORE)", frame, 2,0,0, 0,2,0, 0,0,2, 6,6,6);
+
+    SET_TRANSFORM(frame, 2,0,0, 0,2,0, 0,0,2, 0,0,0);
+    hr = IDirect3DRMFrame_AddTranslation(frame, D3DRMCOMBINE_AFTER, 3.0f, 3.0f, 3.0f);
+    EXPECT_TRANSFORM("AddTranslation (AFTER)", frame, 2,0,0, 0,2,0, 0,0,2, 3,3,3);
+
+
     IDirect3DRMFrame_Release(subframe);
     IDirect3DRMFrame_Release(frame);
     IDirect3DRM_Release(d3drm);
-- 
2.14.3




More information about the wine-devel mailing list