d3drm: Implement IDirect3DRMViewport::GetDirect3DViewport.

Signed-off-by: Aaryaman Vasishta <jem456.vasishta@gmail.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Aaryaman Vasishta 2016-07-28 22:48:49 +05:30 committed by Alexandre Julliard
parent 202df3e1ec
commit c17fd6a859
2 changed files with 80 additions and 5 deletions

View File

@ -1474,12 +1474,13 @@ static void test_Viewport(void)
IDirect3DRMFrame3 *frame3; IDirect3DRMFrame3 *frame3;
IDirect3DRMViewport *viewport; IDirect3DRMViewport *viewport;
IDirect3DRMViewport2 *viewport2; IDirect3DRMViewport2 *viewport2;
IDirect3DViewport *d3d_viewport;
IDirect3DRMObject *obj, *obj2; IDirect3DRMObject *obj, *obj2;
GUID driver; GUID driver;
HWND window; HWND window;
RECT rc; RECT rc;
DWORD size, data, ref1, ref2, ref3, ref4; DWORD size, data, ref1, ref2, ref3, ref4;
DWORD initial_ref1, initial_ref2, initial_ref3, device_ref, frame_ref, frame_ref2; DWORD initial_ref1, initial_ref2, initial_ref3, device_ref, frame_ref, frame_ref2, viewport_ref;
CHAR cname[64] = {0}; CHAR cname[64] = {0};
window = CreateWindowA("static", "d3drm_test", WS_OVERLAPPEDWINDOW, 0, 0, 300, 200, 0, 0, 0, 0); window = CreateWindowA("static", "d3drm_test", WS_OVERLAPPEDWINDOW, 0, 0, 300, 200, 0, 0, 0, 0);
@ -1638,13 +1639,47 @@ static void test_Viewport(void)
hr = IDirect3DRM2_CreateViewport(d3drm2, device1, frame, rc.left, rc.top, rc.right, rc.bottom, &viewport); hr = IDirect3DRM2_CreateViewport(d3drm2, device1, frame, rc.left, rc.top, rc.right, rc.bottom, &viewport);
ok(hr == D3DRM_OK, "Cannot get IDirect3DRMViewport interface (hr = %#x)\n", hr); ok(hr == D3DRM_OK, "Cannot get IDirect3DRMViewport interface (hr = %#x)\n", hr);
hr = IDirect3DRMViewport_GetDirect3DViewport(viewport, &d3d_viewport);
ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr);
viewport_ref = get_refcount((IUnknown *)d3d_viewport);
hr = IDirect3DRMViewport_GetDirect3DViewport(viewport, &d3d_viewport);
ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr);
ref4 = get_refcount((IUnknown *)d3d_viewport);
ok(ref4 > viewport_ref, "Expected ref4 > viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4, viewport_ref);
IDirect3DViewport_Release(d3d_viewport);
ref4 = get_refcount((IUnknown *)d3d_viewport);
ok(ref4 == viewport_ref, "Expected ref4 == viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4, viewport_ref);
IDirect3DViewport_Release(d3d_viewport);
IDirect3DRMViewport_Release(viewport); IDirect3DRMViewport_Release(viewport);
hr = IDirect3DRM3_CreateViewport(d3drm3, device3, frame3, rc.left, rc.top, rc.right, rc.bottom, &viewport2); hr = IDirect3DRM3_CreateViewport(d3drm3, device3, frame3, rc.left, rc.top, rc.right, rc.bottom, &viewport2);
ok(hr == D3DRM_OK, "Cannot get IDirect3DRMViewport2 interface (hr = %#x)\n", hr); ok(hr == D3DRM_OK, "Cannot get IDirect3DRMViewport2 interface (hr = %#x)\n", hr);
hr = IDirect3DRMViewport2_GetDirect3DViewport(viewport2, &d3d_viewport);
ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr);
viewport_ref = get_refcount((IUnknown *)d3d_viewport);
hr = IDirect3DRMViewport2_GetDirect3DViewport(viewport2, &d3d_viewport);
ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr);
ref4 = get_refcount((IUnknown *)d3d_viewport);
ok(ref4 > viewport_ref, "Expected ref4 > viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4, viewport_ref);
IDirect3DViewport_Release(d3d_viewport);
ref4 = get_refcount((IUnknown *)d3d_viewport);
ok(ref4 == viewport_ref, "Expected ref4 == viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4, viewport_ref);
IDirect3DViewport_Release(d3d_viewport);
IDirect3DRMViewport2_Release(viewport2); IDirect3DRMViewport2_Release(viewport2);
hr = IDirect3DRM_CreateViewport(d3drm1, device1, frame, rc.left, rc.top, rc.right, rc.bottom, &viewport); hr = IDirect3DRM_CreateViewport(d3drm1, device1, frame, rc.left, rc.top, rc.right, rc.bottom, &viewport);
ok(hr == D3DRM_OK, "Cannot get IDirect3DRMViewport interface (hr = %x)\n", hr); ok(hr == D3DRM_OK, "Cannot get IDirect3DRMViewport interface (hr = %x)\n", hr);
hr = IDirect3DRMViewport_GetDirect3DViewport(viewport, &d3d_viewport);
ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr);
viewport_ref = get_refcount((IUnknown *)d3d_viewport);
hr = IDirect3DRMViewport_GetDirect3DViewport(viewport, &d3d_viewport);
ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr);
ref4 = get_refcount((IUnknown *)d3d_viewport);
ok(ref4 > viewport_ref, "Expected ref4 > viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4, viewport_ref);
IDirect3DViewport_Release(d3d_viewport);
ref4 = get_refcount((IUnknown *)d3d_viewport);
ok(ref4 == viewport_ref, "Expected ref4 == viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4, viewport_ref);
IDirect3DViewport_Release(d3d_viewport);
hr = IDirect3DRMViewport_QueryInterface(viewport, &IID_IDirect3DRMObject, (void**)&obj); hr = IDirect3DRMViewport_QueryInterface(viewport, &IID_IDirect3DRMObject, (void**)&obj);
ok(hr == D3DRM_OK, "expected D3DRM_OK (hr = %x)\n", hr); ok(hr == D3DRM_OK, "expected D3DRM_OK (hr = %x)\n", hr);
@ -1710,6 +1745,9 @@ static void test_Viewport(void)
ref4 = get_refcount((IUnknown *)d3drm3); ref4 = get_refcount((IUnknown *)d3drm3);
ok(ref4 == ref3, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3, ref4); ok(ref4 == ref3, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3, ref4);
hr = IDirect3DRMViewport_GetDirect3DViewport(viewport, &d3d_viewport);
ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
/* Test all failures together */ /* Test all failures together */
hr = IDirect3DRMViewport_Init(viewport, NULL, frame, rc.left, rc.top, rc.right, rc.bottom); 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); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
@ -1737,6 +1775,18 @@ static void test_Viewport(void)
ref4 = get_refcount((IUnknown *)frame); ref4 = get_refcount((IUnknown *)frame);
ok(ref4 > frame_ref, "Expected ref4 > frame_ref, got frame_ref = %u, ref4 = %u.\n", frame_ref, ref4); ok(ref4 > frame_ref, "Expected ref4 > frame_ref, got frame_ref = %u, ref4 = %u.\n", frame_ref, ref4);
hr = IDirect3DRMViewport_GetDirect3DViewport(viewport, &d3d_viewport);
ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr);
viewport_ref = get_refcount((IUnknown *)d3d_viewport);
hr = IDirect3DRMViewport_GetDirect3DViewport(viewport, &d3d_viewport);
ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr);
ref4 = get_refcount((IUnknown *)d3d_viewport);
ok(ref4 > viewport_ref, "Expected ref4 > viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4, viewport_ref);
IDirect3DViewport_Release(d3d_viewport);
ref4 = get_refcount((IUnknown *)d3d_viewport);
ok(ref4 == viewport_ref, "Expected ref4 == viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4, viewport_ref);
IDirect3DViewport_Release(d3d_viewport);
hr = IDirect3DRMViewport_Init(viewport, device1, frame, rc.left, rc.top, rc.right, rc.bottom); hr = IDirect3DRMViewport_Init(viewport, device1, frame, rc.left, rc.top, rc.right, rc.bottom);
ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
@ -1765,6 +1815,9 @@ static void test_Viewport(void)
ref4 = get_refcount((IUnknown *)d3drm3); ref4 = get_refcount((IUnknown *)d3drm3);
ok(ref4 == ref3, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3, ref4); ok(ref4 == ref3, "Expected ref4 == ref3, got ref3 = %u, ref4 = %u.\n", ref3, ref4);
hr = IDirect3DRMViewport2_GetDirect3DViewport(viewport2, &d3d_viewport);
ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
hr = IDirect3DRMViewport2_Init(viewport2, NULL, frame3, rc.left, rc.top, rc.right, rc.bottom); 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); 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); hr = IDirect3DRMViewport2_Init(viewport2, device3, NULL, rc.left, rc.top, rc.right, rc.bottom);
@ -1785,6 +1838,18 @@ static void test_Viewport(void)
ref4 = get_refcount((IUnknown *)frame3); ref4 = get_refcount((IUnknown *)frame3);
ok(ref4 > frame_ref2, "Expected ref4 > frame_ref2, got frame_ref2 = %u, ref4 = %u.\n", frame_ref2, ref4); ok(ref4 > frame_ref2, "Expected ref4 > frame_ref2, got frame_ref2 = %u, ref4 = %u.\n", frame_ref2, ref4);
hr = IDirect3DRMViewport2_GetDirect3DViewport(viewport2, &d3d_viewport);
ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr);
viewport_ref = get_refcount((IUnknown *)d3d_viewport);
hr = IDirect3DRMViewport2_GetDirect3DViewport(viewport2, &d3d_viewport);
ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr);
ref4 = get_refcount((IUnknown *)d3d_viewport);
ok(ref4 > viewport_ref, "Expected ref4 > viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4, viewport_ref);
IDirect3DViewport_Release(d3d_viewport);
ref4 = get_refcount((IUnknown *)d3d_viewport);
ok(ref4 == viewport_ref, "Expected ref4 == viewport_ref, got ref4 = %u, viewport_ref = %u.\n", ref4, viewport_ref);
IDirect3DViewport_Release(d3d_viewport);
hr = IDirect3DRMViewport2_Init(viewport2, device3, frame3, rc.left, rc.top, rc.right, rc.bottom); hr = IDirect3DRMViewport2_Init(viewport2, device3, frame3, rc.left, rc.top, rc.right, rc.bottom);
ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);

