[PATCH v2 6/6] d3drm: Implement frame Transform
Jeff Smith
whydoubt at gmail.com
Mon Jun 17 20:21:04 CDT 2019
Signed-off-by: Jeff Smith <whydoubt at gmail.com>
---
dlls/d3drm/frame.c | 33 +++++++++++++++++++++++++++------
dlls/d3drm/tests/d3drm.c | 25 ++++++++++++++++++++++++-
2 files changed, 51 insertions(+), 7 deletions(-)
diff --git a/dlls/d3drm/frame.c b/dlls/d3drm/frame.c
index 10aebb704e..a97143cd37 100644
--- a/dlls/d3drm/frame.c
+++ b/dlls/d3drm/frame.c
@@ -1717,6 +1717,13 @@ static HRESULT WINAPI d3drm_frame1_GetTextureTopology(IDirect3DRMFrame *iface, B
return E_NOTIMPL;
}
+static void transform_affine(D3DVECTOR *d, D3DVALUE *s, D3DRMMATRIX4D m)
+{
+ d->u1.x = s->u1.x * m[0][0] + s->u2.y * m[1][0] + s->u3.z * m[2][0] + m[3][0];
+ d->u2.y = s->u1.x * m[0][1] + s->u2.y * m[1][1] + s->u3.z * m[2][1] + m[3][1];
+ d->u3.z = s->u1.x * m[0][2] + s->u2.y * m[1][2] + s->u3.z * m[2][2] + m[3][2];
+}
+
static HRESULT WINAPI d3drm_frame3_InverseTransform(IDirect3DRMFrame3 *iface, D3DVECTOR *d, D3DVECTOR *s)
{
FIXME("iface %p, d %p, s %p stub!\n", iface, d, s);
@@ -2588,23 +2595,37 @@ static HRESULT WINAPI d3drm_frame1_SetZbufferMode(IDirect3DRMFrame *iface, D3DRM
static HRESULT WINAPI d3drm_frame3_Transform(IDirect3DRMFrame3 *iface, D3DVECTOR *d, D3DVECTOR *s)
{
- FIXME("iface %p, d %p, s %p stub!\n", iface, d, s);
+ struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
- return E_NOTIMPL;
+ TRACE("iface %p, d %p, s %p.\n", iface, d, s);
+
+ transform_affine(d, s, frame->transform);
+ while ((frame = frame->parent))
+ {
+ D3DVECTOR temp;
+ memcpy(&temp, d, sizeof(D3DVECTOR));
+ transform_affine(d, &temp, frame->transform);
+ }
+
+ return D3DRM_OK;
}
static HRESULT WINAPI d3drm_frame2_Transform(IDirect3DRMFrame2 *iface, D3DVECTOR *d, D3DVECTOR *s)
{
- FIXME("iface %p, d %p, s %p stub!\n", iface, d, s);
+ struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
- return E_NOTIMPL;
+ TRACE("iface %p, d %p, s %p.\n", iface, d, s);
+
+ return d3drm_frame3_Transform(&frame->IDirect3DRMFrame3_iface, d, s);
}
static HRESULT WINAPI d3drm_frame1_Transform(IDirect3DRMFrame *iface, D3DVECTOR *d, D3DVECTOR *s)
{
- FIXME("iface %p, d %p, s %p stub!\n", iface, d, s);
+ struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);
- return E_NOTIMPL;
+ TRACE("iface %p, d %p, s %p.\n", iface, d, s);
+
+ return d3drm_frame3_Transform(&frame->IDirect3DRMFrame3_iface, d, s);
}
static HRESULT WINAPI d3drm_frame2_AddMoveCallback2(IDirect3DRMFrame2 *iface,
diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c
index 71dbe7793c..a52d102a9a 100644
--- a/dlls/d3drm/tests/d3drm.c
+++ b/dlls/d3drm/tests/d3drm.c
@@ -2749,6 +2749,13 @@ static void set_transform(IDirect3DRMFrame *frame,
IDirect3DRMFrame_AddTransform(frame, D3DRMCOMBINE_REPLACE, matrix);
}
+static void set_vector(D3DVECTOR *vector, D3DVALUE vx, D3DVALUE vy, D3DVALUE vz)
+{
+ vector->x = vx;
+ vector->y = vy;
+ vector->z = vz;
+}
+
static void sanitize_matrix(D3DRMMATRIX4D m)
{
int i, j;
@@ -2767,8 +2774,9 @@ static void test_frame_transform(void)
{
HRESULT hr;
IDirect3DRM *d3drm;
- IDirect3DRMFrame *frame;
+ IDirect3DRMFrame *frame, *subframe;
D3DRMMATRIX4D matrix, add_matrix;
+ D3DVECTOR v1, v2;
hr = Direct3DRMCreate(&d3drm);
ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
@@ -2881,6 +2889,21 @@ static void test_frame_transform(void)
check_matrix(matrix, 1,0,0, 0,0,1, 0,-1,0, 0,0,0, 32);
+ set_transform(frame, 2,0,0, 0,4,0, 0,0,8, 64,64,64);
+ IDirect3DRM_CreateFrame(d3drm, frame, &subframe);
+ set_transform(subframe, 1,0,0, 0,1,0, 0,0,1, 11,11,11);
+ set_vector(&v1, 3,5,7);
+
+ hr = IDirect3DRMFrame_Transform(frame, &v2, &v1);
+ ok(hr == D3DRM_OK, "Cannot transform (hr = %x)", hr);
+ check_vector(&v2, 70,84,120, 32);
+
+ hr = IDirect3DRMFrame_Transform(subframe, &v2, &v1);
+ ok(hr == D3DRM_OK, "Cannot transform subframe (hr = %x)", hr);
+ check_vector(&v2, 92,128,208, 32);
+
+
+ IDirect3DRMFrame_Release(subframe);
IDirect3DRMFrame_Release(frame);
IDirect3DRM_Release(d3drm);
}
--
2.14.3
More information about the wine-devel
mailing list