Commit 49bf4a87 authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

wined3d: Move cursor size check against display mode out of wined3d_device_set_cursor_properties().

parent 47f3afb9
......@@ -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);
......
......@@ -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);
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment