From: Jeff Smith whydoubt@gmail.com
--- dlls/d3drm/Makefile.in | 2 +- dlls/d3drm/d3drm_private.h | 3 ++- dlls/d3drm/device.c | 45 ++++++++++++++++++++++++++++++-------- dlls/d3drm/tests/d3drm.c | 24 ++++++++++---------- dlls/d3drm/viewport.c | 4 ++++ 5 files changed, 55 insertions(+), 23 deletions(-)
diff --git a/dlls/d3drm/Makefile.in b/dlls/d3drm/Makefile.in index e5381b4919c..482302e60f4 100644 --- a/dlls/d3drm/Makefile.in +++ b/dlls/d3drm/Makefile.in @@ -1,6 +1,6 @@ MODULE = d3drm.dll IMPORTLIB = d3drm -IMPORTS = d3dxof ddraw +IMPORTS = d3dxof ddraw user32
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/d3drm/d3drm_private.h b/dlls/d3drm/d3drm_private.h index e07efa1c799..8f434831b37 100644 --- a/dlls/d3drm/d3drm_private.h +++ b/dlls/d3drm/d3drm_private.h @@ -127,13 +127,14 @@ struct d3drm_device IDirect3DRM *d3drm; IDirectDraw *ddraw; IDirectDrawSurface *primary_surface, *render_target; - IDirectDrawClipper *clipper; IDirect3DDevice *device; BOOL dither; D3DRMRENDERQUALITY quality; DWORD rendermode; DWORD height; DWORD width; + HWND window; + BOOL needs_update; };
struct d3drm_face diff --git a/dlls/d3drm/device.c b/dlls/d3drm/device.c index 1a433746224..e6c327a4ade 100644 --- a/dlls/d3drm/device.c +++ b/dlls/d3drm/device.c @@ -51,7 +51,6 @@ void d3drm_device_destroy(struct d3drm_device *device) { TRACE("Releasing primary surface and attached clipper.\n"); IDirectDrawSurface_Release(device->primary_surface); - IDirectDrawClipper_Release(device->clipper); } if (device->ddraw) { @@ -110,8 +109,7 @@ HRESULT d3drm_device_create_surfaces_from_clipper(struct d3drm_device *object, I }
object->primary_surface = primary_surface; - object->clipper = clipper; - IDirectDrawClipper_AddRef(clipper); + object->window = window; *surface = render_target;
return D3DRM_OK; @@ -219,6 +217,8 @@ HRESULT d3drm_device_init(struct d3drm_device *device, UINT version, IDirectDraw device->width = desc.dwWidth; device->height = desc.dwHeight;
+ device->needs_update = FALSE; + return hr; }
@@ -712,23 +712,50 @@ static HRESULT WINAPI d3drm_device1_InitFromClipper(IDirect3DRMDevice *iface,
static HRESULT WINAPI d3drm_device3_Update(IDirect3DRMDevice3 *iface) { - FIXME("iface %p stub!\n", iface); + struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface); + HRESULT hr = D3DRM_OK;
- return D3DRM_OK; + TRACE("iface %p.\n", iface); + + if (device->needs_update) + { + if (device->primary_surface) + { + RECT rt_rect = { 0, 0, device->width, device->height }; + RECT ps_rect = rt_rect; + + ClientToScreen(device->window, (POINT *)&ps_rect.left); + ClientToScreen(device->window, (POINT *)&ps_rect.right); + + TRACE("primary surface rect %s, render target rect %s\n", + wine_dbgstr_rect(&ps_rect), wine_dbgstr_rect(&rt_rect)); + + hr = IDirectDrawSurface_Blt(device->primary_surface, &ps_rect, + device->render_target, &rt_rect, DDBLT_WAIT, NULL); + } + + device->needs_update = FALSE; + } + + return hr; }
static HRESULT WINAPI d3drm_device2_Update(IDirect3DRMDevice2 *iface) { - FIXME("iface %p stub!\n", iface); + struct d3drm_device *device = impl_from_IDirect3DRMDevice2(iface);
- return D3DRM_OK; + TRACE("iface %p.\n", iface); + + return d3drm_device3_Update(&device->IDirect3DRMDevice3_iface); }
static HRESULT WINAPI d3drm_device1_Update(IDirect3DRMDevice *iface) { - FIXME("iface %p stub!\n", iface); + struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
- return D3DRM_OK; + TRACE("iface %p.\n", iface); + + return d3drm_device3_Update(&device->IDirect3DRMDevice3_iface); }
static HRESULT WINAPI d3drm_device3_AddUpdateCallback(IDirect3DRMDevice3 *iface, diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c index 7b60efa1965..cf1ff2e5295 100644 --- a/dlls/d3drm/tests/d3drm.c +++ b/dlls/d3drm/tests/d3drm.c @@ -8763,7 +8763,7 @@ static void test_update_surfaces_1(void) hr = IDirect3DRMDevice_Update(device1); ok(hr == D3DRM_OK, "Cannot update Direct3DRMDevice, hr %#lx.\n", hr); ret_color = get_surface_color(d3drm_primary, 320 + client_pos.x, 240 + client_pos.y); - todo_wine ok(compare_color(ret_color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", ret_color); + ok(compare_color(ret_color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", ret_color);
/* Update modifies primary surface following a viewport clear */ clip_list_size = 0; @@ -8783,7 +8783,7 @@ static void test_update_surfaces_1(void) ret_color = get_surface_color(surface, 320, 240); ok(compare_color(ret_color, 0x00ff7f00, 1), "Got unexpected color 0x%08lx.\n", ret_color); ret_color = get_surface_color(d3drm_primary, 320 + client_pos.x, 240 + client_pos.y); - todo_wine ok(compare_color(ret_color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", ret_color); + ok(compare_color(ret_color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", ret_color); hr = IDirect3DRMDevice_AddUpdateCallback(device1, update_cb_surf_color, &ctx); todo_wine ok(hr == D3DRM_OK, "Cannot add update callback, hr %#lx.\n", hr); hr = IDirect3DRMDevice_Update(device1); @@ -8791,7 +8791,7 @@ static void test_update_surfaces_1(void) hr = IDirect3DRMDevice_DeleteUpdateCallback(device1, update_cb_surf_color, &ctx); todo_wine ok(hr == D3DRM_OK, "Cannot delete update callback, hr %#lx.\n", hr); ret_color = get_surface_color(d3drm_primary, 320 + client_pos.x, 240 + client_pos.y); - todo_wine ok(compare_color(ret_color, 0x00ff7f00, 1), "Got unexpected color 0x%08lx.\n", ret_color); + ok(compare_color(ret_color, 0x00ff7f00, 1), "Got unexpected color 0x%08lx.\n", ret_color); todo_wine ok(compare_color(ctx.color, 0x00ff7f00, 1), "Got unexpected color 0x%08lx.\n", ctx.color);
/* Draw at the window handle location, regardless of clipper alterations */ @@ -8810,7 +8810,7 @@ static void test_update_surfaces_1(void) hr = IDirect3DRMDevice_Update(device1); ok(hr == D3DRM_OK, "Cannot update Direct3DRMDevice, hr %#lx.\n", hr); ret_color = get_surface_color(d3drm_primary, 320 + client_pos.x, 240 + client_pos.y); - todo_wine ok(compare_color(ret_color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", ret_color); + ok(compare_color(ret_color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", ret_color);
IDirect3DRMViewport_Release(viewport); IDirect3DRMFrame_Release(camera); @@ -8932,7 +8932,7 @@ static void test_update_surfaces_2(void) hr = IDirect3DRMDevice_Update(device2); ok(hr == D3DRM_OK, "Cannot update Direct3DRMDevice2, hr %#lx.\n", hr); ret_color = get_surface_color(d3drm_primary, 320 + client_pos.x, 240 + client_pos.y); - todo_wine ok(compare_color(ret_color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", ret_color); + ok(compare_color(ret_color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", ret_color);
/* Update modifies primary surface following a viewport clear */ ctx.surface = d3drm_primary; @@ -8946,7 +8946,7 @@ static void test_update_surfaces_2(void) ret_color = get_surface_color(surface, 320, 240); ok(compare_color(ret_color, 0x00ff7f00, 1), "Got unexpected color 0x%08lx.\n", ret_color); ret_color = get_surface_color(d3drm_primary, 320 + client_pos.x, 240 + client_pos.y); - todo_wine ok(compare_color(ret_color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", ret_color); + ok(compare_color(ret_color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", ret_color); hr = IDirect3DRMDevice2_AddUpdateCallback(device2, update_cb_surf_color, &ctx); todo_wine ok(hr == D3DRM_OK, "Cannot add update callback, hr %#lx.\n", hr); hr = IDirect3DRMDevice2_Update(device2); @@ -8954,7 +8954,7 @@ static void test_update_surfaces_2(void) hr = IDirect3DRMDevice2_DeleteUpdateCallback(device2, update_cb_surf_color, &ctx); todo_wine ok(hr == D3DRM_OK, "Cannot delete update callback, hr %#lx.\n", hr); ret_color = get_surface_color(d3drm_primary, 320 + client_pos.x, 240 + client_pos.y); - todo_wine ok(compare_color(ret_color, 0x00ff7f00, 1), "Got unexpected color 0x%08lx.\n", ret_color); + ok(compare_color(ret_color, 0x00ff7f00, 1), "Got unexpected color 0x%08lx.\n", ret_color); todo_wine ok(compare_color(ctx.color, 0x00ff7f00, 1), "Got unexpected color 0x%08lx.\n", ctx.color);
/* Draw at the window handle location, regardless of clipper alterations */ @@ -8979,7 +8979,7 @@ static void test_update_surfaces_2(void) hr = IDirect3DRMDevice2_Update(device2); ok(hr == D3DRM_OK, "Cannot update Direct3DRMDevice2, hr %#lx.\n", hr); ret_color = get_surface_color(d3drm_primary, 320 + client_pos.x, 240 + client_pos.y); - todo_wine ok(compare_color(ret_color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", ret_color); + ok(compare_color(ret_color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", ret_color);
IDirect3DRMViewport_Release(viewport); IDirect3DRMFrame_Release(camera1); @@ -9097,7 +9097,7 @@ static void test_update_surfaces_3(void) hr = IDirect3DRMDevice3_Update(device3); ok(hr == D3DRM_OK, "Cannot update Direct3DRMDevice3, hr %#lx.\n", hr); ret_color = get_surface_color(d3drm_primary, 320 + client_pos.x, 240 + client_pos.y); - todo_wine ok(compare_color(ret_color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", ret_color); + ok(compare_color(ret_color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", ret_color);
/* Update modifies primary surface following a viewport clear */ ctx.surface = d3drm_primary; @@ -9111,7 +9111,7 @@ static void test_update_surfaces_3(void) ret_color = get_surface_color(surface, 320, 240); ok(compare_color(ret_color, 0x00ff7f00, 1), "Got unexpected color 0x%08lx.\n", ret_color); ret_color = get_surface_color(d3drm_primary, 320 + client_pos.x, 240 + client_pos.y); - todo_wine ok(compare_color(ret_color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", ret_color); + ok(compare_color(ret_color, 0x000000ff, 1), "Got unexpected color 0x%08lx.\n", ret_color); hr = IDirect3DRMDevice3_AddUpdateCallback(device3, update_cb_surf_color, &ctx); todo_wine ok(hr == D3DRM_OK, "Cannot add update callback, hr %#lx.\n", hr); hr = IDirect3DRMDevice3_Update(device3); @@ -9119,7 +9119,7 @@ static void test_update_surfaces_3(void) hr = IDirect3DRMDevice3_DeleteUpdateCallback(device3, update_cb_surf_color, &ctx); todo_wine ok(hr == D3DRM_OK, "Cannot delete update callback, hr %#lx.\n", hr); ret_color = get_surface_color(d3drm_primary, 320 + client_pos.x, 240 + client_pos.y); - todo_wine ok(compare_color(ret_color, 0x00ff7f00, 1), "Got unexpected color 0x%08lx.\n", ret_color); + ok(compare_color(ret_color, 0x00ff7f00, 1), "Got unexpected color 0x%08lx.\n", ret_color); todo_wine ok(compare_color(ctx.color, 0x00ff7f00, 1), "Got unexpected color 0x%08lx.\n", ctx.color);
/* Draw at the window handle location, regardless of clipper alterations */ @@ -9144,7 +9144,7 @@ static void test_update_surfaces_3(void) hr = IDirect3DRMDevice3_Update(device3); ok(hr == D3DRM_OK, "Cannot update Direct3DRMDevice3, hr %#lx.\n", hr); ret_color = get_surface_color(d3drm_primary, 320 + client_pos.x, 240 + client_pos.y); - todo_wine ok(compare_color(ret_color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", ret_color); + ok(compare_color(ret_color, 0x0000ff00, 1), "Got unexpected color 0x%08lx.\n", ret_color);
IDirect3DRMViewport2_Release(viewport); IDirect3DRMFrame3_Release(camera); diff --git a/dlls/d3drm/viewport.c b/dlls/d3drm/viewport.c index 528cae24001..7ba7b0c61b5 100644 --- a/dlls/d3drm/viewport.c +++ b/dlls/d3drm/viewport.c @@ -458,6 +458,8 @@ static HRESULT WINAPI d3drm_viewport2_Clear(IDirect3DRMViewport2 *iface, DWORD f if (FAILED(hr = IDirect3DViewport_Clear(viewport->d3d_viewport, 1, &clear_rect, clear_flags))) return hr;
+ viewport->device->needs_update = TRUE; + return D3DRM_OK; }
@@ -693,6 +695,8 @@ static HRESULT WINAPI d3drm_viewport2_ForceUpdate(IDirect3DRMViewport2* iface, x2 > (vp.dwX + vp.dwWidth) || y2 > (vp.dwY + vp.dwHeight)) return D3DRMERR_BADVALUE;
+ viewport->device->needs_update = TRUE; + return D3DRM_OK; }