Signed-off-by: Jeff Smith whydoubt@gmail.com --- dlls/d3drm/tests/d3drm.c | 33 +++++++++++++++++++++++-- dlls/d3drm/viewport.c | 52 +++++++++++++++++++++++++++++++++------- 2 files changed, 75 insertions(+), 10 deletions(-)
diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c index 9811224f46..32204142a7 100644 --- a/dlls/d3drm/tests/d3drm.c +++ b/dlls/d3drm/tests/d3drm.c @@ -1719,8 +1719,8 @@ static void test_Viewport(void) IDirect3DRM3 *d3drm3; IDirect3DRMDevice *device1, *d3drm_device1; IDirect3DRMDevice3 *device3, *d3drm_device3; - IDirect3DRMFrame *frame; - IDirect3DRMFrame3 *frame3; + IDirect3DRMFrame *frame, *d3drm_frame; + IDirect3DRMFrame3 *frame3, *d3drm_frame3; IDirect3DRMViewport *viewport; IDirect3DRMViewport2 *viewport2; IDirect3DViewport *d3d_viewport; @@ -1789,6 +1789,11 @@ 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_GetCamera(viewport, &d3drm_frame); + ok(SUCCEEDED(hr), "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr); + ok(frame == d3drm_frame, "Expected frame returned = %p, got %p.\n", frame, d3drm_frame); + 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); @@ -1820,6 +1825,11 @@ 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_GetCamera(viewport, &d3drm_frame); + ok(SUCCEEDED(hr), "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr); + ok(frame == d3drm_frame, "Expected frame returned = %p, got %p.\n", frame, d3drm_frame); + 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); @@ -1854,6 +1864,11 @@ 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_GetCamera(viewport2, &d3drm_frame3); + ok(SUCCEEDED(hr), "Cannot get IDirect3DRMFrame3 interface (hr = %x)\n", hr); + ok(frame3 == d3drm_frame3, "Expected frame returned = %p, got %p.\n", frame3, d3drm_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); @@ -2099,6 +2114,11 @@ static void test_Viewport(void) ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); hr = IDirect3DRMViewport_GetDevice(viewport, &d3drm_device1); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); + hr = IDirect3DRMViewport_GetCamera(viewport, &d3drm_frame); + ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); + + hr = IDirect3DRMViewport_SetCamera(viewport, frame); + ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
/* ... test Init failure */ hr = IDirect3DRMViewport_Init(viewport, NULL, frame, rc.left, rc.top, rc.right, rc.bottom); @@ -2171,6 +2191,8 @@ static void test_Viewport(void) ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); hr = IDirect3DRMViewport_GetDirect3DViewport(viewport, NULL); ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); + hr = IDirect3DRMViewport_GetCamera(viewport, NULL); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); hr = IDirect3DRMViewport_SetField(viewport, 0.0f); ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); hr = IDirect3DRMViewport_SetField(viewport, -1.0f); @@ -2207,6 +2229,11 @@ static void test_Viewport(void) ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); hr = IDirect3DRMViewport2_GetDevice(viewport2, &d3drm_device3); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); + hr = IDirect3DRMViewport2_GetCamera(viewport2, &d3drm_frame3); + ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); + + hr = IDirect3DRMViewport2_SetCamera(viewport2, frame3); + ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
/* ... test Init failure */ hr = IDirect3DRMViewport2_Init(viewport2, NULL, frame3, rc.left, rc.top, rc.right, rc.bottom); @@ -2273,6 +2300,8 @@ static void test_Viewport(void) ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); hr = IDirect3DRMViewport2_GetDirect3DViewport(viewport2, NULL); ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); + hr = IDirect3DRMViewport2_GetCamera(viewport2, NULL); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); hr = IDirect3DRMViewport2_SetField(viewport2, 0.0f); ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); hr = IDirect3DRMViewport2_SetField(viewport2, -1.0f); diff --git a/dlls/d3drm/viewport.c b/dlls/d3drm/viewport.c index c2fa189742..a6ad4ea595 100644 --- a/dlls/d3drm/viewport.c +++ b/dlls/d3drm/viewport.c @@ -556,16 +556,29 @@ 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); + HRESULT hr;
- return E_NOTIMPL; + TRACE("iface %p, camera %p.\n", iface, camera); + + if (!viewport->camera) + return D3DRMERR_BADOBJECT; + + IDirect3DRMFrame_Release(viewport->camera); + if (FAILED(hr = IDirect3DRMFrame3_QueryInterface(camera, &IID_IDirect3DRMFrame, (void **)&viewport->camera))) + return hr; + + 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->IDirect3DRMFrame3_iface); }
static HRESULT WINAPI d3drm_viewport2_SetProjection(IDirect3DRMViewport2 *iface, D3DRMPROJECTIONTYPE type) @@ -668,16 +681,39 @@ static HRESULT WINAPI d3drm_viewport1_SetPlane(IDirect3DRMViewport *iface,
static HRESULT WINAPI d3drm_viewport2_GetCamera(IDirect3DRMViewport2 *iface, IDirect3DRMFrame3 **camera) { - FIXME("iface %p, camera %p stub!\n", iface, camera); + struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface); + HRESULT hr;
- return E_NOTIMPL; + TRACE("iface %p, camera %p.\n", iface, camera); + + if (!camera) + return D3DRMERR_BADVALUE; + + if (!viewport->camera) + return D3DRMERR_BADOBJECT; + + if (FAILED(hr = IDirect3DRMFrame_QueryInterface(viewport->camera, &IID_IDirect3DRMFrame3, (void **)camera))) + return hr; + + return D3DRM_OK; }
static HRESULT WINAPI d3drm_viewport1_GetCamera(IDirect3DRMViewport *iface, IDirect3DRMFrame **camera) { - FIXME("iface %p, camera %p stub!\n", iface, camera); + struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
- return E_NOTIMPL; + TRACE("iface %p, camera %p.\n", iface, camera); + + if (!camera) + return D3DRMERR_BADVALUE; + + if (!viewport->camera) + return D3DRMERR_BADOBJECT; + + *camera = viewport->camera; + IDirect3DRMFrame_AddRef(*camera); + + return D3DRM_OK; }
static HRESULT WINAPI d3drm_viewport2_GetDevice(IDirect3DRMViewport2 *iface, IDirect3DRMDevice3 **device)