Commit 17f80954 authored by Aaryaman Vasishta's avatar Aaryaman Vasishta Committed by Alexandre Julliard

d3drm: Implement IDirect3DRMViewport*::GetDevice.

parent 36471380
...@@ -72,6 +72,7 @@ struct d3drm_frame ...@@ -72,6 +72,7 @@ struct d3drm_frame
struct d3drm_viewport struct d3drm_viewport
{ {
struct d3drm_object obj; struct d3drm_object obj;
struct d3drm_device *device;
IDirect3DRMFrame *camera; IDirect3DRMFrame *camera;
IDirect3DRMViewport IDirect3DRMViewport_iface; IDirect3DRMViewport IDirect3DRMViewport_iface;
IDirect3DRMViewport2 IDirect3DRMViewport2_iface; IDirect3DRMViewport2 IDirect3DRMViewport2_iface;
...@@ -116,6 +117,7 @@ HRESULT d3drm_object_delete_destroy_callback(struct d3drm_object *object, D3DRMO ...@@ -116,6 +117,7 @@ HRESULT d3drm_object_delete_destroy_callback(struct d3drm_object *object, D3DRMO
void d3drm_object_cleanup(IDirect3DRMObject *iface, struct d3drm_object *object) DECLSPEC_HIDDEN; 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_IDirect3DRMFrame(IDirect3DRMFrame *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; HRESULT d3drm_texture_create(struct d3drm_texture **texture, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
HRESULT d3drm_frame_create(struct d3drm_frame **frame, IUnknown *parent_frame, IDirect3DRM *d3drm) DECLSPEC_HIDDEN; HRESULT d3drm_frame_create(struct d3drm_frame **frame, IUnknown *parent_frame, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <assert.h>
#include "wine/debug.h" #include "wine/debug.h"
#define COBJMACROS #define COBJMACROS
...@@ -1617,6 +1618,15 @@ static const struct IDirect3DRMWinDeviceVtbl d3drm_device_win_vtbl = ...@@ -1617,6 +1618,15 @@ static const struct IDirect3DRMWinDeviceVtbl d3drm_device_win_vtbl =
d3drm_device_win_HandleActivate, d3drm_device_win_HandleActivate,
}; };
struct d3drm_device *unsafe_impl_from_IDirect3DRMDevice3(IDirect3DRMDevice3 *iface)
{
if (!iface)
return NULL;
assert(iface->lpVtbl == &d3drm_device3_vtbl);
return impl_from_IDirect3DRMDevice3(iface);
}
HRESULT d3drm_device_create(struct d3drm_device **device, IDirect3DRM *d3drm) HRESULT d3drm_device_create(struct d3drm_device **device, IDirect3DRM *d3drm)
{ {
struct d3drm_device *object; struct d3drm_device *object;
......
...@@ -1468,8 +1468,8 @@ static void test_Viewport(void) ...@@ -1468,8 +1468,8 @@ static void test_Viewport(void)
IDirect3DRM *d3drm1; IDirect3DRM *d3drm1;
IDirect3DRM2 *d3drm2; IDirect3DRM2 *d3drm2;
IDirect3DRM3 *d3drm3; IDirect3DRM3 *d3drm3;
IDirect3DRMDevice *device1; IDirect3DRMDevice *device1, *d3drm_device1;
IDirect3DRMDevice3 *device3; IDirect3DRMDevice3 *device3, *d3drm_device3;
IDirect3DRMFrame *frame; IDirect3DRMFrame *frame;
IDirect3DRMFrame3 *frame3; IDirect3DRMFrame3 *frame3;
IDirect3DRMViewport *viewport; IDirect3DRMViewport *viewport;
...@@ -1534,6 +1534,11 @@ static void test_Viewport(void) ...@@ -1534,6 +1534,11 @@ 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_GetDevice(viewport, &d3drm_device1);
ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice interface (hr = %x)\n", hr);
ok(device1 == d3drm_device1, "Expected device returned = %p, got %p.\n", device1, d3drm_device1);
IDirect3DRMDevice_Release(d3drm_device1);
IDirect3DRMViewport_Release(viewport); IDirect3DRMViewport_Release(viewport);
ref4 = get_refcount((IUnknown *)d3drm1); ref4 = get_refcount((IUnknown *)d3drm1);
ok(ref4 == ref1, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4); ok(ref4 == ref1, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4);
...@@ -1559,6 +1564,11 @@ static void test_Viewport(void) ...@@ -1559,6 +1564,11 @@ 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_GetDevice(viewport, &d3drm_device1);
ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice interface (hr = %x)\n", hr);
ok(device1 == d3drm_device1, "Expected device returned = %p, got %p.\n", device1, d3drm_device1);
IDirect3DRMDevice_Release(d3drm_device1);
IDirect3DRMViewport_Release(viewport); IDirect3DRMViewport_Release(viewport);
ref4 = get_refcount((IUnknown *)d3drm1); ref4 = get_refcount((IUnknown *)d3drm1);
ok(ref4 == ref1, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4); ok(ref4 == ref1, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4);
...@@ -1587,6 +1597,11 @@ static void test_Viewport(void) ...@@ -1587,6 +1597,11 @@ 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_GetDevice(viewport2, &d3drm_device3);
ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice3 interface (hr = %x)\n", hr);
ok(device3 == d3drm_device3, "Expected device returned = %p, got %p.\n", device3, d3drm_device3);
IDirect3DRMDevice3_Release(d3drm_device3);
IDirect3DRMViewport2_Release(viewport2); IDirect3DRMViewport2_Release(viewport2);
ref4 = get_refcount((IUnknown *)d3drm1); ref4 = get_refcount((IUnknown *)d3drm1);
ok(ref4 == ref1, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4); ok(ref4 == ref1, "Expected ref4 == ref1, got ref1 = %u, ref4 = %u.\n", ref1, ref4);
...@@ -1803,6 +1818,8 @@ static void test_Viewport(void) ...@@ -1803,6 +1818,8 @@ static void test_Viewport(void)
hr = IDirect3DRMViewport_GetDirect3DViewport(viewport, &d3d_viewport); hr = IDirect3DRMViewport_GetDirect3DViewport(viewport, &d3d_viewport);
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 = IDirect3DRMViewport_GetDevice(viewport, &d3drm_device1);
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);
...@@ -1831,6 +1848,11 @@ static void test_Viewport(void) ...@@ -1831,6 +1848,11 @@ 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_GetDevice(viewport, &d3drm_device1);
ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice3 interface (hr = %x)\n", hr);
ok(device1 == d3drm_device1, "Expected device returned = %p, got %p.\n", device3, d3drm_device3);
IDirect3DRMDevice_Release(d3drm_device1);
hr = IDirect3DRMViewport_GetDirect3DViewport(viewport, &d3d_viewport); hr = IDirect3DRMViewport_GetDirect3DViewport(viewport, &d3d_viewport);
ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr); ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr);
viewport_ref = get_refcount((IUnknown *)d3d_viewport); viewport_ref = get_refcount((IUnknown *)d3d_viewport);
...@@ -1891,6 +1913,8 @@ static void test_Viewport(void) ...@@ -1891,6 +1913,8 @@ static void test_Viewport(void)
hr = IDirect3DRMViewport2_GetDirect3DViewport(viewport2, &d3d_viewport); hr = IDirect3DRMViewport2_GetDirect3DViewport(viewport2, &d3d_viewport);
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_GetDevice(viewport2, &d3drm_device3);
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);
...@@ -1912,6 +1936,11 @@ static void test_Viewport(void) ...@@ -1912,6 +1936,11 @@ 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_GetDevice(viewport2, &d3drm_device3);
ok(SUCCEEDED(hr), "Cannot get IDirect3DRMDevice3 interface (hr = %x)\n", hr);
ok(device3 == d3drm_device3, "Expected device returned = %p, got %p.\n", device3, d3drm_device3);
IDirect3DRMDevice3_Release(d3drm_device3);
hr = IDirect3DRMViewport2_GetDirect3DViewport(viewport2, &d3d_viewport); hr = IDirect3DRMViewport2_GetDirect3DViewport(viewport2, &d3d_viewport);
ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr); ok(SUCCEEDED(hr), "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr);
viewport_ref = get_refcount((IUnknown *)d3d_viewport); viewport_ref = get_refcount((IUnknown *)d3d_viewport);
......
...@@ -280,6 +280,7 @@ static HRESULT WINAPI d3drm_viewport2_Init(IDirect3DRMViewport2 *iface, IDirect3 ...@@ -280,6 +280,7 @@ static HRESULT WINAPI d3drm_viewport2_Init(IDirect3DRMViewport2 *iface, IDirect3
IDirect3DRMFrame3 *camera, DWORD x, DWORD y, DWORD width, DWORD height) IDirect3DRMFrame3 *camera, DWORD x, DWORD y, DWORD width, DWORD height)
{ {
struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface); struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
struct d3drm_device *device_obj = unsafe_impl_from_IDirect3DRMDevice3(device);
D3DVIEWPORT vp; D3DVIEWPORT vp;
D3DVALUE scale; D3DVALUE scale;
IDirect3D *d3d1 = NULL; IDirect3D *d3d1 = NULL;
...@@ -293,9 +294,9 @@ static HRESULT WINAPI d3drm_viewport2_Init(IDirect3DRMViewport2 *iface, IDirect3 ...@@ -293,9 +294,9 @@ static HRESULT WINAPI d3drm_viewport2_Init(IDirect3DRMViewport2 *iface, IDirect3
TRACE("iface %p, device %p, camera %p, x %u, y %u, width %u, height %u.\n", TRACE("iface %p, device %p, camera %p, x %u, y %u, width %u, height %u.\n",
iface, device, camera, x, y, width, height); iface, device, camera, x, y, width, height);
if (!device || !camera if (!device_obj || !camera
|| width > IDirect3DRMDevice3_GetWidth(device) || width > device_obj->width
|| height > IDirect3DRMDevice3_GetHeight(device)) || height > device_obj->height)
{ {
return D3DRMERR_BADOBJECT; return D3DRMERR_BADOBJECT;
} }
...@@ -356,6 +357,7 @@ static HRESULT WINAPI d3drm_viewport2_Init(IDirect3DRMViewport2 *iface, IDirect3 ...@@ -356,6 +357,7 @@ static HRESULT WINAPI d3drm_viewport2_Init(IDirect3DRMViewport2 *iface, IDirect3
hr = IDirect3DViewport_SetBackground(viewport->d3d_viewport, hmat); hr = IDirect3DViewport_SetBackground(viewport->d3d_viewport, hmat);
viewport->material = material; viewport->material = material;
viewport->device = device_obj;
cleanup: cleanup:
...@@ -634,16 +636,32 @@ static HRESULT WINAPI d3drm_viewport1_GetCamera(IDirect3DRMViewport *iface, IDir ...@@ -634,16 +636,32 @@ static HRESULT WINAPI d3drm_viewport1_GetCamera(IDirect3DRMViewport *iface, IDir
static HRESULT WINAPI d3drm_viewport2_GetDevice(IDirect3DRMViewport2 *iface, IDirect3DRMDevice3 **device) static HRESULT WINAPI d3drm_viewport2_GetDevice(IDirect3DRMViewport2 *iface, IDirect3DRMDevice3 **device)
{ {
FIXME("iface %p, device %p stub!\n", iface, device); struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
return E_NOTIMPL; TRACE("iface %p, device %p.\n", iface, device);
if (!viewport->device)
return D3DRMERR_BADOBJECT;
*device = &viewport->device->IDirect3DRMDevice3_iface;
IDirect3DRMDevice3_AddRef(*device);
return D3DRM_OK;
} }
static HRESULT WINAPI d3drm_viewport1_GetDevice(IDirect3DRMViewport *iface, IDirect3DRMDevice **device) static HRESULT WINAPI d3drm_viewport1_GetDevice(IDirect3DRMViewport *iface, IDirect3DRMDevice **device)
{ {
FIXME("iface %p, device %p stub!\n", iface, device); struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
return E_NOTIMPL; TRACE("iface %p, device %p.\n\n", iface, device);
if (!viewport->device)
return D3DRMERR_BADOBJECT;
*device = &viewport->device->IDirect3DRMDevice_iface;
IDirect3DRMDevice_AddRef(*device);
return D3DRM_OK;
} }
static HRESULT WINAPI d3drm_viewport2_GetPlane(IDirect3DRMViewport2 *iface, static HRESULT WINAPI d3drm_viewport2_GetPlane(IDirect3DRMViewport2 *iface,
......
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