From: Jeff Smith whydoubt@gmail.com
Signed-off-by: Jeff Smith whydoubt@gmail.com Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- dlls/d3drm/tests/d3drm.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++- dlls/d3drm/viewport.c | 20 ++++++++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-)
diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c index bb58350d5a1..0f9f9cd6ed6 100644 --- a/dlls/d3drm/tests/d3drm.c +++ b/dlls/d3drm/tests/d3drm.c @@ -1714,7 +1714,7 @@ static void test_Viewport(void) { IDirect3DRMFrame3 *frame3, *d3drm_frame3, *tmp_frame3; IDirect3DRMFrame *frame, *d3drm_frame, *tmp_frame1; - float field, left, top, right, bottom; + float field, left, top, right, bottom, front, back; IDirectDrawClipper *clipper; HRESULT hr; IDirect3DRM *d3drm1; @@ -2146,6 +2146,10 @@ static void test_Viewport(void) ok(right == 10.0f, "Got unexpected right %.8e.\n", right); ok(bottom == 10.0f, "Got unexpected bottom %.8e.\n", bottom); ok(top == 10.0f, "Got unexpected top %.8e.\n", top); + front = IDirect3DRMViewport_GetFront(viewport); + ok(front == -1.0f, "Got unexpected front %.8e\n", front); + back = IDirect3DRMViewport_GetBack(viewport); + ok(back == -1.0f, "Got unexpected back %.8e\n", back);
hr = IDirect3DRMViewport_SetCamera(viewport, frame); ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr); @@ -2153,6 +2157,10 @@ static void test_Viewport(void) ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr); hr = IDirect3DRMViewport_SetPlane(viewport, -0.5f, 0.5f, -0.5f, 0.5f); ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DRMViewport_SetFront(viewport, 1.0f); + 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);
/* Test all failures together */ hr = IDirect3DRMViewport_Init(viewport, NULL, frame, rc.left, rc.top, rc.right, rc.bottom); @@ -2224,6 +2232,10 @@ static void test_Viewport(void) ok(right == 0.5f, "Got unexpected right %.8e.\n", right); ok(bottom == -0.5f, "Got unexpected bottom %.8e.\n", bottom); ok(top == 0.5f, "Got unexpected top %.8e.\n", top); + front = IDirect3DRMViewport_GetFront(viewport); + ok(front == 1.0f, "Got unexpected front %.8e.\n", front); + back = IDirect3DRMViewport_GetBack(viewport); + ok(back == 100.0f, "Got unexpected back %.8e.\n", back);
hr = IDirect3DRMViewport_SetField(viewport, 1.0f); ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr); @@ -2246,6 +2258,14 @@ static void test_Viewport(void) ok(right == 3.0f, "Got unexpected right %.8e.\n", right); ok(bottom == 2.0f, "Got unexpected bottom %.8e.\n", bottom); ok(top == 0.0f, "Got unexpected top %.8e.\n", top); + hr = IDirect3DRMViewport_SetFront(viewport, 2.0f); + ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr); + front = IDirect3DRMViewport_GetFront(viewport); + ok(front == 2.0f, "Got unexpected front %.8e.\n", front); + hr = IDirect3DRMViewport_SetBack(viewport, 200.0f); + 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_Init(viewport, device1, frame, rc.left, rc.top, rc.right, rc.bottom); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); @@ -2259,6 +2279,15 @@ static void test_Viewport(void) ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); hr = IDirect3DRMViewport_SetField(viewport, -1.0f); ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); + hr = IDirect3DRMViewport_SetFront(viewport, 0.0f); + ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DRMViewport_SetFront(viewport, -1.0f); + ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#x.\n", hr); + front = IDirect3DRMViewport_GetFront(viewport); + hr = IDirect3DRMViewport_SetBack(viewport, front); + ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DRMViewport_SetBack(viewport, front / 2.0f); + ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#x.\n", hr);
IDirect3DRMViewport_Release(viewport); ref4 = get_refcount((IUnknown *)d3drm1); @@ -2300,6 +2329,10 @@ static void test_Viewport(void) ok(right == 10.0f, "Got unexpected right %.8e.\n", right); ok(bottom == 10.0f, "Got unexpected bottom %.8e.\n", bottom); ok(top == 10.0f, "Got unexpected top %.8e.\n", top); + front = IDirect3DRMViewport2_GetFront(viewport2); + ok(front == -1.0f, "Got unexpected front %.8e\n", front); + back = IDirect3DRMViewport2_GetBack(viewport2); + ok(back == -1.0f, "Got unexpected back %.8e\n", back);
hr = IDirect3DRMViewport2_SetCamera(viewport2, frame3); ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr); @@ -2307,6 +2340,10 @@ static void test_Viewport(void) ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr); hr = IDirect3DRMViewport2_SetPlane(viewport2, -0.5f, 0.5f, -0.5f, 0.5f); ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DRMViewport2_SetFront(viewport2, 1.0f); + 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_Init(viewport2, NULL, frame3, rc.left, rc.top, rc.right, rc.bottom); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); @@ -2371,6 +2408,10 @@ static void test_Viewport(void) ok(right == 0.5f, "Got unexpected right %.8e.\n", right); ok(bottom == -0.5f, "Got unexpected bottom %.8e.\n", bottom); ok(top == 0.5f, "Got unexpected top %.8e.\n", top); + front = IDirect3DRMViewport2_GetFront(viewport2); + ok(front == 1.0f, "Got unexpected front %.8e.\n", front); + back = IDirect3DRMViewport2_GetBack(viewport2); + ok(back == 100.0f, "Got unexpected back %.8e.\n", back);
hr = IDirect3DRMViewport2_SetField(viewport2, 1.0f); ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr); @@ -2393,6 +2434,14 @@ static void test_Viewport(void) ok(right == 3.0f, "Got unexpected right %.8e.\n", right); ok(bottom == 2.0f, "Got unexpected bottom %.8e.\n", bottom); ok(top == 0.0f, "Got unexpected top %.8e.\n", top); + hr = IDirect3DRMViewport2_SetFront(viewport2, 2.0f); + ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr); + front = IDirect3DRMViewport2_GetFront(viewport2); + ok(front == 2.0f, "Got unexpected front %.8e.\n", front); + hr = IDirect3DRMViewport2_SetBack(viewport2, 200.0f); + 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_Init(viewport2, device3, frame3, rc.left, rc.top, rc.right, rc.bottom); ok(hr == D3DRMERR_BADOBJECT, "Expected hr == D3DRMERR_BADOBJECT, got %#x.\n", hr); @@ -2406,6 +2455,15 @@ static void test_Viewport(void) ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); hr = IDirect3DRMViewport2_SetField(viewport2, -1.0f); ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %#x.\n", hr); + hr = IDirect3DRMViewport2_SetFront(viewport2, 0.0f); + ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DRMViewport2_SetFront(viewport2, -1.0f); + ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#x.\n", hr); + front = IDirect3DRMViewport2_GetFront(viewport2); + hr = IDirect3DRMViewport2_SetBack(viewport2, front); + ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DRMViewport2_SetBack(viewport2, front / 2.0f); + ok(hr == D3DRMERR_BADVALUE, "Got unexpected hr %#x.\n", hr);
IDirect3DRMViewport2_Release(viewport2); ref4 = get_refcount((IUnknown *)d3drm1); diff --git a/dlls/d3drm/viewport.c b/dlls/d3drm/viewport.c index 2c923b14c51..8e959d5f37e 100644 --- a/dlls/d3drm/viewport.c +++ b/dlls/d3drm/viewport.c @@ -373,6 +373,8 @@ static HRESULT WINAPI d3drm_viewport2_Init(IDirect3DRMViewport2 *iface, IDirect3 viewport->clip.top = 0.5f; viewport->clip.right = 0.5f; viewport->clip.bottom = -0.5f; + viewport->clip.front = 1.0f; + viewport->clip.back = 100.0f;
cleanup:
@@ -488,6 +490,12 @@ static HRESULT WINAPI d3drm_viewport2_SetFront(IDirect3DRMViewport2 *iface, D3DV
TRACE("iface %p, front %.8e.\n", iface, front);
+ if (!viewport->d3d_viewport) + return D3DRMERR_BADOBJECT; + + if (front <= 0.0f) + return D3DRMERR_BADVALUE; + viewport->clip.front = front;
return D3DRM_OK; @@ -508,6 +516,12 @@ static HRESULT WINAPI d3drm_viewport2_SetBack(IDirect3DRMViewport2 *iface, D3DVA
TRACE("iface %p, back %.8e.\n", iface, back);
+ if (!viewport->d3d_viewport) + return D3DRMERR_BADOBJECT; + + if (back <= viewport->clip.front) + return D3DRMERR_BADVALUE; + viewport->clip.back = back;
return D3DRM_OK; @@ -919,6 +933,9 @@ static D3DVALUE WINAPI d3drm_viewport2_GetBack(IDirect3DRMViewport2 *iface)
TRACE("iface %p.\n", iface);
+ if (!viewport->d3d_viewport) + return -1.0f; + return viewport->clip.back; }
@@ -937,6 +954,9 @@ static D3DVALUE WINAPI d3drm_viewport2_GetFront(IDirect3DRMViewport2 *iface)
TRACE("iface %p.\n", iface);
+ if (!viewport->d3d_viewport) + return -1.0f; + return viewport->clip.front; }