View File

@ -825,17 +825,27 @@ static D3DRMPROJECTIONTYPE WINAPI d3drm_viewport1_GetProjection(IDirect3DRMViewp
static HRESULT WINAPI d3drm_viewport2_GetDirect3DViewport(IDirect3DRMViewport2 *iface, static HRESULT WINAPI d3drm_viewport2_GetDirect3DViewport(IDirect3DRMViewport2 *iface,
IDirect3DViewport **viewport) IDirect3DViewport **viewport)
{ {
FIXME("iface %p, viewport %p stub!\n", iface, viewport); struct d3drm_viewport *viewport_object = impl_from_IDirect3DRMViewport2(iface);
return E_NOTIMPL; TRACE("iface %p, viewport %p.\n", iface, viewport);
if (!viewport_object->d3d_viewport)
return D3DRMERR_BADOBJECT;
*viewport = viewport_object->d3d_viewport;
IDirect3DViewport_AddRef(*viewport);
return D3DRM_OK;
} }
static HRESULT WINAPI d3drm_viewport1_GetDirect3DViewport(IDirect3DRMViewport *iface, static HRESULT WINAPI d3drm_viewport1_GetDirect3DViewport(IDirect3DRMViewport *iface,
IDirect3DViewport **viewport) IDirect3DViewport **viewport)
{ {
FIXME("iface %p, viewport %p stub!\n", iface, viewport); struct d3drm_viewport *viewport_object = impl_from_IDirect3DRMViewport(iface);
return E_NOTIMPL; TRACE("iface %p, viewport %p.\n", iface, viewport);
return d3drm_viewport2_GetDirect3DViewport(&viewport_object->IDirect3DRMViewport2_iface, viewport);
} }
static HRESULT WINAPI d3drm_viewport2_TransformVectors(IDirect3DRMViewport2 *iface, static HRESULT WINAPI d3drm_viewport2_TransformVectors(IDirect3DRMViewport2 *iface,