[PATCH v2 3/6] d3drm: Implement frame AddTranslation

Jeff Smith whydoubt at gmail.com
Mon Jun 17 20:21:01 CDT 2019


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

diff --git a/dlls/d3drm/frame.c b/dlls/d3drm/frame.c
index ed1e6c719f..7bb848b4c6 100644
--- a/dlls/d3drm/frame.c
+++ b/dlls/d3drm/frame.c
@@ -1015,25 +1015,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 e91b1ddee6..22869e57c5 100644
--- a/dlls/d3drm/tests/d3drm.c
+++ b/dlls/d3drm/tests/d3drm.c
@@ -2795,6 +2795,25 @@ static void test_frame_transform(void)
     ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
 
 
+    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);
+    ok(hr == D3DRM_OK, "Cannot add translation (REPLACE) (hr = %x)", hr);
+    IDirect3DRMFrame_GetTransform(frame, matrix);
+    check_matrix(matrix, 1,0,0, 0,1,0, 0,0,1, 3,3,3, 32);
+
+    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);
+    ok(hr == D3DRM_OK, "Cannot add translation (BEFORE) (hr = %x)", hr);
+    IDirect3DRMFrame_GetTransform(frame, matrix);
+    check_matrix(matrix, 2,0,0, 0,2,0, 0,0,2, 6,6,6, 32);
+
+    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);
+    ok(hr == D3DRM_OK, "Cannot add translation (AFTER) (hr = %x)", hr);
+    IDirect3DRMFrame_GetTransform(frame, matrix);
+    check_matrix(matrix, 2,0,0, 0,2,0, 0,0,2, 3,3,3, 32);
+
+
     IDirect3DRMFrame_Release(frame);
     IDirect3DRM_Release(d3drm);
 }
-- 
2.14.3




More information about the wine-devel mailing list