Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- dlls/d3d8/device.c | 22 ++++++++++++++++++++++ dlls/d3d9/device.c | 22 ++++++++++++++++++++++ dlls/wined3d/device.c | 15 --------------- 3 files changed, 44 insertions(+), 15 deletions(-)
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 23e93df0616..3b3153c6d47 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -739,6 +739,8 @@ static HRESULT WINAPI d3d8_device_SetCursorProperties(IDirect3DDevice8 *iface, { struct d3d8_device *device = impl_from_IDirect3DDevice8(iface); struct d3d8_surface *bitmap_impl = unsafe_impl_from_IDirect3DSurface8(bitmap); + D3DSURFACE_DESC surface_desc; + D3DDISPLAYMODE mode; HRESULT hr;
TRACE("iface %p, hotspot_x %u, hotspot_y %u, bitmap %p.\n", @@ -750,6 +752,26 @@ static HRESULT WINAPI d3d8_device_SetCursorProperties(IDirect3DDevice8 *iface, return D3DERR_INVALIDCALL; }
+ if (FAILED(hr = IDirect3DSurface8_GetDesc(bitmap, &surface_desc))) + { + WARN("Failed to get surface description, hr %#x.\n", hr); + return hr; + } + + if (FAILED(hr = IDirect3D8_GetAdapterDisplayMode(device->d3d_parent, device->adapter_ordinal, + &mode))) + { + WARN("Failed to get device display mode, hr %#x.\n", hr); + return hr; + } + + if (surface_desc.Width > mode.Width || surface_desc.Height > mode.Height) + { + WARN("Surface dimension %ux%u exceeds display mode %ux%u.\n", surface_desc.Width, + surface_desc.Height, mode.Width, mode.Height); + return D3DERR_INVALIDCALL; + } + wined3d_mutex_lock(); hr = wined3d_device_set_cursor_properties(device->wined3d_device, hotspot_x, hotspot_y, bitmap_impl->wined3d_texture, bitmap_impl->sub_resource_idx); diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 61cb505d77a..53137da28f1 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -787,6 +787,8 @@ static HRESULT WINAPI d3d9_device_SetCursorProperties(IDirect3DDevice9Ex *iface, { struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); struct d3d9_surface *bitmap_impl = unsafe_impl_from_IDirect3DSurface9(bitmap); + D3DSURFACE_DESC surface_desc; + D3DDISPLAYMODE mode; HRESULT hr;
TRACE("iface %p, hotspot_x %u, hotspot_y %u, bitmap %p.\n", @@ -798,6 +800,26 @@ static HRESULT WINAPI d3d9_device_SetCursorProperties(IDirect3DDevice9Ex *iface, return D3DERR_INVALIDCALL; }
+ if (FAILED(hr = IDirect3DSurface9_GetDesc(bitmap, &surface_desc))) + { + WARN("Failed to get surface description, hr %#x.\n", hr); + return hr; + } + + if (FAILED(hr = IDirect3D9_GetAdapterDisplayMode(&device->d3d_parent->IDirect3D9Ex_iface, + device->adapter_ordinal, &mode))) + { + WARN("Failed to get device display mode, hr %#x.\n", hr); + return hr; + } + + if (surface_desc.Width > mode.Width || surface_desc.Height > mode.Height) + { + WARN("Surface dimension %ux%u exceeds display mode %ux%u.\n", surface_desc.Width, + surface_desc.Height, mode.Width, mode.Height); + return D3DERR_INVALIDCALL; + } + wined3d_mutex_lock(); hr = wined3d_device_set_cursor_properties(device->wined3d_device, hotspot_x, hotspot_y, bitmap_impl->wined3d_texture, bitmap_impl->sub_resource_idx); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 05087fee244..ee007568d46 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -4910,9 +4910,7 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device { unsigned int texture_level = sub_resource_idx % texture->level_count; unsigned int cursor_width, cursor_height; - struct wined3d_display_mode mode; struct wined3d_map_desc map_desc; - HRESULT hr;
TRACE("device %p, x_hotspot %u, y_hotspot %u, texture %p, sub_resource_idx %u.\n", device, x_hotspot, y_hotspot, texture, sub_resource_idx); @@ -4943,19 +4941,6 @@ HRESULT CDECL wined3d_device_set_cursor_properties(struct wined3d_device *device return WINED3DERR_INVALIDCALL; }
- if (FAILED(hr = wined3d_output_get_display_mode(&device->adapter->outputs[0], &mode, NULL))) - { - ERR("Failed to get display mode, hr %#x.\n", hr); - return WINED3DERR_INVALIDCALL; - } - - if (cursor_width > mode.width || cursor_height > mode.height) - { - WARN("Texture %p, sub-resource %u dimensions are %ux%u, but screen dimensions are %ux%u.\n", - texture, sub_resource_idx, cursor_width, cursor_height, mode.width, mode.height); - return WINED3DERR_INVALIDCALL; - } - /* Do not store the surface's pointer because the application may * release it after setting the cursor image. Windows doesn't * addref the set surface, so we can't do this either without