From: Jeff Smith whydoubt@gmail.com
Signed-off-by: Jeff Smith whydoubt@gmail.com Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- dlls/d3drm/tests/d3drm.c | 33 +++++++++++++++++++++++++++++++++ dlls/d3drm/viewport.c | 22 ++++++++++++++++++---- 2 files changed, 51 insertions(+), 4 deletions(-)
diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c index 403822cf93b..76d2dbe3949 100644 --- a/dlls/d3drm/tests/d3drm.c +++ b/dlls/d3drm/tests/d3drm.c @@ -1791,11 +1791,20 @@ static void test_Viewport(void) ok(device1 == d3drm_device1, "Expected device returned = %p, got %p.\n", device1, d3drm_device1); IDirect3DRMDevice_Release(d3drm_device1);
+ hr = IDirect3DRMViewport_SetCamera(viewport, NULL); + ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr); hr = IDirect3DRMViewport_GetCamera(viewport, &d3drm_frame); ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr); ok(frame == d3drm_frame, "Expected frame returned = %p, got %p.\n", frame, d3drm_frame); IDirect3DRMFrame_Release(d3drm_frame);
+ hr = IDirect3DRMViewport_SetCamera(viewport, tmp_frame1); + ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DRMViewport_GetCamera(viewport, &d3drm_frame); + ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr); + ok(d3drm_frame == tmp_frame1, "Got unexpected frame %p, expected %p.\n", d3drm_frame, tmp_frame1); + IDirect3DRMFrame_Release(d3drm_frame); + IDirect3DRMViewport_Release(viewport); ref4 = get_refcount((IUnknown *)d3drm1); ok(ref4 == ref1, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4); @@ -1826,11 +1835,20 @@ static void test_Viewport(void) ok(device1 == d3drm_device1, "Expected device returned = %p, got %p.\n", device1, d3drm_device1); IDirect3DRMDevice_Release(d3drm_device1);
+ hr = IDirect3DRMViewport_SetCamera(viewport, NULL); + ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr); hr = IDirect3DRMViewport_GetCamera(viewport, &d3drm_frame); ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr); ok(frame == d3drm_frame, "Expected frame returned = %p, got %p.\n", frame, d3drm_frame); IDirect3DRMFrame_Release(d3drm_frame);
+ hr = IDirect3DRMViewport_SetCamera(viewport, tmp_frame1); + ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DRMViewport_GetCamera(viewport, &d3drm_frame); + ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr); + ok(d3drm_frame == tmp_frame1, "Got unexpected frame %p, expected %p.\n", d3drm_frame, tmp_frame1); + IDirect3DRMFrame_Release(d3drm_frame); + IDirect3DRMViewport_Release(viewport); ref4 = get_refcount((IUnknown *)d3drm1); ok(ref4 == ref1, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4); @@ -1864,11 +1882,20 @@ static void test_Viewport(void) ok(device3 == d3drm_device3, "Expected device returned = %p, got %p.\n", device3, d3drm_device3); IDirect3DRMDevice3_Release(d3drm_device3);
+ hr = IDirect3DRMViewport2_SetCamera(viewport2, NULL); + ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr); hr = IDirect3DRMViewport2_GetCamera(viewport2, &d3drm_frame3); ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr); ok(frame3 == d3drm_frame3, "Expected frame returned = %p, got %p.\n", frame3, d3drm_frame3); IDirect3DRMFrame3_Release(d3drm_frame3);
+ hr = IDirect3DRMViewport2_SetCamera(viewport2, tmp_frame3); + ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DRMViewport2_GetCamera(viewport2, &d3drm_frame3); + ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr); + ok(d3drm_frame3 == tmp_frame3, "Got unexpected frame %p, expected %p.\n", d3drm_frame3, tmp_frame3); + IDirect3DRMFrame3_Release(d3drm_frame3); + IDirect3DRMViewport2_Release(viewport2); ref4 = get_refcount((IUnknown *)d3drm1); ok(ref4 == ref1, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4); @@ -2110,6 +2137,9 @@ static void test_Viewport(void) hr = IDirect3DRMViewport_GetCamera(viewport, &d3drm_frame); ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DRMViewport_SetCamera(viewport, frame); + ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr); + /* Test all failures together */ hr = IDirect3DRMViewport_Init(viewport, NULL, frame, rc.left, rc.top, rc.right, rc.bottom); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); @@ -2217,6 +2247,9 @@ static void test_Viewport(void) hr = IDirect3DRMViewport2_GetCamera(viewport2, &d3drm_frame3); ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr);
+ hr = IDirect3DRMViewport2_SetCamera(viewport2, frame3); + ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DRMViewport2_Init(viewport2, NULL, frame3, rc.left, rc.top, rc.right, rc.bottom); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); hr = IDirect3DRMViewport2_Init(viewport2, device3, NULL, rc.left, rc.top, rc.right, rc.bottom); diff --git a/dlls/d3drm/viewport.c b/dlls/d3drm/viewport.c index 833afb9b616..6da7d7e2889 100644 --- a/dlls/d3drm/viewport.c +++ b/dlls/d3drm/viewport.c @@ -556,16 +556,30 @@ static HRESULT WINAPI d3drm_viewport1_SetUniformScaling(IDirect3DRMViewport *ifa
static HRESULT WINAPI d3drm_viewport2_SetCamera(IDirect3DRMViewport2 *iface, IDirect3DRMFrame3 *camera) { - FIXME("iface %p, camera %p stub!\n", iface, camera); + struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface); + struct d3drm_frame *frame = unsafe_impl_from_IDirect3DRMFrame3(camera);
- return E_NOTIMPL; + TRACE("iface %p, camera %p.\n", iface, camera); + + if (!camera || !viewport->camera) + return D3DRMERR_BADOBJECT; + + IDirect3DRMFrame_AddRef(&frame->IDirect3DRMFrame_iface); + IDirect3DRMFrame_Release(viewport->camera); + viewport->camera = &frame->IDirect3DRMFrame_iface; + + return D3DRM_OK; }
static HRESULT WINAPI d3drm_viewport1_SetCamera(IDirect3DRMViewport *iface, IDirect3DRMFrame *camera) { - FIXME("iface %p, camera %p stub!\n", iface, camera); + struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface); + struct d3drm_frame *frame = unsafe_impl_from_IDirect3DRMFrame(camera);
- return E_NOTIMPL; + TRACE("iface %p, camera %p.\n", iface, camera); + + return d3drm_viewport2_SetCamera(&viewport->IDirect3DRMViewport2_iface, + frame ? &frame->IDirect3DRMFrame3_iface : NULL); }
static HRESULT WINAPI d3drm_viewport2_SetProjection(IDirect3DRMViewport2 *iface, D3DRMPROJECTIONTYPE type)