Commit 99a2fec6 authored by Jeff Smith's avatar Jeff Smith Committed by Alexandre Julliard

d3drm: Implement d3drm_viewport2_GetCamera().

parent 9220772d
......@@ -273,6 +273,8 @@ HRESULT d3drm_object_set_name(struct d3drm_object *object, const char *name) DEC
void d3drm_object_cleanup(IDirect3DRMObject *iface, struct d3drm_object *object) DECLSPEC_HIDDEN;
struct d3drm_frame *unsafe_impl_from_IDirect3DRMFrame(IDirect3DRMFrame *iface) DECLSPEC_HIDDEN;
struct d3drm_frame *unsafe_impl_from_IDirect3DRMFrame3(IDirect3DRMFrame3 *iface) DECLSPEC_HIDDEN;
struct d3drm_device *unsafe_impl_from_IDirect3DRMDevice3(IDirect3DRMDevice3 *iface) DECLSPEC_HIDDEN;
HRESULT d3drm_texture_create(struct d3drm_texture **texture, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
......
......@@ -70,8 +70,6 @@ static inline struct d3drm_frame *impl_from_IDirect3DRMFrame3(IDirect3DRMFrame3
return CONTAINING_RECORD(iface, struct d3drm_frame, IDirect3DRMFrame3_iface);
}
static inline struct d3drm_frame *unsafe_impl_from_IDirect3DRMFrame3(IDirect3DRMFrame3 *iface);
static inline struct d3drm_frame_array *impl_from_IDirect3DRMFrameArray(IDirect3DRMFrameArray *iface)
{
return CONTAINING_RECORD(iface, struct d3drm_frame_array, IDirect3DRMFrameArray_iface);
......@@ -3110,7 +3108,7 @@ static const struct IDirect3DRMFrameVtbl d3drm_frame1_vtbl =
d3drm_frame1_Transform,
};
static inline struct d3drm_frame *unsafe_impl_from_IDirect3DRMFrame3(IDirect3DRMFrame3 *iface)
struct d3drm_frame *unsafe_impl_from_IDirect3DRMFrame3(IDirect3DRMFrame3 *iface)
{
if (!iface)
return NULL;
......
......@@ -1712,6 +1712,8 @@ static void test_object(void)
static void test_Viewport(void)
{
IDirect3DRMFrame3 *frame3, *d3drm_frame3, *tmp_frame3;
IDirect3DRMFrame *frame, *d3drm_frame, *tmp_frame1;
IDirectDrawClipper *clipper;
HRESULT hr;
IDirect3DRM *d3drm1;
......@@ -1719,8 +1721,6 @@ static void test_Viewport(void)
IDirect3DRM3 *d3drm3;
IDirect3DRMDevice *device1, *d3drm_device1;
IDirect3DRMDevice3 *device3, *d3drm_device3;
IDirect3DRMFrame *frame;
IDirect3DRMFrame3 *frame3;
IDirect3DRMViewport *viewport;
IDirect3DRMViewport2 *viewport2;
IDirect3DViewport *d3d_viewport;
......@@ -1760,8 +1760,12 @@ static void test_Viewport(void)
hr = IDirect3DRM_CreateFrame(d3drm1, NULL, &frame);
ok(hr == D3DRM_OK, "Cannot get IDirect3DRMFrame interface (hr = %x)\n", hr);
hr = IDirect3DRM_CreateFrame(d3drm1, NULL, &tmp_frame1);
ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DRM3_CreateFrame(d3drm3, NULL, &frame3);
ok(SUCCEEDED(hr), "Cannot get IDirect3DRMFrame3 interface (hr = %x).\n", hr);
hr = IDirect3DRM3_CreateFrame(d3drm3, NULL, &tmp_frame3);
ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
ref1 = get_refcount((IUnknown *)d3drm1);
ref2 = get_refcount((IUnknown *)d3drm2);
......@@ -1787,6 +1791,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(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);
IDirect3DRMViewport_Release(viewport);
ref4 = get_refcount((IUnknown *)d3drm1);
ok(ref4 == ref1, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4);
......@@ -1817,6 +1826,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(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);
IDirect3DRMViewport_Release(viewport);
ref4 = get_refcount((IUnknown *)d3drm1);
ok(ref4 == ref1, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4);
......@@ -1850,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(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);
IDirect3DRMViewport2_Release(viewport2);
ref4 = get_refcount((IUnknown *)d3drm1);
ok(ref4 == ref1, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4);
......@@ -2088,6 +2107,8 @@ 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, "Got unexpected hr %#x.\n", hr);
/* Test all failures together */
hr = IDirect3DRMViewport_Init(viewport, NULL, frame, rc.left, rc.top, rc.right, rc.bottom);
......@@ -2157,6 +2178,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, "Got unexpected hr %#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);
......@@ -2191,6 +2214,8 @@ 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, "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);
......@@ -2253,6 +2278,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, "Got unexpected hr %#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);
......@@ -2283,6 +2310,7 @@ static void test_Viewport(void)
ref4 = get_refcount((IUnknown *)frame3);
ok(ref4 == frame_ref2, "Expected ref4 == frame_ref2, got frame_ref2 = %u, ref4 = %u.\n", frame_ref2, ref4);
IDirect3DRMFrame3_Release(tmp_frame3);
IDirect3DRMFrame3_Release(frame3);
ref4 = get_refcount((IUnknown *)d3drm1);
ok(ref4 > initial_ref1, "Expected ref4 > initial_ref1, got initial_ref1 = %u, ref4 = %u.\n", initial_ref1, ref4);
......@@ -2291,6 +2319,7 @@ static void test_Viewport(void)
ref4 = get_refcount((IUnknown *)d3drm3);
ok(ref4 == initial_ref3, "Expected ref4 == initial_ref3, got initial_ref3 = %u, ref4 = %u.\n", initial_ref3, ref4);
IDirect3DRMFrame3_Release(tmp_frame1);
IDirect3DRMFrame_Release(frame);
ref4 = get_refcount((IUnknown *)d3drm1);
ok(ref4 == initial_ref1, "Expected ref4 == initial_ref1, got initial_ref1 = %u, ref4 = %u.\n", initial_ref1, ref4);
......
......@@ -668,16 +668,38 @@ 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);
return E_NOTIMPL;
TRACE("iface %p, camera %p.\n", iface, camera);
if (!camera)
return D3DRMERR_BADVALUE;
if (!viewport->camera)
return D3DRMERR_BADOBJECT;
return IDirect3DRMFrame_QueryInterface(viewport->camera, &IID_IDirect3DRMFrame3, (void **)camera);
}
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);
struct d3drm_frame *camera_impl;
IDirect3DRMFrame3 *camera3;
HRESULT hr;
return E_NOTIMPL;
TRACE("iface %p, camera %p.\n", iface, camera);
if (!camera)
return D3DRMERR_BADVALUE;
if (FAILED(hr = d3drm_viewport2_GetCamera(&viewport->IDirect3DRMViewport2_iface, &camera3)))
return hr;
camera_impl = unsafe_impl_from_IDirect3DRMFrame3(camera3);
*camera = &camera_impl->IDirect3DRMFrame_iface;
return D3DRM_OK;
}
static HRESULT WINAPI d3drm_viewport2_GetDevice(IDirect3DRMViewport2 *iface, IDirect3DRMDevice3 **device)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment