d3drm: Implement d3drm_viewport2_GetPlane().

Signed-off-by: Jeff Smith <whydoubt@gmail.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jeff Smith 2019-08-30 23:53:52 +04:30 committed by Alexandre Julliard
parent 70568cd120
commit f3adad102d
3 changed files with 111 additions and 13 deletions

View File

@ -89,6 +89,16 @@ struct d3drm_frame
DWORD traversal_options;
};
struct d3drm_box
{
float left;
float top;
float right;
float bottom;
float front;
float back;
};
struct d3drm_viewport
{
struct d3drm_object obj;
@ -99,9 +109,7 @@ struct d3drm_viewport
IDirect3DViewport *d3d_viewport;
IDirect3DMaterial *material;
IDirect3DRM *d3drm;
D3DVALUE back;
D3DVALUE front;
D3DVALUE field;
struct d3drm_box clip;
D3DRMPROJECTIONTYPE projection;
};

View File

@ -1714,6 +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;
IDirectDrawClipper *clipper;
HRESULT hr;
IDirect3DRM *d3drm1;
@ -2136,9 +2137,20 @@ static void test_Viewport(void)
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);
field = IDirect3DRMViewport_GetField(viewport);
ok(field == -1.0f, "Got unexpected field %.8e.\n", field);
left = right = bottom = top = 10.0f;
hr = IDirect3DRMViewport_GetPlane(viewport, &left, &right, &bottom, &top);
ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr);
ok(left == 10.0f, "Got unexpected left %.8e.\n", left);
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);
hr = IDirect3DRMViewport_SetCamera(viewport, frame);
ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DRMViewport_SetField(viewport, 0.5f);
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);
@ -2202,6 +2214,26 @@ static void test_Viewport(void)
ok(vp.dvMaxY == expected_val, "Expected dvMaxY = %f, got %f.\n", expected_val, vp.dvMaxY);
IDirect3DViewport_Release(d3d_viewport);
field = IDirect3DRMViewport_GetField(viewport);
ok(field == 0.5f, "Got unexpected field %.8e.\n", field);
hr = IDirect3DRMViewport_GetPlane(viewport, &left, &right, &bottom, &top);
ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
ok(left == -0.5f, "Got unexpected left %.8e.\n", left);
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);
hr = IDirect3DRMViewport_SetField(viewport, 1.0f);
ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
field = IDirect3DRMViewport_GetField(viewport);
ok(field == 1.0f, "Got unexpected field %.8e.\n", field);
hr = IDirect3DRMViewport_GetPlane(viewport, &left, &right, &bottom, &top);
ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
ok(left == -1.0f, "Got unexpected left %.8e.\n", left);
ok(right == 1.0f, "Got unexpected right %.8e.\n", right);
ok(bottom == -1.0f, "Got unexpected bottom %.8e.\n", bottom);
ok(top == 1.0f, "Got unexpected top %.8e.\n", top);
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);
hr = IDirect3DRMViewport_GetDevice(viewport, NULL);
@ -2246,9 +2278,20 @@ static void test_Viewport(void)
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);
field = IDirect3DRMViewport2_GetField(viewport2);
ok(field == -1.0f, "Got unexpected field %.8e.\n", field);
left = right = bottom = top = 10.0f;
hr = IDirect3DRMViewport2_GetPlane(viewport2, &left, &right, &bottom, &top);
ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr);
ok(left == 10.0f, "Got unexpected left %.8e.\n", left);
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);
hr = IDirect3DRMViewport2_SetCamera(viewport2, frame3);
ok(hr == D3DRMERR_BADOBJECT, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DRMViewport2_SetField(viewport2, 0.5f);
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);
@ -2305,6 +2348,26 @@ static void test_Viewport(void)
ok(vp.dvMaxY == expected_val, "Expected dvMaxY = %f, got %f.\n", expected_val, vp.dvMaxY);
IDirect3DViewport_Release(d3d_viewport);
field = IDirect3DRMViewport2_GetField(viewport2);
ok(field == 0.5f, "Got unexpected field %.8e.\n", field);
hr = IDirect3DRMViewport2_GetPlane(viewport2, &left, &right, &bottom, &top);
ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
ok(left == -0.5f, "Got unexpected left %.8e.\n", left);
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);
hr = IDirect3DRMViewport2_SetField(viewport2, 1.0f);
ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
field = IDirect3DRMViewport2_GetField(viewport2);
ok(field == 1.0f, "Got unexpected field %.8e.\n", field);
hr = IDirect3DRMViewport2_GetPlane(viewport2, &left, &right, &bottom, &top);
ok(hr == D3DRM_OK, "Got unexpected hr %#x.\n", hr);
ok(left == -1.0f, "Got unexpected left %.8e.\n", left);
ok(right == 1.0f, "Got unexpected right %.8e.\n", right);
ok(bottom == -1.0f, "Got unexpected bottom %.8e.\n", bottom);
ok(top == 1.0f, "Got unexpected top %.8e.\n", top);
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);
hr = IDirect3DRMViewport2_GetDevice(viewport2, NULL);

