Signed-off-by: Jeff Smith whydoubt@gmail.com --- dlls/d3drm/tests/d3drm.c | 21 +++++++++++++++++++++ dlls/d3drm/viewport.c | 8 ++++++++ 2 files changed, 29 insertions(+)
diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c index 0f9f9cd6ed..e826e595d8 100644 --- a/dlls/d3drm/tests/d3drm.c +++ b/dlls/d3drm/tests/d3drm.c @@ -1733,6 +1733,7 @@ static void test_Viewport(void) RECT rc; DWORD data, ref1, ref2, ref3, ref4; DWORD initial_ref1, initial_ref2, initial_ref3, device_ref, frame_ref, frame_ref2, viewport_ref; + D3DRMPROJECTIONTYPE ptype;
window = create_window(); GetClientRect(window, &rc); @@ -2150,6 +2151,8 @@ static void test_Viewport(void) ok(front == -1.0f, "Got unexpected front %.8e\n", front); back = IDirect3DRMViewport_GetBack(viewport); ok(back == -1.0f, "Got unexpected back %.8e\n", back); + ptype = IDirect3DRMViewport_GetProjection(viewport); + ok(ptype == -1, "Got unexpected projection type %u.\n", ptype);
hr = IDirect3DRMViewport_SetCamera(viewport, frame); ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr); @@ -2161,6 +2164,8 @@ static void test_Viewport(void) ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr); hr = IDirect3DRMViewport_SetBack(viewport, 100.0f); ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DRMViewport_SetProjection(viewport, D3DRMPROJECT_PERSPECTIVE); + 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); @@ -2236,6 +2241,8 @@ static void test_Viewport(void) ok(front == 1.0f, "Got unexpected front %.8e.\n", front); back = IDirect3DRMViewport_GetBack(viewport); ok(back == 100.0f, "Got unexpected back %.8e.\n", back); + ptype = IDirect3DRMViewport_GetProjection(viewport); + ok(ptype == D3DRMPROJECT_PERSPECTIVE, "Got unexpected projection type %u.\n", ptype);
hr = IDirect3DRMViewport_SetField(viewport, 1.0f); ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr); @@ -2266,6 +2273,10 @@ static void test_Viewport(void) ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr); back = IDirect3DRMViewport_GetBack(viewport); ok(back == 200.0f, "Got unexpected back %.8e.\n", back); + hr = IDirect3DRMViewport_SetProjection(viewport, D3DRMPROJECT_ORTHOGRAPHIC); + ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr); + ptype = IDirect3DRMViewport_GetProjection(viewport); + ok(ptype == D3DRMPROJECT_ORTHOGRAPHIC, "Got unexpected projection type %u.\n", ptype);
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); @@ -2333,6 +2344,8 @@ static void test_Viewport(void) ok(front == -1.0f, "Got unexpected front %.8e\n", front); back = IDirect3DRMViewport2_GetBack(viewport2); ok(back == -1.0f, "Got unexpected back %.8e\n", back); + ptype = IDirect3DRMViewport2_GetProjection(viewport2); + ok(ptype == -1, "Got unexpected projection type %u.\n", ptype);
hr = IDirect3DRMViewport2_SetCamera(viewport2, frame3); ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr); @@ -2344,6 +2357,8 @@ static void test_Viewport(void) ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr); hr = IDirect3DRMViewport2_SetBack(viewport2, 100.0f); ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DRMViewport2_SetProjection(viewport2, D3DRMPROJECT_PERSPECTIVE); + 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); @@ -2412,6 +2427,8 @@ static void test_Viewport(void) ok(front == 1.0f, "Got unexpected front %.8e.\n", front); back = IDirect3DRMViewport2_GetBack(viewport2); ok(back == 100.0f, "Got unexpected back %.8e.\n", back); + ptype = IDirect3DRMViewport2_GetProjection(viewport2); + ok(ptype == D3DRMPROJECT_PERSPECTIVE, "Got unexpected projection type %u.\n", ptype);
hr = IDirect3DRMViewport2_SetField(viewport2, 1.0f); ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr); @@ -2442,6 +2459,10 @@ static void test_Viewport(void) ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr); back = IDirect3DRMViewport2_GetBack(viewport2); ok(back == 200.0f, "Got unexpected back %.8e.\n", back); + hr = IDirect3DRMViewport2_SetProjection(viewport2, D3DRMPROJECT_ORTHOGRAPHIC); + ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr); + ptype = IDirect3DRMViewport2_GetProjection(viewport2); + ok(ptype == D3DRMPROJECT_ORTHOGRAPHIC, "Got unexpected projection type %u.\n", ptype);
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); diff --git a/dlls/d3drm/viewport.c b/dlls/d3drm/viewport.c index 8e959d5f37..da6b38b110 100644 --- a/dlls/d3drm/viewport.c +++ b/dlls/d3drm/viewport.c @@ -376,6 +376,8 @@ static HRESULT WINAPI d3drm_viewport2_Init(IDirect3DRMViewport2 *iface, IDirect3 viewport->clip.front = 1.0f; viewport->clip.back = 100.0f;
+ viewport->projection = D3DRMPROJECT_PERSPECTIVE; + cleanup:
if (FAILED(hr)) @@ -613,6 +615,9 @@ static HRESULT WINAPI d3drm_viewport2_SetProjection(IDirect3DRMViewport2 *iface,
TRACE("iface %p, type %#x.\n", iface, type);
+ if (!viewport->d3d_viewport) + return D3DRMERR_BADOBJECT; + viewport->projection = type;
return D3DRM_OK; @@ -975,6 +980,9 @@ static D3DRMPROJECTIONTYPE WINAPI d3drm_viewport2_GetProjection(IDirect3DRMViewp
TRACE("iface %p.\n", iface);
+ if (!viewport->d3d_viewport) + return (D3DRMPROJECTIONTYPE)(-1); + return viewport->projection; }
Signed-off-by: Jeff Smith whydoubt@gmail.com --- dlls/d3drm/d3drm_private.h | 1 + dlls/d3drm/tests/d3drm.c | 21 +++++++++++++++++++++ dlls/d3drm/viewport.c | 34 ++++++++++++++++++++++++++-------- 3 files changed, 48 insertions(+), 8 deletions(-)
diff --git a/dlls/d3drm/d3drm_private.h b/dlls/d3drm/d3drm_private.h index b5d60e518f..48820b272c 100644 --- a/dlls/d3drm/d3drm_private.h +++ b/dlls/d3drm/d3drm_private.h @@ -111,6 +111,7 @@ struct d3drm_viewport IDirect3DRM *d3drm; struct d3drm_box clip; D3DRMPROJECTIONTYPE projection; + BOOL uniform_scaling; };
struct d3drm_device diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c index e826e595d8..591dc5c0bf 100644 --- a/dlls/d3drm/tests/d3drm.c +++ b/dlls/d3drm/tests/d3drm.c @@ -1734,6 +1734,7 @@ static void test_Viewport(void) DWORD data, ref1, ref2, ref3, ref4; DWORD initial_ref1, initial_ref2, initial_ref3, device_ref, frame_ref, frame_ref2, viewport_ref; D3DRMPROJECTIONTYPE ptype; + BOOL b;
window = create_window(); GetClientRect(window, &rc); @@ -2153,6 +2154,8 @@ static void test_Viewport(void) ok(back == -1.0f, "Got unexpected back %.8e\n", back); ptype = IDirect3DRMViewport_GetProjection(viewport); ok(ptype == -1, "Got unexpected projection type %u.\n", ptype); + b = IDirect3DRMViewport_GetUniformScaling(viewport); + ok(b == -1, "Got unexpected uniform scaling %d.\n", b);
hr = IDirect3DRMViewport_SetCamera(viewport, frame); ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr); @@ -2166,6 +2169,8 @@ static void test_Viewport(void) ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr); hr = IDirect3DRMViewport_SetProjection(viewport, D3DRMPROJECT_PERSPECTIVE); ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DRMViewport_SetUniformScaling(viewport, TRUE); + 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); @@ -2243,6 +2248,8 @@ static void test_Viewport(void) ok(back == 100.0f, "Got unexpected back %.8e.\n", back); ptype = IDirect3DRMViewport_GetProjection(viewport); ok(ptype == D3DRMPROJECT_PERSPECTIVE, "Got unexpected projection type %u.\n", ptype); + b = IDirect3DRMViewport_GetUniformScaling(viewport); + ok(b == TRUE, "Got unexpected uniform scaling %d.\n", b);
hr = IDirect3DRMViewport_SetField(viewport, 1.0f); ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr); @@ -2277,6 +2284,10 @@ static void test_Viewport(void) ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr); ptype = IDirect3DRMViewport_GetProjection(viewport); ok(ptype == D3DRMPROJECT_ORTHOGRAPHIC, "Got unexpected projection type %u.\n", ptype); + hr = IDirect3DRMViewport_SetUniformScaling(viewport, FALSE); + ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr); + b = IDirect3DRMViewport_GetUniformScaling(viewport); + ok(b == FALSE, "Got unexpected uniform scaling %d.\n", b);
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); @@ -2346,6 +2357,8 @@ static void test_Viewport(void) ok(back == -1.0f, "Got unexpected back %.8e\n", back); ptype = IDirect3DRMViewport2_GetProjection(viewport2); ok(ptype == -1, "Got unexpected projection type %u.\n", ptype); + b = IDirect3DRMViewport2_GetUniformScaling(viewport2); + ok(b == -1, "Got unexpected uniform scaling %d.\n", b);
hr = IDirect3DRMViewport2_SetCamera(viewport2, frame3); ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr); @@ -2359,6 +2372,8 @@ static void test_Viewport(void) ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr); hr = IDirect3DRMViewport2_SetProjection(viewport2, D3DRMPROJECT_PERSPECTIVE); ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DRMViewport2_SetUniformScaling(viewport2, TRUE); + 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); @@ -2429,6 +2444,8 @@ static void test_Viewport(void) ok(back == 100.0f, "Got unexpected back %.8e.\n", back); ptype = IDirect3DRMViewport2_GetProjection(viewport2); ok(ptype == D3DRMPROJECT_PERSPECTIVE, "Got unexpected projection type %u.\n", ptype); + b = IDirect3DRMViewport2_GetUniformScaling(viewport2); + ok(b == TRUE, "Got unexpected uniform scaling %d.\n", b);
hr = IDirect3DRMViewport2_SetField(viewport2, 1.0f); ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr); @@ -2463,6 +2480,10 @@ static void test_Viewport(void) ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr); ptype = IDirect3DRMViewport2_GetProjection(viewport2); ok(ptype == D3DRMPROJECT_ORTHOGRAPHIC, "Got unexpected projection type %u.\n", ptype); + hr = IDirect3DRMViewport2_SetUniformScaling(viewport2, FALSE); + ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr); + b = IDirect3DRMViewport2_GetUniformScaling(viewport2); + ok(b == FALSE, "Got unexpected uniform scaling %d.\n", b);
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); diff --git a/dlls/d3drm/viewport.c b/dlls/d3drm/viewport.c index da6b38b110..7307450772 100644 --- a/dlls/d3drm/viewport.c +++ b/dlls/d3drm/viewport.c @@ -378,6 +378,8 @@ static HRESULT WINAPI d3drm_viewport2_Init(IDirect3DRMViewport2 *iface, IDirect3
viewport->projection = D3DRMPROJECT_PERSPECTIVE;
+ viewport->uniform_scaling = TRUE; + cleanup:
if (FAILED(hr)) @@ -569,16 +571,25 @@ static HRESULT WINAPI d3drm_viewport1_SetField(IDirect3DRMViewport *iface, D3DVA
static HRESULT WINAPI d3drm_viewport2_SetUniformScaling(IDirect3DRMViewport2 *iface, BOOL b) { - FIXME("iface %p, b %#x stub!\n", iface, b); + struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
- return E_NOTIMPL; + TRACE("iface %p, b %#x.\n", iface, b); + + if (!viewport->d3d_viewport) + return D3DRMERR_BADOBJECT; + + viewport->uniform_scaling = b; + + return D3DRM_OK; }
static HRESULT WINAPI d3drm_viewport1_SetUniformScaling(IDirect3DRMViewport *iface, BOOL b) { - FIXME("iface %p, b %#x stub!\n", iface, b); + struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
- return E_NOTIMPL; + TRACE("iface %p, b %#x.\n", iface, b); + + return d3drm_viewport2_SetUniformScaling(&viewport->IDirect3DRMViewport2_iface, b); }
static HRESULT WINAPI d3drm_viewport2_SetCamera(IDirect3DRMViewport2 *iface, IDirect3DRMFrame3 *camera) @@ -842,16 +853,23 @@ static HRESULT WINAPI d3drm_viewport1_Pick(IDirect3DRMViewport *iface,
static BOOL WINAPI d3drm_viewport2_GetUniformScaling(IDirect3DRMViewport2 *iface) { - FIXME("iface %p stub!\n", iface); + struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
- return FALSE; + TRACE("iface %p.\n", iface); + + if (!viewport->d3d_viewport) + return -1; + + return viewport->uniform_scaling; }
static BOOL WINAPI d3drm_viewport1_GetUniformScaling(IDirect3DRMViewport *iface) { - FIXME("iface %p stub!\n", iface); + struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface); + + TRACE("iface %p.\n", iface);
- return FALSE; + return d3drm_viewport2_GetUniformScaling(&viewport->IDirect3DRMViewport2_iface); }
static LONG WINAPI d3drm_viewport2_GetX(IDirect3DRMViewport2 *iface)
Signed-off-by: Jeff Smith whydoubt@gmail.com --- dlls/d3drm/d3drm_private.h | 9 ++++++ dlls/d3drm/tests/d3drm.c | 32 +++++++++++++++++++ dlls/d3drm/viewport.c | 65 ++++++++++++++++++++++++++++---------- 3 files changed, 90 insertions(+), 16 deletions(-)
diff --git a/dlls/d3drm/d3drm_private.h b/dlls/d3drm/d3drm_private.h index 48820b272c..00828d22ab 100644 --- a/dlls/d3drm/d3drm_private.h +++ b/dlls/d3drm/d3drm_private.h @@ -99,6 +99,14 @@ struct d3drm_box float back; };
+struct d3drm_rect +{ + DWORD x; + DWORD y; + DWORD width; + DWORD height; +}; + struct d3drm_viewport { struct d3drm_object obj; @@ -110,6 +118,7 @@ struct d3drm_viewport IDirect3DMaterial *material; IDirect3DRM *d3drm; struct d3drm_box clip; + struct d3drm_rect port; D3DRMPROJECTIONTYPE projection; BOOL uniform_scaling; }; diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c index 591dc5c0bf..d6f8322813 100644 --- a/dlls/d3drm/tests/d3drm.c +++ b/dlls/d3drm/tests/d3drm.c @@ -2156,6 +2156,14 @@ static void test_Viewport(void) ok(ptype == -1, "Got unexpected projection type %u.\n", ptype); b = IDirect3DRMViewport_GetUniformScaling(viewport); ok(b == -1, "Got unexpected uniform scaling %d.\n", b); + data = IDirect3DRMViewport_GetX(viewport); + ok(data == -1, "Got unexpected X %d.\n", data); + data = IDirect3DRMViewport_GetY(viewport); + ok(data == -1, "Got unexpected Y %d.\n", data); + data = IDirect3DRMViewport_GetWidth(viewport); + ok(data == -1, "Got unexpected width %d.\n", data); + data = IDirect3DRMViewport_GetHeight(viewport); + ok(data == -1, "Got unexpected height %d.\n", data);
hr = IDirect3DRMViewport_SetCamera(viewport, frame); ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr); @@ -2250,6 +2258,14 @@ static void test_Viewport(void) ok(ptype == D3DRMPROJECT_PERSPECTIVE, "Got unexpected projection type %u.\n", ptype); b = IDirect3DRMViewport_GetUniformScaling(viewport); ok(b == TRUE, "Got unexpected uniform scaling %d.\n", b); + data = IDirect3DRMViewport_GetX(viewport); + ok(data == rc.left, "Got unexpected X %d.\n", data); + data = IDirect3DRMViewport_GetY(viewport); + ok(data == rc.top, "Got unexpected Y %d.\n", data); + data = IDirect3DRMViewport_GetWidth(viewport); + ok(data == rc.right, "Got unexpected width %d.\n", data); + data = IDirect3DRMViewport_GetHeight(viewport); + ok(data == rc.bottom, "Got unexpected height %d.\n", data);
hr = IDirect3DRMViewport_SetField(viewport, 1.0f); ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr); @@ -2359,6 +2375,14 @@ static void test_Viewport(void) ok(ptype == -1, "Got unexpected projection type %u.\n", ptype); b = IDirect3DRMViewport2_GetUniformScaling(viewport2); ok(b == -1, "Got unexpected uniform scaling %d.\n", b); + data = IDirect3DRMViewport2_GetX(viewport2); + ok(data == -1, "Got unexpected X %d.\n", data); + data = IDirect3DRMViewport2_GetY(viewport2); + ok(data == -1, "Got unexpected Y %d.\n", data); + data = IDirect3DRMViewport2_GetWidth(viewport2); + ok(data == -1, "Got unexpected width %d.\n", data); + data = IDirect3DRMViewport2_GetHeight(viewport2); + ok(data == -1, "Got unexpected height %d.\n", data);
hr = IDirect3DRMViewport2_SetCamera(viewport2, frame3); ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr); @@ -2446,6 +2470,14 @@ static void test_Viewport(void) ok(ptype == D3DRMPROJECT_PERSPECTIVE, "Got unexpected projection type %u.\n", ptype); b = IDirect3DRMViewport2_GetUniformScaling(viewport2); ok(b == TRUE, "Got unexpected uniform scaling %d.\n", b); + data = IDirect3DRMViewport2_GetX(viewport2); + ok(data == rc.left, "Got unexpected X %d.\n", data); + data = IDirect3DRMViewport2_GetY(viewport2); + ok(data == rc.top, "Got unexpected Y %d.\n", data); + data = IDirect3DRMViewport2_GetWidth(viewport2); + ok(data == rc.right, "Got unexpected width %d.\n", data); + data = IDirect3DRMViewport2_GetHeight(viewport2); + ok(data == rc.bottom, "Got unexpected height %d.\n", data);
hr = IDirect3DRMViewport2_SetField(viewport2, 1.0f); ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr); diff --git a/dlls/d3drm/viewport.c b/dlls/d3drm/viewport.c index 7307450772..25a83e6e89 100644 --- a/dlls/d3drm/viewport.c +++ b/dlls/d3drm/viewport.c @@ -380,6 +380,11 @@ static HRESULT WINAPI d3drm_viewport2_Init(IDirect3DRMViewport2 *iface, IDirect3
viewport->uniform_scaling = TRUE;
+ viewport->port.x = x; + viewport->port.y = y; + viewport->port.width = width; + viewport->port.height = height; + cleanup:
if (FAILED(hr)) @@ -874,58 +879,86 @@ static BOOL WINAPI d3drm_viewport1_GetUniformScaling(IDirect3DRMViewport *iface)
static LONG WINAPI d3drm_viewport2_GetX(IDirect3DRMViewport2 *iface) { - FIXME("iface %p stub!\n", iface); + struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
- return E_NOTIMPL; + TRACE("iface %p.\n", iface); + + if (!viewport->d3d_viewport) + return -1; + + return viewport->port.x; }
static LONG WINAPI d3drm_viewport1_GetX(IDirect3DRMViewport *iface) { - FIXME("iface %p stub!\n", iface); + struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
- return E_NOTIMPL; + TRACE("iface %p.\n", iface); + + return d3drm_viewport2_GetX(&viewport->IDirect3DRMViewport2_iface); }
static LONG WINAPI d3drm_viewport2_GetY(IDirect3DRMViewport2 *iface) { - FIXME("iface %p stub!\n", iface); + struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
- return E_NOTIMPL; + TRACE("iface %p.\n", iface); + + if (!viewport->d3d_viewport) + return -1; + + return viewport->port.y; }
static LONG WINAPI d3drm_viewport1_GetY(IDirect3DRMViewport *iface) { - FIXME("iface %p stub!\n", iface); + struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
- return E_NOTIMPL; + TRACE("iface %p.\n", iface); + + return d3drm_viewport2_GetY(&viewport->IDirect3DRMViewport2_iface); }
static DWORD WINAPI d3drm_viewport2_GetWidth(IDirect3DRMViewport2 *iface) { - FIXME("iface %p stub!\n", iface); + struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
- return E_NOTIMPL; + TRACE("iface %p.\n", iface); + + if (!viewport->d3d_viewport) + return -1; + + return viewport->port.width; }
static DWORD WINAPI d3drm_viewport1_GetWidth(IDirect3DRMViewport *iface) { - FIXME("iface %p stub!\n", iface); + struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
- return E_NOTIMPL; + TRACE("iface %p.\n", iface); + + return d3drm_viewport2_GetWidth(&viewport->IDirect3DRMViewport2_iface); }
static DWORD WINAPI d3drm_viewport2_GetHeight(IDirect3DRMViewport2 *iface) { - FIXME("iface %p stub!\n", iface); + struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
- return E_NOTIMPL; + TRACE("iface %p.\n", iface); + + if (!viewport->d3d_viewport) + return -1; + + return viewport->port.height; }
static DWORD WINAPI d3drm_viewport1_GetHeight(IDirect3DRMViewport *iface) { - FIXME("iface %p stub!\n", iface); + struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
- return E_NOTIMPL; + TRACE("iface %p.\n", iface); + + return d3drm_viewport2_GetHeight(&viewport->IDirect3DRMViewport2_iface); }
static D3DVALUE WINAPI d3drm_viewport2_GetField(IDirect3DRMViewport2 *iface)
Signed-off-by: Jeff Smith whydoubt@gmail.com --- dlls/d3drm/tests/d3drm.c | 32 ++++++++++++++++++++++++++++++++ dlls/d3drm/viewport.c | 16 ++++++++++++++-- 2 files changed, 46 insertions(+), 2 deletions(-)
diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c index d6f8322813..7317a316fa 100644 --- a/dlls/d3drm/tests/d3drm.c +++ b/dlls/d3drm/tests/d3drm.c @@ -1921,6 +1921,14 @@ static void test_Viewport(void) ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); ok(!viewport, "Expected viewport returned == NULL, got %p.\n", viewport); viewport = (IDirect3DRMViewport *)0xdeadbeef; + hr = IDirect3DRM_CreateViewport(d3drm1, device1, frame, rc.left + 1, rc.top, rc.right, rc.bottom, &viewport); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); + ok(!viewport, "Expected viewport returned == NULL, got %p.\n", viewport); + viewport = (IDirect3DRMViewport *)0xdeadbeef; + hr = IDirect3DRM_CreateViewport(d3drm1, device1, frame, rc.left, rc.top + 1, rc.right, rc.bottom, &viewport); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); + ok(!viewport, "Expected viewport returned == NULL, got %p.\n", viewport); + viewport = (IDirect3DRMViewport *)0xdeadbeef; hr = IDirect3DRM_CreateViewport(d3drm1, device1, frame, rc.left, rc.top, rc.right + 1, rc.bottom + 1, &viewport); ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); ok(!viewport, "Expected viewport returned == NULL, got %p.\n", viewport); @@ -1944,6 +1952,14 @@ static void test_Viewport(void) ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); ok(!viewport, "Expected viewport returned == NULL, got %p.\n", viewport); viewport = (IDirect3DRMViewport *)0xdeadbeef; + hr = IDirect3DRM2_CreateViewport(d3drm2, device1, frame, rc.left + 1, rc.top, rc.right, rc.bottom, &viewport); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); + ok(!viewport, "Expected viewport returned == NULL, got %p.\n", viewport); + viewport = (IDirect3DRMViewport *)0xdeadbeef; + hr = IDirect3DRM2_CreateViewport(d3drm2, device1, frame, rc.left, rc.top + 1, rc.right, rc.bottom, &viewport); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); + ok(!viewport, "Expected viewport returned == NULL, got %p.\n", viewport); + viewport = (IDirect3DRMViewport *)0xdeadbeef; hr = IDirect3DRM2_CreateViewport(d3drm2, device1, frame, rc.left, rc.top, rc.right + 1, rc.bottom + 1, &viewport); ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); ok(!viewport, "Expected viewport returned == NULL, got %p.\n", viewport); @@ -1967,6 +1983,14 @@ static void test_Viewport(void) ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); ok(!viewport2, "Expected viewport returned == NULL, got %p.\n", viewport2); viewport2 = (IDirect3DRMViewport2 *)0xdeadbeef; + hr = IDirect3DRM3_CreateViewport(d3drm3, device3, frame3, rc.left + 1, rc.top, rc.right, rc.bottom, &viewport2); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); + ok(!viewport2, "Expected viewport returned == NULL, got %p.\n", viewport2); + viewport2 = (IDirect3DRMViewport2 *)0xdeadbeef; + hr = IDirect3DRM3_CreateViewport(d3drm3, device3, frame3, rc.left, rc.top + 1, rc.right, rc.bottom, &viewport2); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); + ok(!viewport2, "Expected viewport returned == NULL, got %p.\n", viewport2); + viewport2 = (IDirect3DRMViewport2 *)0xdeadbeef; hr = IDirect3DRM3_CreateViewport(d3drm3, device3, frame3, rc.left, rc.top, rc.right + 1, rc.bottom + 1, &viewport2); ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); ok(!viewport2, "Expected viewport returned == NULL, got %p.\n", viewport2); @@ -2191,6 +2215,10 @@ static void test_Viewport(void) ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); hr = IDirect3DRMViewport_Init(viewport, device1, frame, rc.left, rc.top, rc.right, rc.bottom + 1); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); + hr = IDirect3DRMViewport_Init(viewport, device1, frame, rc.left + 1, rc.top, rc.right, rc.bottom); + ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); + hr = IDirect3DRMViewport_Init(viewport, device1, frame, rc.left, rc.top + 1, rc.right, rc.bottom); + ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
device_ref = get_refcount((IUnknown *)device1); frame_ref = get_refcount((IUnknown *)frame); @@ -2409,6 +2437,10 @@ static void test_Viewport(void) ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); hr = IDirect3DRMViewport2_Init(viewport2, device3, frame3, rc.left, rc.top, rc.right, rc.bottom + 1); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); + hr = IDirect3DRMViewport2_Init(viewport2, device3, frame3, rc.left + 1, rc.top, rc.right, rc.bottom); + ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); + hr = IDirect3DRMViewport2_Init(viewport2, device3, frame3, rc.left, rc.top + 1, rc.right, rc.bottom); + ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr);
device_ref = get_refcount((IUnknown *)device3); frame_ref2 = get_refcount((IUnknown *)frame3); diff --git a/dlls/d3drm/viewport.c b/dlls/d3drm/viewport.c index 25a83e6e89..24fa198de5 100644 --- a/dlls/d3drm/viewport.c +++ b/dlls/d3drm/viewport.c @@ -300,6 +300,19 @@ static HRESULT WINAPI d3drm_viewport1_GetClassName(IDirect3DRMViewport *iface, D return d3drm_viewport2_GetClassName(&viewport->IDirect3DRMViewport2_iface, size, name); }
+static HRESULT d3drm_viewport_check_device_dims(struct d3drm_device *device, + DWORD x, DWORD y, DWORD width, DWORD height) +{ + if (x > device->width || y > device->height + || width > device->width || height > device->height + || x + width > device->width || y + height > device->height) + { + return D3DRMERR_BADVALUE; + } + + return D3D_OK; +} + static HRESULT WINAPI d3drm_viewport2_Init(IDirect3DRMViewport2 *iface, IDirect3DRMDevice3 *device, IDirect3DRMFrame3 *camera, DWORD x, DWORD y, DWORD width, DWORD height) { @@ -317,8 +330,7 @@ static HRESULT WINAPI d3drm_viewport2_Init(IDirect3DRMViewport2 *iface, IDirect3 iface, device, camera, x, y, width, height);
if (!device_obj || !camera - || width > device_obj->width - || height > device_obj->height) + || FAILED(d3drm_viewport_check_device_dims(device_obj, x, y, width, height))) { return D3DRMERR_BADOBJECT; }
Signed-off-by: Jeff Smith whydoubt@gmail.com --- dlls/d3drm/tests/d3drm.c | 260 +++++++++++++++++++++++++++++++++++++-- dlls/d3drm/viewport.c | 26 +++- 2 files changed, 275 insertions(+), 11 deletions(-)
diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c index 7317a316fa..01560ba1c2 100644 --- a/dlls/d3drm/tests/d3drm.c +++ b/dlls/d3drm/tests/d3drm.c @@ -6739,6 +6739,250 @@ static void test_viewport_qi(void) IDirect3DRM_Release(d3drm1); }
+static void test_viewport_configure1(void) +{ + IDirectDraw *ddraw; + IDirectDrawClipper *clipper; + IDirect3DRM *d3drm1; + IDirect3DRMFrame *frame1, *camera1; + IDirect3DRMDevice *device1; + IDirect3DViewport *d3d_viewport; + IDirect3DRMViewport *viewport1; + D3DVIEWPORT vp; + DWORD x, y, w, h; + HWND window; + GUID driver = IID_IDirect3DRGBDevice; + HRESULT hr; + RECT rc; + + /* Setup */ + window = create_window(); + GetClientRect(window, &rc); + hr = DirectDrawCreate(NULL, &ddraw, NULL); + ok(hr == D3D_OK, "Cannot create IDirectDraw interface (hr = %#x).\n", hr); + hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); + ok(hr == D3D_OK, "Failed to set cooperative level (hr = %#x).\n", hr); + hr = IDirectDraw_CreateClipper(ddraw, 0, &clipper, NULL); + ok(hr == D3D_OK, "Cannot create clipper (hr = %#x).\n", hr); + hr = IDirectDrawClipper_SetHWnd(clipper, 0, window); + ok(hr == D3D_OK, "Cannot set HWnd to Clipper (hr = %#x)\n", hr); + hr = Direct3DRMCreate(&d3drm1); + ok(hr == D3D_OK, "Cannot get IDirect3DRM interface (hr = %#x).\n", hr); + hr = IDirect3DRM_CreateDeviceFromClipper(d3drm1, clipper, &driver, rc.right, rc.bottom, &device1); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRMDevice interface (hr = %#x)\n", hr); + hr = IDirect3DRM_CreateFrame(d3drm1, NULL, &frame1); + ok(hr == D3D_OK, "Cannot get IDirect3DRMFrame interface (hr = %#x)\n", hr); + hr = IDirect3DRM_CreateFrame(d3drm1, frame1, &camera1); + ok(hr == D3D_OK, "Cannot get IDirect3DRMFrame interface (hr = %#x)\n", hr); + hr = IDirect3DRM_CreateViewport(d3drm1, device1, camera1, 0, 0, rc.right, + rc.bottom, &viewport1); + ok(hr == D3D_OK, "Cannot get IDirect3DRMViewport2 interface (hr = %#x)\n", hr); + + /* Check initial state of D3D viewport values */ + hr = IDirect3DRMViewport_GetDirect3DViewport(viewport1, &d3d_viewport); + ok(hr == D3D_OK, "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr); + vp.dwSize = sizeof(vp); + hr = IDirect3DViewport_GetViewport(d3d_viewport, &vp); + ok(hr == D3D_OK, "Cannot get D3DVIEWPORT struct (hr = %#x).\n", hr); + ok(vp.dwX == 0, "Got unexpected viewport X position %u.\n", vp.dwX); + ok(vp.dwY == 0, "Got unexpected viewport Y position %u.\n", vp.dwY); + ok(vp.dwWidth == rc.right, "Got unexpected viewport width %u.\n", vp.dwWidth); + ok(vp.dwHeight == rc.bottom, "Got unexpected viewport height %u.\n", vp.dwHeight); + IDirect3DViewport_Release(d3d_viewport); + + /* Check initial state of X/Y/Width/Height values */ + x = IDirect3DRMViewport_GetX(viewport1); + y = IDirect3DRMViewport_GetY(viewport1); + w = IDirect3DRMViewport_GetWidth(viewport1); + h = IDirect3DRMViewport_GetHeight(viewport1); + ok(x == 0, "Got unexpected X %d.\n", x); + ok(y == 0, "Got unexpected Y %d.\n", y); + ok(w == rc.right, "Got unexpected width %d.\n", w); + ok(h == rc.bottom, "Got unexpected height %d.\n", h); + + hr = IDirect3DRMViewport_Configure(viewport1, rc.left + 10, rc.top + 10, + rc.right - 20, rc.bottom - 20); + ok(hr == D3D_OK, "Cannot configure viewport (hr = %#x).\n", hr); + + /* Verify that D3D viewport values did NOT change */ + hr = IDirect3DRMViewport_GetDirect3DViewport(viewport1, &d3d_viewport); + ok(hr == D3D_OK, "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr); + vp.dwSize = sizeof(vp); + hr = IDirect3DViewport_GetViewport(d3d_viewport, &vp); + ok(hr == D3D_OK, "Cannot get D3DVIEWPORT struct (hr = %#x).\n", hr); + ok(vp.dwX == 0, "Got unexpected viewport X position %u.\n", vp.dwX); + ok(vp.dwY == 0, "Got unexpected viewport Y position %u.\n", vp.dwY); + ok(vp.dwWidth == rc.right, "Got unexpected viewport width %u.\n", vp.dwWidth); + ok(vp.dwHeight == rc.bottom, "Got unexpected viewport height %u.\n", vp.dwHeight); + IDirect3DViewport_Release(d3d_viewport); + + /* Verify that X/Y/Width/Height values changed */ + x = IDirect3DRMViewport_GetX(viewport1); + y = IDirect3DRMViewport_GetY(viewport1); + w = IDirect3DRMViewport_GetWidth(viewport1); + h = IDirect3DRMViewport_GetHeight(viewport1); + ok(x == rc.left + 10, "Got unexpected X %d.\n", x); + ok(y == rc.top + 10, "Got unexpected Y %d.\n", y); + ok(w == rc.right - 20, "Got unexpected width %d.\n", w); + ok(h == rc.bottom - 20, "Got unexpected height %d.\n", h); + + /* Test Configure with good values */ + hr = IDirect3DRMViewport_Configure(viewport1, rc.left, rc.top, rc.right, rc.bottom); + ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr); + hr = IDirect3DRMViewport_Configure(viewport1, rc.left + 1, rc.top, rc.right - 1, rc.bottom); + ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr); + hr = IDirect3DRMViewport_Configure(viewport1, rc.left, rc.top + 1, rc.right, rc.bottom - 1); + ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr); + + /* Test Configure errors */ + hr = IDirect3DRMViewport_Configure(viewport1, rc.left + 1, rc.top, rc.right, rc.bottom); + ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr); + hr = IDirect3DRMViewport_Configure(viewport1, rc.left, rc.top + 1, rc.right, rc.bottom); + ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr); + hr = IDirect3DRMViewport_Configure(viewport1, rc.left, rc.top, rc.right + 1, rc.bottom); + ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr); + hr = IDirect3DRMViewport_Configure(viewport1, rc.left, rc.top, rc.right, rc.bottom + 1); + ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr); + hr = IDirect3DRMViewport_Configure(viewport1, -1, rc.top, rc.right, rc.bottom); + ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr); + hr = IDirect3DRMViewport_Configure(viewport1, rc.left, -1, rc.right, rc.bottom); + ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr); + + /* Teardown */ + IDirect3DRMViewport_Release(viewport1); + IDirect3DRMFrame_Release(frame1); + IDirect3DRMFrame_Release(camera1); + IDirect3DRMDevice_Release(device1); + IDirect3DRM_Release(d3drm1); + IDirectDrawClipper_Release(clipper); + IDirectDraw_Release(ddraw); + DestroyWindow(window); +} + +static void test_viewport_configure2(void) +{ + IDirectDraw *ddraw; + IDirectDrawClipper *clipper; + IDirect3DRM *d3drm1; + IDirect3DRM3 *d3drm3; + IDirect3DRMFrame3 *frame3, *camera3; + IDirect3DRMDevice3 *device3; + IDirect3DViewport *d3d_viewport; + IDirect3DRMViewport2 *viewport2; + D3DVIEWPORT vp; + DWORD x, y, w, h; + HWND window; + GUID driver = IID_IDirect3DRGBDevice; + HRESULT hr; + RECT rc; + + /* Setup */ + window = create_window(); + GetClientRect(window, &rc); + hr = DirectDrawCreate(NULL, &ddraw, NULL); + ok(hr == D3D_OK, "Cannot create IDirectDraw interface (hr = %#x).\n", hr); + hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); + ok(hr == D3D_OK, "Failed to set cooperative level (hr = %#x).\n", hr); + hr = IDirectDraw_CreateClipper(ddraw, 0, &clipper, NULL); + ok(hr == D3D_OK, "Cannot create clipper (hr = %#x).\n", hr); + hr = IDirectDrawClipper_SetHWnd(clipper, 0, window); + ok(hr == D3D_OK, "Cannot set HWnd to Clipper (hr = %#x)\n", hr); + hr = Direct3DRMCreate(&d3drm1); + ok(hr == D3D_OK, "Cannot get IDirect3DRM interface (hr = %#x).\n", hr); + hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM3, (void **)&d3drm3); + ok(hr == D3D_OK, "Cannot get IDirect3DRM3 interface (hr = %#x).\n", hr); + hr = IDirect3DRM3_CreateDeviceFromClipper(d3drm3, clipper, &driver, rc.right, rc.bottom, &device3); + ok(hr == D3DRM_OK, "Cannot get IDirect3DRMDevice3 interface (hr = %#x)\n", hr); + hr = IDirect3DRM3_CreateFrame(d3drm3, NULL, &frame3); + ok(hr == D3D_OK, "Cannot get IDirect3DRMFrame3 interface (hr = %#x)\n", hr); + hr = IDirect3DRM3_CreateFrame(d3drm3, frame3, &camera3); + ok(hr == D3D_OK, "Cannot get IDirect3DRMFrame3 interface (hr = %#x)\n", hr); + hr = IDirect3DRM3_CreateViewport(d3drm3, device3, camera3, 0, 0, rc.right, + rc.bottom, &viewport2); + ok(hr == D3D_OK, "Cannot get IDirect3DRMViewport2 interface (hr = %#x)\n", hr); + + /* Check initial state of D3D viewport values */ + hr = IDirect3DRMViewport2_GetDirect3DViewport(viewport2, &d3d_viewport); + ok(hr == D3D_OK, "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr); + vp.dwSize = sizeof(vp); + hr = IDirect3DViewport_GetViewport(d3d_viewport, &vp); + ok(hr == D3D_OK, "Cannot get D3DVIEWPORT struct (hr = %#x).\n", hr); + ok(vp.dwX == 0, "Got unexpected viewport X position %u.\n", vp.dwX); + ok(vp.dwY == 0, "Got unexpected viewport Y position %u.\n", vp.dwY); + ok(vp.dwWidth == rc.right, "Got unexpected viewport width %u.\n", vp.dwWidth); + ok(vp.dwHeight == rc.bottom, "Got unexpected viewport height %u.\n", vp.dwHeight); + IDirect3DViewport_Release(d3d_viewport); + + /* Check initial state of X/Y/Width/Height values */ + x = IDirect3DRMViewport2_GetX(viewport2); + y = IDirect3DRMViewport2_GetY(viewport2); + w = IDirect3DRMViewport2_GetWidth(viewport2); + h = IDirect3DRMViewport2_GetHeight(viewport2); + ok(x == 0, "Got unexpected X %d.\n", x); + ok(y == 0, "Got unexpected Y %d.\n", y); + ok(w == rc.right, "Got unexpected width %d.\n", w); + ok(h == rc.bottom, "Got unexpected height %d.\n", h); + + hr = IDirect3DRMViewport2_Configure(viewport2, rc.left + 10, rc.top + 10, + rc.right - 20, rc.bottom - 20); + ok(hr == D3D_OK, "Cannot configure viewport (hr = %#x).\n", hr); + + /* Verify that D3D viewport values did NOT change */ + hr = IDirect3DRMViewport2_GetDirect3DViewport(viewport2, &d3d_viewport); + ok(hr == D3D_OK, "Cannot get IDirect3DViewport interface (hr = %#x).\n", hr); + vp.dwSize = sizeof(vp); + hr = IDirect3DViewport_GetViewport(d3d_viewport, &vp); + ok(hr == D3D_OK, "Cannot get D3DVIEWPORT struct (hr = %#x).\n", hr); + ok(vp.dwX == 0, "Got unexpected viewport X position %u.\n", vp.dwX); + ok(vp.dwY == 0, "Got unexpected viewport Y position %u.\n", vp.dwY); + ok(vp.dwWidth == rc.right, "Got unexpected viewport width %u.\n", vp.dwWidth); + ok(vp.dwHeight == rc.bottom, "Got unexpected viewport height %u.\n", vp.dwHeight); + IDirect3DViewport_Release(d3d_viewport); + + /* Verify that X/Y/Width/Height values changed */ + x = IDirect3DRMViewport2_GetX(viewport2); + y = IDirect3DRMViewport2_GetY(viewport2); + w = IDirect3DRMViewport2_GetWidth(viewport2); + h = IDirect3DRMViewport2_GetHeight(viewport2); + ok(x == rc.left + 10, "Got unexpected X %d.\n", x); + ok(y == rc.top + 10, "Got unexpected Y %d.\n", y); + ok(w == rc.right - 20, "Got unexpected width %d.\n", w); + ok(h == rc.bottom - 20, "Got unexpected height %d.\n", h); + + /* Test Configure with good values */ + hr = IDirect3DRMViewport2_Configure(viewport2, rc.left, rc.top, rc.right, rc.bottom); + ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr); + hr = IDirect3DRMViewport2_Configure(viewport2, rc.left + 1, rc.top, rc.right - 1, rc.bottom); + ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr); + hr = IDirect3DRMViewport2_Configure(viewport2, rc.left, rc.top + 1, rc.right, rc.bottom - 1); + ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr); + + /* Test Configure errors */ + hr = IDirect3DRMViewport2_Configure(viewport2, rc.left + 1, rc.top, rc.right, rc.bottom); + ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr); + hr = IDirect3DRMViewport2_Configure(viewport2, rc.left, rc.top + 1, rc.right, rc.bottom); + ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr); + hr = IDirect3DRMViewport2_Configure(viewport2, rc.left, rc.top, rc.right + 1, rc.bottom); + ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr); + hr = IDirect3DRMViewport2_Configure(viewport2, rc.left, rc.top, rc.right, rc.bottom + 1); + ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr); + hr = IDirect3DRMViewport2_Configure(viewport2, -1, rc.top, rc.right, rc.bottom); + ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr); + hr = IDirect3DRMViewport2_Configure(viewport2, rc.left, -1, rc.right, rc.bottom); + ok(hr == D3DRMERR_BADVALUE, "Unexpected hr %#x.\n", hr); + + /* Teardown */ + IDirect3DRMViewport2_Release(viewport2); + IDirect3DRMFrame3_Release(frame3); + IDirect3DRMFrame3_Release(camera3); + IDirect3DRMDevice3_Release(device3); + IDirect3DRM3_Release(d3drm3); + IDirect3DRM_Release(d3drm1); + IDirectDrawClipper_Release(clipper); + IDirectDraw_Release(ddraw); + DestroyWindow(window); +} + static D3DCOLOR get_surface_color(IDirectDrawSurface *surface, UINT x, UINT y) { RECT rect = { x, y, x + 1, y + 1 }; @@ -7083,7 +7327,7 @@ static void test_viewport_clear1(void) ok(ret_color == 0xff0000ff, "Expected scene color returned == 0xff00ff00, got %#x.\n", ret_color);
hr = IDirect3DRMViewport_Configure(viewport1, 0, 0, rc.right, rc.bottom); - todo_wine ok(SUCCEEDED(hr), "Cannot configure viewport (hr = %#x).\n", hr); + ok(SUCCEEDED(hr), "Cannot configure viewport (hr = %#x).\n", hr); hr = IDirect3DRMViewport_Clear(viewport1); ok(SUCCEEDED(hr), "Cannot clear viewport (hr = %#x).\n", hr); ret_color = get_surface_color(surface, 100, 200); @@ -7098,7 +7342,7 @@ static void test_viewport_clear1(void) ok(SUCCEEDED(hr), "Cannot get attached depth surface (hr = %x).\n", hr);
hr = IDirect3DRMViewport_Configure(viewport1, 0, 0, rc.right, rc.bottom); - todo_wine ok(SUCCEEDED(hr), "Cannot configure viewport (hr = %#x).\n", hr); + ok(SUCCEEDED(hr), "Cannot configure viewport (hr = %#x).\n", hr); hr = IDirect3DRMViewport_Clear(viewport1); ok(SUCCEEDED(hr), "Cannot clear viewport (hr = %#x).\n", hr); ret_color = get_surface_color(surface, 100, 200); @@ -7125,7 +7369,7 @@ static void test_viewport_clear1(void)
clear_depth_surface(ds, 0x7fff); hr = IDirect3DRMViewport_Configure(viewport1, 0, 0, rc.right, rc.bottom); - todo_wine ok(SUCCEEDED(hr), "Cannot configure viewport (hr = %#x).\n", hr); + ok(SUCCEEDED(hr), "Cannot configure viewport (hr = %#x).\n", hr); hr = IDirect3DRMViewport_Clear(viewport1); ok(SUCCEEDED(hr), "Cannot clear viewport (hr = %#x).\n", hr);
@@ -7309,7 +7553,7 @@ static void test_viewport_clear2(void) todo_wine ok(compare_color(ret_color, 0x00bada55, 1), "Got unexpected color 0x%08x.\n", ret_color);
hr = IDirect3DRMViewport2_Configure(viewport2, 0, 0, rc.right, rc.bottom); - todo_wine ok(SUCCEEDED(hr), "Cannot configure viewport (hr = %#x).\n", hr); + ok(SUCCEEDED(hr), "Cannot configure viewport (hr = %#x).\n", hr); hr = IDirect3DRMViewport2_Clear(viewport2, D3DRMCLEAR_ALL); ok(SUCCEEDED(hr), "Cannot clear viewport (hr = %#x).\n", hr);
@@ -7337,7 +7581,7 @@ static void test_viewport_clear2(void)
/* This version of Clear still clears the depth surface even if it's deleted from the render target. */ hr = IDirect3DRMViewport2_Configure(viewport2, 0, 0, rc.right, rc.bottom); - todo_wine ok(SUCCEEDED(hr), "Cannot configure viewport (hr = %#x).\n", hr); + ok(SUCCEEDED(hr), "Cannot configure viewport (hr = %#x).\n", hr); hr = IDirect3DRMViewport2_Clear(viewport2, D3DRMCLEAR_ALL); ok(SUCCEEDED(hr), "Cannot clear viewport (hr = %#x).\n", hr);
@@ -7354,14 +7598,14 @@ static void test_viewport_clear2(void)
/* Clear with no flags */ hr = IDirect3DRMViewport2_Configure(viewport2, 0, 0, rc.right, rc.bottom); - todo_wine ok(SUCCEEDED(hr), "Cannot configure viewport (hr = %#x).\n", hr); + ok(SUCCEEDED(hr), "Cannot configure viewport (hr = %#x).\n", hr); hr = IDirect3DRMViewport2_Clear(viewport2, 0); ok(SUCCEEDED(hr), "Cannot clear viewport (hr = %#x).\n", hr); ret_color = get_surface_color(surface, 320, 240); todo_wine ok(compare_color(ret_color, 0x00bada55, 1), "Got unexpected color 0x%08x.\n", ret_color);
hr = IDirect3DRMViewport2_Configure(viewport2, 0, 0, rc.right, rc.bottom); - todo_wine ok(SUCCEEDED(hr), "Cannot configure viewport (hr = %#x).\n", hr); + ok(SUCCEEDED(hr), "Cannot configure viewport (hr = %#x).\n", hr); hr = IDirect3DRMViewport2_Clear(viewport2, D3DRMCLEAR_ALL); ok(SUCCEEDED(hr), "Cannot clear viewport (hr = %#x).\n", hr); ret_color = get_surface_color(surface, 320, 240); @@ -8170,6 +8414,8 @@ START_TEST(d3drm) test_load_texture(); test_texture_qi(); test_viewport_qi(); + test_viewport_configure1(); + test_viewport_configure2(); test_viewport_clear1(); test_viewport_clear2(); test_create_texture_from_surface(); diff --git a/dlls/d3drm/viewport.c b/dlls/d3drm/viewport.c index 24fa198de5..4fde3206cf 100644 --- a/dlls/d3drm/viewport.c +++ b/dlls/d3drm/viewport.c @@ -691,17 +691,35 @@ static HRESULT WINAPI d3drm_viewport1_InverseTransform(IDirect3DRMViewport *ifac static HRESULT WINAPI d3drm_viewport2_Configure(IDirect3DRMViewport2 *iface, LONG x, LONG y, DWORD width, DWORD height) { - FIXME("iface %p, x %d, y %d, width %u, height %u stub!\n", iface, x, y, width, height); + struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
- return E_NOTIMPL; + TRACE("iface %p, x %d, y %d, width %u, height %u.\n", iface, x, y, width, height); + + if (!viewport->device) + return D3DRMERR_BADOBJECT; + + if (x < 0 || y < 0 + || FAILED(d3drm_viewport_check_device_dims(viewport->device, x, y, width, height))) + { + return D3DRMERR_BADVALUE; + } + + viewport->port.x = x; + viewport->port.y = y; + viewport->port.width = width; + viewport->port.height = height; + + return D3DRM_OK; }
static HRESULT WINAPI d3drm_viewport1_Configure(IDirect3DRMViewport *iface, LONG x, LONG y, DWORD width, DWORD height) { - FIXME("iface %p, x %d, y %d, width %u, height %u stub!\n", iface, x, y, width, height); + struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
- return E_NOTIMPL; + TRACE("iface %p, x %d, y %d, width %u, height %u.\n", iface, x, y, width, height); + + return d3drm_viewport2_Configure(&viewport->IDirect3DRMViewport2_iface, x, y, width, height); }
static HRESULT WINAPI d3drm_viewport2_ForceUpdate(IDirect3DRMViewport2* iface,