View File

@ -369,6 +369,11 @@ static HRESULT WINAPI d3drm_viewport2_Init(IDirect3DRMViewport2 *iface, IDirect3
viewport->material = material;
viewport->device = device_obj;
viewport->clip.left = -0.5f;
viewport->clip.top = 0.5f;
viewport->clip.right = 0.5f;
viewport->clip.bottom = -0.5f;
cleanup:
if (FAILED(hr))
@ -483,7 +488,7 @@ static HRESULT WINAPI d3drm_viewport2_SetFront(IDirect3DRMViewport2 *iface, D3DV
TRACE("iface %p, front %.8e.\n", iface, front);
viewport->front = front;
viewport->clip.front = front;
return D3DRM_OK;
}
@ -503,7 +508,7 @@ static HRESULT WINAPI d3drm_viewport2_SetBack(IDirect3DRMViewport2 *iface, D3DVA
TRACE("iface %p, back %.8e.\n", iface, back);
viewport->back = back;
viewport->clip.back = back;
return D3DRM_OK;
}
@ -523,10 +528,16 @@ static HRESULT WINAPI d3drm_viewport2_SetField(IDirect3DRMViewport2 *iface, D3DV
TRACE("iface %p, field %.8e.\n", iface, field);
if (!viewport->d3d_viewport)
return D3DRMERR_BADOBJECT;
if (field <= 0.0f)
return D3DRMERR_BADVALUE;
viewport->field = field;
viewport->clip.left = -field;
viewport->clip.right = field;
viewport->clip.bottom = -field;
viewport->clip.top = field;
return D3DRM_OK;
}
@ -755,19 +766,31 @@ static HRESULT WINAPI d3drm_viewport1_GetDevice(IDirect3DRMViewport *iface, IDir
static HRESULT WINAPI d3drm_viewport2_GetPlane(IDirect3DRMViewport2 *iface,
D3DVALUE *left, D3DVALUE *right, D3DVALUE *bottom, D3DVALUE *top)
{
FIXME("iface %p, left %p, right %p, bottom %p, top %p stub!\n",
struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport2(iface);
TRACE("iface %p, left %p, right %p, bottom %p, top %p.\n",
iface, left, right, bottom, top);
return E_NOTIMPL;
if (!viewport->d3d_viewport)
return D3DRMERR_BADOBJECT;
*left = viewport->clip.left;
*right = viewport->clip.right;
*bottom = viewport->clip.bottom;
*top = viewport->clip.top;
return D3DRM_OK;
}
static HRESULT WINAPI d3drm_viewport1_GetPlane(IDirect3DRMViewport *iface,
D3DVALUE *left, D3DVALUE *right, D3DVALUE *bottom, D3DVALUE *top)
{
FIXME("iface %p, left %p, right %p, bottom %p, top %p stub!\n",
struct d3drm_viewport *viewport = impl_from_IDirect3DRMViewport(iface);
TRACE("iface %p, left %p, right %p, bottom %p, top %p.\n",
iface, left, right, bottom, top);
return E_NOTIMPL;
return d3drm_viewport2_GetPlane(&viewport->IDirect3DRMViewport2_iface, left, right, bottom, top);
}
static HRESULT WINAPI d3drm_viewport2_Pick(IDirect3DRMViewport2 *iface,
@ -862,7 +885,11 @@ static D3DVALUE WINAPI d3drm_viewport2_GetField(IDirect3DRMViewport2 *iface)
TRACE("iface %p.\n", iface);
return viewport->field;
if (!viewport->d3d_viewport)
return -1.0f;
return (viewport->clip.right - viewport->clip.left
+ viewport->clip.top - viewport->clip.bottom) / 4.0f;
}
static D3DVALUE WINAPI d3drm_viewport1_GetField(IDirect3DRMViewport *iface)
@ -880,7 +907,7 @@ static D3DVALUE WINAPI d3drm_viewport2_GetBack(IDirect3DRMViewport2 *iface)
TRACE("iface %p.\n", iface);
return viewport->back;
return viewport->clip.back;
}
static D3DVALUE WINAPI d3drm_viewport1_GetBack(IDirect3DRMViewport *iface)
@ -898,7 +925,7 @@ static D3DVALUE WINAPI d3drm_viewport2_GetFront(IDirect3DRMViewport2 *iface)
TRACE("iface %p.\n", iface);
return viewport->front;
return viewport->clip.front;
}
static D3DVALUE WINAPI d3drm_viewport1_GetFront(IDirect3DRMViewport *iface)